Make ArrayBase operator+=(scalar) and -=(scalar) use SelfCwiseBinaryOp optimization

This commit is contained in:
Gael Guennebaud
2013-08-19 16:40:50 +02:00
parent 127d7f2071
commit 2b15e00106
3 changed files with 21 additions and 5 deletions

View File

@@ -177,6 +177,24 @@ inline Derived& DenseBase<Derived>::operator*=(const Scalar& other)
return derived();
}
template<typename Derived>
inline Derived& ArrayBase<Derived>::operator+=(const Scalar& other)
{
typedef typename Derived::PlainObject PlainObject;
SelfCwiseBinaryOp<internal::scalar_sum_op<Scalar>, Derived, typename PlainObject::ConstantReturnType> tmp(derived());
tmp = PlainObject::Constant(rows(),cols(),other);
return derived();
}
template<typename Derived>
inline Derived& ArrayBase<Derived>::operator-=(const Scalar& other)
{
typedef typename Derived::PlainObject PlainObject;
SelfCwiseBinaryOp<internal::scalar_difference_op<Scalar>, Derived, typename PlainObject::ConstantReturnType> tmp(derived());
tmp = PlainObject::Constant(rows(),cols(),other);
return derived();
}
template<typename Derived>
inline Derived& DenseBase<Derived>::operator/=(const Scalar& other)
{