Added support for expm1 in Eigen.

This commit is contained in:
Srinivas Vasudevan
2016-12-02 14:13:01 -08:00
parent 27873008d4
commit 218764ee1f
15 changed files with 171 additions and 13 deletions

View File

@@ -262,6 +262,26 @@ struct functor_traits<scalar_exp_op<Scalar> > {
};
};
/** \internal
*
* \brief Template functor to compute the exponential of a scalar - 1.
*
* \sa class CwiseUnaryOp, ArrayBase::expm1()
*/
template<typename Scalar> struct scalar_expm1_op {
EIGEN_EMPTY_STRUCT_CTOR(scalar_expm1_op)
EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::expm1(a); }
template <typename Packet>
EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pexpm1(a); }
};
template <typename Scalar>
struct functor_traits<scalar_expm1_op<Scalar> > {
enum {
PacketAccess = packet_traits<Scalar>::HasExpm1,
Cost = functor_traits<scalar_exp_op<Scalar> >::Cost // TODO measure cost of expm1
};
};
/** \internal
*
* \brief Template functor to compute the logarithm of a scalar