From 464fc297cfb95a56064472a82b200fdac754ab8c Mon Sep 17 00:00:00 2001 From: Manoj Rajagopalan Date: Sat, 26 Jun 2010 17:37:17 -0400 Subject: [PATCH] Included definitions for rowRange() and colRange() member functions of DenseBase --- Eigen/src/Core/Block.h | 110 ++++++++++++++++++++++++++++++++++++- Eigen/src/Core/DenseBase.h | 8 +++ 2 files changed, 117 insertions(+), 1 deletion(-) diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index 7d9ae500d..5fb7126e6 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -679,9 +679,62 @@ DenseBase::bottomRows() const +/** \returns a block consisting of a range of rows of *this. + * + * \param startRow the index of the first row in the block + * \param numRows the number of rows in the block + * + * Example: \include MatrixBase_rowRange_int.cpp + * Output: \verbinclude MatrixBase_rowRange_int.out + * + * \sa class Block, block(Index,Index,Index,Index) + */ +template +inline typename DenseBase::RowsBlockXpr DenseBase + ::rowRange(Index startRow, Index numRows) +{ + return RowsBlockXpr(derived(), startRow, 0, numRows, cols()); +} + +/** This is the const version of rowRange(Index,Index).*/ +template +inline const typename DenseBase::RowsBlockXpr +DenseBase::rowRange(Index startRow, Index numRows) const +{ + return RowsBlockXpr(derived(), startRow, 0, numRows, cols()); +} + +/** \returns a block consisting of a range of rows of *this. + * + * \param N the number of rows in the block + * \param startRow the index of the first row in the block + * + * Example: \include MatrixBase_template_int_rowRange.cpp + * Output: \verbinclude MatrixBase_template_int_rowRange.out + * + * \sa class Block, block(Index,Index,Index,Index) + */ +template +template +inline typename DenseBase::template NRowsBlockXpr::Type +DenseBase::rowRange(Index startRow) +{ + return typename DenseBase::template NRowsBlockXpr::Type(derived(), startRow, 0, N, cols()); +} + +/** This is the const version of rowRange().*/ +template +template +inline const typename DenseBase::template NRowsBlockXpr::Type +DenseBase::rowRange(Index startRow) const +{ + return typename DenseBase::template NRowsBlockXpr::Type(derived(), startRow, 0, N, cols()); +} -/** \returns a block consisting of the top columns of *this. + + +/** \returns a block consisting of the left columns of *this. * * \param n the number of columns in the block * @@ -788,6 +841,61 @@ DenseBase::rightCols() const +/** \returns a block consisting of a range of columns of *this. + * + * \param startCol the index of the first column in the block + * \param numCols the number of columns in the block + * + * Example: \include MatrixBase_colRange_int.cpp + * Output: \verbinclude MatrixBase_colRange_int.out + * + * \sa class Block, block(Index,Index,Index,Index) + */ +template +inline typename DenseBase::ColsBlockXpr DenseBase + ::colRange(Index startCol, Index numCols) +{ + return ColsBlockXpr(derived(), 0, startCol, rows(), numCols); +} + +/** This is the const version of colRange(Index,Index).*/ +template +inline const typename DenseBase::ColsBlockXpr +DenseBase::colRange(Index startCol, Index numCols) const +{ + return ColsBlockXpr(derived(), 0, startCol, rows(), numCols); +} + +/** \returns a block consisting of a range of columns of *this. + * + * \param N the number of columns in the block + * \param startCol the index of the first column in the block + * + * Example: \include MatrixBase_template_int_colRange.cpp + * Output: \verbinclude MatrixBase_template_int_colRange.out + * + * \sa class Block, block(Index,Index,Index,Index) + */ +template +template +inline typename DenseBase::template NColsBlockXpr::Type +DenseBase::colRange(Index startCol) +{ + return typename NColsBlockXpr::Type(derived(), 0, startCol, rows(), N); +} + +/** This is the const version of colRange().*/ +template +template +inline const typename DenseBase::template NColsBlockXpr::Type +DenseBase::colRange(Index startCol) const +{ + return typename NColsBlockXpr::Type(derived(), 0, startCol, rows(), N); +} + + + + /** \returns a fixed-size expression of a block in *this. * diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index 8c1e24fec..c42c4b8d1 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -327,10 +327,14 @@ template class DenseBase const RowsBlockXpr topRows(Index n) const; RowsBlockXpr bottomRows(Index n); const RowsBlockXpr bottomRows(Index n) const; + RowsBlockXpr rowRange(Index startRow, Index numRows); + const RowsBlockXpr rowRange(Index startRow, Index numRows) const; ColsBlockXpr leftCols(Index n); const ColsBlockXpr leftCols(Index n) const; ColsBlockXpr rightCols(Index n); const ColsBlockXpr rightCols(Index n) const; + ColsBlockXpr colRange(Index startCol, Index numCols); + const ColsBlockXpr colRange(Index startCol, Index numCols) const; template Block topLeftCorner(); template const Block topLeftCorner() const; @@ -345,10 +349,14 @@ template class DenseBase template const typename NRowsBlockXpr::Type topRows() const; template typename NRowsBlockXpr::Type bottomRows(); template const typename NRowsBlockXpr::Type bottomRows() const; + template typename NRowsBlockXpr::Type rowRange(Index startRow); + template const typename NRowsBlockXpr::Type rowRange(Index startRow) const; template typename NColsBlockXpr::Type leftCols(); template const typename NColsBlockXpr::Type leftCols() const; template typename NColsBlockXpr::Type rightCols(); template const typename NColsBlockXpr::Type rightCols() const; + template typename NColsBlockXpr::Type colRange(Index startCol); + template const typename NColsBlockXpr::Type colRange(Index startCol) const; template Block block(Index startRow, Index startCol);