aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/GlobalFunctions.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2016-06-14 15:26:37 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2016-06-14 15:26:37 +0200
commit70dad84b737374e97319733ebff6f36e86ac384d (patch)
tree45c0a4a839881354926ee7ff9dd3a7563ecfef95 /Eigen/src/Core/GlobalFunctions.h
parent62134082aa0dd33cb7328f9f9a86491d21a52444 (diff)
Generalize expr/expr and scalar/expr wrt scalar types.
Diffstat (limited to 'Eigen/src/Core/GlobalFunctions.h')
-rw-r--r--Eigen/src/Core/GlobalFunctions.h34
1 files changed, 26 insertions, 8 deletions
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 <typename Derived>
- inline const Eigen::CwiseUnaryOp<Eigen::internal::scalar_inverse_mult_op<typename Derived::Scalar>, const Derived>
- operator/(const typename Derived::Scalar& s, const Eigen::ArrayBase<Derived>& a)
+#ifdef EIGEN_PARSED_BY_DOXYGEN
+ template<typename Scalar,typename Derived>
+ inline const CwiseBinaryOp<internal::scalar_quotient_op<Scalar,Derived::Scalar>,Constant<Scalar>,Derived>
+ operator/(const Scalar& s,const Eigen::ArrayBase<Derived>& a);
+#else
+ template<typename Scalar, typename Derived>
+ inline typename internal::enable_if< !(internal::is_same<typename Derived::Scalar,Scalar>::value)
+ && ScalarBinaryOpTraits<Scalar,typename Derived::Scalar>::Defined,
+ const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,Derived,quotient) >::type
+ operator/(const Scalar& s, const Eigen::ArrayBase<Derived>& a)
{
- return Eigen::CwiseUnaryOp<Eigen::internal::scalar_inverse_mult_op<typename Derived::Scalar>, const Derived>(
- a.derived(),
- Eigen::internal::scalar_inverse_mult_op<typename Derived::Scalar>(s)
- );
+ return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,Derived,quotient)(
+ typename internal::plain_constant_type<Derived,Scalar>::type(a.rows(), a.cols(), s), a.derived() );
+ }
+
+ template<typename Derived>
+ inline const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(typename Derived::Scalar,Derived,quotient)
+ operator/(const typename Derived::Scalar& s, const Eigen::ArrayBase<Derived>& a)
+ {
+ return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(typename Derived::Scalar,Derived,quotient)(
+ typename internal::plain_constant_type<Derived,typename Derived::Scalar>::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.
*