Some functors were not generic wrt packet-type.

This commit is contained in:
Gael Guennebaud 2015-08-07 17:41:39 +02:00
parent e68c7b8368
commit 60e4260d0d
2 changed files with 21 additions and 21 deletions

View File

@ -341,7 +341,6 @@ template<> struct functor_traits<scalar_boolean_or_op> {
*/
template<typename Scalar>
struct scalar_multiple_op {
typedef typename packet_traits<Scalar>::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 <typename Packet>
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const
{ return internal::pmul(a, pset1<Packet>(m_other)); }
typename add_const_on_value_type<typename NumTraits<Scalar>::Nested>::type m_other;
@ -379,11 +379,11 @@ struct functor_traits<scalar_multiple2_op<Scalar1,Scalar2> >
*/
template<typename Scalar>
struct scalar_quotient1_op {
typedef typename packet_traits<Scalar>::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 <typename Packet>
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const
{ return internal::pdiv(a, pset1<Packet>(m_other)); }
typename add_const_on_value_type<typename NumTraits<Scalar>::Nested>::type m_other;
@ -421,11 +421,11 @@ template<typename LhsScalar,typename RhsScalar> struct functor_is_product_like<s
/* If you wonder why doing the pset1() in packetOp() is an optimization check scalar_multiple_op */
template<typename Scalar>
struct scalar_add_op {
typedef typename packet_traits<Scalar>::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 <typename Packet>
inline const Packet packetOp(const Packet& a) const
{ return internal::padd(a, pset1<Packet>(m_other)); }
const Scalar m_other;
@ -440,10 +440,10 @@ struct functor_traits<scalar_add_op<Scalar> >
*/
template<typename Scalar>
struct scalar_sub_op {
typedef typename packet_traits<Scalar>::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 <typename Packet>
inline const Packet packetOp(const Packet& a) const
{ return internal::psub(a, pset1<Packet>(m_other)); }
const Scalar m_other;
@ -458,10 +458,10 @@ struct functor_traits<scalar_sub_op<Scalar> >
*/
template<typename Scalar>
struct scalar_rsub_op {
typedef typename packet_traits<Scalar>::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 <typename Packet>
inline const Packet packetOp(const Packet& a) const
{ return internal::psub(pset1<Packet>(m_other), a); }
const Scalar m_other;

View File

@ -231,7 +231,7 @@ struct functor_traits<scalar_imag_ref_op<Scalar> >
template<typename Scalar> 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<Scalar>::type Packet;
template <typename Packet>
inline Packet packetOp(const Packet& a) const { return internal::pexp(a); }
};
template<typename Scalar>
@ -247,7 +247,7 @@ struct functor_traits<scalar_exp_op<Scalar> >
template<typename Scalar> 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<Scalar>::type Packet;
template <typename Packet>
inline Packet packetOp(const Packet& a) const { return internal::plog(a); }
};
template<typename Scalar>
@ -263,7 +263,7 @@ struct functor_traits<scalar_log_op<Scalar> >
template<typename Scalar> 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<Scalar>::type Packet;
template <typename Packet>
inline Packet packetOp(const Packet& a) const { return internal::plog10(a); }
};
template<typename Scalar>
@ -277,7 +277,7 @@ struct functor_traits<scalar_log10_op<Scalar> >
template<typename Scalar> 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<Scalar>::type Packet;
template <typename Packet>
inline Packet packetOp(const Packet& a) const { return internal::psqrt(a); }
};
template<typename Scalar>
@ -295,7 +295,7 @@ struct functor_traits<scalar_sqrt_op<Scalar> >
template<typename Scalar> 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<Scalar>::type Packet;
template <typename Packet>
inline Packet packetOp(const Packet& a) const { return internal::prsqrt(a); }
};
@ -314,7 +314,7 @@ struct functor_traits<scalar_rsqrt_op<Scalar> >
template<typename Scalar> 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<Scalar>::type Packet;
template <typename Packet>
inline Packet packetOp(const Packet& a) const { return internal::pcos(a); }
};
template<typename Scalar>
@ -333,7 +333,7 @@ struct functor_traits<scalar_cos_op<Scalar> >
template<typename Scalar> 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<Scalar>::type Packet;
template <typename Packet>
inline Packet packetOp(const Packet& a) const { return internal::psin(a); }
};
template<typename Scalar>
@ -353,7 +353,7 @@ struct functor_traits<scalar_sin_op<Scalar> >
template<typename Scalar> 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<Scalar>::type Packet;
template <typename Packet>
inline Packet packetOp(const Packet& a) const { return internal::ptan(a); }
};
template<typename Scalar>
@ -372,7 +372,7 @@ struct functor_traits<scalar_tan_op<Scalar> >
template<typename Scalar> 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<Scalar>::type Packet;
template <typename Packet>
inline Packet packetOp(const Packet& a) const { return internal::pacos(a); }
};
template<typename Scalar>
@ -391,7 +391,7 @@ struct functor_traits<scalar_acos_op<Scalar> >
template<typename Scalar> 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<Scalar>::type Packet;
template <typename Packet>
inline Packet packetOp(const Packet& a) const { return internal::pasin(a); }
};
template<typename Scalar>
@ -410,7 +410,7 @@ struct functor_traits<scalar_asin_op<Scalar> >
template<typename Scalar> 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<Scalar>::type Packet;
template <typename Packet>
inline Packet packetOp(const Packet& a) const { return internal::patan(a); }
};
template<typename Scalar>
@ -429,7 +429,7 @@ struct functor_traits<scalar_atan_op<Scalar> >
template<typename Scalar> 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<Scalar>::type Packet;
template <typename Packet>
inline Packet packetOp(const Packet& a) const { return internal::ptanh(a); }
};
template<typename Scalar>
@ -448,7 +448,7 @@ struct functor_traits<scalar_tanh_op<Scalar> >
template<typename Scalar> 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<Scalar>::type Packet;
template <typename Packet>
inline Packet packetOp(const Packet& a) const { return internal::psinh(a); }
};
template<typename Scalar>
@ -467,7 +467,7 @@ struct functor_traits<scalar_sinh_op<Scalar> >
template<typename Scalar> 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<Scalar>::type Packet;
template <typename Packet>
inline Packet packetOp(const Packet& a) const { return internal::pcosh(a); }
};
template<typename Scalar>
@ -534,7 +534,7 @@ struct functor_traits<scalar_cube_op<Scalar> >
template<typename Scalar> 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<Scalar>::type Packet;
template <typename Packet>
inline Packet packetOp(const Packet& a) const { return internal::pround(a); }
};
template<typename Scalar>
@ -553,7 +553,7 @@ struct functor_traits<scalar_round_op<Scalar> >
template<typename Scalar> 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<Scalar>::type Packet;
template <typename Packet>
inline Packet packetOp(const Packet& a) const { return internal::pfloor(a); }
};
template<typename Scalar>