mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Add log10 array support
This commit is contained in:
parent
19a71056ae
commit
a5e49976f5
@ -206,6 +206,7 @@ EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(atan, Atan)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(arg, Arg)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(exp, Exp)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(log, Ln)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(log10, Log10)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(sqrt, Sqrt)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(round, Round)
|
||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(floor, Floor)
|
||||
|
@ -61,6 +61,7 @@ struct default_packet_traits
|
||||
HasSqrt = 0,
|
||||
HasExp = 0,
|
||||
HasLog = 0,
|
||||
HasLog10 = 0,
|
||||
HasPow = 0,
|
||||
|
||||
HasSin = 0,
|
||||
@ -359,6 +360,10 @@ Packet pexp(const Packet& a) { using std::exp; return exp(a); }
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet plog(const Packet& a) { using std::log; return log(a); }
|
||||
|
||||
/** \internal \returns the log10 of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet plog10(const Packet& a) { using std::log10; return log10(a); }
|
||||
|
||||
/** \internal \returns the square-root of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet psqrt(const Packet& a) { using std::sqrt; return sqrt(a); }
|
||||
|
@ -48,6 +48,7 @@ namespace Eigen
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(atan,scalar_atan_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)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(abs,scalar_abs_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(arg,scalar_arg_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sqrt,scalar_sqrt_op)
|
||||
|
@ -254,6 +254,21 @@ template<typename Scalar>
|
||||
struct functor_traits<scalar_log_op<Scalar> >
|
||||
{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasLog }; };
|
||||
|
||||
/** \internal
|
||||
*
|
||||
* \brief Template functor to compute the base-10 logarithm of a scalar
|
||||
*
|
||||
* \sa class CwiseUnaryOp, Cwise::log10()
|
||||
*/
|
||||
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;
|
||||
inline Packet packetOp(const Packet& a) const { return internal::plog10(a); }
|
||||
};
|
||||
template<typename Scalar>
|
||||
struct functor_traits<scalar_log10_op<Scalar> >
|
||||
{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasLog10 }; };
|
||||
|
||||
/** \internal
|
||||
* \brief Template functor to compute the square root of a scalar
|
||||
|
@ -8,6 +8,7 @@ typedef CwiseUnaryOp<internal::scalar_inverse_op<Scalar>, const Derived> Inverse
|
||||
|
||||
typedef CwiseUnaryOp<internal::scalar_exp_op<Scalar>, const Derived> ExpReturnType;
|
||||
typedef CwiseUnaryOp<internal::scalar_log_op<Scalar>, const Derived> LogReturnType;
|
||||
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_acos_op<Scalar>, const Derived> AcosReturnType;
|
||||
@ -99,6 +100,22 @@ log() const
|
||||
return LogReturnType(derived());
|
||||
}
|
||||
|
||||
/** \returns an expression of the coefficient-wise base-10 logarithm of *this.
|
||||
*
|
||||
* This function computes the coefficient-wise base-10 logarithm.
|
||||
*
|
||||
* Example: \include Cwise_log10.cpp
|
||||
* Output: \verbinclude Cwise_log10.out
|
||||
*
|
||||
* \sa log()
|
||||
*/
|
||||
EIGEN_DEVICE_FUNC
|
||||
inline const Log10ReturnType
|
||||
log10() const
|
||||
{
|
||||
return Log10ReturnType(derived());
|
||||
}
|
||||
|
||||
/** \returns an expression of the coefficient-wise square root of *this.
|
||||
*
|
||||
* This function computes the coefficient-wise square root. The function MatrixBase::sqrt() in the
|
||||
|
@ -204,6 +204,9 @@ template<typename ArrayType> void array_real(const ArrayType& m)
|
||||
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.log(), log(m1));
|
||||
VERIFY_IS_APPROX(m1.log10(), log10(m1));
|
||||
VERIFY_IS_APPROX(m1.arg(), arg(m1));
|
||||
VERIFY_IS_APPROX(m1.round(), round(m1));
|
||||
VERIFY_IS_APPROX(m1.floor(), floor(m1));
|
||||
VERIFY_IS_APPROX(m1.ceil(), ceil(m1));
|
||||
@ -269,6 +272,8 @@ template<typename ArrayType> void array_complex(const ArrayType& m)
|
||||
|
||||
VERIFY_IS_APPROX(m1.sqrt(), m2);
|
||||
VERIFY_IS_APPROX(m1.sqrt(), Eigen::sqrt(m1));
|
||||
VERIFY_IS_APPROX(m1.log(), log(m1));
|
||||
VERIFY_IS_APPROX(m1.log10(), log10(m1));
|
||||
VERIFY_IS_APPROX(m1.arg(), arg(m1));
|
||||
VERIFY_IS_APPROX(m1.round(), round(m1));
|
||||
VERIFY_IS_APPROX(m1.floor(), floor(m1));
|
||||
|
Loading…
x
Reference in New Issue
Block a user