Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
BlockMethods.h
00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr> 00005 // Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com> 00006 // 00007 // This Source Code Form is subject to the terms of the Mozilla 00008 // Public License v. 2.0. If a copy of the MPL was not distributed 00009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 00010 00011 00012 #ifndef EIGEN_PARSED_BY_DOXYGEN 00013 00014 /** \internal expression type of a column */ 00015 typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ColXpr; 00016 typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ConstColXpr; 00017 /** \internal expression type of a row */ 00018 typedef Block<Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowXpr; 00019 typedef const Block<const Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowXpr; 00020 /** \internal expression type of a block of whole columns */ 00021 typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ColsBlockXpr; 00022 typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ConstColsBlockXpr; 00023 /** \internal expression type of a block of whole rows */ 00024 typedef Block<Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowsBlockXpr; 00025 typedef const Block<const Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowsBlockXpr; 00026 /** \internal expression type of a block of whole columns */ 00027 template<int N> struct NColsBlockXpr { typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; }; 00028 template<int N> struct ConstNColsBlockXpr { typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; }; 00029 /** \internal expression type of a block of whole rows */ 00030 template<int N> struct NRowsBlockXpr { typedef Block<Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; }; 00031 template<int N> struct ConstNRowsBlockXpr { typedef const Block<const Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; }; 00032 00033 typedef VectorBlock<Derived> SegmentReturnType; 00034 typedef const VectorBlock<const Derived> ConstSegmentReturnType; 00035 template<int Size> struct FixedSegmentReturnType { typedef VectorBlock<Derived, Size> Type; }; 00036 template<int Size> struct ConstFixedSegmentReturnType { typedef const VectorBlock<const Derived, Size> Type; }; 00037 00038 #endif // not EIGEN_PARSED_BY_DOXYGEN 00039 00040 /** \returns a dynamic-size expression of a block in *this. 00041 * 00042 * \param startRow the first row in the block 00043 * \param startCol the first column in the block 00044 * \param blockRows the number of rows in the block 00045 * \param blockCols the number of columns in the block 00046 * 00047 * Example: \include MatrixBase_block_int_int_int_int.cpp 00048 * Output: \verbinclude MatrixBase_block_int_int_int_int.out 00049 * 00050 * \note Even though the returned expression has dynamic size, in the case 00051 * when it is applied to a fixed-size matrix, it inherits a fixed maximal size, 00052 * which means that evaluating it does not cause a dynamic memory allocation. 00053 * 00054 * \sa class Block, block(Index,Index) 00055 */ 00056 inline Block<Derived> block(Index startRow, Index startCol, Index blockRows, Index blockCols) 00057 { 00058 return Block<Derived>(derived(), startRow, startCol, blockRows, blockCols); 00059 } 00060 00061 /** This is the const version of block(Index,Index,Index,Index). */ 00062 inline const Block<const Derived> block(Index startRow, Index startCol, Index blockRows, Index blockCols) const 00063 { 00064 return Block<const Derived>(derived(), startRow, startCol, blockRows, blockCols); 00065 } 00066 00067 00068 00069 00070 /** \returns a dynamic-size expression of a top-right corner of *this. 00071 * 00072 * \param cRows the number of rows in the corner 00073 * \param cCols the number of columns in the corner 00074 * 00075 * Example: \include MatrixBase_topRightCorner_int_int.cpp 00076 * Output: \verbinclude MatrixBase_topRightCorner_int_int.out 00077 * 00078 * \sa class Block, block(Index,Index,Index,Index) 00079 */ 00080 inline Block<Derived> topRightCorner(Index cRows, Index cCols) 00081 { 00082 return Block<Derived>(derived(), 0, cols() - cCols, cRows, cCols); 00083 } 00084 00085 /** This is the const version of topRightCorner(Index, Index).*/ 00086 inline const Block<const Derived> topRightCorner(Index cRows, Index cCols) const 00087 { 00088 return Block<const Derived>(derived(), 0, cols() - cCols, cRows, cCols); 00089 } 00090 00091 /** \returns an expression of a fixed-size top-right corner of *this. 00092 * 00093 * \tparam CRows the number of rows in the corner 00094 * \tparam CCols the number of columns in the corner 00095 * 00096 * Example: \include MatrixBase_template_int_int_topRightCorner.cpp 00097 * Output: \verbinclude MatrixBase_template_int_int_topRightCorner.out 00098 * 00099 * \sa class Block, block<int,int>(Index,Index) 00100 */ 00101 template<int CRows, int CCols> 00102 inline Block<Derived, CRows, CCols> topRightCorner() 00103 { 00104 return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols); 00105 } 00106 00107 /** This is the const version of topRightCorner<int, int>().*/ 00108 template<int CRows, int CCols> 00109 inline const Block<const Derived, CRows, CCols> topRightCorner() const 00110 { 00111 return Block<const Derived, CRows, CCols>(derived(), 0, cols() - CCols); 00112 } 00113 00114 /** \returns an expression of a top-right corner of *this. 00115 * 00116 * \tparam CRows number of rows in corner as specified at compile-time 00117 * \tparam CCols number of columns in corner as specified at compile-time 00118 * \param cRows number of rows in corner as specified at run-time 00119 * \param cCols number of columns in corner as specified at run-time 00120 * 00121 * This function is mainly useful for corners where the number of rows is specified at compile-time 00122 * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time 00123 * information should not contradict. In other words, \a cRows should equal \a CRows unless 00124 * \a CRows is \a Dynamic, and the same for the number of columns. 00125 * 00126 * Example: \include MatrixBase_template_int_int_topRightCorner_int_int.cpp 00127 * Output: \verbinclude MatrixBase_template_int_int_topRightCorner_int_int.out 00128 * 00129 * \sa class Block 00130 */ 00131 template<int CRows, int CCols> 00132 inline Block<Derived, CRows, CCols> topRightCorner(Index cRows, Index cCols) 00133 { 00134 return Block<Derived, CRows, CCols>(derived(), 0, cols() - cCols, cRows, cCols); 00135 } 00136 00137 /** This is the const version of topRightCorner<int, int>(Index, Index).*/ 00138 template<int CRows, int CCols> 00139 inline const Block<const Derived, CRows, CCols> topRightCorner(Index cRows, Index cCols) const 00140 { 00141 return Block<const Derived, CRows, CCols>(derived(), 0, cols() - cCols, cRows, cCols); 00142 } 00143 00144 00145 00146 /** \returns a dynamic-size expression of a top-left corner of *this. 00147 * 00148 * \param cRows the number of rows in the corner 00149 * \param cCols the number of columns in the corner 00150 * 00151 * Example: \include MatrixBase_topLeftCorner_int_int.cpp 00152 * Output: \verbinclude MatrixBase_topLeftCorner_int_int.out 00153 * 00154 * \sa class Block, block(Index,Index,Index,Index) 00155 */ 00156 inline Block<Derived> topLeftCorner(Index cRows, Index cCols) 00157 { 00158 return Block<Derived>(derived(), 0, 0, cRows, cCols); 00159 } 00160 00161 /** This is the const version of topLeftCorner(Index, Index).*/ 00162 inline const Block<const Derived> topLeftCorner(Index cRows, Index cCols) const 00163 { 00164 return Block<const Derived>(derived(), 0, 0, cRows, cCols); 00165 } 00166 00167 /** \returns an expression of a fixed-size top-left corner of *this. 00168 * 00169 * The template parameters CRows and CCols are the number of rows and columns in the corner. 00170 * 00171 * Example: \include MatrixBase_template_int_int_topLeftCorner.cpp 00172 * Output: \verbinclude MatrixBase_template_int_int_topLeftCorner.out 00173 * 00174 * \sa class Block, block(Index,Index,Index,Index) 00175 */ 00176 template<int CRows, int CCols> 00177 inline Block<Derived, CRows, CCols> topLeftCorner() 00178 { 00179 return Block<Derived, CRows, CCols>(derived(), 0, 0); 00180 } 00181 00182 /** This is the const version of topLeftCorner<int, int>().*/ 00183 template<int CRows, int CCols> 00184 inline const Block<const Derived, CRows, CCols> topLeftCorner() const 00185 { 00186 return Block<const Derived, CRows, CCols>(derived(), 0, 0); 00187 } 00188 00189 /** \returns an expression of a top-left corner of *this. 00190 * 00191 * \tparam CRows number of rows in corner as specified at compile-time 00192 * \tparam CCols number of columns in corner as specified at compile-time 00193 * \param cRows number of rows in corner as specified at run-time 00194 * \param cCols number of columns in corner as specified at run-time 00195 * 00196 * This function is mainly useful for corners where the number of rows is specified at compile-time 00197 * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time 00198 * information should not contradict. In other words, \a cRows should equal \a CRows unless 00199 * \a CRows is \a Dynamic, and the same for the number of columns. 00200 * 00201 * Example: \include MatrixBase_template_int_int_topLeftCorner_int_int.cpp 00202 * Output: \verbinclude MatrixBase_template_int_int_topLeftCorner_int_int.out 00203 * 00204 * \sa class Block 00205 */ 00206 template<int CRows, int CCols> 00207 inline Block<Derived, CRows, CCols> topLeftCorner(Index cRows, Index cCols) 00208 { 00209 return Block<Derived, CRows, CCols>(derived(), 0, 0, cRows, cCols); 00210 } 00211 00212 /** This is the const version of topLeftCorner<int, int>(Index, Index).*/ 00213 template<int CRows, int CCols> 00214 inline const Block<const Derived, CRows, CCols> topLeftCorner(Index cRows, Index cCols) const 00215 { 00216 return Block<const Derived, CRows, CCols>(derived(), 0, 0, cRows, cCols); 00217 } 00218 00219 00220 00221 /** \returns a dynamic-size expression of a bottom-right corner of *this. 00222 * 00223 * \param cRows the number of rows in the corner 00224 * \param cCols the number of columns in the corner 00225 * 00226 * Example: \include MatrixBase_bottomRightCorner_int_int.cpp 00227 * Output: \verbinclude MatrixBase_bottomRightCorner_int_int.out 00228 * 00229 * \sa class Block, block(Index,Index,Index,Index) 00230 */ 00231 inline Block<Derived> bottomRightCorner(Index cRows, Index cCols) 00232 { 00233 return Block<Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols); 00234 } 00235 00236 /** This is the const version of bottomRightCorner(Index, Index).*/ 00237 inline const Block<const Derived> bottomRightCorner(Index cRows, Index cCols) const 00238 { 00239 return Block<const Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols); 00240 } 00241 00242 /** \returns an expression of a fixed-size bottom-right corner of *this. 00243 * 00244 * The template parameters CRows and CCols are the number of rows and columns in the corner. 00245 * 00246 * Example: \include MatrixBase_template_int_int_bottomRightCorner.cpp 00247 * Output: \verbinclude MatrixBase_template_int_int_bottomRightCorner.out 00248 * 00249 * \sa class Block, block(Index,Index,Index,Index) 00250 */ 00251 template<int CRows, int CCols> 00252 inline Block<Derived, CRows, CCols> bottomRightCorner() 00253 { 00254 return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols); 00255 } 00256 00257 /** This is the const version of bottomRightCorner<int, int>().*/ 00258 template<int CRows, int CCols> 00259 inline const Block<const Derived, CRows, CCols> bottomRightCorner() const 00260 { 00261 return Block<const Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols); 00262 } 00263 00264 /** \returns an expression of a bottom-right corner of *this. 00265 * 00266 * \tparam CRows number of rows in corner as specified at compile-time 00267 * \tparam CCols number of columns in corner as specified at compile-time 00268 * \param cRows number of rows in corner as specified at run-time 00269 * \param cCols number of columns in corner as specified at run-time 00270 * 00271 * This function is mainly useful for corners where the number of rows is specified at compile-time 00272 * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time 00273 * information should not contradict. In other words, \a cRows should equal \a CRows unless 00274 * \a CRows is \a Dynamic, and the same for the number of columns. 00275 * 00276 * Example: \include MatrixBase_template_int_int_bottomRightCorner_int_int.cpp 00277 * Output: \verbinclude MatrixBase_template_int_int_bottomRightCorner_int_int.out 00278 * 00279 * \sa class Block 00280 */ 00281 template<int CRows, int CCols> 00282 inline Block<Derived, CRows, CCols> bottomRightCorner(Index cRows, Index cCols) 00283 { 00284 return Block<Derived, CRows, CCols>(derived(), rows() - cRows, cols() - cCols, cRows, cCols); 00285 } 00286 00287 /** This is the const version of bottomRightCorner<int, int>(Index, Index).*/ 00288 template<int CRows, int CCols> 00289 inline const Block<const Derived, CRows, CCols> bottomRightCorner(Index cRows, Index cCols) const 00290 { 00291 return Block<const Derived, CRows, CCols>(derived(), rows() - cRows, cols() - cCols, cRows, cCols); 00292 } 00293 00294 00295 00296 /** \returns a dynamic-size expression of a bottom-left corner of *this. 00297 * 00298 * \param cRows the number of rows in the corner 00299 * \param cCols the number of columns in the corner 00300 * 00301 * Example: \include MatrixBase_bottomLeftCorner_int_int.cpp 00302 * Output: \verbinclude MatrixBase_bottomLeftCorner_int_int.out 00303 * 00304 * \sa class Block, block(Index,Index,Index,Index) 00305 */ 00306 inline Block<Derived> bottomLeftCorner(Index cRows, Index cCols) 00307 { 00308 return Block<Derived>(derived(), rows() - cRows, 0, cRows, cCols); 00309 } 00310 00311 /** This is the const version of bottomLeftCorner(Index, Index).*/ 00312 inline const Block<const Derived> bottomLeftCorner(Index cRows, Index cCols) const 00313 { 00314 return Block<const Derived>(derived(), rows() - cRows, 0, cRows, cCols); 00315 } 00316 00317 /** \returns an expression of a fixed-size bottom-left corner of *this. 00318 * 00319 * The template parameters CRows and CCols are the number of rows and columns in the corner. 00320 * 00321 * Example: \include MatrixBase_template_int_int_bottomLeftCorner.cpp 00322 * Output: \verbinclude MatrixBase_template_int_int_bottomLeftCorner.out 00323 * 00324 * \sa class Block, block(Index,Index,Index,Index) 00325 */ 00326 template<int CRows, int CCols> 00327 inline Block<Derived, CRows, CCols> bottomLeftCorner() 00328 { 00329 return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0); 00330 } 00331 00332 /** This is the const version of bottomLeftCorner<int, int>().*/ 00333 template<int CRows, int CCols> 00334 inline const Block<const Derived, CRows, CCols> bottomLeftCorner() const 00335 { 00336 return Block<const Derived, CRows, CCols>(derived(), rows() - CRows, 0); 00337 } 00338 00339 /** \returns an expression of a bottom-left corner of *this. 00340 * 00341 * \tparam CRows number of rows in corner as specified at compile-time 00342 * \tparam CCols number of columns in corner as specified at compile-time 00343 * \param cRows number of rows in corner as specified at run-time 00344 * \param cCols number of columns in corner as specified at run-time 00345 * 00346 * This function is mainly useful for corners where the number of rows is specified at compile-time 00347 * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time 00348 * information should not contradict. In other words, \a cRows should equal \a CRows unless 00349 * \a CRows is \a Dynamic, and the same for the number of columns. 00350 * 00351 * Example: \include MatrixBase_template_int_int_bottomLeftCorner_int_int.cpp 00352 * Output: \verbinclude MatrixBase_template_int_int_bottomLeftCorner_int_int.out 00353 * 00354 * \sa class Block 00355 */ 00356 template<int CRows, int CCols> 00357 inline Block<Derived, CRows, CCols> bottomLeftCorner(Index cRows, Index cCols) 00358 { 00359 return Block<Derived, CRows, CCols>(derived(), rows() - cRows, 0, cRows, cCols); 00360 } 00361 00362 /** This is the const version of bottomLeftCorner<int, int>(Index, Index).*/ 00363 template<int CRows, int CCols> 00364 inline const Block<const Derived, CRows, CCols> bottomLeftCorner(Index cRows, Index cCols) const 00365 { 00366 return Block<const Derived, CRows, CCols>(derived(), rows() - cRows, 0, cRows, cCols); 00367 } 00368 00369 00370 00371 /** \returns a block consisting of the top rows of *this. 00372 * 00373 * \param n the number of rows in the block 00374 * 00375 * Example: \include MatrixBase_topRows_int.cpp 00376 * Output: \verbinclude MatrixBase_topRows_int.out 00377 * 00378 * \sa class Block, block(Index,Index,Index,Index) 00379 */ 00380 inline RowsBlockXpr topRows(Index n) 00381 { 00382 return RowsBlockXpr(derived(), 0, 0, n, cols()); 00383 } 00384 00385 /** This is the const version of topRows(Index).*/ 00386 inline ConstRowsBlockXpr topRows(Index n) const 00387 { 00388 return ConstRowsBlockXpr(derived(), 0, 0, n, cols()); 00389 } 00390 00391 /** \returns a block consisting of the top rows of *this. 00392 * 00393 * \tparam N the number of rows in the block as specified at compile-time 00394 * \param n the number of rows in the block as specified at run-time 00395 * 00396 * The compile-time and run-time information should not contradict. In other words, 00397 * \a n should equal \a N unless \a N is \a Dynamic. 00398 * 00399 * Example: \include MatrixBase_template_int_topRows.cpp 00400 * Output: \verbinclude MatrixBase_template_int_topRows.out 00401 * 00402 * \sa class Block, block(Index,Index,Index,Index) 00403 */ 00404 template<int N> 00405 inline typename NRowsBlockXpr<N>::Type topRows(Index n = N) 00406 { 00407 return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols()); 00408 } 00409 00410 /** This is the const version of topRows<int>().*/ 00411 template<int N> 00412 inline typename ConstNRowsBlockXpr<N>::Type topRows(Index n = N) const 00413 { 00414 return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols()); 00415 } 00416 00417 00418 00419 /** \returns a block consisting of the bottom rows of *this. 00420 * 00421 * \param n the number of rows in the block 00422 * 00423 * Example: \include MatrixBase_bottomRows_int.cpp 00424 * Output: \verbinclude MatrixBase_bottomRows_int.out 00425 * 00426 * \sa class Block, block(Index,Index,Index,Index) 00427 */ 00428 inline RowsBlockXpr bottomRows(Index n) 00429 { 00430 return RowsBlockXpr(derived(), rows() - n, 0, n, cols()); 00431 } 00432 00433 /** This is the const version of bottomRows(Index).*/ 00434 inline ConstRowsBlockXpr bottomRows(Index n) const 00435 { 00436 return ConstRowsBlockXpr(derived(), rows() - n, 0, n, cols()); 00437 } 00438 00439 /** \returns a block consisting of the bottom rows of *this. 00440 * 00441 * \tparam N the number of rows in the block as specified at compile-time 00442 * \param n the number of rows in the block as specified at run-time 00443 * 00444 * The compile-time and run-time information should not contradict. In other words, 00445 * \a n should equal \a N unless \a N is \a Dynamic. 00446 * 00447 * Example: \include MatrixBase_template_int_bottomRows.cpp 00448 * Output: \verbinclude MatrixBase_template_int_bottomRows.out 00449 * 00450 * \sa class Block, block(Index,Index,Index,Index) 00451 */ 00452 template<int N> 00453 inline typename NRowsBlockXpr<N>::Type bottomRows(Index n = N) 00454 { 00455 return typename NRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols()); 00456 } 00457 00458 /** This is the const version of bottomRows<int>().*/ 00459 template<int N> 00460 inline typename ConstNRowsBlockXpr<N>::Type bottomRows(Index n = N) const 00461 { 00462 return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols()); 00463 } 00464 00465 00466 00467 /** \returns a block consisting of a range of rows of *this. 00468 * 00469 * \param startRow the index of the first row in the block 00470 * \param n the number of rows in the block 00471 * 00472 * Example: \include DenseBase_middleRows_int.cpp 00473 * Output: \verbinclude DenseBase_middleRows_int.out 00474 * 00475 * \sa class Block, block(Index,Index,Index,Index) 00476 */ 00477 inline RowsBlockXpr middleRows(Index startRow, Index n) 00478 { 00479 return RowsBlockXpr(derived(), startRow, 0, n, cols()); 00480 } 00481 00482 /** This is the const version of middleRows(Index,Index).*/ 00483 inline ConstRowsBlockXpr middleRows(Index startRow, Index n) const 00484 { 00485 return ConstRowsBlockXpr(derived(), startRow, 0, n, cols()); 00486 } 00487 00488 /** \returns a block consisting of a range of rows of *this. 00489 * 00490 * \tparam N the number of rows in the block as specified at compile-time 00491 * \param startRow the index of the first row in the block 00492 * \param n the number of rows in the block as specified at run-time 00493 * 00494 * The compile-time and run-time information should not contradict. In other words, 00495 * \a n should equal \a N unless \a N is \a Dynamic. 00496 * 00497 * Example: \include DenseBase_template_int_middleRows.cpp 00498 * Output: \verbinclude DenseBase_template_int_middleRows.out 00499 * 00500 * \sa class Block, block(Index,Index,Index,Index) 00501 */ 00502 template<int N> 00503 inline typename NRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N) 00504 { 00505 return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols()); 00506 } 00507 00508 /** This is the const version of middleRows<int>().*/ 00509 template<int N> 00510 inline typename ConstNRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N) const 00511 { 00512 return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols()); 00513 } 00514 00515 00516 00517 /** \returns a block consisting of the left columns of *this. 00518 * 00519 * \param n the number of columns in the block 00520 * 00521 * Example: \include MatrixBase_leftCols_int.cpp 00522 * Output: \verbinclude MatrixBase_leftCols_int.out 00523 * 00524 * \sa class Block, block(Index,Index,Index,Index) 00525 */ 00526 inline ColsBlockXpr leftCols(Index n) 00527 { 00528 return ColsBlockXpr(derived(), 0, 0, rows(), n); 00529 } 00530 00531 /** This is the const version of leftCols(Index).*/ 00532 inline ConstColsBlockXpr leftCols(Index n) const 00533 { 00534 return ConstColsBlockXpr(derived(), 0, 0, rows(), n); 00535 } 00536 00537 /** \returns a block consisting of the left columns of *this. 00538 * 00539 * \tparam N the number of columns in the block as specified at compile-time 00540 * \param n the number of columns in the block as specified at run-time 00541 * 00542 * The compile-time and run-time information should not contradict. In other words, 00543 * \a n should equal \a N unless \a N is \a Dynamic. 00544 * 00545 * Example: \include MatrixBase_template_int_leftCols.cpp 00546 * Output: \verbinclude MatrixBase_template_int_leftCols.out 00547 * 00548 * \sa class Block, block(Index,Index,Index,Index) 00549 */ 00550 template<int N> 00551 inline typename NColsBlockXpr<N>::Type leftCols(Index n = N) 00552 { 00553 return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n); 00554 } 00555 00556 /** This is the const version of leftCols<int>().*/ 00557 template<int N> 00558 inline typename ConstNColsBlockXpr<N>::Type leftCols(Index n = N) const 00559 { 00560 return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n); 00561 } 00562 00563 00564 00565 /** \returns a block consisting of the right columns of *this. 00566 * 00567 * \param n the number of columns in the block 00568 * 00569 * Example: \include MatrixBase_rightCols_int.cpp 00570 * Output: \verbinclude MatrixBase_rightCols_int.out 00571 * 00572 * \sa class Block, block(Index,Index,Index,Index) 00573 */ 00574 inline ColsBlockXpr rightCols(Index n) 00575 { 00576 return ColsBlockXpr(derived(), 0, cols() - n, rows(), n); 00577 } 00578 00579 /** This is the const version of rightCols(Index).*/ 00580 inline ConstColsBlockXpr rightCols(Index n) const 00581 { 00582 return ConstColsBlockXpr(derived(), 0, cols() - n, rows(), n); 00583 } 00584 00585 /** \returns a block consisting of the right columns of *this. 00586 * 00587 * \tparam N the number of columns in the block as specified at compile-time 00588 * \param n the number of columns in the block as specified at run-time 00589 * 00590 * The compile-time and run-time information should not contradict. In other words, 00591 * \a n should equal \a N unless \a N is \a Dynamic. 00592 * 00593 * Example: \include MatrixBase_template_int_rightCols.cpp 00594 * Output: \verbinclude MatrixBase_template_int_rightCols.out 00595 * 00596 * \sa class Block, block(Index,Index,Index,Index) 00597 */ 00598 template<int N> 00599 inline typename NColsBlockXpr<N>::Type rightCols(Index n = N) 00600 { 00601 return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n); 00602 } 00603 00604 /** This is the const version of rightCols<int>().*/ 00605 template<int N> 00606 inline typename ConstNColsBlockXpr<N>::Type rightCols(Index n = N) const 00607 { 00608 return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n); 00609 } 00610 00611 00612 00613 /** \returns a block consisting of a range of columns of *this. 00614 * 00615 * \param startCol the index of the first column in the block 00616 * \param numCols the number of columns in the block 00617 * 00618 * Example: \include DenseBase_middleCols_int.cpp 00619 * Output: \verbinclude DenseBase_middleCols_int.out 00620 * 00621 * \sa class Block, block(Index,Index,Index,Index) 00622 */ 00623 inline ColsBlockXpr middleCols(Index startCol, Index numCols) 00624 { 00625 return ColsBlockXpr(derived(), 0, startCol, rows(), numCols); 00626 } 00627 00628 /** This is the const version of middleCols(Index,Index).*/ 00629 inline ConstColsBlockXpr middleCols(Index startCol, Index numCols) const 00630 { 00631 return ConstColsBlockXpr(derived(), 0, startCol, rows(), numCols); 00632 } 00633 00634 /** \returns a block consisting of a range of columns of *this. 00635 * 00636 * \tparam N the number of columns in the block as specified at compile-time 00637 * \param startCol the index of the first column in the block 00638 * \param n the number of columns in the block as specified at run-time 00639 * 00640 * The compile-time and run-time information should not contradict. In other words, 00641 * \a n should equal \a N unless \a N is \a Dynamic. 00642 * 00643 * Example: \include DenseBase_template_int_middleCols.cpp 00644 * Output: \verbinclude DenseBase_template_int_middleCols.out 00645 * 00646 * \sa class Block, block(Index,Index,Index,Index) 00647 */ 00648 template<int N> 00649 inline typename NColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N) 00650 { 00651 return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n); 00652 } 00653 00654 /** This is the const version of middleCols<int>().*/ 00655 template<int N> 00656 inline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N) const 00657 { 00658 return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n); 00659 } 00660 00661 00662 00663 /** \returns a fixed-size expression of a block in *this. 00664 * 00665 * The template parameters \a BlockRows and \a BlockCols are the number of 00666 * rows and columns in the block. 00667 * 00668 * \param startRow the first row in the block 00669 * \param startCol the first column in the block 00670 * 00671 * Example: \include MatrixBase_block_int_int.cpp 00672 * Output: \verbinclude MatrixBase_block_int_int.out 00673 * 00674 * \note since block is a templated member, the keyword template has to be used 00675 * if the matrix type is also a template parameter: \code m.template block<3,3>(1,1); \endcode 00676 * 00677 * \sa class Block, block(Index,Index,Index,Index) 00678 */ 00679 template<int BlockRows, int BlockCols> 00680 inline Block<Derived, BlockRows, BlockCols> block(Index startRow, Index startCol) 00681 { 00682 return Block<Derived, BlockRows, BlockCols>(derived(), startRow, startCol); 00683 } 00684 00685 /** This is the const version of block<>(Index, Index). */ 00686 template<int BlockRows, int BlockCols> 00687 inline const Block<const Derived, BlockRows, BlockCols> block(Index startRow, Index startCol) const 00688 { 00689 return Block<const Derived, BlockRows, BlockCols>(derived(), startRow, startCol); 00690 } 00691 00692 /** \returns an expression of a block in *this. 00693 * 00694 * \tparam BlockRows number of rows in block as specified at compile-time 00695 * \tparam BlockCols number of columns in block as specified at compile-time 00696 * \param startRow the first row in the block 00697 * \param startCol the first column in the block 00698 * \param blockRows number of rows in block as specified at run-time 00699 * \param blockCols number of columns in block as specified at run-time 00700 * 00701 * This function is mainly useful for blocks where the number of rows is specified at compile-time 00702 * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time 00703 * information should not contradict. In other words, \a blockRows should equal \a BlockRows unless 00704 * \a BlockRows is \a Dynamic, and the same for the number of columns. 00705 * 00706 * Example: \include MatrixBase_template_int_int_block_int_int_int_int.cpp 00707 * Output: \verbinclude MatrixBase_template_int_int_block_int_int_int_int.cpp 00708 * 00709 * \sa class Block, block(Index,Index,Index,Index) 00710 */ 00711 template<int BlockRows, int BlockCols> 00712 inline Block<Derived, BlockRows, BlockCols> block(Index startRow, Index startCol, 00713 Index blockRows, Index blockCols) 00714 { 00715 return Block<Derived, BlockRows, BlockCols>(derived(), startRow, startCol, blockRows, blockCols); 00716 } 00717 00718 /** This is the const version of block<>(Index, Index, Index, Index). */ 00719 template<int BlockRows, int BlockCols> 00720 inline const Block<const Derived, BlockRows, BlockCols> block(Index startRow, Index startCol, 00721 Index blockRows, Index blockCols) const 00722 { 00723 return Block<const Derived, BlockRows, BlockCols>(derived(), startRow, startCol, blockRows, blockCols); 00724 } 00725 00726 /** \returns an expression of the \a i-th column of *this. Note that the numbering starts at 0. 00727 * 00728 * Example: \include MatrixBase_col.cpp 00729 * Output: \verbinclude MatrixBase_col.out 00730 * 00731 * \sa row(), class Block */ 00732 inline ColXpr col(Index i) 00733 { 00734 return ColXpr(derived(), i); 00735 } 00736 00737 /** This is the const version of col(). */ 00738 inline ConstColXpr col(Index i) const 00739 { 00740 return ConstColXpr(derived(), i); 00741 } 00742 00743 /** \returns an expression of the \a i-th row of *this. Note that the numbering starts at 0. 00744 * 00745 * Example: \include MatrixBase_row.cpp 00746 * Output: \verbinclude MatrixBase_row.out 00747 * 00748 * \sa col(), class Block */ 00749 inline RowXpr row(Index i) 00750 { 00751 return RowXpr(derived(), i); 00752 } 00753 00754 /** This is the const version of row(). */ 00755 inline ConstRowXpr row(Index i) const 00756 { 00757 return ConstRowXpr(derived(), i); 00758 } 00759 00760 /** \returns a dynamic-size expression of a segment (i.e. a vector block) in *this. 00761 * 00762 * \only_for_vectors 00763 * 00764 * \param start the first coefficient in the segment 00765 * \param n the number of coefficients in the segment 00766 * 00767 * Example: \include MatrixBase_segment_int_int.cpp 00768 * Output: \verbinclude MatrixBase_segment_int_int.out 00769 * 00770 * \note Even though the returned expression has dynamic size, in the case 00771 * when it is applied to a fixed-size vector, it inherits a fixed maximal size, 00772 * which means that evaluating it does not cause a dynamic memory allocation. 00773 * 00774 * \sa class Block, segment(Index) 00775 */ 00776 inline SegmentReturnType segment(Index start, Index n) 00777 { 00778 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 00779 return SegmentReturnType(derived(), start, n); 00780 } 00781 00782 00783 /** This is the const version of segment(Index,Index).*/ 00784 inline ConstSegmentReturnType segment(Index start, Index n) const 00785 { 00786 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 00787 return ConstSegmentReturnType(derived(), start, n); 00788 } 00789 00790 /** \returns a dynamic-size expression of the first coefficients of *this. 00791 * 00792 * \only_for_vectors 00793 * 00794 * \param n the number of coefficients in the segment 00795 * 00796 * Example: \include MatrixBase_start_int.cpp 00797 * Output: \verbinclude MatrixBase_start_int.out 00798 * 00799 * \note Even though the returned expression has dynamic size, in the case 00800 * when it is applied to a fixed-size vector, it inherits a fixed maximal size, 00801 * which means that evaluating it does not cause a dynamic memory allocation. 00802 * 00803 * \sa class Block, block(Index,Index) 00804 */ 00805 inline SegmentReturnType head(Index n) 00806 { 00807 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 00808 return SegmentReturnType(derived(), 0, n); 00809 } 00810 00811 /** This is the const version of head(Index).*/ 00812 inline ConstSegmentReturnType head(Index n) const 00813 { 00814 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 00815 return ConstSegmentReturnType(derived(), 0, n); 00816 } 00817 00818 /** \returns a dynamic-size expression of the last coefficients of *this. 00819 * 00820 * \only_for_vectors 00821 * 00822 * \param n the number of coefficients in the segment 00823 * 00824 * Example: \include MatrixBase_end_int.cpp 00825 * Output: \verbinclude MatrixBase_end_int.out 00826 * 00827 * \note Even though the returned expression has dynamic size, in the case 00828 * when it is applied to a fixed-size vector, it inherits a fixed maximal size, 00829 * which means that evaluating it does not cause a dynamic memory allocation. 00830 * 00831 * \sa class Block, block(Index,Index) 00832 */ 00833 inline SegmentReturnType tail(Index n) 00834 { 00835 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 00836 return SegmentReturnType(derived(), this->size() - n, n); 00837 } 00838 00839 /** This is the const version of tail(Index).*/ 00840 inline ConstSegmentReturnType tail(Index n) const 00841 { 00842 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 00843 return ConstSegmentReturnType(derived(), this->size() - n, n); 00844 } 00845 00846 /** \returns a fixed-size expression of a segment (i.e. a vector block) in \c *this 00847 * 00848 * \only_for_vectors 00849 * 00850 * \tparam N the number of coefficients in the segment as specified at compile-time 00851 * \param start the index of the first element in the segment 00852 * \param n the number of coefficients in the segment as specified at compile-time 00853 * 00854 * The compile-time and run-time information should not contradict. In other words, 00855 * \a n should equal \a N unless \a N is \a Dynamic. 00856 * 00857 * Example: \include MatrixBase_template_int_segment.cpp 00858 * Output: \verbinclude MatrixBase_template_int_segment.out 00859 * 00860 * \sa class Block 00861 */ 00862 template<int N> 00863 inline typename FixedSegmentReturnType<N>::Type segment(Index start, Index n = N) 00864 { 00865 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 00866 return typename FixedSegmentReturnType<N>::Type(derived(), start, n); 00867 } 00868 00869 /** This is the const version of segment<int>(Index).*/ 00870 template<int N> 00871 inline typename ConstFixedSegmentReturnType<N>::Type segment(Index start, Index n = N) const 00872 { 00873 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 00874 return typename ConstFixedSegmentReturnType<N>::Type(derived(), start, n); 00875 } 00876 00877 /** \returns a fixed-size expression of the first coefficients of *this. 00878 * 00879 * \only_for_vectors 00880 * 00881 * \tparam N the number of coefficients in the segment as specified at compile-time 00882 * \param n the number of coefficients in the segment as specified at run-time 00883 * 00884 * The compile-time and run-time information should not contradict. In other words, 00885 * \a n should equal \a N unless \a N is \a Dynamic. 00886 * 00887 * Example: \include MatrixBase_template_int_start.cpp 00888 * Output: \verbinclude MatrixBase_template_int_start.out 00889 * 00890 * \sa class Block 00891 */ 00892 template<int N> 00893 inline typename FixedSegmentReturnType<N>::Type head(Index n = N) 00894 { 00895 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 00896 return typename FixedSegmentReturnType<N>::Type(derived(), 0, n); 00897 } 00898 00899 /** This is the const version of head<int>().*/ 00900 template<int N> 00901 inline typename ConstFixedSegmentReturnType<N>::Type head(Index n = N) const 00902 { 00903 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 00904 return typename ConstFixedSegmentReturnType<N>::Type(derived(), 0, n); 00905 } 00906 00907 /** \returns a fixed-size expression of the last coefficients of *this. 00908 * 00909 * \only_for_vectors 00910 * 00911 * \tparam N the number of coefficients in the segment as specified at compile-time 00912 * \param n the number of coefficients in the segment as specified at run-time 00913 * 00914 * The compile-time and run-time information should not contradict. In other words, 00915 * \a n should equal \a N unless \a N is \a Dynamic. 00916 * 00917 * Example: \include MatrixBase_template_int_end.cpp 00918 * Output: \verbinclude MatrixBase_template_int_end.out 00919 * 00920 * \sa class Block 00921 */ 00922 template<int N> 00923 inline typename FixedSegmentReturnType<N>::Type tail(Index n = N) 00924 { 00925 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 00926 return typename FixedSegmentReturnType<N>::Type(derived(), size() - n); 00927 } 00928 00929 /** This is the const version of tail<int>.*/ 00930 template<int N> 00931 inline typename ConstFixedSegmentReturnType<N>::Type tail(Index n = N) const 00932 { 00933 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 00934 return typename ConstFixedSegmentReturnType<N>::Type(derived(), size() - n); 00935 }
Generated on Thu Nov 17 2022 22:01:27 by
1.7.2