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 | |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame^] | 26 | <table class="manual"> |
| 27 | <tr><th>\b %Block \b operation</td> |
| 28 | <th>Version constructing a \n dynamic-size block expression</th> |
| 29 | <th>Version constructing a \n fixed-size block expression</th></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 | |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame^] | 48 | <table class="example"> |
| 49 | <tr><th>Example:</th><th>Output:</th></tr> |
| 50 | <tr><td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 51 | \include Tutorial_BlockOperations_print_block.cpp |
| 52 | </td> |
| 53 | <td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 54 | \verbinclude Tutorial_BlockOperations_print_block.out |
| 55 | </td></tr></table> |
| 56 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 57 | In the above example the \link DenseBase::block() .block() \endlink function was employed as a \em rvalue, i.e. |
| 58 | 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] | 59 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 60 | 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] | 61 | |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame^] | 62 | <table class="example"> |
| 63 | <tr><th>Example:</th><th>Output:</th></tr> |
| 64 | <tr><td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 65 | \include Tutorial_BlockOperations_block_assignment.cpp |
| 66 | </td> |
| 67 | <td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 68 | \verbinclude Tutorial_BlockOperations_block_assignment.out |
| 69 | </td></tr></table> |
| 70 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 71 | While the \link DenseBase::block() .block() \endlink method can be used for any block operation, there are |
| 72 | other methods for special cases, providing more specialized API and/or better performance. On the topic of performance, all what |
| 73 | 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, |
| 74 | 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] | 75 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 76 | The rest of this page describes these specialized methods. |
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 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 80 | Individual columns and rows are special cases of blocks. Eigen provides methods to easily address them: |
| 81 | \link DenseBase::col() .col() \endlink and \link DenseBase::row() .row()\endlink. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 82 | |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame^] | 83 | <table class="manual"> |
| 84 | <tr><th>%Block operation</th> |
| 85 | <th>Method</th> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 86 | <tr><td>i<sup>th</sup> row |
| 87 | \link DenseBase::row() * \endlink</td> |
| 88 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 89 | matrix.row(i);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 90 | </tr> |
| 91 | <tr><td>j<sup>th</sup> column |
| 92 | \link DenseBase::col() * \endlink</td> |
| 93 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 94 | matrix.col(j);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 95 | </tr> |
| 96 | </table> |
| 97 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 98 | 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] | 99 | |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame^] | 100 | <table class="example"> |
| 101 | <tr><th>Example:</th><th>Output:</th></tr> |
| 102 | <tr><td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 103 | \include Tutorial_BlockOperations_colrow.cpp |
| 104 | </td> |
| 105 | <td> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 106 | \verbinclude Tutorial_BlockOperations_colrow.out |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 107 | </td></tr></table> |
| 108 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 109 | That example also demonstrates that block expressions (here columns) can be used in arithmetic like any other expression. |
| 110 | |
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 | \section TutorialBlockOperationsSyntaxCorners Corner-related operations |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 113 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 114 | Eigen also provides special methods for blocks that are flushed against one of the corners or sides of a |
| 115 | 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] | 116 | to a block in the top-left corner of a matrix. |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 117 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 118 | The different possibilities are summarized in the following table: |
| 119 | |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame^] | 120 | <table class="manual"> |
| 121 | <tr><th>%Block \b operation</td> |
| 122 | <th>Version constructing a \n dynamic-size block expression</th> |
| 123 | <th>Version constructing a \n fixed-size block expression</th></tr> |
Jitse Niesen | 3070164 | 2010-06-29 11:42:51 +0100 | [diff] [blame] | 124 | <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] | 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 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 128 | matrix.topLeftCorner<p,q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 129 | </tr> |
Jitse Niesen | 3070164 | 2010-06-29 11:42:51 +0100 | [diff] [blame] | 130 | <tr><td>Bottom-left p by q block |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 131 | \link DenseBase::bottomLeftCorner() * \endlink</td> |
| 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 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 135 | matrix.bottomLeftCorner<p,q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 136 | </tr> |
Jitse Niesen | 3070164 | 2010-06-29 11:42:51 +0100 | [diff] [blame] | 137 | <tr><td>Top-right p by q block |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 138 | \link DenseBase::topRightCorner() * \endlink</td> |
| 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 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 142 | matrix.topRightCorner<p,q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 143 | </tr> |
Jitse Niesen | 3070164 | 2010-06-29 11:42:51 +0100 | [diff] [blame] | 144 | <tr><td>Bottom-right p by q block |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 145 | \link DenseBase::bottomRightCorner() * \endlink</td> |
| 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 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 149 | matrix.bottomRightCorner<p,q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 150 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 151 | <tr><td>%Block containing the first q rows |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 152 | \link DenseBase::topRows() * \endlink</td> |
| 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 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 156 | matrix.topRows<q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 157 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 158 | <tr><td>%Block containing the last q rows |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 159 | \link DenseBase::bottomRows() * \endlink</td> |
| 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 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 163 | matrix.bottomRows<q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 164 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 165 | <tr><td>%Block containing the first p columns |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 166 | \link DenseBase::leftCols() * \endlink</td> |
| 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 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 170 | matrix.leftCols<p>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 171 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 172 | <tr><td>%Block containing the last q columns |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 173 | \link DenseBase::rightCols() * \endlink</td> |
| 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 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 177 | matrix.rightCols<q>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 178 | </tr> |
| 179 | </table> |
| 180 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 181 | 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] | 182 | |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame^] | 183 | <table class="example"> |
| 184 | <tr><th>Example:</th><th>Output:</th></tr> |
| 185 | <tr><td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 186 | \include Tutorial_BlockOperations_corner.cpp |
| 187 | </td> |
| 188 | <td> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 189 | \verbinclude Tutorial_BlockOperations_corner.out |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 190 | </td></tr></table> |
| 191 | |
| 192 | |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 193 | \section TutorialBlockOperationsSyntaxVectors Block operations for vectors |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 194 | |
Benoit Jacob | 1c15a6d | 2010-10-18 08:44:27 -0400 | [diff] [blame] | 195 | 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] | 196 | |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame^] | 197 | <table class="manual"> |
| 198 | <tr><th> %Block operation</th> |
| 199 | <th>Version constructing a \n dynamic-size block expression</th> |
| 200 | <th>Version constructing a \n fixed-size block expression</th></tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 201 | <tr><td>%Block containing the first \p n elements |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 202 | \link DenseBase::head() * \endlink</td> |
| 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 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 206 | vector.head<n>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 207 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 208 | <tr><td>%Block containing the last \p n elements |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 209 | \link DenseBase::tail() * \endlink</td> |
| 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 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 213 | vector.tail<n>();\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 214 | </tr> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 215 | <tr><td>%Block containing \p n elements, starting at position \p i |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 216 | \link DenseBase::segment() * \endlink</td> |
| 217 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 218 | vector.segment(i,n);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 219 | <td>\code |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 220 | vector.segment<n>(i);\endcode </td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 221 | </tr> |
| 222 | </table> |
| 223 | |
| 224 | |
| 225 | An example is presented below: |
Gael Guennebaud | f66fe26 | 2010-10-19 11:40:49 +0200 | [diff] [blame^] | 226 | <table class="example"> |
| 227 | <tr><th>Example:</th><th>Output:</th></tr> |
| 228 | <tr><td> |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 229 | \include Tutorial_BlockOperations_vector.cpp |
| 230 | </td> |
| 231 | <td> |
Jitse Niesen | b0bd1cf | 2010-07-14 10:16:12 +0100 | [diff] [blame] | 232 | \verbinclude Tutorial_BlockOperations_vector.out |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 233 | </td></tr></table> |
| 234 | |
Benoit Jacob | 4d4a23c | 2010-06-30 10:11:55 -0400 | [diff] [blame] | 235 | \li \b Next: \ref TutorialAdvancedInitialization |
Carlos Becker | 97889a7 | 2010-06-28 18:42:59 +0100 | [diff] [blame] | 236 | |
| 237 | */ |
| 238 | |
| 239 | } |