mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Add hyperbolic trigonometric functions from std array support
This commit is contained in:
parent
a5e49976f5
commit
f89fcefa79
@ -198,10 +198,13 @@ EIGEN_MKL_VML_SPECIALIZE_ASSIGN(SliceVectorizedTraversal,NoUnrolling)
|
||||
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(sin, Sin)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(asin, Asin)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(sinh, Sinh)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(cos, Cos)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(acos, Acos)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(cosh, Cosh)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(tan, Tan)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(atan, Atan)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(tanh, Tanh)
|
||||
//EIGEN_MKL_VML_DECLARE_UNARY_CALLS(abs, Abs)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(arg, Arg)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(exp, Exp)
|
||||
|
@ -70,6 +70,9 @@ struct default_packet_traits
|
||||
HasASin = 0,
|
||||
HasACos = 0,
|
||||
HasATan = 0,
|
||||
HasSinh = 0,
|
||||
HasCosh = 0,
|
||||
HasTanh = 0,
|
||||
|
||||
HasRound = 0,
|
||||
HasFloor = 0,
|
||||
@ -348,10 +351,22 @@ Packet pasin(const Packet& a) { using std::asin; return asin(a); }
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet pacos(const Packet& a) { using std::acos; return acos(a); }
|
||||
|
||||
/** \internal \returns the atan of \a a (coeff-wise) */
|
||||
/** \internal \returns the arc tangent of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet patan(const Packet& a) { using std::atan; return atan(a); }
|
||||
|
||||
/** \internal \returns the hyperbolic sine of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet psinh(const Packet& a) { using std::sinh; return sinh(a); }
|
||||
|
||||
/** \internal \returns the hyperbolic cosine of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet pcosh(const Packet& a) { using std::cosh; return cosh(a); }
|
||||
|
||||
/** \internal \returns the hyperbolic tan of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet ptanh(const Packet& a) { using std::tanh; return tanh(a); }
|
||||
|
||||
/** \internal \returns the exp of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet pexp(const Packet& a) { using std::exp; return exp(a); }
|
||||
|
@ -42,10 +42,13 @@ namespace Eigen
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(conj,scalar_conjugate_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sin,scalar_sin_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cos,scalar_cos_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(asin,scalar_asin_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(acos,scalar_acos_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(tan,scalar_tan_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(atan,scalar_atan_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(asin,scalar_asin_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(acos,scalar_acos_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sinh,scalar_sinh_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cosh,scalar_cosh_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(tanh,scalar_tanh_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(exp,scalar_exp_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log,scalar_log_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log10,scalar_log10_op)
|
||||
|
@ -384,7 +384,6 @@ struct functor_traits<scalar_asin_op<Scalar> >
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/** \internal
|
||||
* \brief Template functor to compute the atan of a scalar
|
||||
* \sa class CwiseUnaryOp, ArrayBase::atan()
|
||||
@ -404,6 +403,63 @@ struct functor_traits<scalar_atan_op<Scalar> >
|
||||
};
|
||||
};
|
||||
|
||||
/** \internal
|
||||
* \brief Template functor to compute the tanh of a scalar
|
||||
* \sa class CwiseUnaryOp, ArrayBase::tanh()
|
||||
*/
|
||||
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;
|
||||
inline Packet packetOp(const Packet& a) const { return internal::ptanh(a); }
|
||||
};
|
||||
template<typename Scalar>
|
||||
struct functor_traits<scalar_tanh_op<Scalar> >
|
||||
{
|
||||
enum {
|
||||
Cost = 5 * NumTraits<Scalar>::MulCost,
|
||||
PacketAccess = packet_traits<Scalar>::HasTanh
|
||||
};
|
||||
};
|
||||
|
||||
/** \internal
|
||||
* \brief Template functor to compute the sinh of a scalar
|
||||
* \sa class CwiseUnaryOp, ArrayBase::sinh()
|
||||
*/
|
||||
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;
|
||||
inline Packet packetOp(const Packet& a) const { return internal::psinh(a); }
|
||||
};
|
||||
template<typename Scalar>
|
||||
struct functor_traits<scalar_sinh_op<Scalar> >
|
||||
{
|
||||
enum {
|
||||
Cost = 5 * NumTraits<Scalar>::MulCost,
|
||||
PacketAccess = packet_traits<Scalar>::HasSinh
|
||||
};
|
||||
};
|
||||
|
||||
/** \internal
|
||||
* \brief Template functor to compute the cosh of a scalar
|
||||
* \sa class CwiseUnaryOp, ArrayBase::cosh()
|
||||
*/
|
||||
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;
|
||||
inline Packet packetOp(const Packet& a) const { return internal::pcosh(a); }
|
||||
};
|
||||
template<typename Scalar>
|
||||
struct functor_traits<scalar_cosh_op<Scalar> >
|
||||
{
|
||||
enum {
|
||||
Cost = 5 * NumTraits<Scalar>::MulCost,
|
||||
PacketAccess = packet_traits<Scalar>::HasCosh
|
||||
};
|
||||
};
|
||||
|
||||
/** \internal
|
||||
* \brief Template functor to compute the inverse of a scalar
|
||||
* \sa class CwiseUnaryOp, Cwise::inverse()
|
||||
|
@ -11,10 +11,13 @@ typedef CwiseUnaryOp<internal::scalar_log_op<Scalar>, const Derived> LogReturnTy
|
||||
typedef CwiseUnaryOp<internal::scalar_log10_op<Scalar>, const Derived> Log10ReturnType;
|
||||
typedef CwiseUnaryOp<internal::scalar_cos_op<Scalar>, const Derived> CosReturnType;
|
||||
typedef CwiseUnaryOp<internal::scalar_sin_op<Scalar>, const Derived> SinReturnType;
|
||||
typedef CwiseUnaryOp<internal::scalar_tan_op<Scalar>, const Derived> TanReturnType;
|
||||
typedef CwiseUnaryOp<internal::scalar_acos_op<Scalar>, const Derived> AcosReturnType;
|
||||
typedef CwiseUnaryOp<internal::scalar_asin_op<Scalar>, const Derived> AsinReturnType;
|
||||
typedef CwiseUnaryOp<internal::scalar_tan_op<Scalar>, const Derived> TanReturnType;
|
||||
typedef CwiseUnaryOp<internal::scalar_atan_op<Scalar>, const Derived> AtanReturnType;
|
||||
typedef CwiseUnaryOp<internal::scalar_tanh_op<Scalar>, const Derived> TanhReturnType;
|
||||
typedef CwiseUnaryOp<internal::scalar_sinh_op<Scalar>, const Derived> SinhReturnType;
|
||||
typedef CwiseUnaryOp<internal::scalar_cosh_op<Scalar>, const Derived> CoshReturnType;
|
||||
typedef CwiseUnaryOp<internal::scalar_pow_op<Scalar>, const Derived> PowReturnType;
|
||||
typedef CwiseUnaryOp<internal::scalar_square_op<Scalar>, const Derived> SquareReturnType;
|
||||
typedef CwiseUnaryOp<internal::scalar_cube_op<Scalar>, const Derived> CubeReturnType;
|
||||
@ -168,6 +171,33 @@ sin() const
|
||||
return SinReturnType(derived());
|
||||
}
|
||||
|
||||
/** \returns an expression of the coefficient-wise tan of *this.
|
||||
*
|
||||
* Example: \include Cwise_tan.cpp
|
||||
* Output: \verbinclude Cwise_tan.out
|
||||
*
|
||||
* \sa cos(), sin()
|
||||
*/
|
||||
EIGEN_DEVICE_FUNC
|
||||
inline const TanReturnType
|
||||
tan() const
|
||||
{
|
||||
return TanReturnType(derived());
|
||||
}
|
||||
|
||||
/** \returns an expression of the coefficient-wise arc tan of *this.
|
||||
*
|
||||
* Example: \include Cwise_atan.cpp
|
||||
* Output: \verbinclude Cwise_atan.out
|
||||
*
|
||||
* \sa tan(), asin(), acos()
|
||||
*/
|
||||
inline const AtanReturnType
|
||||
atan() const
|
||||
{
|
||||
return AtanReturnType(derived());
|
||||
}
|
||||
|
||||
/** \returns an expression of the coefficient-wise arc cosine of *this.
|
||||
*
|
||||
* Example: \include Cwise_acos.cpp
|
||||
@ -196,31 +226,43 @@ asin() const
|
||||
return AsinReturnType(derived());
|
||||
}
|
||||
|
||||
/** \returns an expression of the coefficient-wise tan of *this.
|
||||
/** \returns an expression of the coefficient-wise hyperbolic tan of *this.
|
||||
*
|
||||
* Example: \include Cwise_tan.cpp
|
||||
* Output: \verbinclude Cwise_tan.out
|
||||
* Example: \include Cwise_tanh.cpp
|
||||
* Output: \verbinclude Cwise_tanh.out
|
||||
*
|
||||
* \sa cos(), sin()
|
||||
* \sa tan(), sinh(), cosh()
|
||||
*/
|
||||
EIGEN_DEVICE_FUNC
|
||||
inline const TanReturnType
|
||||
tan() const
|
||||
inline const TanhReturnType
|
||||
tanh() const
|
||||
{
|
||||
return TanReturnType(derived());
|
||||
return TanhReturnType(derived());
|
||||
}
|
||||
|
||||
/** \returns an expression of the coefficient-wise arc tan of *this.
|
||||
/** \returns an expression of the coefficient-wise hyperbolic sin of *this.
|
||||
*
|
||||
* Example: \include Cwise_atan.cpp
|
||||
* Output: \verbinclude Cwise_atan.out
|
||||
* Example: \include Cwise_sinh.cpp
|
||||
* Output: \verbinclude Cwise_sinh.out
|
||||
*
|
||||
* \sa cos(), sin(), tan()
|
||||
* \sa sin(), tanh(), cosh()
|
||||
*/
|
||||
inline const AtanReturnType
|
||||
atan() const
|
||||
inline const SinhReturnType
|
||||
sinh() const
|
||||
{
|
||||
return AtanReturnType(derived());
|
||||
return SinhReturnType(derived());
|
||||
}
|
||||
|
||||
/** \returns an expression of the coefficient-wise hyperbolic cos of *this.
|
||||
*
|
||||
* Example: \include Cwise_cosh.cpp
|
||||
* Output: \verbinclude Cwise_cosh.out
|
||||
*
|
||||
* \sa tan(), sinh(), cosh()
|
||||
*/
|
||||
inline const CoshReturnType
|
||||
cosh() const
|
||||
{
|
||||
return CoshReturnType(derived());
|
||||
}
|
||||
|
||||
/** \returns an expression of the coefficient-wise power of *this to the given exponent.
|
||||
|
@ -200,10 +200,13 @@ template<typename ArrayType> void array_real(const ArrayType& m)
|
||||
// these tests are mostly to check possible compilation issues.
|
||||
VERIFY_IS_APPROX(m1.sin(), sin(m1));
|
||||
VERIFY_IS_APPROX(m1.cos(), cos(m1));
|
||||
VERIFY_IS_APPROX(m1.tan(), tan(m1));
|
||||
VERIFY_IS_APPROX(m1.asin(), asin(m1));
|
||||
VERIFY_IS_APPROX(m1.acos(), acos(m1));
|
||||
VERIFY_IS_APPROX(m1.tan(), tan(m1));
|
||||
VERIFY_IS_APPROX(m1.atan(), atan(m1));
|
||||
VERIFY_IS_APPROX(m1.sinh(), sinh(m1));
|
||||
VERIFY_IS_APPROX(m1.cosh(), cosh(m1));
|
||||
VERIFY_IS_APPROX(m1.tanh(), tanh(m1));
|
||||
VERIFY_IS_APPROX(m1.log(), log(m1));
|
||||
VERIFY_IS_APPROX(m1.log10(), log10(m1));
|
||||
VERIFY_IS_APPROX(m1.arg(), arg(m1));
|
||||
@ -281,6 +284,12 @@ template<typename ArrayType> void array_complex(const ArrayType& m)
|
||||
VERIFY_IS_APPROX(m1.isnan(), isnan(m1));
|
||||
VERIFY_IS_APPROX(m1.isinf(), isinf(m1));
|
||||
VERIFY_IS_APPROX(m1.square(), square(m1));
|
||||
VERIFY_IS_APPROX(m1.sin(), sin(m1));
|
||||
VERIFY_IS_APPROX(m1.cos(), cos(m1));
|
||||
VERIFY_IS_APPROX(m1.tan(), tan(m1));
|
||||
VERIFY_IS_APPROX(m1.sinh(), sinh(m1));
|
||||
VERIFY_IS_APPROX(m1.cosh(), cosh(m1));
|
||||
VERIFY_IS_APPROX(m1.tanh(), tanh(m1));
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user