From 2b15e001068f548b852d58472b9b29f1a7bf1a2c Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 19 Aug 2013 16:40:50 +0200 Subject: Make ArrayBase operator+=(scalar) and -=(scalar) use SelfCwiseBinaryOp optimization --- Eigen/src/Core/SelfCwiseBinaryOp.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'Eigen/src/Core/SelfCwiseBinaryOp.h') 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 @@ -177,6 +177,24 @@ inline Derived& DenseBase::operator*=(const Scalar& other) return derived(); } +template +inline Derived& ArrayBase::operator+=(const Scalar& other) +{ + typedef typename Derived::PlainObject PlainObject; + SelfCwiseBinaryOp, Derived, typename PlainObject::ConstantReturnType> tmp(derived()); + tmp = PlainObject::Constant(rows(),cols(),other); + return derived(); +} + +template +inline Derived& ArrayBase::operator-=(const Scalar& other) +{ + typedef typename Derived::PlainObject PlainObject; + SelfCwiseBinaryOp, Derived, typename PlainObject::ConstantReturnType> tmp(derived()); + tmp = PlainObject::Constant(rows(),cols(),other); + return derived(); +} + template inline Derived& DenseBase::operator/=(const Scalar& other) { -- cgit v1.2.3