diff options
author | Gael Guennebaud <g.gael@free.fr> | 2014-02-18 10:52:00 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2014-02-18 10:52:00 +0100 |
commit | 2d136d3d7f0623189e42be44d45e1353d1cde93e (patch) | |
tree | 637fb123ed1bd6a82a6b86d37f78e6ea316decef /Eigen | |
parent | 873401032bf91e092413cdd7b56848f7b485490a (diff) |
Get rid of SeflCwiseBinaryOp
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/src/Core/ArrayBase.h | 54 | ||||
-rw-r--r-- | Eigen/src/Core/SelfCwiseBinaryOp.h | 48 |
2 files changed, 102 insertions, 0 deletions
diff --git a/Eigen/src/Core/ArrayBase.h b/Eigen/src/Core/ArrayBase.h index 2c9ace4a7..c528de733 100644 --- a/Eigen/src/Core/ArrayBase.h +++ b/Eigen/src/Core/ArrayBase.h @@ -177,6 +177,59 @@ template<typename Derived> class ArrayBase {EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;} }; +#ifdef EIGEN_TEST_EVALUATORS +/** replaces \c *this by \c *this - \a other. + * + * \returns a reference to \c *this + */ +template<typename Derived> +template<typename OtherDerived> +EIGEN_STRONG_INLINE Derived & +ArrayBase<Derived>::operator-=(const ArrayBase<OtherDerived> &other) +{ + call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar>()); + return derived(); +} + +/** replaces \c *this by \c *this + \a other. + * + * \returns a reference to \c *this + */ +template<typename Derived> +template<typename OtherDerived> +EIGEN_STRONG_INLINE Derived & +ArrayBase<Derived>::operator+=(const ArrayBase<OtherDerived>& other) +{ + call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar>()); + return derived(); +} + +/** replaces \c *this by \c *this * \a other coefficient wise. + * + * \returns a reference to \c *this + */ +template<typename Derived> +template<typename OtherDerived> +EIGEN_STRONG_INLINE Derived & +ArrayBase<Derived>::operator*=(const ArrayBase<OtherDerived>& other) +{ + call_assignment(derived(), other.derived(), internal::mul_assign_op<Scalar>()); + return derived(); +} + +/** replaces \c *this by \c *this / \a other coefficient wise. + * + * \returns a reference to \c *this + */ +template<typename Derived> +template<typename OtherDerived> +EIGEN_STRONG_INLINE Derived & +ArrayBase<Derived>::operator/=(const ArrayBase<OtherDerived>& other) +{ + call_assignment(derived(), other.derived(), internal::div_assign_op<Scalar>()); + return derived(); +} +#else // EIGEN_TEST_EVALUATORS /** replaces \c *this by \c *this - \a other. * * \returns a reference to \c *this @@ -232,6 +285,7 @@ ArrayBase<Derived>::operator/=(const ArrayBase<OtherDerived>& other) tmp = other.derived(); return derived(); } +#endif } // end namespace Eigen diff --git a/Eigen/src/Core/SelfCwiseBinaryOp.h b/Eigen/src/Core/SelfCwiseBinaryOp.h index 65864adf8..ae7f9b887 100644 --- a/Eigen/src/Core/SelfCwiseBinaryOp.h +++ b/Eigen/src/Core/SelfCwiseBinaryOp.h @@ -12,6 +12,8 @@ namespace Eigen { +#ifndef EIGEN_TEST_EVALUATORS + /** \class SelfCwiseBinaryOp * \ingroup Core_Module * @@ -179,6 +181,51 @@ template<typename BinaryOp, typename Lhs, typename Rhs> class SelfCwiseBinaryOp SelfCwiseBinaryOp& operator=(const SelfCwiseBinaryOp&); }; +#endif // EIGEN_TEST_EVALUATORS + +#ifdef EIGEN_TEST_EVALUATORS +template<typename Derived> +inline Derived& DenseBase<Derived>::operator*=(const Scalar& other) +{ + typedef typename Derived::PlainObject PlainObject; + internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::mul_assign_op<Scalar>()); + return derived(); +} + +template<typename Derived> +inline Derived& ArrayBase<Derived>::operator+=(const Scalar& other) +{ + typedef typename Derived::PlainObject PlainObject; + internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::add_assign_op<Scalar>()); + return derived(); +} + +template<typename Derived> +inline Derived& ArrayBase<Derived>::operator-=(const Scalar& other) +{ + typedef typename Derived::PlainObject PlainObject; + internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::sub_assign_op<Scalar>()); + return derived(); +} + +template<typename Derived> +inline Derived& DenseBase<Derived>::operator/=(const Scalar& other) +{ + typedef typename Derived::PlainObject PlainObject; + + typedef typename internal::conditional<NumTraits<Scalar>::IsInteger, + internal::div_assign_op<Scalar>, + internal::mul_assign_op<Scalar> >::type AssignOp; + + Scalar actual_other; + if(NumTraits<Scalar>::IsInteger) actual_other = other; + else actual_other = Scalar(1)/other; + + internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),actual_other), AssignOp()); + + return derived(); +} +#else template<typename Derived> inline Derived& DenseBase<Derived>::operator*=(const Scalar& other) { @@ -220,6 +267,7 @@ inline Derived& DenseBase<Derived>::operator/=(const Scalar& other) tmp = PlainObject::Constant(rows(),cols(), actual_other); return derived(); } +#endif } // end namespace Eigen |