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/Block.h | 172 +++++++++++++++---------------- Eigen/src/Core/CommaInitializer.h | 42 ++++---- Eigen/src/Core/CwiseBinaryOp.h | 13 +-- Eigen/src/Core/CwiseNullaryOp.h | 15 +-- Eigen/src/Core/CwiseUnaryOp.h | 69 +++++++------ Eigen/src/Core/Map.h | 24 ++--- Eigen/src/plugins/ArrayCwiseBinaryOps.h | 121 ---------------------- Eigen/src/plugins/CommonCwiseBinaryOps.h | 6 +- Eigen/src/plugins/CommonCwiseUnaryOps.h | 18 ++-- Eigen/src/plugins/MatrixCwiseBinaryOps.h | 12 +-- Eigen/src/plugins/MatrixCwiseUnaryOps.h | 4 +- 11 files changed, 191 insertions(+), 305 deletions(-) diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index ac8f20fa2..d0e6d4ee8 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -30,7 +30,7 @@ * * \brief Expression of a fixed-size or dynamic-size block * - * \param MatrixType the type of the object in which we are taking a block + * \param XprType the type of the expression in which we are taking a block * \param BlockRows the number of rows of the block we are taking at compile time (optional) * \param BlockCols the number of columns of the block we are taking at compile time (optional) * \param _DirectAccessStatus \internal used for partial specialization @@ -47,7 +47,7 @@ * \include class_Block.cpp * Output: \verbinclude class_Block.out * - * \note Even though this expression has dynamic size, in the case where \a MatrixType + * \note Even though this expression has dynamic size, in the case where \a XprType * has fixed size, this expression inherits a fixed maximal size which means that evaluating * it does not cause a dynamic memory allocation. * @@ -57,99 +57,99 @@ * * \sa DenseBase::block(int,int,int,int), DenseBase::block(int,int), class VectorBlock */ -template -struct ei_traits > : ei_traits +template +struct ei_traits > : ei_traits { - typedef typename ei_traits::Scalar Scalar; - typedef typename ei_traits::StorageKind StorageKind; - typedef typename ei_traits::XprKind XprKind; - typedef typename ei_nested::type MatrixTypeNested; - typedef typename ei_unref::type _MatrixTypeNested; + typedef typename ei_traits::Scalar Scalar; + typedef typename ei_traits::StorageKind StorageKind; + typedef typename ei_traits::XprKind XprKind; + typedef typename ei_nested::type XprTypeNested; + typedef typename ei_unref::type _XprTypeNested; enum{ - MatrixRows = ei_traits::RowsAtCompileTime, - MatrixCols = ei_traits::ColsAtCompileTime, + MatrixRows = ei_traits::RowsAtCompileTime, + MatrixCols = ei_traits::ColsAtCompileTime, RowsAtCompileTime = MatrixRows == 0 ? 0 : BlockRows, ColsAtCompileTime = MatrixCols == 0 ? 0 : BlockCols, MaxRowsAtCompileTime = BlockRows==0 ? 0 : RowsAtCompileTime != Dynamic ? int(RowsAtCompileTime) - : int(ei_traits::MaxRowsAtCompileTime), + : int(ei_traits::MaxRowsAtCompileTime), MaxColsAtCompileTime = BlockCols==0 ? 0 : ColsAtCompileTime != Dynamic ? int(ColsAtCompileTime) - : int(ei_traits::MaxColsAtCompileTime), - MatrixTypeIsRowMajor = (int(ei_traits::Flags)&RowMajorBit) != 0, + : int(ei_traits::MaxColsAtCompileTime), + XprTypeIsRowMajor = (int(ei_traits::Flags)&RowMajorBit) != 0, IsRowMajor = (MaxRowsAtCompileTime==1&&MaxColsAtCompileTime!=1) ? 1 : (MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0 - : MatrixTypeIsRowMajor, - HasSameStorageOrderAsMatrixType = (IsRowMajor == MatrixTypeIsRowMajor), - InnerSize = MatrixTypeIsRowMajor // notice how it's MatrixTypeIsRowMajor here, not IsRowMajor. Inner size is computed wrt the host matrix's storage order. + : XprTypeIsRowMajor, + HasSameStorageOrderAsXprType = (IsRowMajor == XprTypeIsRowMajor), + InnerSize = XprTypeIsRowMajor // notice how it's XprTypeIsRowMajor here, not IsRowMajor. Inner size is computed wrt the host matrix's storage order. ? int(ColsAtCompileTime) : int(RowsAtCompileTime), - InnerStrideAtCompileTime = HasSameStorageOrderAsMatrixType - ? int(ei_inner_stride_at_compile_time::ret) - : int(ei_outer_stride_at_compile_time::ret), - OuterStrideAtCompileTime = HasSameStorageOrderAsMatrixType - ? int(ei_outer_stride_at_compile_time::ret) - : int(ei_inner_stride_at_compile_time::ret), + InnerStrideAtCompileTime = HasSameStorageOrderAsXprType + ? int(ei_inner_stride_at_compile_time::ret) + : int(ei_outer_stride_at_compile_time::ret), + OuterStrideAtCompileTime = HasSameStorageOrderAsXprType + ? int(ei_outer_stride_at_compile_time::ret) + : int(ei_inner_stride_at_compile_time::ret), MaskPacketAccessBit = (InnerSize == Dynamic || (InnerSize % ei_packet_traits::size) == 0) && (InnerStrideAtCompileTime == 1) ? PacketAccessBit : 0, FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ? LinearAccessBit : 0, - Flags0 = ei_traits::Flags & (HereditaryBits | MaskPacketAccessBit | DirectAccessBit), + Flags0 = ei_traits::Flags & (HereditaryBits | MaskPacketAccessBit | DirectAccessBit), Flags1 = Flags0 | FlagsLinearAccessBit, Flags = (Flags1 & ~RowMajorBit) | (IsRowMajor ? RowMajorBit : 0) }; }; -template class Block - : public ei_dense_xpr_base >::type +template class Block + : public ei_dense_xpr_base >::type { public: - typedef typename MatrixType::template MakeBase< Block >::Type Base; + typedef typename XprType::template MakeBase< Block >::Type Base; EIGEN_DENSE_PUBLIC_INTERFACE(Block) class InnerIterator; /** Column or Row constructor */ - inline Block(const MatrixType& matrix, int i) - : m_matrix(matrix), - // It is a row if and only if BlockRows==1 and BlockCols==MatrixType::ColsAtCompileTime, - // and it is a column if and only if BlockRows==MatrixType::RowsAtCompileTime and BlockCols==1, + inline Block(const XprType& xpr, int i) + : m_xpr(xpr), + // It is a row if and only if BlockRows==1 and BlockCols==XprType::ColsAtCompileTime, + // and it is a column if and only if BlockRows==XprType::RowsAtCompileTime and BlockCols==1, // all other cases are invalid. // The case a 1x1 matrix seems ambiguous, but the result is the same anyway. - m_startRow( (BlockRows==1) && (BlockCols==MatrixType::ColsAtCompileTime) ? i : 0), - m_startCol( (BlockRows==MatrixType::RowsAtCompileTime) && (BlockCols==1) ? i : 0), - m_blockRows(BlockRows==1 ? 1 : matrix.rows()), - m_blockCols(BlockCols==1 ? 1 : matrix.cols()) + m_startRow( (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0), + m_startCol( (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? i : 0), + m_blockRows(BlockRows==1 ? 1 : xpr.rows()), + m_blockCols(BlockCols==1 ? 1 : xpr.cols()) { ei_assert( (i>=0) && ( - ((BlockRows==1) && (BlockCols==MatrixType::ColsAtCompileTime) && i= 0 && BlockRows >= 1 && startRow + BlockRows <= matrix.rows() - && startCol >= 0 && BlockCols >= 1 && startCol + BlockCols <= matrix.cols()); + ei_assert(startRow >= 0 && BlockRows >= 1 && startRow + BlockRows <= xpr.rows() + && startCol >= 0 && BlockCols >= 1 && startCol + BlockCols <= xpr.cols()); } /** Dynamic-size constructor */ - inline Block(const MatrixType& matrix, + inline Block(const XprType& xpr, int startRow, int startCol, int blockRows, int blockCols) - : m_matrix(matrix), m_startRow(startRow), m_startCol(startCol), + : m_xpr(xpr), m_startRow(startRow), m_startCol(startCol), m_blockRows(blockRows), m_blockCols(blockCols) { ei_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows) && (ColsAtCompileTime==Dynamic || ColsAtCompileTime==blockCols)); - ei_assert(startRow >= 0 && blockRows >= 0 && startRow + blockRows <= matrix.rows() - && startCol >= 0 && blockCols >= 0 && startCol + blockCols <= matrix.cols()); + ei_assert(startRow >= 0 && blockRows >= 0 && startRow + blockRows <= xpr.rows() + && startCol >= 0 && blockCols >= 0 && startCol + blockCols <= xpr.cols()); } EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block) @@ -159,25 +159,25 @@ template inline PacketScalar packet(int row, int col) const { - return m_matrix.template packet + return m_xpr.template packet (row + m_startRow.value(), col + m_startCol.value()); } template inline void writePacket(int row, int col, const PacketScalar& x) { - m_matrix.const_cast_derived().template writePacket + m_xpr.const_cast_derived().template writePacket (row + m_startRow.value(), col + m_startCol.value(), x); } template inline PacketScalar packet(int index) const { - return m_matrix.template packet + return m_xpr.template packet (m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index), m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0)); } @@ -207,7 +207,7 @@ template inline void writePacket(int index, const PacketScalar& x) { - m_matrix.const_cast_derived().template writePacket + m_xpr.const_cast_derived().template writePacket (m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index), m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0), x); } @@ -221,17 +221,17 @@ template m_startRow; - const ei_int_if_dynamic m_startCol; + const typename XprType::Nested m_xpr; + const ei_int_if_dynamic m_startRow; + const ei_int_if_dynamic m_startCol; const ei_int_if_dynamic m_blockRows; const ei_int_if_dynamic m_blockCols; }; /** \internal */ -template -class Block - : public MapBase > +template +class Block + : public MapBase > { public: @@ -242,56 +242,56 @@ class Block /** Column or Row constructor */ - inline Block(const MatrixType& matrix, int i) - : Base(&matrix.const_cast_derived().coeffRef( - (BlockRows==1) && (BlockCols==MatrixType::ColsAtCompileTime) ? i : 0, - (BlockRows==MatrixType::RowsAtCompileTime) && (BlockCols==1) ? i : 0), - BlockRows==1 ? 1 : matrix.rows(), - BlockCols==1 ? 1 : matrix.cols()), - m_matrix(matrix) + inline Block(const XprType& xpr, int i) + : Base(&xpr.const_cast_derived().coeffRef( + (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0, + (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? i : 0), + BlockRows==1 ? 1 : xpr.rows(), + BlockCols==1 ? 1 : xpr.cols()), + m_xpr(xpr) { ei_assert( (i>=0) && ( - ((BlockRows==1) && (BlockCols==MatrixType::ColsAtCompileTime) && i= 0 && BlockRows >= 1 && startRow + BlockRows <= matrix.rows() - && startCol >= 0 && BlockCols >= 1 && startCol + BlockCols <= matrix.cols()); + ei_assert(startRow >= 0 && BlockRows >= 1 && startRow + BlockRows <= xpr.rows() + && startCol >= 0 && BlockCols >= 1 && startCol + BlockCols <= xpr.cols()); } /** Dynamic-size constructor */ - inline Block(const MatrixType& matrix, + inline Block(const XprType& xpr, int startRow, int startCol, int blockRows, int blockCols) - : Base(&matrix.const_cast_derived().coeffRef(startRow,startCol), blockRows, blockCols), - m_matrix(matrix) + : Base(&xpr.const_cast_derived().coeffRef(startRow,startCol), blockRows, blockCols), + m_xpr(xpr) { ei_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows) && (ColsAtCompileTime==Dynamic || ColsAtCompileTime==blockCols)); - ei_assert(startRow >= 0 && blockRows >= 0 && startRow + blockRows <= matrix.rows() - && startCol >= 0 && blockCols >= 0 && startCol + blockCols <= matrix.cols()); + ei_assert(startRow >= 0 && blockRows >= 0 && startRow + blockRows <= xpr.rows() + && startCol >= 0 && blockCols >= 0 && startCol + blockCols <= xpr.cols()); } /** \sa MapBase::innerStride() */ inline int innerStride() const { - return ei_traits::HasSameStorageOrderAsMatrixType - ? m_matrix.innerStride() - : m_matrix.outerStride(); + return ei_traits::HasSameStorageOrderAsXprType + ? m_xpr.innerStride() + : m_xpr.outerStride(); } /** \sa MapBase::outerStride() */ inline int outerStride() const { - return ei_traits::HasSameStorageOrderAsMatrixType - ? m_matrix.outerStride() - : m_matrix.innerStride(); + return ei_traits::HasSameStorageOrderAsXprType + ? m_xpr.outerStride() + : m_xpr.innerStride(); } #ifndef __SUNPRO_CC @@ -302,13 +302,13 @@ class Block #ifndef EIGEN_PARSED_BY_DOXYGEN /** \internal used by allowAligned() */ - inline Block(const MatrixType& matrix, const Scalar* data, int blockRows, int blockCols) - : Base(data, blockRows, blockCols), m_matrix(matrix) + inline Block(const XprType& xpr, const Scalar* data, int blockRows, int blockCols) + : Base(data, blockRows, blockCols), m_xpr(xpr) {} #endif protected: - const typename MatrixType::Nested m_matrix; + const typename XprType::Nested m_xpr; }; /** \returns a dynamic-size expression of a block in *this. diff --git a/Eigen/src/Core/CommaInitializer.h b/Eigen/src/Core/CommaInitializer.h index a312b40f5..adfca4f9a 100644 --- a/Eigen/src/Core/CommaInitializer.h +++ b/Eigen/src/Core/CommaInitializer.h @@ -36,38 +36,38 @@ * * \sa \ref MatrixBaseCommaInitRef "MatrixBase::operator<<", CommaInitializer::finished() */ -template +template struct CommaInitializer { - typedef typename ei_traits::Scalar Scalar; - inline CommaInitializer(MatrixType& mat, const Scalar& s) - : m_matrix(mat), m_row(0), m_col(1), m_currentBlockRows(1) + typedef typename ei_traits::Scalar Scalar; + inline CommaInitializer(XprType& xpr, const Scalar& s) + : m_xpr(xpr), m_row(0), m_col(1), m_currentBlockRows(1) { - m_matrix.coeffRef(0,0) = s; + m_xpr.coeffRef(0,0) = s; } template - inline CommaInitializer(MatrixType& mat, const DenseBase& other) - : m_matrix(mat), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows()) + inline CommaInitializer(XprType& xpr, const DenseBase& other) + : m_xpr(xpr), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows()) { - m_matrix.block(0, 0, other.rows(), other.cols()) = other; + m_xpr.block(0, 0, other.rows(), other.cols()) = other; } /* inserts a scalar value in the target matrix */ CommaInitializer& operator,(const Scalar& s) { - if (m_col==m_matrix.cols()) + if (m_col==m_xpr.cols()) { m_row+=m_currentBlockRows; m_col = 0; m_currentBlockRows = 1; - ei_assert(m_row CommaInitializer& operator,(const DenseBase& other) { - if (m_col==m_matrix.cols()) + if (m_col==m_xpr.cols()) { m_row+=m_currentBlockRows; m_col = 0; m_currentBlockRows = other.rows(); - ei_assert(m_row+m_currentBlockRows<=m_matrix.rows() + ei_assert(m_row+m_currentBlockRows<=m_xpr.rows() && "Too many rows passed to comma initializer (operator<<)"); } - ei_assert(m_col (m_row, m_col) = other; else - m_matrix.block(m_row, m_col, other.rows(), other.cols()) = other; + m_xpr.block(m_row, m_col, other.rows(), other.cols()) = other; m_col += other.cols(); return *this; } inline ~CommaInitializer() { - ei_assert((m_row+m_currentBlockRows) == m_matrix.rows() - && m_col == m_matrix.cols() + ei_assert((m_row+m_currentBlockRows) == m_xpr.rows() + && m_col == m_xpr.cols() && "Too few coefficients passed to comma initializer (operator<<)"); } @@ -110,9 +110,9 @@ struct CommaInitializer * quaternion.fromRotationMatrix((Matrix3f() << axis0, axis1, axis2).finished()); * \endcode */ - inline MatrixType& finished() { return m_matrix; } + inline XprType& finished() { return m_xpr; } - MatrixType& m_matrix; // target matrix + XprType& m_xpr; // target expression int m_row; // current row id int m_col; // current col id int m_currentBlockRows; // current block height diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h index dd74f5b5c..18baf0307 100644 --- a/Eigen/src/Core/CwiseBinaryOp.h +++ b/Eigen/src/Core/CwiseBinaryOp.h @@ -28,18 +28,19 @@ /** \class CwiseBinaryOp * - * \brief Generic expression of a coefficient-wise operator between two matrices or vectors + * \brief Generic expression where a coefficient-wise binary operator is applied to two expressions * * \param BinaryOp template functor implementing the operator * \param Lhs the type of the left-hand side * \param Rhs the type of the right-hand side * - * This class represents an expression of a generic binary operator of two matrices or vectors. - * It is the return type of the operator+, operator-, and the Cwise methods, and most - * of the time this is the only way it is used. + * This class represents an expression where a coefficient-wise binary operator is applied to two expressions. + * It is the return type of binary operators, by which we mean only those binary operators where + * both the left-hand side and the right-hand side are Eigen expressions. + * For example, the return type of matrix1+matrix2 is a CwiseBinaryOp. * - * However, if you want to write a function returning such an expression, you - * will need to use this class. + * Most of the time, this is the only way that it is used, so you typically don't have to name + * CwiseBinaryOp types explicitly. * * \sa MatrixBase::binaryExpr(const MatrixBase &,const CustomBinaryOp &) const, class CwiseUnaryOp, class CwiseNullaryOp */ diff --git a/Eigen/src/Core/CwiseNullaryOp.h b/Eigen/src/Core/CwiseNullaryOp.h index 2fba90488..179df611c 100644 --- a/Eigen/src/Core/CwiseNullaryOp.h +++ b/Eigen/src/Core/CwiseNullaryOp.h @@ -30,9 +30,10 @@ * \brief Generic expression of a matrix where all coefficients are defined by a functor * * \param NullaryOp template functor implementing the operator + * \param PlainObjectType the underlying plain matrix/array type * * This class represents an expression of a generic nullary operator. - * It is the return type of the Ones(), Zero(), Constant(), Identity() and Random() functions, + * It is the return type of the Ones(), Zero(), Constant(), Identity() and Random() methods, * and most of the time this is the only way it is used. * * However, if you want to write a function returning such an expression, you @@ -40,11 +41,11 @@ * * \sa class CwiseUnaryOp, class CwiseBinaryOp, DenseBase::NullaryExpr() */ -template -struct ei_traits > : ei_traits +template +struct ei_traits > : ei_traits { enum { - Flags = (ei_traits::Flags + Flags = (ei_traits::Flags & ( HereditaryBits | (ei_functor_has_linear_access::ret ? LinearAccessBit : 0) | (ei_functor_traits::PacketAccess ? PacketAccessBit : 0))) @@ -53,13 +54,13 @@ struct ei_traits > : ei_traits }; }; -template +template class CwiseNullaryOp : ei_no_assignment_operator, - public MatrixType::template MakeBase< CwiseNullaryOp >::Type + public PlainObjectType::template MakeBase< CwiseNullaryOp >::Type { public: - typedef typename MatrixType::template MakeBase< CwiseNullaryOp >::Type Base; + typedef typename PlainObjectType::template MakeBase< CwiseNullaryOp >::Type Base; EIGEN_DENSE_PUBLIC_INTERFACE(CwiseNullaryOp) CwiseNullaryOp(int rows, int cols, const NullaryOp& func = NullaryOp()) 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 diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h index c7018ce53..eb7262bdb 100644 --- a/Eigen/src/Core/Map.h +++ b/Eigen/src/Core/Map.h @@ -30,7 +30,7 @@ * * \brief A matrix or vector expression mapping an existing array of data. * - * \param MatrixType the equivalent matrix type of the mapped data + * \param PlainObjectType the equivalent matrix type of the mapped data * \param Options specifies whether the pointer is \c Aligned, or \c Unaligned. * The default is \c Unaligned. * \param StrideType optionnally specifies strides. By default, Map assumes the memory layout @@ -73,11 +73,11 @@ * * \sa Matrix::Map() */ -template -struct ei_traits > - : public ei_traits +template +struct ei_traits > + : public ei_traits { - typedef typename MatrixType::Scalar Scalar; + typedef typename PlainObjectType::Scalar Scalar; enum { InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime, OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime, @@ -85,21 +85,21 @@ struct ei_traits > HasNoOuterStride = OuterStrideAtCompileTime == 0, HasNoStride = HasNoInnerStride && HasNoOuterStride, IsAligned = int(int(Options)&Aligned)==Aligned, - IsDynamicSize = MatrixType::SizeAtCompileTime==Dynamic, + IsDynamicSize = PlainObjectType::SizeAtCompileTime==Dynamic, KeepsPacketAccess = bool(HasNoInnerStride) && ( bool(IsDynamicSize) || HasNoOuterStride || ( OuterStrideAtCompileTime!=Dynamic && ((int(OuterStrideAtCompileTime)*sizeof(Scalar))%16)==0 ) ), - Flags0 = ei_traits::Flags, + Flags0 = ei_traits::Flags, Flags1 = IsAligned ? int(Flags0) | AlignedBit : int(Flags0) & ~AlignedBit, Flags2 = HasNoStride ? int(Flags1) : int(Flags1 & ~LinearAccessBit), Flags = KeepsPacketAccess ? int(Flags2) : (int(Flags2) & ~PacketAccessBit) }; }; -template class Map - : public MapBase > +template class Map + : public MapBase > { public: @@ -128,7 +128,7 @@ template class Map inline Map(const Scalar* data, const StrideType& stride = StrideType()) : Base(data), m_stride(stride) { - MatrixType::Base::_check_template_params(); + PlainObjectType::Base::_check_template_params(); } /** Constructor in the dynamic-size vector case. @@ -140,7 +140,7 @@ template class Map inline Map(const Scalar* data, int size, const StrideType& stride = StrideType()) : Base(data, size), m_stride(stride) { - MatrixType::Base::_check_template_params(); + PlainObjectType::Base::_check_template_params(); } /** Constructor in the dynamic-size matrix case. @@ -153,7 +153,7 @@ template class Map inline Map(const Scalar* data, int rows, int cols, const StrideType& stride = StrideType()) : Base(data, rows, cols), m_stride(stride) { - MatrixType::Base::_check_template_params(); + PlainObjectType::Base::_check_template_params(); } diff --git a/Eigen/src/plugins/ArrayCwiseBinaryOps.h b/Eigen/src/plugins/ArrayCwiseBinaryOps.h index 87d1d4145..b48a58234 100644 --- a/Eigen/src/plugins/ArrayCwiseBinaryOps.h +++ b/Eigen/src/plugins/ArrayCwiseBinaryOps.h @@ -1,4 +1,3 @@ - /** \returns an expression of the coefficient wise product of \c *this and \a other * * \sa MatrixBase::cwiseProduct @@ -88,13 +87,6 @@ EIGEN_MAKE_CWISE_BINARY_OP(operator>=,std::greater_equal) * \sa all(), any(), isApprox(), isMuchSmallerThan() */ EIGEN_MAKE_CWISE_BINARY_OP(operator==,std::equal_to) -// template -// template -// inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to) -// operator==(const MatrixBase &other) const -// { -// return EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)(_expression(), other.derived()); -// } /** \returns an expression of the coefficient-wise != operator of *this and \a other * @@ -109,95 +101,6 @@ EIGEN_MAKE_CWISE_BINARY_OP(operator==,std::equal_to) * \sa all(), any(), isApprox(), isMuchSmallerThan() */ EIGEN_MAKE_CWISE_BINARY_OP(operator!=,std::not_equal_to) -// template -// template -// inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to) -// operator!=(const MatrixBase &other) const -// { -// return EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)(_expression(), other.derived()); -// } - -// comparisons to scalar value - -#if 0 - -/** \returns an expression of the coefficient-wise \< operator of *this and a scalar \a s - * - * \sa operator<(const MatrixBase &) const - */ -inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less) -operator<(Scalar s) const -{ - return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)(_expression(), - typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); -} - -/** \returns an expression of the coefficient-wise \<= operator of *this and a scalar \a s - * - * \sa operator<=(const MatrixBase &) const - */ -inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal) -operator<=(Scalar s) const -{ - return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)(_expression(), - typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); -} - -/** \returns an expression of the coefficient-wise \> operator of *this and a scalar \a s - * - * \sa operator>(const MatrixBase &) const - */ -inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater) -operator>(Scalar s) const -{ - return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)(_expression(), - typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); -} - -/** \returns an expression of the coefficient-wise \>= operator of *this and a scalar \a s - * - * \sa operator>=(const MatrixBase &) const - */ -inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal) -operator>=(Scalar s) const -{ - return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)(_expression(), - typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); -} - -/** \returns an expression of the coefficient-wise == operator of *this and a scalar \a s - * - * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. - * In order to check for equality between two vectors or matrices with floating-point coefficients, it is - * generally a far better idea to use a fuzzy comparison as provided by isApprox() and - * isMuchSmallerThan(). - * - * \sa operator==(const MatrixBase &) const - */ -inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to) -operator==(Scalar s) const -{ - return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)(_expression(), - typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); -} - -/** \returns an expression of the coefficient-wise != operator of *this and a scalar \a s - * - * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. - * In order to check for equality between two vectors or matrices with floating-point coefficients, it is - * generally a far better idea to use a fuzzy comparison as provided by isApprox() and - * isMuchSmallerThan(). - * - * \sa operator!=(const MatrixBase &) const - */ -inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to) -operator!=(Scalar s) const -{ - return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)(_expression(), - typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); -} - -#endif // scalar addition @@ -220,18 +123,6 @@ operator+(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS& return other + scalar; } -/** Adds the given \a scalar to each coeff of this expression. - * - * Example: \include Cwise_plus_equal.cpp - * Output: \verbinclude Cwise_plus_equal.out - * - * \sa operator+(), operator-=() - */ -// inline Derived& operator+=(const Scalar& scalar) -// { -// return derived() = *this + scalar; -// } - /** \returns an expression of \c *this with each coeff decremented by the constant \a scalar * * Example: \include Cwise_minus.cpp @@ -250,15 +141,3 @@ operator-(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS& { return (-other) + scalar; } - -/** Substracts the given \a scalar from each coeff of this expression. - * - * Example: \include Cwise_minus_equal.cpp - * Output: \verbinclude Cwise_minus_equal.out - * - * \sa operator+=(), operator-() - */ -// inline Derived& operator-=(const Scalar& scalar) -// { -// return derived() = *this - scalar; -// } diff --git a/Eigen/src/plugins/CommonCwiseBinaryOps.h b/Eigen/src/plugins/CommonCwiseBinaryOps.h index 762cb3b8c..400a7b0e0 100644 --- a/Eigen/src/plugins/CommonCwiseBinaryOps.h +++ b/Eigen/src/plugins/CommonCwiseBinaryOps.h @@ -29,7 +29,7 @@ * * \note If you want to substract a given scalar from all coefficients, see Cwise::operator-(). * - * \sa class CwiseBinaryOp, MatrixBase::operator-=() + * \sa class CwiseBinaryOp, operator-=() */ EIGEN_MAKE_CWISE_BINARY_OP(operator-,ei_scalar_difference_op) @@ -37,7 +37,7 @@ EIGEN_MAKE_CWISE_BINARY_OP(operator-,ei_scalar_difference_op) * * \note If you want to add a given scalar to all coefficients, see Cwise::operator+(). * - * \sa class CwiseBinaryOp, MatrixBase::operator+=() + * \sa class CwiseBinaryOp, operator+=() */ EIGEN_MAKE_CWISE_BINARY_OP(operator+,ei_scalar_sum_op) @@ -50,7 +50,7 @@ EIGEN_MAKE_CWISE_BINARY_OP(operator+,ei_scalar_sum_op) * \include class_CwiseBinaryOp.cpp * Output: \verbinclude class_CwiseBinaryOp.out * - * \sa class CwiseBinaryOp, MatrixBase::operator+, MatrixBase::operator-, MatrixBase::cwiseProduct + * \sa class CwiseBinaryOp, operator+, operator-, cwiseProduct */ template EIGEN_STRONG_INLINE const CwiseBinaryOp diff --git a/Eigen/src/plugins/CommonCwiseUnaryOps.h b/Eigen/src/plugins/CommonCwiseUnaryOps.h index ec76ca38f..74601c2d2 100644 --- a/Eigen/src/plugins/CommonCwiseUnaryOps.h +++ b/Eigen/src/plugins/CommonCwiseUnaryOps.h @@ -27,28 +27,28 @@ #ifndef EIGEN_PARSED_BY_DOXYGEN -/** \internal Represents a scalar multiple of a matrix */ +/** \internal Represents a scalar multiple of an expression */ typedef CwiseUnaryOp, Derived> ScalarMultipleReturnType; -/** \internal Represents a quotient of a matrix by a scalar*/ +/** \internal Represents a quotient of an expression by a scalar*/ typedef CwiseUnaryOp, Derived> ScalarQuotient1ReturnType; -/** \internal the return type of MatrixBase::conjugate() */ +/** \internal the return type of conjugate() */ typedef typename ei_meta_if::IsComplex, const CwiseUnaryOp, Derived>, const Derived& >::ret ConjugateReturnType; -/** \internal the return type of MatrixBase::real() const */ +/** \internal the return type of real() const */ typedef typename ei_meta_if::IsComplex, const CwiseUnaryOp, Derived>, const Derived& >::ret RealReturnType; -/** \internal the return type of MatrixBase::real() */ +/** \internal the return type of real() */ typedef typename ei_meta_if::IsComplex, CwiseUnaryView, Derived>, Derived& >::ret NonConstRealReturnType; -/** \internal the return type of MatrixBase::imag() const */ +/** \internal the return type of imag() const */ typedef CwiseUnaryOp, Derived> ImagReturnType; -/** \internal the return type of MatrixBase::imag() */ +/** \internal the return type of imag() */ typedef CwiseUnaryView, Derived> NonConstImagReturnType; #endif // not EIGEN_PARSED_BY_DOXYGEN @@ -139,7 +139,7 @@ imag() const { return derived(); } * \include class_CwiseUnaryOp.cpp * Output: \verbinclude class_CwiseUnaryOp.out * - * \sa class CwiseUnaryOp, class CwiseBinarOp, MatrixBase::operator-, Cwise::abs + * \sa class CwiseUnaryOp, class CwiseBinarOp */ template inline const CwiseUnaryOp @@ -157,7 +157,7 @@ unaryExpr(const CustomUnaryOp& func = CustomUnaryOp()) const * \include class_CwiseUnaryOp.cpp * Output: \verbinclude class_CwiseUnaryOp.out * - * \sa class CwiseUnaryOp, class CwiseBinarOp, MatrixBase::operator-, Cwise::abs + * \sa class CwiseUnaryOp, class CwiseBinarOp */ template inline const CwiseUnaryView diff --git a/Eigen/src/plugins/MatrixCwiseBinaryOps.h b/Eigen/src/plugins/MatrixCwiseBinaryOps.h index 1efe7b314..dd91fbd75 100644 --- a/Eigen/src/plugins/MatrixCwiseBinaryOps.h +++ b/Eigen/src/plugins/MatrixCwiseBinaryOps.h @@ -43,13 +43,13 @@ cwiseProduct(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const * * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. * In order to check for equality between two vectors or matrices with floating-point coefficients, it is - * generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and - * MatrixBase::isMuchSmallerThan(). + * generally a far better idea to use a fuzzy comparison as provided by isApprox() and + * isMuchSmallerThan(). * * Example: \include MatrixBase_cwiseEqual.cpp * Output: \verbinclude MatrixBase_cwiseEqual.out * - * \sa MatrixBase::cwiseNotEqual(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan() + * \sa cwiseNotEqual(), isApprox(), isMuchSmallerThan() */ template inline const CwiseBinaryOp, Derived, OtherDerived> @@ -62,13 +62,13 @@ cwiseEqual(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const * * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. * In order to check for equality between two vectors or matrices with floating-point coefficients, it is - * generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and - * MatrixBase::isMuchSmallerThan(). + * generally a far better idea to use a fuzzy comparison as provided by isApprox() and + * isMuchSmallerThan(). * * Example: \include MatrixBase_cwiseNotEqual.cpp * Output: \verbinclude MatrixBase_cwiseNotEqual.out * - * \sa MatrixBase::cwiseEqual(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan() + * \sa cwiseEqual(), isApprox(), isMuchSmallerThan() */ template inline const CwiseBinaryOp, Derived, OtherDerived> diff --git a/Eigen/src/plugins/MatrixCwiseUnaryOps.h b/Eigen/src/plugins/MatrixCwiseUnaryOps.h index 8927711ed..6ffaf675c 100644 --- a/Eigen/src/plugins/MatrixCwiseUnaryOps.h +++ b/Eigen/src/plugins/MatrixCwiseUnaryOps.h @@ -69,8 +69,8 @@ cwiseInverse() const { return derived(); } * * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. * In order to check for equality between two vectors or matrices with floating-point coefficients, it is - * generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and - * MatrixBase::isMuchSmallerThan(). + * generally a far better idea to use a fuzzy comparison as provided by isApprox() and + * isMuchSmallerThan(). * * \sa cwiseEqual(const MatrixBase &) const */ -- cgit v1.2.3