Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 1 | namespace Eigen { |
| 2 | |
Benoit Jacob | 4d4a23c | 2010-06-30 10:11:55 -0400 | [diff] [blame] | 3 | /** \page TutorialBlockOperations Tutorial page 4 - %Block operations |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 4 | \ingroup Tutorial |
| 5 | |
| 6 | \li \b Previous: \ref TutorialArrayClass |
Benoit Jacob | 4d4a23c | 2010-06-30 10:11:55 -0400 | [diff] [blame] | 7 | \li \b Next: \ref TutorialAdvancedInitialization |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 8 | |
Benoit Jacob | 5a52f28 | 2010-07-01 20:52:40 -0400 | [diff] [blame] | 9 | This tutorial page explains the essentials of block operations. |
| 10 | A block is a rectangular part of a matrix or array. Blocks expressions can be used both |
| 11 | as rvalues and as lvalues. As usual with Eigen expressions, this abstraction has zero runtime cost |
| 12 | provided that you let your compiler optimize. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 13 | |
| 14 | \b Table \b of \b contents |
Benoit Jacob | 5a52f28 | 2010-07-01 20:52:40 -0400 | [diff] [blame] | 15 | - \ref TutorialBlockOperationsUsing |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 16 | - \ref TutorialBlockOperationsSyntaxColumnRows |
| 17 | - \ref TutorialBlockOperationsSyntaxCorners |
| 18 | - \ref TutorialBlockOperationsSyntaxVectors |
| 19 | |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 20 | |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 21 | \section TutorialBlockOperationsUsing Using block operations |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 22 | |
| 23 | The most general block operation in Eigen is called \link DenseBase::block() .block() \endlink. |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 24 | This function returns a block of size <tt>(p,q)</tt> whose origin is at <tt>(i,j)</tt>. |
| 25 | There are two versions, whose syntax is as follows: |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 26 | |
| 27 | <table class="tutorial_code" align="center"> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 28 | <tr><td align="center">\b %Block \b operation</td> |
| 29 | <td align="center">Default version</td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 30 | <td align="center">Optimized version when the<br>size is known at compile time</td></tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 31 | <tr><td>%Block of size <tt>(p,q)</tt>, starting at <tt>(i,j)</tt></td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 32 | <td>\code |
Benoit Jacob | 5a52f28 | 2010-07-01 20:52:40 -0400 | [diff] [blame] | 33 | matrix.block(i,j,p,q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 34 | <td>\code |
Benoit Jacob | 5a52f28 | 2010-07-01 20:52:40 -0400 | [diff] [blame] | 35 | matrix.block<p,q>(i,j);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 36 | </tr> |
| 37 | </table> |
| 38 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 39 | The default version is a method which takes four arguments. It can always be used. The optimized version |
| 40 | takes two template arguments (the size of the block) and two normal arguments (the position of the block). |
| 41 | It can only be used if the size of the block is known at compile time, but it may be faster than the |
| 42 | non-optimized version, especially if the size of the block is small. Both versions can be used on fixed-size |
| 43 | and dynamic-size matrices and arrays. |
| 44 | |
| 45 | The following program uses the default and optimized versions to print the values of several blocks inside a |
| 46 | matrix. |
| 47 | |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 48 | <table class="tutorial_code"><tr><td> |
| 49 | \include Tutorial_BlockOperations_print_block.cpp |
| 50 | </td> |
| 51 | <td> |
| 52 | Output: |
| 53 | \verbinclude Tutorial_BlockOperations_print_block.out |
| 54 | </td></tr></table> |
| 55 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 56 | In the above example the \link DenseBase::block() .block() \endlink function was employed |
| 57 | to read the values inside matrix \p m . However, blocks can also be used as lvalues, meaning that you can |
| 58 | assign to a block. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 59 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 60 | This is illustrated in the following example, which uses arrays instead of matrices. The coefficients of the |
| 61 | 5-by-5 array \c n are first all set to 0.6, but then the 3-by-3 block in the middle is set to the values in |
| 62 | \c m . The penultimate line shows that blocks can be combined with matrices and arrays to create more complex |
| 63 | expressions. Blocks of an array are an array expression, and thus the multiplication here is coefficient-wise |
| 64 | multiplication. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 65 | |
| 66 | <table class="tutorial_code"><tr><td> |
| 67 | \include Tutorial_BlockOperations_block_assignment.cpp |
| 68 | </td> |
| 69 | <td> |
| 70 | Output: |
| 71 | \verbinclude Tutorial_BlockOperations_block_assignment.out |
| 72 | </td></tr></table> |
| 73 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 74 | The \link DenseBase::block() .block() \endlink method is used for general block operations, but there are |
| 75 | other methods for special cases. These are described in the rest of this page. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 76 | |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 77 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 78 | \section TutorialBlockOperationsSyntaxColumnRows Columns and rows |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 79 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 80 | Individual columns and rows are special cases of blocks. Eigen provides methods to easily access them: |
| 81 | \link DenseBase::col() .col() \endlink and \link DenseBase::row() .row()\endlink. There is no syntax variant |
| 82 | for an optimized version. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 83 | |
| 84 | <table class="tutorial_code" align="center"> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 85 | <tr><td align="center">\b %Block \b operation</td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 86 | <td align="center">Default version</td> |
| 87 | <td align="center">Optimized version when the<br>size is known at compile time</td></tr> |
| 88 | <tr><td>i<sup>th</sup> row |
| 89 | \link DenseBase::row() * \endlink</td> |
| 90 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 91 | matrix.row(i);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 92 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 93 | matrix.row(i);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 94 | </tr> |
| 95 | <tr><td>j<sup>th</sup> column |
| 96 | \link DenseBase::col() * \endlink</td> |
| 97 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 98 | matrix.col(j);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 99 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 100 | matrix.col(j);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 101 | </tr> |
| 102 | </table> |
| 103 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 104 | The argument for \p col() and \p row() is the index of the column or row to be accessed, starting at |
| 105 | 0. Therefore, \p col(0) will access the first column and \p col(1) the second one. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 106 | |
| 107 | <table class="tutorial_code"><tr><td> |
| 108 | C++ code: |
| 109 | \include Tutorial_BlockOperations_colrow.cpp |
| 110 | </td> |
| 111 | <td> |
| 112 | Output: |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 113 | \verbinclude Tutorial_BlockOperations_colrow.out |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 114 | </td></tr></table> |
| 115 | |
| 116 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 117 | \section TutorialBlockOperationsSyntaxCorners Corner-related operations |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 118 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 119 | Eigen also provides special methods for blocks that are flushed against one of the corners or sides of a |
| 120 | matrix or array. For instance, \link DenseBase::topLeftCorner() .topLeftCorner() \endlink can be used to refer |
| 121 | to a block in the top-left corner of a matrix. Use <tt>matrix.topLeftCorner(p,q)</tt> to access the block |
| 122 | consisting of the coefficients <tt>matrix(i,j)</tt> with \c i < \c p and \c j < \c q. As an other |
| 123 | example, blocks consisting of whole rows flushed against the top side of the matrix can be accessed by |
| 124 | \link DenseBase::topRows() .topRows() \endlink. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 125 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 126 | The different possibilities are summarized in the following table: |
| 127 | |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 128 | <table class="tutorial_code" align="center"> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 129 | <tr><td align="center">\b %Block \b operation</td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 130 | <td align="center">Default version</td> |
| 131 | <td align="center">Optimized version when the<br>size is known at compile time</td></tr> |
Jitse Niesen | 3070164 | 2010-06-29 11:42:51 +0100 | [diff] [blame] | 132 | <tr><td>Top-left p by q block \link DenseBase::topLeftCorner() * \endlink</td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 133 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 134 | matrix.topLeftCorner(p,q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 135 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 136 | matrix.topLeftCorner<p,q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 137 | </tr> |
Jitse Niesen | 3070164 | 2010-06-29 11:42:51 +0100 | [diff] [blame] | 138 | <tr><td>Bottom-left p by q block |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 139 | \link DenseBase::bottomLeftCorner() * \endlink</td> |
| 140 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 141 | matrix.bottomLeftCorner(p,q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 142 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 143 | matrix.bottomLeftCorner<p,q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 144 | </tr> |
Jitse Niesen | 3070164 | 2010-06-29 11:42:51 +0100 | [diff] [blame] | 145 | <tr><td>Top-right p by q block |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 146 | \link DenseBase::topRightCorner() * \endlink</td> |
| 147 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 148 | matrix.topRightCorner(p,q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 149 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 150 | matrix.topRightCorner<p,q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 151 | </tr> |
Jitse Niesen | 3070164 | 2010-06-29 11:42:51 +0100 | [diff] [blame] | 152 | <tr><td>Bottom-right p by q block |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 153 | \link DenseBase::bottomRightCorner() * \endlink</td> |
| 154 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 155 | matrix.bottomRightCorner(p,q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 156 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 157 | matrix.bottomRightCorner<p,q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 158 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 159 | <tr><td>%Block containing the first q rows |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 160 | \link DenseBase::topRows() * \endlink</td> |
| 161 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 162 | matrix.topRows(q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 163 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 164 | matrix.topRows<q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 165 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 166 | <tr><td>%Block containing the last q rows |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 167 | \link DenseBase::bottomRows() * \endlink</td> |
| 168 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 169 | matrix.bottomRows(q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 170 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 171 | matrix.bottomRows<q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 172 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 173 | <tr><td>%Block containing the first p columns |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 174 | \link DenseBase::leftCols() * \endlink</td> |
| 175 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 176 | matrix.leftCols(p);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 177 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 178 | matrix.leftCols<p>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 179 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 180 | <tr><td>%Block containing the last q columns |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 181 | \link DenseBase::rightCols() * \endlink</td> |
| 182 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 183 | matrix.rightCols(q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 184 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 185 | matrix.rightCols<q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 186 | </tr> |
| 187 | </table> |
| 188 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 189 | Here is a simple example illustrating the use of the operations presented above: |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 190 | |
| 191 | <table class="tutorial_code"><tr><td> |
| 192 | C++ code: |
| 193 | \include Tutorial_BlockOperations_corner.cpp |
| 194 | </td> |
| 195 | <td> |
| 196 | Output: |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 197 | \verbinclude Tutorial_BlockOperations_corner.out |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 198 | </td></tr></table> |
| 199 | |
| 200 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 201 | \section TutorialBlockOperationsSyntaxVectors Block operations for vectors |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 202 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 203 | Eigen also provides a set of block operations designed specifically for vectors and one-dimensional arrays: |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 204 | |
| 205 | <table class="tutorial_code" align="center"> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 206 | <tr><td align="center">\b %Block \b operation</td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 207 | <td align="center">Default version</td> |
| 208 | <td align="center">Optimized version when the<br>size is known at compile time</td></tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 209 | <tr><td>%Block containing the first \p n elements |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 210 | \link DenseBase::head() * \endlink</td> |
| 211 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 212 | vector.head(n);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 213 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 214 | vector.head<n>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 215 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 216 | <tr><td>%Block containing the last \p n elements |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 217 | \link DenseBase::tail() * \endlink</td> |
| 218 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 219 | vector.tail(n);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 220 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 221 | vector.tail<n>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 222 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 223 | <tr><td>%Block containing \p n elements, starting at position \p i |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 224 | \link DenseBase::segment() * \endlink</td> |
| 225 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 226 | vector.segment(i,n);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 227 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 228 | vector.segment<n>(i);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 229 | </tr> |
| 230 | </table> |
| 231 | |
| 232 | |
| 233 | An example is presented below: |
| 234 | <table class="tutorial_code"><tr><td> |
| 235 | C++ code: |
| 236 | \include Tutorial_BlockOperations_vector.cpp |
| 237 | </td> |
| 238 | <td> |
| 239 | Output: |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame^] | 240 | \verbinclude Tutorial_BlockOperations_vector.out |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 241 | </td></tr></table> |
| 242 | |
Benoit Jacob | 4d4a23c | 2010-06-30 10:11:55 -0400 | [diff] [blame] | 243 | \li \b Next: \ref TutorialAdvancedInitialization |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 244 | |
| 245 | */ |
| 246 | |
| 247 | } |