mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-11-27 06:30:28 +08:00
add tan function in Array world
This commit is contained in:
parent
1eae6d0fb9
commit
d028262e06
@ -705,6 +705,26 @@ struct functor_traits<scalar_sin_op<Scalar> >
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/** \internal
|
||||
* \brief Template functor to compute the tan of a scalar
|
||||
* \sa class CwiseUnaryOp, Cwise::tan()
|
||||
*/
|
||||
template<typename Scalar> struct scalar_tan_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_tan_op)
|
||||
inline const Scalar operator() (const Scalar& a) const { return tan(a); }
|
||||
typedef typename packet_traits<Scalar>::type Packet;
|
||||
inline Packet packetOp(const Packet& a) const { return internal::ptan(a); }
|
||||
};
|
||||
template<typename Scalar>
|
||||
struct functor_traits<scalar_tan_op<Scalar> >
|
||||
{
|
||||
enum {
|
||||
Cost = 5 * NumTraits<Scalar>::MulCost,
|
||||
PacketAccess = packet_traits<Scalar>::HasTan
|
||||
};
|
||||
};
|
||||
|
||||
/** \internal
|
||||
* \brief Template functor to raise a scalar to a power
|
||||
* \sa class CwiseUnaryOp, Cwise::pow
|
||||
|
@ -237,6 +237,10 @@ Packet psin(const Packet& a) { return sin(a); }
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet pcos(const Packet& a) { return cos(a); }
|
||||
|
||||
/** \internal \returns the tan of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet ptan(const Packet& a) { return tan(a); }
|
||||
|
||||
/** \internal \returns the exp of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet pexp(const Packet& a) { return exp(a); }
|
||||
|
@ -93,6 +93,20 @@ sin() const
|
||||
}
|
||||
|
||||
|
||||
/** \returns an expression of the coefficient-wise tan of *this.
|
||||
*
|
||||
* Example: \include Cwise_tan.cpp
|
||||
* Output: \verbinclude Cwise_tan.out
|
||||
*
|
||||
* \sa cos(), sin()
|
||||
*/
|
||||
inline const CwiseUnaryOp<internal::scalar_tan_op<Scalar>, Derived>
|
||||
tan() const
|
||||
{
|
||||
return derived();
|
||||
}
|
||||
|
||||
|
||||
/** \returns an expression of the coefficient-wise power of *this to the given exponent.
|
||||
*
|
||||
* Example: \include Cwise_pow.cpp
|
||||
|
2
doc/snippets/Cwise_tan.cpp
Normal file
2
doc/snippets/Cwise_tan.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
Array3d v(M_PI, M_PI/2, M_PI/3);
|
||||
cout << v.tan() << endl;
|
Loading…
Reference in New Issue
Block a user