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 | There are two versions, whose syntax is as follows: |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 25 | |
| 26 | <table class="tutorial_code" align="center"> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 27 | <tr><td align="center">\b %Block \b operation</td> |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame^] | 28 | <td align="center">Version constructing a dynamic-size block expression</td> |
| 29 | <td align="center">Version constructing a fixed-size block expression</td></tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 30 | <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] | 31 | <td>\code |
Benoit Jacob | 5a52f28 | 2010-07-01 20:52:40 -0400 | [diff] [blame] | 32 | matrix.block(i,j,p,q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 33 | <td>\code |
Benoit Jacob | 5a52f28 | 2010-07-01 20:52:40 -0400 | [diff] [blame] | 34 | matrix.block<p,q>(i,j);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 35 | </tr> |
| 36 | </table> |
| 37 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame^] | 38 | As always in Eigen, indices start at 0. |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 39 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame^] | 40 | Both versions can be used on fixed-size and dynamic-size matrices and arrays. |
| 41 | These two expressions are semantically equivalent. |
| 42 | The only difference is that the fixed-size version will typically give you faster code if the block size is small, |
| 43 | but requires this size to be known at compile time. |
| 44 | |
| 45 | 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] | 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 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame^] | 56 | In the above example the \link DenseBase::block() .block() \endlink function was employed as a \em rvalue, i.e. |
| 57 | 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] | 58 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame^] | 59 | 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] | 60 | |
| 61 | <table class="tutorial_code"><tr><td> |
| 62 | \include Tutorial_BlockOperations_block_assignment.cpp |
| 63 | </td> |
| 64 | <td> |
| 65 | Output: |
| 66 | \verbinclude Tutorial_BlockOperations_block_assignment.out |
| 67 | </td></tr></table> |
| 68 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame^] | 69 | While the \link DenseBase::block() .block() \endlink method can be used for any block operation, there are |
| 70 | other methods for special cases, providing more specialized API and/or better performance. On the topic of performance, all what |
| 71 | 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, |
| 72 | 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] | 73 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame^] | 74 | The rest of this page describes these specialized methods. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 75 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 76 | \section TutorialBlockOperationsSyntaxColumnRows Columns and rows |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 77 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame^] | 78 | Individual columns and rows are special cases of blocks. Eigen provides methods to easily address them: |
| 79 | \link DenseBase::col() .col() \endlink and \link DenseBase::row() .row()\endlink. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 80 | |
| 81 | <table class="tutorial_code" align="center"> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 82 | <tr><td align="center">\b %Block \b operation</td> |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame^] | 83 | <td align="center">Method</td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 84 | <tr><td>i<sup>th</sup> row |
| 85 | \link DenseBase::row() * \endlink</td> |
| 86 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 87 | matrix.row(i);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 88 | </tr> |
| 89 | <tr><td>j<sup>th</sup> column |
| 90 | \link DenseBase::col() * \endlink</td> |
| 91 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 92 | matrix.col(j);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 93 | </tr> |
| 94 | </table> |
| 95 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame^] | 96 | 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] | 97 | |
| 98 | <table class="tutorial_code"><tr><td> |
| 99 | C++ code: |
| 100 | \include Tutorial_BlockOperations_colrow.cpp |
| 101 | </td> |
| 102 | <td> |
| 103 | Output: |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 104 | \verbinclude Tutorial_BlockOperations_colrow.out |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 105 | </td></tr></table> |
| 106 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame^] | 107 | That example also demonstrates that block expressions (here columns) can be used in arithmetic like any other expression. |
| 108 | |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 109 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 110 | \section TutorialBlockOperationsSyntaxCorners Corner-related operations |
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 | Eigen also provides special methods for blocks that are flushed against one of the corners or sides of a |
| 113 | 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^] | 114 | to a block in the top-left corner of a matrix. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 115 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 116 | The different possibilities are summarized in the following table: |
| 117 | |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 118 | <table class="tutorial_code" align="center"> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 119 | <tr><td align="center">\b %Block \b operation</td> |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame^] | 120 | <td align="center">Version constructing a dynamic-size block expression</td> |
| 121 | <td align="center">Version constructing a fixed-size block expression</td></tr> |
Jitse Niesen | 3070164 | 2010-06-29 11:42:51 +0100 | [diff] [blame] | 122 | <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] | 123 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 124 | matrix.topLeftCorner(p,q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 125 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 126 | matrix.topLeftCorner<p,q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 127 | </tr> |
Jitse Niesen | 3070164 | 2010-06-29 11:42:51 +0100 | [diff] [blame] | 128 | <tr><td>Bottom-left p by q block |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 129 | \link DenseBase::bottomLeftCorner() * \endlink</td> |
| 130 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 131 | matrix.bottomLeftCorner(p,q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 132 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 133 | matrix.bottomLeftCorner<p,q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 134 | </tr> |
Jitse Niesen | 3070164 | 2010-06-29 11:42:51 +0100 | [diff] [blame] | 135 | <tr><td>Top-right p by q block |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 136 | \link DenseBase::topRightCorner() * \endlink</td> |
| 137 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 138 | matrix.topRightCorner(p,q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 139 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 140 | matrix.topRightCorner<p,q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 141 | </tr> |
Jitse Niesen | 3070164 | 2010-06-29 11:42:51 +0100 | [diff] [blame] | 142 | <tr><td>Bottom-right p by q block |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 143 | \link DenseBase::bottomRightCorner() * \endlink</td> |
| 144 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 145 | matrix.bottomRightCorner(p,q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 146 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 147 | matrix.bottomRightCorner<p,q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 148 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 149 | <tr><td>%Block containing the first q rows |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 150 | \link DenseBase::topRows() * \endlink</td> |
| 151 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 152 | matrix.topRows(q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 153 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 154 | matrix.topRows<q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 155 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 156 | <tr><td>%Block containing the last q rows |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 157 | \link DenseBase::bottomRows() * \endlink</td> |
| 158 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 159 | matrix.bottomRows(q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 160 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 161 | matrix.bottomRows<q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 162 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 163 | <tr><td>%Block containing the first p columns |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 164 | \link DenseBase::leftCols() * \endlink</td> |
| 165 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 166 | matrix.leftCols(p);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 167 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 168 | matrix.leftCols<p>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 169 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 170 | <tr><td>%Block containing the last q columns |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 171 | \link DenseBase::rightCols() * \endlink</td> |
| 172 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 173 | matrix.rightCols(q);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 174 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 175 | matrix.rightCols<q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 176 | </tr> |
| 177 | </table> |
| 178 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 179 | 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] | 180 | |
| 181 | <table class="tutorial_code"><tr><td> |
| 182 | C++ code: |
| 183 | \include Tutorial_BlockOperations_corner.cpp |
| 184 | </td> |
| 185 | <td> |
| 186 | Output: |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 187 | \verbinclude Tutorial_BlockOperations_corner.out |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 188 | </td></tr></table> |
| 189 | |
| 190 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 191 | \section TutorialBlockOperationsSyntaxVectors Block operations for vectors |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 192 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame^] | 193 | 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] | 194 | |
| 195 | <table class="tutorial_code" align="center"> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 196 | <tr><td align="center">\b %Block \b operation</td> |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame^] | 197 | <td align="center">Version constructing a dynamic-size block expression</td> |
| 198 | <td align="center">Version constructing a fixed-size block expression</td></tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 199 | <tr><td>%Block containing the first \p n elements |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 200 | \link DenseBase::head() * \endlink</td> |
| 201 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 202 | vector.head(n);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 203 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 204 | vector.head<n>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 205 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 206 | <tr><td>%Block containing the last \p n elements |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 207 | \link DenseBase::tail() * \endlink</td> |
| 208 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 209 | vector.tail(n);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 210 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 211 | vector.tail<n>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 212 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 213 | <tr><td>%Block containing \p n elements, starting at position \p i |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 214 | \link DenseBase::segment() * \endlink</td> |
| 215 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 216 | vector.segment(i,n);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 217 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 218 | vector.segment<n>(i);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 219 | </tr> |
| 220 | </table> |
| 221 | |
| 222 | |
| 223 | An example is presented below: |
| 224 | <table class="tutorial_code"><tr><td> |
| 225 | C++ code: |
| 226 | \include Tutorial_BlockOperations_vector.cpp |
| 227 | </td> |
| 228 | <td> |
| 229 | Output: |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 230 | \verbinclude Tutorial_BlockOperations_vector.out |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 231 | </td></tr></table> |
| 232 | |
Benoit Jacob | 4d4a23c | 2010-06-30 10:11:55 -0400 | [diff] [blame] | 233 | \li \b Next: \ref TutorialAdvancedInitialization |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 234 | |
| 235 | */ |
| 236 | |
| 237 | } |