namespace Eigen {
/** \eigenManualPage TutorialBlockOperations Block operations
This page explains the essentials of block operations.
A block is a rectangular part of a matrix or array. Blocks expressions can be used both
as rvalues and as lvalues. As usual with Eigen expressions, this abstraction has zero runtime cost
provided that you let your compiler optimize.
\eigenAutoToc
\section TutorialBlockOperationsUsing Using block operations
The most general block operation in Eigen is called \link DenseBase::block() .block() \endlink.
There are two versions, whose syntax is as follows:
%Block \b operation
| Version constructing a \n dynamic-size block expression |
Version constructing a \n fixed-size block expression |
Top-left p by q block \link DenseBase::topLeftCorner() * \endlink |
\code
matrix.topLeftCorner(p,q);\endcode |
\code
matrix.topLeftCorner ();\endcode |
Bottom-left p by q block
\link DenseBase::bottomLeftCorner() * \endlink |
\code
matrix.bottomLeftCorner(p,q);\endcode |
\code
matrix.bottomLeftCorner ();\endcode |
Top-right p by q block
\link DenseBase::topRightCorner() * \endlink |
\code
matrix.topRightCorner(p,q);\endcode |
\code
matrix.topRightCorner ();\endcode |
Bottom-right p by q block
\link DenseBase::bottomRightCorner() * \endlink |
\code
matrix.bottomRightCorner(p,q);\endcode |
\code
matrix.bottomRightCorner ();\endcode |
%Block containing the first q rows
\link DenseBase::topRows() * \endlink |
\code
matrix.topRows(q);\endcode |
\code
matrix.topRows();\endcode |
%Block containing the last q rows
\link DenseBase::bottomRows() * \endlink |
\code
matrix.bottomRows(q);\endcode |
\code
matrix.bottomRows();\endcode |
%Block containing the first p columns
\link DenseBase::leftCols() * \endlink |
\code
matrix.leftCols(p);\endcode |
\code
matrix.leftCols ();\endcode |
%Block containing the last q columns
\link DenseBase::rightCols() * \endlink |
\code
matrix.rightCols(q);\endcode |
\code
matrix.rightCols();\endcode |
Here is a simple example illustrating the use of the operations presented above:
%Block operation |
Version constructing a \n dynamic-size block expression |
Version constructing a \n fixed-size block expression |
%Block containing the first \p n elements
\link DenseBase::head() * \endlink |
\code
vector.head(n);\endcode |
\code
vector.head();\endcode |
%Block containing the last \p n elements
\link DenseBase::tail() * \endlink |
\code
vector.tail(n);\endcode |
\code
vector.tail();\endcode |
%Block containing \p n elements, starting at position \p i
\link DenseBase::segment() * \endlink |
\code
vector.segment(i,n);\endcode |
\code
vector.segment(i);\endcode |
An example is presented below: