From 6eee2918d93ecb23c9b241a3d146e72f251fcfa4 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 27 Jul 2012 11:56:20 +0200 Subject: extend quotient functor to allow for mixed types (complex-real) --- Eigen/src/Core/Functors.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'Eigen/src/Core/Functors.h') diff --git a/Eigen/src/Core/Functors.h b/Eigen/src/Core/Functors.h index 278c46c6b..c9e8ab150 100644 --- a/Eigen/src/Core/Functors.h +++ b/Eigen/src/Core/Functors.h @@ -204,21 +204,28 @@ struct functor_traits > { * * \sa class CwiseBinaryOp, Cwise::operator/() */ -template struct scalar_quotient_op { +template struct scalar_quotient_op { + enum { + // TODO vectorize mixed product + Vectorizable = is_same::value && packet_traits::HasDiv && packet_traits::HasDiv + }; + typedef typename scalar_product_traits::ReturnType result_type; EIGEN_EMPTY_STRUCT_CTOR(scalar_quotient_op) - EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { return a / b; } + EIGEN_STRONG_INLINE const result_type operator() (const LhsScalar& a, const RhsScalar& b) const { return a / b; } template EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const { return internal::pdiv(a,b); } }; -template -struct functor_traits > { +template +struct functor_traits > { enum { - Cost = 2 * NumTraits::MulCost, - PacketAccess = packet_traits::HasDiv + Cost = (NumTraits::MulCost + NumTraits::MulCost), // rough estimate! + PacketAccess = scalar_quotient_op::Vectorizable }; }; + + /** \internal * \brief Template functor to compute the and of two booleans * @@ -660,6 +667,7 @@ template struct functor_has_linear_access struct functor_allows_mixing_real_and_complex { enum { ret = 0 }; }; template struct functor_allows_mixing_real_and_complex > { enum { ret = 1 }; }; template struct functor_allows_mixing_real_and_complex > { enum { ret = 1 }; }; +template struct functor_allows_mixing_real_and_complex > { enum { ret = 1 }; }; /** \internal -- cgit v1.2.3