aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/CwiseUnaryOp.h
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2010-04-18 22:14:55 -0400
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2010-04-18 22:14:55 -0400
commit504a31f643468d05a10e3474b76a61e80022df59 (patch)
tree7a1e64c8e95c001a998aa27d9ccb31a68a197339 /Eigen/src/Core/CwiseUnaryOp.h
parent34b14c48f31e5b794d48fd083f5fa39d7b4a6411 (diff)
renaming (MatrixType ---> whatever appropriate)
and documentation improvements
Diffstat (limited to 'Eigen/src/Core/CwiseUnaryOp.h')
-rw-r--r--Eigen/src/Core/CwiseUnaryOp.h69
1 files changed, 37 insertions, 32 deletions
diff --git a/Eigen/src/Core/CwiseUnaryOp.h b/Eigen/src/Core/CwiseUnaryOp.h
index fb0f2f6ad..3ac1ec9ea 100644
--- a/Eigen/src/Core/CwiseUnaryOp.h
+++ b/Eigen/src/Core/CwiseUnaryOp.h
@@ -28,79 +28,84 @@
/** \class CwiseUnaryOp
*
- * \brief Generic expression of a coefficient-wise unary operator of a matrix or a vector
+ * \brief Generic expression where a coefficient-wise unary operator is applied to an expression
*
* \param UnaryOp template functor implementing the operator
- * \param MatrixType the type of the matrix we are applying the unary operator
+ * \param XprType the type of the expression to which we are applying the unary operator
*
- * This class represents an expression of a generic unary operator of a matrix or a vector.
- * It is the return type of the unary operator-, of a matrix or a vector, and most
- * of the time this is the only way it is used.
+ * This class represents an expression where a unary operator is applied to an expression.
+ * It is the return type of all operations taking exactly 1 input expression, regardless of the
+ * presence of other inputs such as scalars. For example, the operator* in the expression 3*matrix
+ * is considered unary, because only the right-hand side is an expression, and its
+ * return type is a specialization of CwiseUnaryOp.
+ *
+ * Most of the time, this is the only way that it is used, so you typically don't have to name
+ * CwiseUnaryOp types explicitly.
*
* \sa MatrixBase::unaryExpr(const CustomUnaryOp &) const, class CwiseBinaryOp, class CwiseNullaryOp
*/
-template<typename UnaryOp, typename MatrixType>
-struct ei_traits<CwiseUnaryOp<UnaryOp, MatrixType> >
- : ei_traits<MatrixType>
+template<typename UnaryOp, typename XprType>
+struct ei_traits<CwiseUnaryOp<UnaryOp, XprType> >
+ : ei_traits<XprType>
{
typedef typename ei_result_of<
- UnaryOp(typename MatrixType::Scalar)
+ UnaryOp(typename XprType::Scalar)
>::type Scalar;
- typedef typename MatrixType::Nested MatrixTypeNested;
- typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
+ typedef typename XprType::Nested XprTypeNested;
+ typedef typename ei_unref<XprTypeNested>::type _XprTypeNested;
enum {
- Flags = _MatrixTypeNested::Flags & (
+ Flags = _XprTypeNested::Flags & (
HereditaryBits | LinearAccessBit | AlignedBit
| (ei_functor_traits<UnaryOp>::PacketAccess ? PacketAccessBit : 0)),
- CoeffReadCost = _MatrixTypeNested::CoeffReadCost + ei_functor_traits<UnaryOp>::Cost
+ CoeffReadCost = _XprTypeNested::CoeffReadCost + ei_functor_traits<UnaryOp>::Cost
};
};
-template<typename UnaryOp, typename MatrixType, typename StorageKind>
+template<typename UnaryOp, typename XprType, typename StorageKind>
class CwiseUnaryOpImpl;
-template<typename UnaryOp, typename MatrixType>
+template<typename UnaryOp, typename XprType>
class CwiseUnaryOp : ei_no_assignment_operator,
- public CwiseUnaryOpImpl<UnaryOp, MatrixType, typename ei_traits<MatrixType>::StorageKind>
+ public CwiseUnaryOpImpl<UnaryOp, XprType, typename ei_traits<XprType>::StorageKind>
{
public:
- typedef typename CwiseUnaryOpImpl<UnaryOp, MatrixType,typename ei_traits<MatrixType>::StorageKind>::Base Base;
+ typedef typename CwiseUnaryOpImpl<UnaryOp, XprType,typename ei_traits<XprType>::StorageKind>::Base Base;
EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(CwiseUnaryOp)
- inline CwiseUnaryOp(const MatrixType& mat, const UnaryOp& func = UnaryOp())
- : m_matrix(mat), m_functor(func) {}
+ inline CwiseUnaryOp(const XprType& xpr, const UnaryOp& func = UnaryOp())
+ : m_xpr(xpr), m_functor(func) {}
- EIGEN_STRONG_INLINE int rows() const { return m_matrix.rows(); }
- EIGEN_STRONG_INLINE int cols() const { return m_matrix.cols(); }
+ EIGEN_STRONG_INLINE int rows() const { return m_xpr.rows(); }
+ EIGEN_STRONG_INLINE int cols() const { return m_xpr.cols(); }
/** \returns the functor representing the unary operation */
const UnaryOp& functor() const { return m_functor; }
/** \returns the nested expression */
- const typename ei_cleantype<typename MatrixType::Nested>::type&
- nestedExpression() const { return m_matrix; }
+ const typename ei_cleantype<typename XprType::Nested>::type&
+ nestedExpression() const { return m_xpr; }
/** \returns the nested expression */
- typename ei_cleantype<typename MatrixType::Nested>::type&
- nestedExpression() { return m_matrix.const_cast_derived(); }
+ typename ei_cleantype<typename XprType::Nested>::type&
+ nestedExpression() { return m_xpr.const_cast_derived(); }
protected:
- const typename MatrixType::Nested m_matrix;
+ const typename XprType::Nested m_xpr;
const UnaryOp m_functor;
};
// This is the generic implementation for dense storage.
-// It can be used for any matrix types implementing the dense concept.
-template<typename UnaryOp, typename MatrixType>
-class CwiseUnaryOpImpl<UnaryOp,MatrixType,Dense>
- : public MatrixType::template MakeBase< CwiseUnaryOp<UnaryOp, MatrixType> >::Type
+// It can be used for any expression types implementing the dense concept.
+template<typename UnaryOp, typename XprType>
+class CwiseUnaryOpImpl<UnaryOp,XprType,Dense>
+ : public XprType::template MakeBase< CwiseUnaryOp<UnaryOp, XprType> >::Type
{
- typedef CwiseUnaryOp<UnaryOp, MatrixType> Derived;
+ typedef CwiseUnaryOp<UnaryOp, XprType> Derived;
public:
- typedef typename MatrixType::template MakeBase< CwiseUnaryOp<UnaryOp, MatrixType> >::Type Base;
+ typedef typename XprType::template MakeBase< CwiseUnaryOp<UnaryOp, XprType> >::Type Base;
EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
EIGEN_STRONG_INLINE const Scalar coeff(int row, int col) const