diff options
author | Gael Guennebaud <g.gael@free.fr> | 2013-08-19 16:40:50 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2013-08-19 16:40:50 +0200 |
commit | 2b15e001068f548b852d58472b9b29f1a7bf1a2c (patch) | |
tree | 086ad5d158ff13b80bba632f72c3506efca65c8b /Eigen/src/Core/SelfCwiseBinaryOp.h | |
parent | 127d7f2071c9be2a62f881d53d0b696f43053453 (diff) |
Make ArrayBase operator+=(scalar) and -=(scalar) use SelfCwiseBinaryOp optimization
Diffstat (limited to 'Eigen/src/Core/SelfCwiseBinaryOp.h')
-rw-r--r-- | Eigen/src/Core/SelfCwiseBinaryOp.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Eigen/src/Core/SelfCwiseBinaryOp.h b/Eigen/src/Core/SelfCwiseBinaryOp.h index 96012eaf8..3d2deff98 100644 --- a/Eigen/src/Core/SelfCwiseBinaryOp.h +++ b/Eigen/src/Core/SelfCwiseBinaryOp.h @@ -178,6 +178,24 @@ inline Derived& DenseBase<Derived>::operator*=(const Scalar& other) } 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) { typedef typename internal::conditional<NumTraits<Scalar>::IsInteger, |