diff options
author | 2009-08-24 09:46:17 -0400 | |
---|---|---|
committer | 2009-08-24 09:46:17 -0400 | |
commit | b8106e97b40b3a4f4653642e9f244bdae058437b (patch) | |
tree | cb266d79d5687687f0f374c77cb875fb249ba958 /Eigen/src/Core | |
parent | f31b5a71148387310a55a96158a494e83a19a0e2 (diff) |
add logAbsDeterminant()
move log and exp functors from Array to Core
update documentation
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r-- | Eigen/src/Core/CwiseUnaryOp.h | 29 | ||||
-rw-r--r-- | Eigen/src/Core/Functors.h | 30 |
2 files changed, 59 insertions, 0 deletions
diff --git a/Eigen/src/Core/CwiseUnaryOp.h b/Eigen/src/Core/CwiseUnaryOp.h index 3ffb24833..d701c25d9 100644 --- a/Eigen/src/Core/CwiseUnaryOp.h +++ b/Eigen/src/Core/CwiseUnaryOp.h @@ -205,6 +205,35 @@ MatrixBase<Derived>::cast() const return derived(); } +/** \returns an expression of the coefficient-wise exponential of *this. + * + * Example: \include Cwise_exp.cpp + * Output: \verbinclude Cwise_exp.out + * + * \sa pow(), log(), sin(), cos() + */ +template<typename ExpressionType> +inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op) +Cwise<ExpressionType>::exp() const +{ + return _expression(); +} + +/** \returns an expression of the coefficient-wise logarithm of *this. + * + * Example: \include Cwise_log.cpp + * Output: \verbinclude Cwise_log.out + * + * \sa exp() + */ +template<typename ExpressionType> +inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op) +Cwise<ExpressionType>::log() const +{ + return _expression(); +} + + /** \relates MatrixBase */ template<typename Derived> EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ScalarMultipleReturnType diff --git a/Eigen/src/Core/Functors.h b/Eigen/src/Core/Functors.h index a4c9604df..0c68d7434 100644 --- a/Eigen/src/Core/Functors.h +++ b/Eigen/src/Core/Functors.h @@ -299,6 +299,36 @@ struct ei_functor_traits<ei_scalar_imag_op<Scalar> > { enum { Cost = 0, PacketAccess = false }; }; /** \internal + * + * \brief Template functor to compute the exponential of a scalar + * + * \sa class CwiseUnaryOp, Cwise::exp() + */ +template<typename Scalar> struct ei_scalar_exp_op EIGEN_EMPTY_STRUCT { + inline const Scalar operator() (const Scalar& a) const { return ei_exp(a); } + typedef typename ei_packet_traits<Scalar>::type Packet; + inline Packet packetOp(const Packet& a) const { return ei_pexp(a); } +}; +template<typename Scalar> +struct ei_functor_traits<ei_scalar_exp_op<Scalar> > +{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = ei_packet_traits<Scalar>::HasExp }; }; + +/** \internal + * + * \brief Template functor to compute the logarithm of a scalar + * + * \sa class CwiseUnaryOp, Cwise::log() + */ +template<typename Scalar> struct ei_scalar_log_op EIGEN_EMPTY_STRUCT { + inline const Scalar operator() (const Scalar& a) const { return ei_log(a); } + typedef typename ei_packet_traits<Scalar>::type Packet; + inline Packet packetOp(const Packet& a) const { return ei_plog(a); } +}; +template<typename Scalar> +struct ei_functor_traits<ei_scalar_log_op<Scalar> > +{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = ei_packet_traits<Scalar>::HasLog }; }; + +/** \internal * \brief Template functor to multiply a scalar by a fixed other one * * \sa class CwiseUnaryOp, MatrixBase::operator*, MatrixBase::operator/ |