From 504a31f643468d05a10e3474b76a61e80022df59 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Sun, 18 Apr 2010 22:14:55 -0400 Subject: renaming (MatrixType ---> whatever appropriate) and documentation improvements --- Eigen/src/Core/CwiseUnaryOp.h | 69 +++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 32 deletions(-) (limited to 'Eigen/src/Core/CwiseUnaryOp.h') 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 -struct ei_traits > - : ei_traits +template +struct ei_traits > + : ei_traits { typedef typename ei_result_of< - UnaryOp(typename MatrixType::Scalar) + UnaryOp(typename XprType::Scalar) >::type Scalar; - typedef typename MatrixType::Nested MatrixTypeNested; - typedef typename ei_unref::type _MatrixTypeNested; + typedef typename XprType::Nested XprTypeNested; + typedef typename ei_unref::type _XprTypeNested; enum { - Flags = _MatrixTypeNested::Flags & ( + Flags = _XprTypeNested::Flags & ( HereditaryBits | LinearAccessBit | AlignedBit | (ei_functor_traits::PacketAccess ? PacketAccessBit : 0)), - CoeffReadCost = _MatrixTypeNested::CoeffReadCost + ei_functor_traits::Cost + CoeffReadCost = _XprTypeNested::CoeffReadCost + ei_functor_traits::Cost }; }; -template +template class CwiseUnaryOpImpl; -template +template class CwiseUnaryOp : ei_no_assignment_operator, - public CwiseUnaryOpImpl::StorageKind> + public CwiseUnaryOpImpl::StorageKind> { public: - typedef typename CwiseUnaryOpImpl::StorageKind>::Base Base; + typedef typename CwiseUnaryOpImpl::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::type& - nestedExpression() const { return m_matrix; } + const typename ei_cleantype::type& + nestedExpression() const { return m_xpr; } /** \returns the nested expression */ - typename ei_cleantype::type& - nestedExpression() { return m_matrix.const_cast_derived(); } + typename ei_cleantype::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 -class CwiseUnaryOpImpl - : public MatrixType::template MakeBase< CwiseUnaryOp >::Type +// It can be used for any expression types implementing the dense concept. +template +class CwiseUnaryOpImpl + : public XprType::template MakeBase< CwiseUnaryOp >::Type { - typedef CwiseUnaryOp Derived; + typedef CwiseUnaryOp Derived; public: - typedef typename MatrixType::template MakeBase< CwiseUnaryOp >::Type Base; + typedef typename XprType::template MakeBase< CwiseUnaryOp >::Type Base; EIGEN_DENSE_PUBLIC_INTERFACE(Derived) EIGEN_STRONG_INLINE const Scalar coeff(int row, int col) const -- cgit v1.2.3