From 60e4260d0d114f030f2425c4c5d681bc1afb3219 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 7 Aug 2015 17:41:39 +0200 Subject: [PATCH] Some functors were not generic wrt packet-type. --- Eigen/src/Core/functors/BinaryFunctors.h | 10 ++++---- Eigen/src/Core/functors/UnaryFunctors.h | 32 ++++++++++++------------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Eigen/src/Core/functors/BinaryFunctors.h b/Eigen/src/Core/functors/BinaryFunctors.h index 5dee6247e..cc0e80a33 100644 --- a/Eigen/src/Core/functors/BinaryFunctors.h +++ b/Eigen/src/Core/functors/BinaryFunctors.h @@ -341,7 +341,6 @@ template<> struct functor_traits { */ template struct scalar_multiple_op { - typedef typename packet_traits::type Packet; // FIXME default copy constructors seems bugged with std::complex<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE scalar_multiple_op(const scalar_multiple_op& other) : m_other(other.m_other) { } @@ -349,6 +348,7 @@ struct scalar_multiple_op { EIGEN_STRONG_INLINE scalar_multiple_op(const Scalar& other) : m_other(other) { } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator() (const Scalar& a) const { return a * m_other; } + template EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const { return internal::pmul(a, pset1(m_other)); } typename add_const_on_value_type::Nested>::type m_other; @@ -379,11 +379,11 @@ struct functor_traits > */ template struct scalar_quotient1_op { - typedef typename packet_traits::type Packet; // FIXME default copy constructors seems bugged with std::complex<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE scalar_quotient1_op(const scalar_quotient1_op& other) : m_other(other.m_other) { } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE scalar_quotient1_op(const Scalar& other) : m_other(other) {} EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator() (const Scalar& a) const { return a / m_other; } + template EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const { return internal::pdiv(a, pset1(m_other)); } typename add_const_on_value_type::Nested>::type m_other; @@ -421,11 +421,11 @@ template struct functor_is_product_like struct scalar_add_op { - typedef typename packet_traits::type Packet; // FIXME default copy constructors seems bugged with std::complex<> EIGEN_DEVICE_FUNC inline scalar_add_op(const scalar_add_op& other) : m_other(other.m_other) { } EIGEN_DEVICE_FUNC inline scalar_add_op(const Scalar& other) : m_other(other) { } EIGEN_DEVICE_FUNC inline Scalar operator() (const Scalar& a) const { return a + m_other; } + template inline const Packet packetOp(const Packet& a) const { return internal::padd(a, pset1(m_other)); } const Scalar m_other; @@ -440,10 +440,10 @@ struct functor_traits > */ template struct scalar_sub_op { - typedef typename packet_traits::type Packet; inline scalar_sub_op(const scalar_sub_op& other) : m_other(other.m_other) { } inline scalar_sub_op(const Scalar& other) : m_other(other) { } inline Scalar operator() (const Scalar& a) const { return a - m_other; } + template inline const Packet packetOp(const Packet& a) const { return internal::psub(a, pset1(m_other)); } const Scalar m_other; @@ -458,10 +458,10 @@ struct functor_traits > */ template struct scalar_rsub_op { - typedef typename packet_traits::type Packet; inline scalar_rsub_op(const scalar_rsub_op& other) : m_other(other.m_other) { } inline scalar_rsub_op(const Scalar& other) : m_other(other) { } inline Scalar operator() (const Scalar& a) const { return m_other - a; } + template inline const Packet packetOp(const Packet& a) const { return internal::psub(pset1(m_other), a); } const Scalar m_other; diff --git a/Eigen/src/Core/functors/UnaryFunctors.h b/Eigen/src/Core/functors/UnaryFunctors.h index 9b4f49c3c..537406b60 100644 --- a/Eigen/src/Core/functors/UnaryFunctors.h +++ b/Eigen/src/Core/functors/UnaryFunctors.h @@ -231,7 +231,7 @@ struct functor_traits > template struct scalar_exp_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_exp_op) EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { using std::exp; return exp(a); } - typedef typename packet_traits::type Packet; + template inline Packet packetOp(const Packet& a) const { return internal::pexp(a); } }; template @@ -247,7 +247,7 @@ struct functor_traits > template struct scalar_log_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_log_op) EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { using std::log; return log(a); } - typedef typename packet_traits::type Packet; + template inline Packet packetOp(const Packet& a) const { return internal::plog(a); } }; template @@ -263,7 +263,7 @@ struct functor_traits > template struct scalar_log10_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_log10_op) EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { using std::log10; return log10(a); } - typedef typename packet_traits::type Packet; + template inline Packet packetOp(const Packet& a) const { return internal::plog10(a); } }; template @@ -277,7 +277,7 @@ struct functor_traits > template struct scalar_sqrt_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_sqrt_op) EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { using std::sqrt; return sqrt(a); } - typedef typename packet_traits::type Packet; + template inline Packet packetOp(const Packet& a) const { return internal::psqrt(a); } }; template @@ -295,7 +295,7 @@ struct functor_traits > template struct scalar_rsqrt_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_rsqrt_op) EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { using std::sqrt; return Scalar(1)/sqrt(a); } - typedef typename packet_traits::type Packet; + template inline Packet packetOp(const Packet& a) const { return internal::prsqrt(a); } }; @@ -314,7 +314,7 @@ struct functor_traits > template struct scalar_cos_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_cos_op) EIGEN_DEVICE_FUNC inline Scalar operator() (const Scalar& a) const { using std::cos; return cos(a); } - typedef typename packet_traits::type Packet; + template inline Packet packetOp(const Packet& a) const { return internal::pcos(a); } }; template @@ -333,7 +333,7 @@ struct functor_traits > template struct scalar_sin_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_sin_op) EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { using std::sin; return sin(a); } - typedef typename packet_traits::type Packet; + template inline Packet packetOp(const Packet& a) const { return internal::psin(a); } }; template @@ -353,7 +353,7 @@ struct functor_traits > template struct scalar_tan_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_tan_op) EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { using std::tan; return tan(a); } - typedef typename packet_traits::type Packet; + template inline Packet packetOp(const Packet& a) const { return internal::ptan(a); } }; template @@ -372,7 +372,7 @@ struct functor_traits > template struct scalar_acos_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_acos_op) EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { using std::acos; return acos(a); } - typedef typename packet_traits::type Packet; + template inline Packet packetOp(const Packet& a) const { return internal::pacos(a); } }; template @@ -391,7 +391,7 @@ struct functor_traits > template struct scalar_asin_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_asin_op) EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { using std::asin; return asin(a); } - typedef typename packet_traits::type Packet; + template inline Packet packetOp(const Packet& a) const { return internal::pasin(a); } }; template @@ -410,7 +410,7 @@ struct functor_traits > template struct scalar_atan_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_atan_op) inline const Scalar operator() (const Scalar& a) const { using std::atan; return atan(a); } - typedef typename packet_traits::type Packet; + template inline Packet packetOp(const Packet& a) const { return internal::patan(a); } }; template @@ -429,7 +429,7 @@ struct functor_traits > template struct scalar_tanh_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_tanh_op) inline const Scalar operator() (const Scalar& a) const { using std::tanh; return tanh(a); } - typedef typename packet_traits::type Packet; + template inline Packet packetOp(const Packet& a) const { return internal::ptanh(a); } }; template @@ -448,7 +448,7 @@ struct functor_traits > template struct scalar_sinh_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_sinh_op) inline const Scalar operator() (const Scalar& a) const { using std::sinh; return sinh(a); } - typedef typename packet_traits::type Packet; + template inline Packet packetOp(const Packet& a) const { return internal::psinh(a); } }; template @@ -467,7 +467,7 @@ struct functor_traits > template struct scalar_cosh_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_cosh_op) inline const Scalar operator() (const Scalar& a) const { using std::cosh; return cosh(a); } - typedef typename packet_traits::type Packet; + template inline Packet packetOp(const Packet& a) const { return internal::pcosh(a); } }; template @@ -534,7 +534,7 @@ struct functor_traits > template struct scalar_round_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_round_op) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return numext::round(a); } - typedef typename packet_traits::type Packet; + template inline Packet packetOp(const Packet& a) const { return internal::pround(a); } }; template @@ -553,7 +553,7 @@ struct functor_traits > template struct scalar_floor_op { EIGEN_EMPTY_STRUCT_CTOR(scalar_floor_op) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return numext::floor(a); } - typedef typename packet_traits::type Packet; + template inline Packet packetOp(const Packet& a) const { return internal::pfloor(a); } }; template