diff options
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/Core | 2 | ||||
-rw-r--r-- | Eigen/src/Core/Block.h | 68 | ||||
-rw-r--r-- | Eigen/src/Core/FixedBlock.h (renamed from Eigen/src/Core/DynBlock.h) | 92 | ||||
-rw-r--r-- | Eigen/src/Core/ForwardDeclarations.h | 4 | ||||
-rw-r--r-- | Eigen/src/Core/MatrixBase.h | 10 | ||||
-rw-r--r-- | Eigen/src/Core/Util.h | 3 |
6 files changed, 89 insertions, 90 deletions
diff --git a/Eigen/Core b/Eigen/Core index b1aaa8774..12b55b0da 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -22,7 +22,7 @@ namespace Eigen { #include "src/Core/Product.h" #include "src/Core/Row.h" #include "src/Core/Column.h" -#include "src/Core/DynBlock.h" +#include "src/Core/FixedBlock.h" #include "src/Core/Block.h" #include "src/Core/Minor.h" #include "src/Core/Transpose.h" diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index 22410b9be..28c39f3d0 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -28,17 +28,15 @@ /** \class Block * - * \brief Expression of a fixed-size block + * \brief Expression of a dynamic-size block * * \param MatrixType the type of the object in which we are taking a block - * \param BlockRows the number of rows of the block we are taking - * \param BlockCols the number of columns of the block we are taking * - * This class represents an expression of a fixed-size block. It is the return + * This class represents an expression of a dynamic-size block. It is the return * type of MatrixBase::block() and most of the time this is the only way it * is used. * - * However, if you want to directly maniputate fixed-size block expressions, + * However, if you want to directly maniputate dynamic-size block expressions, * for instance if you want to write a function returning such an expression, you * will need to use this class. * @@ -46,37 +44,39 @@ * \include class_Block.cpp * Output: \verbinclude class_Block.out * - * \sa MatrixBase::block(), class DynBlock + * \sa MatrixBase::block() */ -template<typename MatrixType, int BlockRows, int BlockCols> class Block - : public MatrixBase<typename MatrixType::Scalar, - Block<MatrixType, BlockRows, BlockCols> > +template<typename MatrixType> class Block + : public MatrixBase<typename MatrixType::Scalar, Block<MatrixType> > { public: typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Ref MatRef; - friend class MatrixBase<Scalar, Block<MatrixType, BlockRows, BlockCols> >; + friend class MatrixBase<Scalar, Block<MatrixType> >; - Block(const MatRef& matrix, int startRow, int startCol) - : m_matrix(matrix), m_startRow(startRow), m_startCol(startCol) + Block(const MatRef& matrix, + int startRow, int startCol, + int blockRows, int blockCols) + : m_matrix(matrix), m_startRow(startRow), m_startCol(startCol), + m_blockRows(blockRows), m_blockCols(blockCols) { - assert(startRow >= 0 && BlockRows >= 1 && startRow + BlockRows <= matrix.rows() - && startCol >= 0 && BlockCols >= 1 && startCol + BlockCols <= matrix.cols()); + assert(startRow >= 0 && blockRows >= 1 && startRow + blockRows <= matrix.rows() + && startCol >= 0 && blockCols >= 1 && startCol + blockCols <= matrix.cols()); } EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block) private: - enum{ - RowsAtCompileTime = BlockRows, - ColsAtCompileTime = BlockCols, - MaxRowsAtCompileTime = BlockRows, - MaxColsAtCompileTime = BlockCols + enum { + RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime == 1 ? 1 : Dynamic, + ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime == 1 ? 1 : Dynamic, + MaxRowsAtCompileTime = RowsAtCompileTime == 1 ? 1 : MatrixType::Traits::MaxRowsAtCompileTime, + MaxColsAtCompileTime = ColsAtCompileTime == 1 ? 1 : MatrixType::Traits::MaxColsAtCompileTime }; const Block& _ref() const { return *this; } - int _rows() const { return BlockRows; } - int _cols() const { return BlockCols; } + int _rows() const { return m_blockRows; } + int _cols() const { return m_blockCols; } Scalar& _coeffRef(int row, int col) { @@ -90,37 +90,35 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block protected: MatRef m_matrix; - const int m_startRow, m_startCol; + const int m_startRow, m_startCol, m_blockRows, m_blockCols; }; -/** \returns a fixed-size expression of a block in *this. - * - * The template parameters \a blockRows and \a blockCols are the number of - * rows and columns in the block +/** \returns a dynamic-size expression of a block in *this. * * \param startRow the first row in the block * \param startCol the first column in the block + * \param blockRows the number of rows in the block + * \param blockCols the number of columns in the block * * Example: \include MatrixBase_block.cpp * Output: \verbinclude MatrixBase_block.out * - * \sa class Block, dynBlock() + * \sa class Block, fixedBlock() */ template<typename Scalar, typename Derived> -template<int BlockRows, int BlockCols> -Block<Derived, BlockRows, BlockCols> MatrixBase<Scalar, Derived> - ::block(int startRow, int startCol) +Block<Derived> MatrixBase<Scalar, Derived> + ::block(int startRow, int startCol, int blockRows, int blockCols) { - return Block<Derived, BlockRows, BlockCols>(ref(), startRow, startCol); + return Block<Derived>(ref(), startRow, startCol, blockRows, blockCols); } /** This is the const version of block(). */ template<typename Scalar, typename Derived> -template<int BlockRows, int BlockCols> -const Block<Derived, BlockRows, BlockCols> MatrixBase<Scalar, Derived> - ::block(int startRow, int startCol) const +const Block<Derived> MatrixBase<Scalar, Derived> + ::block(int startRow, int startCol, int blockRows, int blockCols) const { - return Block<Derived, BlockRows, BlockCols>(ref(), startRow, startCol); + return Block<Derived>(ref(), startRow, startCol, blockRows, blockCols); } + #endif // EIGEN_BLOCK_H diff --git a/Eigen/src/Core/DynBlock.h b/Eigen/src/Core/FixedBlock.h index 3c863bb80..00d7e558a 100644 --- a/Eigen/src/Core/DynBlock.h +++ b/Eigen/src/Core/FixedBlock.h @@ -23,60 +23,60 @@ // License. This exception does not invalidate any other reasons why a work // based on this file might be covered by the GNU General Public License. -#ifndef EIGEN_DYNBLOCK_H -#define EIGEN_DYNBLOCK_H +#ifndef EIGEN_FIXEDBLOCK_H +#define EIGEN_FIXEDBLOCK_H -/** \class DynBlock +/** \class FixedBlock * - * \brief Expression of a dynamic-size block + * \brief Expression of a fixed-size block * * \param MatrixType the type of the object in which we are taking a block + * \param BlockRows the number of rows of the block we are taking + * \param BlockCols the number of columns of the block we are taking * - * This class represents an expression of a dynamic-size block. It is the return - * type of MatrixBase::dynBlock() and most of the time this is the only way it + * This class represents an expression of a fixed-size block. It is the return + * type of MatrixBase::fixedBlock() and most of the time this is the only way it * is used. * - * However, if you want to directly maniputate dynamic-size block expressions, + * However, if you want to directly maniputate fixed-size block expressions, * for instance if you want to write a function returning such an expression, you * will need to use this class. * * Here is an example illustrating this: - * \include class_DynBlock.cpp - * Output: \verbinclude class_DynBlock.out + * \include class_FixedBlock.cpp + * Output: \verbinclude class_FixedBlock.out * - * \sa MatrixBase::dynBlock() + * \sa MatrixBase::fixedBlock(), class Block */ -template<typename MatrixType> class DynBlock - : public MatrixBase<typename MatrixType::Scalar, DynBlock<MatrixType> > +template<typename MatrixType, int BlockRows, int BlockCols> class FixedBlock + : public MatrixBase<typename MatrixType::Scalar, + FixedBlock<MatrixType, BlockRows, BlockCols> > { public: typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Ref MatRef; - friend class MatrixBase<Scalar, DynBlock<MatrixType> >; + friend class MatrixBase<Scalar, FixedBlock<MatrixType, BlockRows, BlockCols> >; - DynBlock(const MatRef& matrix, - int startRow, int startCol, - int blockRows, int blockCols) - : m_matrix(matrix), m_startRow(startRow), m_startCol(startCol), - m_blockRows(blockRows), m_blockCols(blockCols) + FixedBlock(const MatRef& matrix, int startRow, int startCol) + : m_matrix(matrix), m_startRow(startRow), m_startCol(startCol) { - assert(startRow >= 0 && blockRows >= 1 && startRow + blockRows <= matrix.rows() - && startCol >= 0 && blockCols >= 1 && startCol + blockCols <= matrix.cols()); + assert(startRow >= 0 && BlockRows >= 1 && startRow + BlockRows <= matrix.rows() + && startCol >= 0 && BlockCols >= 1 && startCol + BlockCols <= matrix.cols()); } - EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DynBlock) + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(FixedBlock) private: - enum { - RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime == 1 ? 1 : Dynamic, - ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime == 1 ? 1 : Dynamic, - MaxRowsAtCompileTime = RowsAtCompileTime == 1 ? 1 : MatrixType::Traits::MaxRowsAtCompileTime, - MaxColsAtCompileTime = ColsAtCompileTime == 1 ? 1 : MatrixType::Traits::MaxColsAtCompileTime + enum{ + RowsAtCompileTime = BlockRows, + ColsAtCompileTime = BlockCols, + MaxRowsAtCompileTime = BlockRows, + MaxColsAtCompileTime = BlockCols }; - const DynBlock& _ref() const { return *this; } - int _rows() const { return m_blockRows; } - int _cols() const { return m_blockCols; } + const FixedBlock& _ref() const { return *this; } + int _rows() const { return BlockRows; } + int _cols() const { return BlockCols; } Scalar& _coeffRef(int row, int col) { @@ -90,35 +90,37 @@ template<typename MatrixType> class DynBlock protected: MatRef m_matrix; - const int m_startRow, m_startCol, m_blockRows, m_blockCols; + const int m_startRow, m_startCol; }; -/** \returns a dynamic-size expression of a block in *this. +/** \returns a fixed-size expression of a block in *this. + * + * The template parameters \a blockRows and \a blockCols are the number of + * rows and columns in the block * * \param startRow the first row in the block * \param startCol the first column in the block - * \param blockRows the number of rows in the block - * \param blockCols the number of columns in the block * - * Example: \include MatrixBase_dynBlock.cpp - * Output: \verbinclude MatrixBase_dynBlock.out + * Example: \include MatrixBase_block.cpp + * Output: \verbinclude MatrixBase_block.out * - * \sa class DynBlock, block() + * \sa class FixedBlock, block() */ template<typename Scalar, typename Derived> -DynBlock<Derived> MatrixBase<Scalar, Derived> - ::dynBlock(int startRow, int startCol, int blockRows, int blockCols) +template<int BlockRows, int BlockCols> +FixedBlock<Derived, BlockRows, BlockCols> MatrixBase<Scalar, Derived> + ::fixedBlock(int startRow, int startCol) { - return DynBlock<Derived>(ref(), startRow, startCol, blockRows, blockCols); + return FixedBlock<Derived, BlockRows, BlockCols>(ref(), startRow, startCol); } -/** This is the const version of dynBlock(). */ +/** This is the const version of fixedBlock(). */ template<typename Scalar, typename Derived> -const DynBlock<Derived> MatrixBase<Scalar, Derived> - ::dynBlock(int startRow, int startCol, int blockRows, int blockCols) const +template<int BlockRows, int BlockCols> +const FixedBlock<Derived, BlockRows, BlockCols> MatrixBase<Scalar, Derived> + ::fixedBlock(int startRow, int startCol) const { - return DynBlock<Derived>(ref(), startRow, startCol, blockRows, blockCols); + return FixedBlock<Derived, BlockRows, BlockCols>(ref(), startRow, startCol); } - -#endif // EIGEN_DYNBLOCK_H +#endif // EIGEN_FIXEDBLOCK_H diff --git a/Eigen/src/Core/ForwardDeclarations.h b/Eigen/src/Core/ForwardDeclarations.h index 07c6e3f69..5f969667c 100644 --- a/Eigen/src/Core/ForwardDeclarations.h +++ b/Eigen/src/Core/ForwardDeclarations.h @@ -32,8 +32,8 @@ template<typename NewScalar, typename MatrixType> class Cast; template<typename MatrixType> class Row; template<typename MatrixType> class Column; template<typename MatrixType> class Minor; -template<typename MatrixType> class DynBlock; -template<typename MatrixType, int BlockRows, int BlockCols> class Block; +template<typename MatrixType> class Block; +template<typename MatrixType, int BlockRows, int BlockCols> class FixedBlock; template<typename MatrixType> class Transpose; template<typename MatrixType> class Conjugate; template<typename MatrixType> class Opposite; diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 6dd9d00b0..dc0292f97 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -184,14 +184,14 @@ template<typename Scalar, typename Derived> class MatrixBase Minor<Derived> minor(int row, int col); const Minor<Derived> minor(int row, int col) const; - DynBlock<Derived> dynBlock(int startRow, int startCol, int blockRows, int blockCols); - const DynBlock<Derived> - dynBlock(int startRow, int startCol, int blockRows, int blockCols) const; + Block<Derived> block(int startRow, int startCol, int blockRows, int blockCols); + const Block<Derived> + block(int startRow, int startCol, int blockRows, int blockCols) const; template<int BlockRows, int BlockCols> - Block<Derived, BlockRows, BlockCols> block(int startRow, int startCol); + FixedBlock<Derived, BlockRows, BlockCols> fixedBlock(int startRow, int startCol); template<int BlockRows, int BlockCols> - const Block<Derived, BlockRows, BlockCols> block(int startRow, int startCol) const; + const FixedBlock<Derived, BlockRows, BlockCols> fixedBlock(int startRow, int startCol) const; Transpose<Derived> transpose(); const Transpose<Derived> transpose() const; diff --git a/Eigen/src/Core/Util.h b/Eigen/src/Core/Util.h index d8db03caf..935a3dea6 100644 --- a/Eigen/src/Core/Util.h +++ b/Eigen/src/Core/Util.h @@ -113,12 +113,11 @@ template<int Value> class IntAtRunTimeIfDynamic template<> class IntAtRunTimeIfDynamic<Dynamic> { int m_value; + IntAtRunTimeIfDynamic() {} public: explicit IntAtRunTimeIfDynamic(int value) : m_value(value) {} int value() const { return m_value; } void setValue(int value) { m_value = value; } - private: - IntAtRunTimeIfDynamic() {} }; #endif // EIGEN_UTIL_H |