diff options
author | Gael Guennebaud <g.gael@free.fr> | 2016-06-14 12:06:10 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2016-06-14 12:06:10 +0200 |
commit | a8c08e8b8e8bdd486a5a27b9f1e92c48ef4361cd (patch) | |
tree | 2c80ba97d7f03930acf827514ddce17baf1dfa00 /Eigen/src/plugins/ArrayCwiseBinaryOps.h | |
parent | 756ac4a93dea57bf61079c4867e712a8c26d77f6 (diff) |
Implement expr+scalar, scalar+expr, expr-scalar, and scalar-expr as binary expressions, and generalize supported scalar types.
The following functors are now deprecated: scalar_add_op, scalar_sub_op, and scalar_rsub_op.
Diffstat (limited to 'Eigen/src/plugins/ArrayCwiseBinaryOps.h')
-rw-r--r-- | Eigen/src/plugins/ArrayCwiseBinaryOps.h | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/Eigen/src/plugins/ArrayCwiseBinaryOps.h b/Eigen/src/plugins/ArrayCwiseBinaryOps.h index 351762e82..8bf4e9b18 100644 --- a/Eigen/src/plugins/ArrayCwiseBinaryOps.h +++ b/Eigen/src/plugins/ArrayCwiseBinaryOps.h @@ -192,48 +192,49 @@ EIGEN_MAKE_CWISE_COMP_OP(operator!=, NEQ) #undef EIGEN_MAKE_CWISE_COMP_R_OP // scalar addition - +#ifndef EIGEN_PARSED_BY_DOXYGEN +EIGEN_MAKE_SCALAR_BINARY_OP(operator+,sum); +#else /** \returns an expression of \c *this with each coeff incremented by the constant \a scalar * + * \tparam T is the scalar type of \a scalar. It must be compatible with the scalar type of the given expression. + * * Example: \include Cwise_plus.cpp * Output: \verbinclude Cwise_plus.out * * \sa operator+=(), operator-() */ -EIGEN_DEVICE_FUNC -inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived> -operator+(const Scalar& scalar) const -{ - return CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>(derived(), internal::scalar_add_op<Scalar>(scalar)); -} - -EIGEN_DEVICE_FUNC -friend inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived> -operator+(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other) -{ - return other + scalar; -} +template<typename T> +const CwiseBinaryOp<internal::scalar_sum_op<Scalar,T>,Derived,Constant<Scalar> > operator+(const T& scalar) const; +/** \returns an expression of \a expr with each coeff incremented by the constant \a scalar + * + * \tparam T is the scalar type of \a scalar. It must be compatible with the scalar type of the given expression. + */ +template<typename T> friend +const CwiseBinaryOp<internal::scalar_sum_op<T,Scalar>,Constant<Scalar>,Derived> operator+(const T& scalar, const StorageBaseType& expr); +#endif +#ifndef EIGEN_PARSED_BY_DOXYGEN +EIGEN_MAKE_SCALAR_BINARY_OP(operator-,difference); +#else /** \returns an expression of \c *this with each coeff decremented by the constant \a scalar * + * \tparam T is the scalar type of \a scalar. It must be compatible with the scalar type of the given expression. + * * Example: \include Cwise_minus.cpp * Output: \verbinclude Cwise_minus.out * - * \sa operator+(), operator-=() + * \sa operator+=(), operator-() */ -EIGEN_DEVICE_FUNC -inline const CwiseUnaryOp<internal::scalar_sub_op<Scalar>, const Derived> -operator-(const Scalar& scalar) const -{ - return CwiseUnaryOp<internal::scalar_sub_op<Scalar>, const Derived>(derived(), internal::scalar_sub_op<Scalar>(scalar));; -} - -EIGEN_DEVICE_FUNC -friend inline const CwiseUnaryOp<internal::scalar_rsub_op<Scalar>, const Derived> -operator-(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other) -{ - return CwiseUnaryOp<internal::scalar_rsub_op<Scalar>, const Derived>(other.derived(), internal::scalar_rsub_op<Scalar>(scalar));; -} +template<typename T> +const CwiseBinaryOp<internal::scalar_difference_op<Scalar,T>,Derived,Constant<Scalar> > operator-(const T& scalar) const; +/** \returns an expression of the constant matrix of value \a scalar decremented by the coefficients of \a expr + * + * \tparam T is the scalar type of \a scalar. It must be compatible with the scalar type of the given expression. + */ +template<typename T> friend +const CwiseBinaryOp<internal::scalar_difference_op<T,Scalar>,Constant<Scalar>,Derived> operator-(const T& scalar, const StorageBaseType& expr); +#endif /** \returns an expression of the coefficient-wise && operator of *this and \a other * |