mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Merged in rmlarsen/eigen (pull request PR-570)
Add support for inverse hyperbolic functions. Fix cost of division.
This commit is contained in:
@@ -66,6 +66,11 @@ namespace Eigen
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sinh,scalar_sinh_op,hyperbolic sine,\sa ArrayBase::sinh)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cosh,scalar_cosh_op,hyperbolic cosine,\sa ArrayBase::cosh)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(tanh,scalar_tanh_op,hyperbolic tangent,\sa ArrayBase::tanh)
|
||||
#if EIGEN_HAS_CXX11_MATH
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(asinh,scalar_asinh_op,inverse hyperbolic sine,\sa ArrayBase::asinh)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(acosh,scalar_acosh_op,inverse hyperbolic cosine,\sa ArrayBase::acosh)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(atanh,scalar_atanh_op,inverse hyperbolic tangent,\sa ArrayBase::atanh)
|
||||
#endif
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(logistic,scalar_logistic_op,logistic function,\sa ArrayBase::logistic)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(lgamma,scalar_lgamma_op,natural logarithm of the gamma function,\sa ArrayBase::lgamma)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(digamma,scalar_digamma_op,derivative of lgamma,\sa ArrayBase::digamma)
|
||||
|
||||
@@ -468,6 +468,11 @@ template<typename Derived> class MatrixBase
|
||||
const MatrixFunctionReturnValue<Derived> matrixFunction(StemFunction f) const;
|
||||
EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue, cosh, hyperbolic cosine)
|
||||
EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue, sinh, hyperbolic sine)
|
||||
#if EIGEN_HAS_CXX11_MATH
|
||||
EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue, atanh, inverse hyperbolic cosine)
|
||||
EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue, acosh, inverse hyperbolic cosine)
|
||||
EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue, asinh, inverse hyperbolic sine)
|
||||
#endif
|
||||
EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue, cos, cosine)
|
||||
EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue, sin, sine)
|
||||
EIGEN_MATRIX_FUNCTION(MatrixSquareRootReturnValue, sqrt, square root)
|
||||
|
||||
@@ -548,6 +548,23 @@ struct functor_traits<scalar_tanh_op<Scalar> > {
|
||||
};
|
||||
};
|
||||
|
||||
#if EIGEN_HAS_CXX11_MATH
|
||||
/** \internal
|
||||
* \brief Template functor to compute the atanh of a scalar
|
||||
* \sa class CwiseUnaryOp, ArrayBase::atanh()
|
||||
*/
|
||||
template <typename Scalar>
|
||||
struct scalar_atanh_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_atanh_op)
|
||||
EIGEN_DEVICE_FUNC inline const Scalar operator()(const Scalar& a) const { return numext::atanh(a); }
|
||||
};
|
||||
|
||||
template <typename Scalar>
|
||||
struct functor_traits<scalar_atanh_op<Scalar> > {
|
||||
enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false };
|
||||
};
|
||||
#endif
|
||||
|
||||
/** \internal
|
||||
* \brief Template functor to compute the sinh of a scalar
|
||||
* \sa class CwiseUnaryOp, ArrayBase::sinh()
|
||||
@@ -567,6 +584,23 @@ struct functor_traits<scalar_sinh_op<Scalar> >
|
||||
};
|
||||
};
|
||||
|
||||
#if EIGEN_HAS_CXX11_MATH
|
||||
/** \internal
|
||||
* \brief Template functor to compute the asinh of a scalar
|
||||
* \sa class CwiseUnaryOp, ArrayBase::asinh()
|
||||
*/
|
||||
template <typename Scalar>
|
||||
struct scalar_asinh_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_asinh_op)
|
||||
EIGEN_DEVICE_FUNC inline const Scalar operator()(const Scalar& a) const { return numext::asinh(a); }
|
||||
};
|
||||
|
||||
template <typename Scalar>
|
||||
struct functor_traits<scalar_asinh_op<Scalar> > {
|
||||
enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false };
|
||||
};
|
||||
#endif
|
||||
|
||||
/** \internal
|
||||
* \brief Template functor to compute the cosh of a scalar
|
||||
* \sa class CwiseUnaryOp, ArrayBase::cosh()
|
||||
@@ -586,6 +620,23 @@ struct functor_traits<scalar_cosh_op<Scalar> >
|
||||
};
|
||||
};
|
||||
|
||||
#if EIGEN_HAS_CXX11_MATH
|
||||
/** \internal
|
||||
* \brief Template functor to compute the acosh of a scalar
|
||||
* \sa class CwiseUnaryOp, ArrayBase::acosh()
|
||||
*/
|
||||
template <typename Scalar>
|
||||
struct scalar_acosh_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_acosh_op)
|
||||
EIGEN_DEVICE_FUNC inline const Scalar operator()(const Scalar& a) const { return numext::acosh(a); }
|
||||
};
|
||||
|
||||
template <typename Scalar>
|
||||
struct functor_traits<scalar_acosh_op<Scalar> > {
|
||||
enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false };
|
||||
};
|
||||
#endif
|
||||
|
||||
/** \internal
|
||||
* \brief Template functor to compute the inverse of a scalar
|
||||
* \sa class CwiseUnaryOp, Cwise::inverse()
|
||||
@@ -598,9 +649,13 @@ struct scalar_inverse_op {
|
||||
EIGEN_DEVICE_FUNC inline const Packet packetOp(const Packet& a) const
|
||||
{ return internal::pdiv(pset1<Packet>(Scalar(1)),a); }
|
||||
};
|
||||
template<typename Scalar>
|
||||
struct functor_traits<scalar_inverse_op<Scalar> >
|
||||
{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasDiv }; };
|
||||
template <typename Scalar>
|
||||
struct functor_traits<scalar_inverse_op<Scalar> > {
|
||||
enum {
|
||||
PacketAccess = packet_traits<Scalar>::HasDiv,
|
||||
Cost = scalar_div_cost<Scalar, PacketAccess>::value
|
||||
};
|
||||
};
|
||||
|
||||
/** \internal
|
||||
* \brief Template functor to compute the square of a scalar
|
||||
|
||||
Reference in New Issue
Block a user