In the above example the \link DenseBase::block() .block() \endlink function was employed as a \em rvalue, i.e.
it was only read from. However, blocks can also be used as \em lvalues, meaning that you can assign to a block.
This is illustrated in the following example. This example also demonstrates blocks in arrays, which works exactly like the above-demonstrated blocks in matrices.
While the \link DenseBase::block() .block() \endlink method can be used for any block operation, there are
other methods for special cases, providing more specialized API and/or better performance. On the topic of performance, all what
matters is that you give Eigen as much information as possible at compile time. For example, if your block is a single whole column in a matrix,
using the specialized \link DenseBase::col() .col() \endlink function described below lets Eigen know that, which can give it optimization opportunities.
The rest of this page describes these specialized methods.
\section TutorialBlockOperationsSyntaxColumnRows Columns and rows
Individual columns and rows are special cases of blocks. Eigen provides methods to easily address them:
\link DenseBase::col() .col() \endlink and \link DenseBase::row() .row()\endlink.
<table class="manual">
<tr><th>%Block operation</th>
<th>Method</th>
<tr><td>i<sup>th</sup> row
\link DenseBase::row() * \endlink</td>
<td>\code
matrix.row(i);\endcode </td>
</tr>
<tr><td>j<sup>th</sup> column
\link DenseBase::col() * \endlink</td>
<td>\code
matrix.col(j);\endcode </td>
</tr>
</table>
The argument for \p col() and \p row() is the index of the column or row to be accessed. As always in Eigen, indices start at 0.
<table class="example">
<tr><th>Example:</th><th>Output:</th></tr>
<tr><td>
\include Tutorial_BlockOperations_colrow.cpp
</td>
<td>
\verbinclude Tutorial_BlockOperations_colrow.out
</td></tr></table>
That example also demonstrates that block expressions (here columns) can be used in arithmetic like any other expression.