Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 1 | namespace Eigen { |
| 2 | |
Gael Guennebaud | 93ee82b | 2013-01-05 16:37:11 +0100 | [diff] [blame] | 3 | /** \eigenManualPage TutorialBlockOperations Block operations |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 4 | |
| 5 | \li \b Previous: \ref TutorialArrayClass |
Benoit Jacob | 4d4a23c | 2010-06-30 10:11:55 -0400 | [diff] [blame] | 6 | \li \b Next: \ref TutorialAdvancedInitialization |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 7 | |
Benoit Jacob | 5a52f28 | 2010-07-01 20:52:40 -0400 | [diff] [blame] | 8 | This tutorial page explains the essentials of block operations. |
| 9 | A block is a rectangular part of a matrix or array. Blocks expressions can be used both |
| 10 | as rvalues and as lvalues. As usual with Eigen expressions, this abstraction has zero runtime cost |
| 11 | provided that you let your compiler optimize. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 12 | |
Gael Guennebaud | 93ee82b | 2013-01-05 16:37:11 +0100 | [diff] [blame] | 13 | \eigenAutoToc |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 14 | |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 15 | \section TutorialBlockOperationsUsing Using block operations |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 16 | |
| 17 | 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] | 18 | There are two versions, whose syntax is as follows: |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 19 | |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame] | 20 | <table class="manual"> |
| 21 | <tr><th>\b %Block \b operation</td> |
| 22 | <th>Version constructing a \n dynamic-size block expression</th> |
| 23 | <th>Version constructing a \n fixed-size block expression</th></tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 24 | <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] | 25 | <td>\code |
Benoit Jacob | 5a52f28 | 2010-07-01 20:52:40 -0400 | [diff] [blame] | 26 | matrix.block(i,j,p,q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 27 | <td>\code |
Benoit Jacob | 5a52f28 | 2010-07-01 20:52:40 -0400 | [diff] [blame] | 28 | matrix.block<p,q>(i,j);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 29 | </tr> |
| 30 | </table> |
| 31 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 32 | As always in Eigen, indices start at 0. |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 33 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 34 | Both versions can be used on fixed-size and dynamic-size matrices and arrays. |
| 35 | These two expressions are semantically equivalent. |
| 36 | The only difference is that the fixed-size version will typically give you faster code if the block size is small, |
| 37 | but requires this size to be known at compile time. |
| 38 | |
| 39 | The following program uses the dynamic-size and fixed-size versions to print the values of several blocks inside a |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 40 | matrix. |
| 41 | |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame] | 42 | <table class="example"> |
| 43 | <tr><th>Example:</th><th>Output:</th></tr> |
| 44 | <tr><td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 45 | \include Tutorial_BlockOperations_print_block.cpp |
| 46 | </td> |
| 47 | <td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 48 | \verbinclude Tutorial_BlockOperations_print_block.out |
| 49 | </td></tr></table> |
| 50 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 51 | In the above example the \link DenseBase::block() .block() \endlink function was employed as a \em rvalue, i.e. |
| 52 | it was only read from. However, blocks can also be used as \em lvalues, meaning that you can assign to a block. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 53 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 54 | This is illustrated in the following example. This example also demonstrates blocks in arrays, which works exactly like the above-demonstrated blocks in matrices. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 55 | |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame] | 56 | <table class="example"> |
| 57 | <tr><th>Example:</th><th>Output:</th></tr> |
| 58 | <tr><td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 59 | \include Tutorial_BlockOperations_block_assignment.cpp |
| 60 | </td> |
| 61 | <td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 62 | \verbinclude Tutorial_BlockOperations_block_assignment.out |
| 63 | </td></tr></table> |
| 64 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 65 | While the \link DenseBase::block() .block() \endlink method can be used for any block operation, there are |
| 66 | other methods for special cases, providing more specialized API and/or better performance. On the topic of performance, all what |
| 67 | 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, |
| 68 | using the specialized \link DenseBase::col() .col() \endlink function described below lets Eigen know that, which can give it optimization opportunities. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 69 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 70 | The rest of this page describes these specialized methods. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 71 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 72 | \section TutorialBlockOperationsSyntaxColumnRows Columns and rows |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 73 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 74 | Individual columns and rows are special cases of blocks. Eigen provides methods to easily address them: |
| 75 | \link DenseBase::col() .col() \endlink and \link DenseBase::row() .row()\endlink. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 76 | |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame] | 77 | <table class="manual"> |
| 78 | <tr><th>%Block operation</th> |
| 79 | <th>Method</th> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 80 | <tr><td>i<sup>th</sup> row |
| 81 | \link DenseBase::row() * \endlink</td> |
| 82 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 83 | matrix.row(i);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 84 | </tr> |
| 85 | <tr><td>j<sup>th</sup> column |
| 86 | \link DenseBase::col() * \endlink</td> |
| 87 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 88 | matrix.col(j);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 89 | </tr> |
| 90 | </table> |
| 91 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 92 | 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. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 93 | |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame] | 94 | <table class="example"> |
| 95 | <tr><th>Example:</th><th>Output:</th></tr> |
| 96 | <tr><td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 97 | \include Tutorial_BlockOperations_colrow.cpp |
| 98 | </td> |
| 99 | <td> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 100 | \verbinclude Tutorial_BlockOperations_colrow.out |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 101 | </td></tr></table> |
| 102 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 103 | That example also demonstrates that block expressions (here columns) can be used in arithmetic like any other expression. |
| 104 | |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 105 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 106 | \section TutorialBlockOperationsSyntaxCorners Corner-related operations |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 107 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 108 | Eigen also provides special methods for blocks that are flushed against one of the corners or sides of a |
| 109 | matrix or array. For instance, \link DenseBase::topLeftCorner() .topLeftCorner() \endlink can be used to refer |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 110 | to a block in the top-left corner of a matrix. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 111 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 112 | The different possibilities are summarized in the following table: |
| 113 | |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame] | 114 | <table class="manual"> |
| 115 | <tr><th>%Block \b operation</td> |
| 116 | <th>Version constructing a \n dynamic-size block expression</th> |
| 117 | <th>Version constructing a \n fixed-size block expression</th></tr> |
Jitse Niesen | 3070164 | 2010-06-29 11:42:51 +0100 | [diff] [blame] | 118 | <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] | 119 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 120 | matrix.topLeftCorner(p,q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 121 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 122 | matrix.topLeftCorner<p,q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 123 | </tr> |
Jitse Niesen | 3070164 | 2010-06-29 11:42:51 +0100 | [diff] [blame] | 124 | <tr><td>Bottom-left p by q block |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 125 | \link DenseBase::bottomLeftCorner() * \endlink</td> |
| 126 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 127 | matrix.bottomLeftCorner(p,q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 128 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 129 | matrix.bottomLeftCorner<p,q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 130 | </tr> |
Jitse Niesen | 3070164 | 2010-06-29 11:42:51 +0100 | [diff] [blame] | 131 | <tr><td>Top-right p by q block |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 132 | \link DenseBase::topRightCorner() * \endlink</td> |
| 133 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 134 | matrix.topRightCorner(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.topRightCorner<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-right p by q block |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 139 | \link DenseBase::bottomRightCorner() * \endlink</td> |
| 140 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 141 | matrix.bottomRightCorner(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.bottomRightCorner<p,q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 144 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 145 | <tr><td>%Block containing the first q rows |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 146 | \link DenseBase::topRows() * \endlink</td> |
| 147 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 148 | matrix.topRows(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.topRows<q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 151 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 152 | <tr><td>%Block containing the last q rows |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 153 | \link DenseBase::bottomRows() * \endlink</td> |
| 154 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 155 | matrix.bottomRows(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.bottomRows<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 p columns |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 160 | \link DenseBase::leftCols() * \endlink</td> |
| 161 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 162 | matrix.leftCols(p);\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.leftCols<p>();\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 columns |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 167 | \link DenseBase::rightCols() * \endlink</td> |
| 168 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 169 | matrix.rightCols(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.rightCols<q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 172 | </tr> |
| 173 | </table> |
| 174 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 175 | 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] | 176 | |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame] | 177 | <table class="example"> |
| 178 | <tr><th>Example:</th><th>Output:</th></tr> |
| 179 | <tr><td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 180 | \include Tutorial_BlockOperations_corner.cpp |
| 181 | </td> |
| 182 | <td> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 183 | \verbinclude Tutorial_BlockOperations_corner.out |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 184 | </td></tr></table> |
| 185 | |
| 186 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 187 | \section TutorialBlockOperationsSyntaxVectors Block operations for vectors |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 188 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 189 | Eigen also provides a set of block operations designed specifically for the special case of vectors and one-dimensional arrays: |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 190 | |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame] | 191 | <table class="manual"> |
| 192 | <tr><th> %Block operation</th> |
| 193 | <th>Version constructing a \n dynamic-size block expression</th> |
| 194 | <th>Version constructing a \n fixed-size block expression</th></tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 195 | <tr><td>%Block containing the first \p n elements |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 196 | \link DenseBase::head() * \endlink</td> |
| 197 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 198 | vector.head(n);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 199 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 200 | vector.head<n>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 201 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 202 | <tr><td>%Block containing the last \p n elements |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 203 | \link DenseBase::tail() * \endlink</td> |
| 204 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 205 | vector.tail(n);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 206 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 207 | vector.tail<n>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 208 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 209 | <tr><td>%Block containing \p n elements, starting at position \p i |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 210 | \link DenseBase::segment() * \endlink</td> |
| 211 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 212 | vector.segment(i,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.segment<n>(i);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 215 | </tr> |
| 216 | </table> |
| 217 | |
| 218 | |
| 219 | An example is presented below: |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame] | 220 | <table class="example"> |
| 221 | <tr><th>Example:</th><th>Output:</th></tr> |
| 222 | <tr><td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 223 | \include Tutorial_BlockOperations_vector.cpp |
| 224 | </td> |
| 225 | <td> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 226 | \verbinclude Tutorial_BlockOperations_vector.out |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 227 | </td></tr></table> |
| 228 | |
Benoit Jacob | 4d4a23c | 2010-06-30 10:11:55 -0400 | [diff] [blame] | 229 | \li \b Next: \ref TutorialAdvancedInitialization |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 230 | |
| 231 | */ |
| 232 | |
| 233 | } |