aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Array
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2009-03-26 12:50:24 +0000
committerGravatar Gael Guennebaud <g.gael@free.fr>2009-03-26 12:50:24 +0000
commitce5669dbf9d3ed3502531a73b43184859d5881d2 (patch)
tree43f47cf897790e544bf579b6571608da840cfcb3 /Eigen/src/Array
parent62de40f8bb82bae0abeb8978d29725d0e3c8939e (diff)
* enable vectorization of sin, cos, etc. by default with an option to
disable them (-DEIGEN_FAST_MATH=0) * add a specialization of MatrixBase::operator*(RealScalar) for fast "matrix of complex" times scalar products (even more useful for autodiff scalar types)
Diffstat (limited to 'Eigen/src/Array')
-rw-r--r--Eigen/src/Array/CwiseOperators.h4
-rw-r--r--Eigen/src/Array/Functors.h28
2 files changed, 25 insertions, 7 deletions
diff --git a/Eigen/src/Array/CwiseOperators.h b/Eigen/src/Array/CwiseOperators.h
index 4b6346daa..9fcfbc9c0 100644
--- a/Eigen/src/Array/CwiseOperators.h
+++ b/Eigen/src/Array/CwiseOperators.h
@@ -82,7 +82,7 @@ Cwise<ExpressionType>::log() const
* Example: \include Cwise_cos.cpp
* Output: \verbinclude Cwise_cos.out
*
- * \sa sin(), exp()
+ * \sa sin(), exp(), EIGEN_FAST_MATH
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cos_op)
@@ -99,7 +99,7 @@ Cwise<ExpressionType>::cos() const
* Example: \include Cwise_sin.cpp
* Output: \verbinclude Cwise_sin.out
*
- * \sa cos(), exp()
+ * \sa cos(), exp(), EIGEN_FAST_MATH
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sin_op)
diff --git a/Eigen/src/Array/Functors.h b/Eigen/src/Array/Functors.h
index 0aae7fd2c..9759ebf2a 100644
--- a/Eigen/src/Array/Functors.h
+++ b/Eigen/src/Array/Functors.h
@@ -73,10 +73,12 @@ struct ei_functor_traits<ei_scalar_sqrt_op<Scalar> >
*/
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 = false }; };
+{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = ei_packet_traits<Scalar>::HasExp }; };
/** \internal
*
@@ -88,10 +90,12 @@ struct ei_functor_traits<ei_scalar_exp_op<Scalar> >
*/
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 = false }; };
+{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = ei_packet_traits<Scalar>::HasLog }; };
/** \internal
*
@@ -102,11 +106,18 @@ struct ei_functor_traits<ei_scalar_log_op<Scalar> >
* \sa class CwiseUnaryOp, Cwise::cos()
*/
template<typename Scalar> struct ei_scalar_cos_op EIGEN_EMPTY_STRUCT {
- inline const Scalar operator() (const Scalar& a) const { return ei_cos(a); }
+ inline Scalar operator() (const Scalar& a) const { return ei_cos(a); }
+ typedef typename ei_packet_traits<Scalar>::type Packet;
+ inline Packet packetOp(const Packet& a) const { return ei_pcos(a); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_cos_op<Scalar> >
-{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
+{
+ enum {
+ Cost = 5 * NumTraits<Scalar>::MulCost,
+ PacketAccess = ei_packet_traits<Scalar>::HasCos && EIGEN_FAST_MATH
+ };
+};
/** \internal
*
@@ -118,10 +129,17 @@ struct ei_functor_traits<ei_scalar_cos_op<Scalar> >
*/
template<typename Scalar> struct ei_scalar_sin_op EIGEN_EMPTY_STRUCT {
inline const Scalar operator() (const Scalar& a) const { return ei_sin(a); }
+ typedef typename ei_packet_traits<Scalar>::type Packet;
+ inline Packet packetOp(const Packet& a) const { return ei_psin(a); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_sin_op<Scalar> >
-{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
+{
+ enum {
+ Cost = 5 * NumTraits<Scalar>::MulCost,
+ PacketAccess = ei_packet_traits<Scalar>::HasSin && EIGEN_FAST_MATH
+ };
+};
/** \internal
*