From 70dad84b737374e97319733ebff6f36e86ac384d Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 14 Jun 2016 15:26:37 +0200 Subject: Generalize expr/expr and scalar/expr wrt scalar types. --- Eigen/src/Core/GlobalFunctions.h | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'Eigen/src/Core/GlobalFunctions.h') diff --git a/Eigen/src/Core/GlobalFunctions.h b/Eigen/src/Core/GlobalFunctions.h index 60e2ccfed..5ffa6c694 100644 --- a/Eigen/src/Core/GlobalFunctions.h +++ b/Eigen/src/Core/GlobalFunctions.h @@ -175,17 +175,35 @@ namespace Eigen #endif /** - * \brief Component-wise division of a scalar by array elements. + * \brief Component-wise division of the scalar \a s by array elements of \a a. + * + * \tparam Scalar is the scalar type of \a x. It must be compatible with the scalar type of the given array expression (\c Derived::Scalar). + * + * \relates ArrayBase **/ - template - inline const Eigen::CwiseUnaryOp, const Derived> - operator/(const typename Derived::Scalar& s, const Eigen::ArrayBase& a) +#ifdef EIGEN_PARSED_BY_DOXYGEN + template + inline const CwiseBinaryOp,Constant,Derived> + operator/(const Scalar& s,const Eigen::ArrayBase& a); +#else + template + inline typename internal::enable_if< !(internal::is_same::value) + && ScalarBinaryOpTraits::Defined, + const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,Derived,quotient) >::type + operator/(const Scalar& s, const Eigen::ArrayBase& a) { - return Eigen::CwiseUnaryOp, const Derived>( - a.derived(), - Eigen::internal::scalar_inverse_mult_op(s) - ); + return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,Derived,quotient)( + typename internal::plain_constant_type::type(a.rows(), a.cols(), s), a.derived() ); + } + + template + inline const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(typename Derived::Scalar,Derived,quotient) + operator/(const typename Derived::Scalar& s, const Eigen::ArrayBase& a) + { + return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(typename Derived::Scalar,Derived,quotient)( + typename internal::plain_constant_type::type(a.rows(), a.cols(), s), a.derived() ); } +#endif /** \cpp11 \returns an expression of the coefficient-wise igamma(\a a, \a x) to the given arrays. * -- cgit v1.2.3