BlockMethods.h (59020B)
1 // This file is part of Eigen, a lightweight C++ template library 2 // for linear algebra. 3 // 4 // Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr> 5 // Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com> 6 // 7 // This Source Code Form is subject to the terms of the Mozilla 8 // Public License v. 2.0. If a copy of the MPL was not distributed 9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 11 #ifndef EIGEN_PARSED_BY_DOXYGEN 12 13 /// \internal expression type of a column */ 14 typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ColXpr; 15 typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ConstColXpr; 16 /// \internal expression type of a row */ 17 typedef Block<Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowXpr; 18 typedef const Block<const Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowXpr; 19 /// \internal expression type of a block of whole columns */ 20 typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ColsBlockXpr; 21 typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ConstColsBlockXpr; 22 /// \internal expression type of a block of whole rows */ 23 typedef Block<Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowsBlockXpr; 24 typedef const Block<const Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowsBlockXpr; 25 /// \internal expression type of a block of whole columns */ 26 template<int N> struct NColsBlockXpr { typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; }; 27 template<int N> struct ConstNColsBlockXpr { typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; }; 28 /// \internal expression type of a block of whole rows */ 29 template<int N> struct NRowsBlockXpr { typedef Block<Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; }; 30 template<int N> struct ConstNRowsBlockXpr { typedef const Block<const Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; }; 31 /// \internal expression of a block */ 32 typedef Block<Derived> BlockXpr; 33 typedef const Block<const Derived> ConstBlockXpr; 34 /// \internal expression of a block of fixed sizes */ 35 template<int Rows, int Cols> struct FixedBlockXpr { typedef Block<Derived,Rows,Cols> Type; }; 36 template<int Rows, int Cols> struct ConstFixedBlockXpr { typedef Block<const Derived,Rows,Cols> Type; }; 37 38 typedef VectorBlock<Derived> SegmentReturnType; 39 typedef const VectorBlock<const Derived> ConstSegmentReturnType; 40 template<int Size> struct FixedSegmentReturnType { typedef VectorBlock<Derived, Size> Type; }; 41 template<int Size> struct ConstFixedSegmentReturnType { typedef const VectorBlock<const Derived, Size> Type; }; 42 43 /// \internal inner-vector 44 typedef Block<Derived,IsRowMajor?1:Dynamic,IsRowMajor?Dynamic:1,true> InnerVectorReturnType; 45 typedef Block<const Derived,IsRowMajor?1:Dynamic,IsRowMajor?Dynamic:1,true> ConstInnerVectorReturnType; 46 47 /// \internal set of inner-vectors 48 typedef Block<Derived,Dynamic,Dynamic,true> InnerVectorsReturnType; 49 typedef Block<const Derived,Dynamic,Dynamic,true> ConstInnerVectorsReturnType; 50 51 #endif // not EIGEN_PARSED_BY_DOXYGEN 52 53 /// \returns an expression of a block in \c *this with either dynamic or fixed sizes. 54 /// 55 /// \param startRow the first row in the block 56 /// \param startCol the first column in the block 57 /// \param blockRows number of rows in the block, specified at either run-time or compile-time 58 /// \param blockCols number of columns in the block, specified at either run-time or compile-time 59 /// \tparam NRowsType the type of the value handling the number of rows in the block, typically Index. 60 /// \tparam NColsType the type of the value handling the number of columns in the block, typically Index. 61 /// 62 /// Example using runtime (aka dynamic) sizes: \include MatrixBase_block_int_int_int_int.cpp 63 /// Output: \verbinclude MatrixBase_block_int_int_int_int.out 64 /// 65 /// \newin{3.4}: 66 /// 67 /// The number of rows \a blockRows and columns \a blockCols can also be specified at compile-time by passing Eigen::fix<N>, 68 /// or Eigen::fix<N>(n) as arguments. In the later case, \c n plays the role of a runtime fallback value in case \c N equals Eigen::Dynamic. 69 /// Here is an example with a fixed number of rows \c NRows and dynamic number of columns \c cols: 70 /// \code 71 /// mat.block(i,j,fix<NRows>,cols) 72 /// \endcode 73 /// 74 /// This function thus fully covers the features offered by the following overloads block<NRows,NCols>(Index, Index), 75 /// and block<NRows,NCols>(Index, Index, Index, Index) that are thus obsolete. Indeed, this generic version avoids 76 /// redundancy, it preserves the argument order, and prevents the need to rely on the template keyword in templated code. 77 /// 78 /// but with less redundancy and more consistency as it does not modify the argument order 79 /// and seamlessly enable hybrid fixed/dynamic sizes. 80 /// 81 /// \note Even in the case that the returned expression has dynamic size, in the case 82 /// when it is applied to a fixed-size matrix, it inherits a fixed maximal size, 83 /// which means that evaluating it does not cause a dynamic memory allocation. 84 /// 85 EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 86 /// 87 /// \sa class Block, fix, fix<N>(int) 88 /// 89 template<typename NRowsType, typename NColsType> 90 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 91 #ifndef EIGEN_PARSED_BY_DOXYGEN 92 typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 93 #else 94 typename FixedBlockXpr<...,...>::Type 95 #endif 96 block(Index startRow, Index startCol, NRowsType blockRows, NColsType blockCols) 97 { 98 return typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type( 99 derived(), startRow, startCol, internal::get_runtime_value(blockRows), internal::get_runtime_value(blockCols)); 100 } 101 102 /// This is the const version of block(Index,Index,NRowsType,NColsType) 103 template<typename NRowsType, typename NColsType> 104 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 105 #ifndef EIGEN_PARSED_BY_DOXYGEN 106 const typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 107 #else 108 const typename ConstFixedBlockXpr<...,...>::Type 109 #endif 110 block(Index startRow, Index startCol, NRowsType blockRows, NColsType blockCols) const 111 { 112 return typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type( 113 derived(), startRow, startCol, internal::get_runtime_value(blockRows), internal::get_runtime_value(blockCols)); 114 } 115 116 117 118 /// \returns a expression of a top-right corner of \c *this with either dynamic or fixed sizes. 119 /// 120 /// \param cRows the number of rows in the corner 121 /// \param cCols the number of columns in the corner 122 /// \tparam NRowsType the type of the value handling the number of rows in the block, typically Index. 123 /// \tparam NColsType the type of the value handling the number of columns in the block, typically Index. 124 /// 125 /// Example with dynamic sizes: \include MatrixBase_topRightCorner_int_int.cpp 126 /// Output: \verbinclude MatrixBase_topRightCorner_int_int.out 127 /// 128 /// The number of rows \a blockRows and columns \a blockCols can also be specified at compile-time by passing Eigen::fix<N>, 129 /// or Eigen::fix<N>(n) as arguments. See \link block(Index,Index,NRowsType,NColsType) block() \endlink for the details. 130 /// 131 EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 132 /// 133 /// \sa block(Index,Index,NRowsType,NColsType), class Block 134 /// 135 template<typename NRowsType, typename NColsType> 136 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 137 #ifndef EIGEN_PARSED_BY_DOXYGEN 138 typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 139 #else 140 typename FixedBlockXpr<...,...>::Type 141 #endif 142 topRightCorner(NRowsType cRows, NColsType cCols) 143 { 144 return typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 145 (derived(), 0, cols() - internal::get_runtime_value(cCols), internal::get_runtime_value(cRows), internal::get_runtime_value(cCols)); 146 } 147 148 /// This is the const version of topRightCorner(NRowsType, NColsType). 149 template<typename NRowsType, typename NColsType> 150 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 151 #ifndef EIGEN_PARSED_BY_DOXYGEN 152 const typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 153 #else 154 const typename ConstFixedBlockXpr<...,...>::Type 155 #endif 156 topRightCorner(NRowsType cRows, NColsType cCols) const 157 { 158 return typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 159 (derived(), 0, cols() - internal::get_runtime_value(cCols), internal::get_runtime_value(cRows), internal::get_runtime_value(cCols)); 160 } 161 162 /// \returns an expression of a fixed-size top-right corner of \c *this. 163 /// 164 /// \tparam CRows the number of rows in the corner 165 /// \tparam CCols the number of columns in the corner 166 /// 167 /// Example: \include MatrixBase_template_int_int_topRightCorner.cpp 168 /// Output: \verbinclude MatrixBase_template_int_int_topRightCorner.out 169 /// 170 EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 171 /// 172 /// \sa class Block, block<int,int>(Index,Index) 173 /// 174 template<int CRows, int CCols> 175 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 176 typename FixedBlockXpr<CRows,CCols>::Type topRightCorner() 177 { 178 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - CCols); 179 } 180 181 /// This is the const version of topRightCorner<int, int>(). 182 template<int CRows, int CCols> 183 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 184 const typename ConstFixedBlockXpr<CRows,CCols>::Type topRightCorner() const 185 { 186 return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - CCols); 187 } 188 189 /// \returns an expression of a top-right corner of \c *this. 190 /// 191 /// \tparam CRows number of rows in corner as specified at compile-time 192 /// \tparam CCols number of columns in corner as specified at compile-time 193 /// \param cRows number of rows in corner as specified at run-time 194 /// \param cCols number of columns in corner as specified at run-time 195 /// 196 /// This function is mainly useful for corners where the number of rows is specified at compile-time 197 /// and the number of columns is specified at run-time, or vice versa. The compile-time and run-time 198 /// information should not contradict. In other words, \a cRows should equal \a CRows unless 199 /// \a CRows is \a Dynamic, and the same for the number of columns. 200 /// 201 /// Example: \include MatrixBase_template_int_int_topRightCorner_int_int.cpp 202 /// Output: \verbinclude MatrixBase_template_int_int_topRightCorner_int_int.out 203 /// 204 EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 205 /// 206 /// \sa class Block 207 /// 208 template<int CRows, int CCols> 209 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 210 typename FixedBlockXpr<CRows,CCols>::Type topRightCorner(Index cRows, Index cCols) 211 { 212 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - cCols, cRows, cCols); 213 } 214 215 /// This is the const version of topRightCorner<int, int>(Index, Index). 216 template<int CRows, int CCols> 217 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 218 const typename ConstFixedBlockXpr<CRows,CCols>::Type topRightCorner(Index cRows, Index cCols) const 219 { 220 return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - cCols, cRows, cCols); 221 } 222 223 224 225 /// \returns an expression of a top-left corner of \c *this with either dynamic or fixed sizes. 226 /// 227 /// \param cRows the number of rows in the corner 228 /// \param cCols the number of columns in the corner 229 /// \tparam NRowsType the type of the value handling the number of rows in the block, typically Index. 230 /// \tparam NColsType the type of the value handling the number of columns in the block, typically Index. 231 /// 232 /// Example: \include MatrixBase_topLeftCorner_int_int.cpp 233 /// Output: \verbinclude MatrixBase_topLeftCorner_int_int.out 234 /// 235 /// The number of rows \a blockRows and columns \a blockCols can also be specified at compile-time by passing Eigen::fix<N>, 236 /// or Eigen::fix<N>(n) as arguments. See \link block(Index,Index,NRowsType,NColsType) block() \endlink for the details. 237 /// 238 EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 239 /// 240 /// \sa block(Index,Index,NRowsType,NColsType), class Block 241 /// 242 template<typename NRowsType, typename NColsType> 243 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 244 #ifndef EIGEN_PARSED_BY_DOXYGEN 245 typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 246 #else 247 typename FixedBlockXpr<...,...>::Type 248 #endif 249 topLeftCorner(NRowsType cRows, NColsType cCols) 250 { 251 return typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 252 (derived(), 0, 0, internal::get_runtime_value(cRows), internal::get_runtime_value(cCols)); 253 } 254 255 /// This is the const version of topLeftCorner(Index, Index). 256 template<typename NRowsType, typename NColsType> 257 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 258 #ifndef EIGEN_PARSED_BY_DOXYGEN 259 const typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 260 #else 261 const typename ConstFixedBlockXpr<...,...>::Type 262 #endif 263 topLeftCorner(NRowsType cRows, NColsType cCols) const 264 { 265 return typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 266 (derived(), 0, 0, internal::get_runtime_value(cRows), internal::get_runtime_value(cCols)); 267 } 268 269 /// \returns an expression of a fixed-size top-left corner of \c *this. 270 /// 271 /// The template parameters CRows and CCols are the number of rows and columns in the corner. 272 /// 273 /// Example: \include MatrixBase_template_int_int_topLeftCorner.cpp 274 /// Output: \verbinclude MatrixBase_template_int_int_topLeftCorner.out 275 /// 276 EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 277 /// 278 /// \sa block(Index,Index,NRowsType,NColsType), class Block 279 /// 280 template<int CRows, int CCols> 281 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 282 typename FixedBlockXpr<CRows,CCols>::Type topLeftCorner() 283 { 284 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0); 285 } 286 287 /// This is the const version of topLeftCorner<int, int>(). 288 template<int CRows, int CCols> 289 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 290 const typename ConstFixedBlockXpr<CRows,CCols>::Type topLeftCorner() const 291 { 292 return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0); 293 } 294 295 /// \returns an expression of a top-left corner of \c *this. 296 /// 297 /// \tparam CRows number of rows in corner as specified at compile-time 298 /// \tparam CCols number of columns in corner as specified at compile-time 299 /// \param cRows number of rows in corner as specified at run-time 300 /// \param cCols number of columns in corner as specified at run-time 301 /// 302 /// This function is mainly useful for corners where the number of rows is specified at compile-time 303 /// and the number of columns is specified at run-time, or vice versa. The compile-time and run-time 304 /// information should not contradict. In other words, \a cRows should equal \a CRows unless 305 /// \a CRows is \a Dynamic, and the same for the number of columns. 306 /// 307 /// Example: \include MatrixBase_template_int_int_topLeftCorner_int_int.cpp 308 /// Output: \verbinclude MatrixBase_template_int_int_topLeftCorner_int_int.out 309 /// 310 EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 311 /// 312 /// \sa class Block 313 /// 314 template<int CRows, int CCols> 315 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 316 typename FixedBlockXpr<CRows,CCols>::Type topLeftCorner(Index cRows, Index cCols) 317 { 318 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0, cRows, cCols); 319 } 320 321 /// This is the const version of topLeftCorner<int, int>(Index, Index). 322 template<int CRows, int CCols> 323 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 324 const typename ConstFixedBlockXpr<CRows,CCols>::Type topLeftCorner(Index cRows, Index cCols) const 325 { 326 return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0, cRows, cCols); 327 } 328 329 330 331 /// \returns an expression of a bottom-right corner of \c *this with either dynamic or fixed sizes. 332 /// 333 /// \param cRows the number of rows in the corner 334 /// \param cCols the number of columns in the corner 335 /// \tparam NRowsType the type of the value handling the number of rows in the block, typically Index. 336 /// \tparam NColsType the type of the value handling the number of columns in the block, typically Index. 337 /// 338 /// Example: \include MatrixBase_bottomRightCorner_int_int.cpp 339 /// Output: \verbinclude MatrixBase_bottomRightCorner_int_int.out 340 /// 341 /// The number of rows \a blockRows and columns \a blockCols can also be specified at compile-time by passing Eigen::fix<N>, 342 /// or Eigen::fix<N>(n) as arguments. See \link block(Index,Index,NRowsType,NColsType) block() \endlink for the details. 343 /// 344 EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 345 /// 346 /// \sa block(Index,Index,NRowsType,NColsType), class Block 347 /// 348 template<typename NRowsType, typename NColsType> 349 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 350 #ifndef EIGEN_PARSED_BY_DOXYGEN 351 typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 352 #else 353 typename FixedBlockXpr<...,...>::Type 354 #endif 355 bottomRightCorner(NRowsType cRows, NColsType cCols) 356 { 357 return typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 358 (derived(), rows() - internal::get_runtime_value(cRows), cols() - internal::get_runtime_value(cCols), 359 internal::get_runtime_value(cRows), internal::get_runtime_value(cCols)); 360 } 361 362 /// This is the const version of bottomRightCorner(NRowsType, NColsType). 363 template<typename NRowsType, typename NColsType> 364 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 365 #ifndef EIGEN_PARSED_BY_DOXYGEN 366 const typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 367 #else 368 const typename ConstFixedBlockXpr<...,...>::Type 369 #endif 370 bottomRightCorner(NRowsType cRows, NColsType cCols) const 371 { 372 return typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 373 (derived(), rows() - internal::get_runtime_value(cRows), cols() - internal::get_runtime_value(cCols), 374 internal::get_runtime_value(cRows), internal::get_runtime_value(cCols)); 375 } 376 377 /// \returns an expression of a fixed-size bottom-right corner of \c *this. 378 /// 379 /// The template parameters CRows and CCols are the number of rows and columns in the corner. 380 /// 381 /// Example: \include MatrixBase_template_int_int_bottomRightCorner.cpp 382 /// Output: \verbinclude MatrixBase_template_int_int_bottomRightCorner.out 383 /// 384 EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 385 /// 386 /// \sa block(Index,Index,NRowsType,NColsType), class Block 387 /// 388 template<int CRows, int CCols> 389 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 390 typename FixedBlockXpr<CRows,CCols>::Type bottomRightCorner() 391 { 392 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, cols() - CCols); 393 } 394 395 /// This is the const version of bottomRightCorner<int, int>(). 396 template<int CRows, int CCols> 397 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 398 const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomRightCorner() const 399 { 400 return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, cols() - CCols); 401 } 402 403 /// \returns an expression of a bottom-right corner of \c *this. 404 /// 405 /// \tparam CRows number of rows in corner as specified at compile-time 406 /// \tparam CCols number of columns in corner as specified at compile-time 407 /// \param cRows number of rows in corner as specified at run-time 408 /// \param cCols number of columns in corner as specified at run-time 409 /// 410 /// This function is mainly useful for corners where the number of rows is specified at compile-time 411 /// and the number of columns is specified at run-time, or vice versa. The compile-time and run-time 412 /// information should not contradict. In other words, \a cRows should equal \a CRows unless 413 /// \a CRows is \a Dynamic, and the same for the number of columns. 414 /// 415 /// Example: \include MatrixBase_template_int_int_bottomRightCorner_int_int.cpp 416 /// Output: \verbinclude MatrixBase_template_int_int_bottomRightCorner_int_int.out 417 /// 418 EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 419 /// 420 /// \sa class Block 421 /// 422 template<int CRows, int CCols> 423 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 424 typename FixedBlockXpr<CRows,CCols>::Type bottomRightCorner(Index cRows, Index cCols) 425 { 426 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols); 427 } 428 429 /// This is the const version of bottomRightCorner<int, int>(Index, Index). 430 template<int CRows, int CCols> 431 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 432 const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomRightCorner(Index cRows, Index cCols) const 433 { 434 return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols); 435 } 436 437 438 439 /// \returns an expression of a bottom-left corner of \c *this with either dynamic or fixed sizes. 440 /// 441 /// \param cRows the number of rows in the corner 442 /// \param cCols the number of columns in the corner 443 /// \tparam NRowsType the type of the value handling the number of rows in the block, typically Index. 444 /// \tparam NColsType the type of the value handling the number of columns in the block, typically Index. 445 /// 446 /// Example: \include MatrixBase_bottomLeftCorner_int_int.cpp 447 /// Output: \verbinclude MatrixBase_bottomLeftCorner_int_int.out 448 /// 449 /// The number of rows \a blockRows and columns \a blockCols can also be specified at compile-time by passing Eigen::fix<N>, 450 /// or Eigen::fix<N>(n) as arguments. See \link block(Index,Index,NRowsType,NColsType) block() \endlink for the details. 451 /// 452 EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 453 /// 454 /// \sa block(Index,Index,NRowsType,NColsType), class Block 455 /// 456 template<typename NRowsType, typename NColsType> 457 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 458 #ifndef EIGEN_PARSED_BY_DOXYGEN 459 typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 460 #else 461 typename FixedBlockXpr<...,...>::Type 462 #endif 463 bottomLeftCorner(NRowsType cRows, NColsType cCols) 464 { 465 return typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 466 (derived(), rows() - internal::get_runtime_value(cRows), 0, 467 internal::get_runtime_value(cRows), internal::get_runtime_value(cCols)); 468 } 469 470 /// This is the const version of bottomLeftCorner(NRowsType, NColsType). 471 template<typename NRowsType, typename NColsType> 472 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 473 #ifndef EIGEN_PARSED_BY_DOXYGEN 474 typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 475 #else 476 typename ConstFixedBlockXpr<...,...>::Type 477 #endif 478 bottomLeftCorner(NRowsType cRows, NColsType cCols) const 479 { 480 return typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type 481 (derived(), rows() - internal::get_runtime_value(cRows), 0, 482 internal::get_runtime_value(cRows), internal::get_runtime_value(cCols)); 483 } 484 485 /// \returns an expression of a fixed-size bottom-left corner of \c *this. 486 /// 487 /// The template parameters CRows and CCols are the number of rows and columns in the corner. 488 /// 489 /// Example: \include MatrixBase_template_int_int_bottomLeftCorner.cpp 490 /// Output: \verbinclude MatrixBase_template_int_int_bottomLeftCorner.out 491 /// 492 EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 493 /// 494 /// \sa block(Index,Index,NRowsType,NColsType), class Block 495 /// 496 template<int CRows, int CCols> 497 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 498 typename FixedBlockXpr<CRows,CCols>::Type bottomLeftCorner() 499 { 500 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, 0); 501 } 502 503 /// This is the const version of bottomLeftCorner<int, int>(). 504 template<int CRows, int CCols> 505 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 506 const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomLeftCorner() const 507 { 508 return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, 0); 509 } 510 511 /// \returns an expression of a bottom-left corner of \c *this. 512 /// 513 /// \tparam CRows number of rows in corner as specified at compile-time 514 /// \tparam CCols number of columns in corner as specified at compile-time 515 /// \param cRows number of rows in corner as specified at run-time 516 /// \param cCols number of columns in corner as specified at run-time 517 /// 518 /// This function is mainly useful for corners where the number of rows is specified at compile-time 519 /// and the number of columns is specified at run-time, or vice versa. The compile-time and run-time 520 /// information should not contradict. In other words, \a cRows should equal \a CRows unless 521 /// \a CRows is \a Dynamic, and the same for the number of columns. 522 /// 523 /// Example: \include MatrixBase_template_int_int_bottomLeftCorner_int_int.cpp 524 /// Output: \verbinclude MatrixBase_template_int_int_bottomLeftCorner_int_int.out 525 /// 526 EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 527 /// 528 /// \sa class Block 529 /// 530 template<int CRows, int CCols> 531 EIGEN_STRONG_INLINE 532 typename FixedBlockXpr<CRows,CCols>::Type bottomLeftCorner(Index cRows, Index cCols) 533 { 534 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, 0, cRows, cCols); 535 } 536 537 /// This is the const version of bottomLeftCorner<int, int>(Index, Index). 538 template<int CRows, int CCols> 539 EIGEN_STRONG_INLINE 540 const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomLeftCorner(Index cRows, Index cCols) const 541 { 542 return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, 0, cRows, cCols); 543 } 544 545 546 547 /// \returns a block consisting of the top rows of \c *this. 548 /// 549 /// \param n the number of rows in the block 550 /// \tparam NRowsType the type of the value handling the number of rows in the block, typically Index. 551 /// 552 /// Example: \include MatrixBase_topRows_int.cpp 553 /// Output: \verbinclude MatrixBase_topRows_int.out 554 /// 555 /// The number of rows \a n can also be specified at compile-time by passing Eigen::fix<N>, 556 /// or Eigen::fix<N>(n) as arguments. 557 /// See \link block(Index,Index,NRowsType,NColsType) block() \endlink for the details. 558 /// 559 EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major) 560 /// 561 /// \sa block(Index,Index,NRowsType,NColsType), class Block 562 /// 563 template<typename NRowsType> 564 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 565 #ifndef EIGEN_PARSED_BY_DOXYGEN 566 typename NRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type 567 #else 568 typename NRowsBlockXpr<...>::Type 569 #endif 570 topRows(NRowsType n) 571 { 572 return typename NRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type 573 (derived(), 0, 0, internal::get_runtime_value(n), cols()); 574 } 575 576 /// This is the const version of topRows(NRowsType). 577 template<typename NRowsType> 578 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 579 #ifndef EIGEN_PARSED_BY_DOXYGEN 580 const typename ConstNRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type 581 #else 582 const typename ConstNRowsBlockXpr<...>::Type 583 #endif 584 topRows(NRowsType n) const 585 { 586 return typename ConstNRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type 587 (derived(), 0, 0, internal::get_runtime_value(n), cols()); 588 } 589 590 /// \returns a block consisting of the top rows of \c *this. 591 /// 592 /// \tparam N the number of rows in the block as specified at compile-time 593 /// \param n the number of rows in the block as specified at run-time 594 /// 595 /// The compile-time and run-time information should not contradict. In other words, 596 /// \a n should equal \a N unless \a N is \a Dynamic. 597 /// 598 /// Example: \include MatrixBase_template_int_topRows.cpp 599 /// Output: \verbinclude MatrixBase_template_int_topRows.out 600 /// 601 EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major) 602 /// 603 /// \sa block(Index,Index,NRowsType,NColsType), class Block 604 /// 605 template<int N> 606 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 607 typename NRowsBlockXpr<N>::Type topRows(Index n = N) 608 { 609 return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols()); 610 } 611 612 /// This is the const version of topRows<int>(). 613 template<int N> 614 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 615 typename ConstNRowsBlockXpr<N>::Type topRows(Index n = N) const 616 { 617 return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols()); 618 } 619 620 621 622 /// \returns a block consisting of the bottom rows of \c *this. 623 /// 624 /// \param n the number of rows in the block 625 /// \tparam NRowsType the type of the value handling the number of rows in the block, typically Index. 626 /// 627 /// Example: \include MatrixBase_bottomRows_int.cpp 628 /// Output: \verbinclude MatrixBase_bottomRows_int.out 629 /// 630 /// The number of rows \a n can also be specified at compile-time by passing Eigen::fix<N>, 631 /// or Eigen::fix<N>(n) as arguments. 632 /// See \link block(Index,Index,NRowsType,NColsType) block() \endlink for the details. 633 /// 634 EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major) 635 /// 636 /// \sa block(Index,Index,NRowsType,NColsType), class Block 637 /// 638 template<typename NRowsType> 639 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 640 #ifndef EIGEN_PARSED_BY_DOXYGEN 641 typename NRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type 642 #else 643 typename NRowsBlockXpr<...>::Type 644 #endif 645 bottomRows(NRowsType n) 646 { 647 return typename NRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type 648 (derived(), rows() - internal::get_runtime_value(n), 0, internal::get_runtime_value(n), cols()); 649 } 650 651 /// This is the const version of bottomRows(NRowsType). 652 template<typename NRowsType> 653 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 654 #ifndef EIGEN_PARSED_BY_DOXYGEN 655 const typename ConstNRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type 656 #else 657 const typename ConstNRowsBlockXpr<...>::Type 658 #endif 659 bottomRows(NRowsType n) const 660 { 661 return typename ConstNRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type 662 (derived(), rows() - internal::get_runtime_value(n), 0, internal::get_runtime_value(n), cols()); 663 } 664 665 /// \returns a block consisting of the bottom rows of \c *this. 666 /// 667 /// \tparam N the number of rows in the block as specified at compile-time 668 /// \param n the number of rows in the block as specified at run-time 669 /// 670 /// The compile-time and run-time information should not contradict. In other words, 671 /// \a n should equal \a N unless \a N is \a Dynamic. 672 /// 673 /// Example: \include MatrixBase_template_int_bottomRows.cpp 674 /// Output: \verbinclude MatrixBase_template_int_bottomRows.out 675 /// 676 EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major) 677 /// 678 /// \sa block(Index,Index,NRowsType,NColsType), class Block 679 /// 680 template<int N> 681 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 682 typename NRowsBlockXpr<N>::Type bottomRows(Index n = N) 683 { 684 return typename NRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols()); 685 } 686 687 /// This is the const version of bottomRows<int>(). 688 template<int N> 689 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 690 typename ConstNRowsBlockXpr<N>::Type bottomRows(Index n = N) const 691 { 692 return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols()); 693 } 694 695 696 697 /// \returns a block consisting of a range of rows of \c *this. 698 /// 699 /// \param startRow the index of the first row in the block 700 /// \param n the number of rows in the block 701 /// \tparam NRowsType the type of the value handling the number of rows in the block, typically Index. 702 /// 703 /// Example: \include DenseBase_middleRows_int.cpp 704 /// Output: \verbinclude DenseBase_middleRows_int.out 705 /// 706 /// The number of rows \a n can also be specified at compile-time by passing Eigen::fix<N>, 707 /// or Eigen::fix<N>(n) as arguments. 708 /// See \link block(Index,Index,NRowsType,NColsType) block() \endlink for the details. 709 /// 710 EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major) 711 /// 712 /// \sa block(Index,Index,NRowsType,NColsType), class Block 713 /// 714 template<typename NRowsType> 715 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 716 #ifndef EIGEN_PARSED_BY_DOXYGEN 717 typename NRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type 718 #else 719 typename NRowsBlockXpr<...>::Type 720 #endif 721 middleRows(Index startRow, NRowsType n) 722 { 723 return typename NRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type 724 (derived(), startRow, 0, internal::get_runtime_value(n), cols()); 725 } 726 727 /// This is the const version of middleRows(Index,NRowsType). 728 template<typename NRowsType> 729 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 730 #ifndef EIGEN_PARSED_BY_DOXYGEN 731 const typename ConstNRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type 732 #else 733 const typename ConstNRowsBlockXpr<...>::Type 734 #endif 735 middleRows(Index startRow, NRowsType n) const 736 { 737 return typename ConstNRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type 738 (derived(), startRow, 0, internal::get_runtime_value(n), cols()); 739 } 740 741 /// \returns a block consisting of a range of rows of \c *this. 742 /// 743 /// \tparam N the number of rows in the block as specified at compile-time 744 /// \param startRow the index of the first row in the block 745 /// \param n the number of rows in the block as specified at run-time 746 /// 747 /// The compile-time and run-time information should not contradict. In other words, 748 /// \a n should equal \a N unless \a N is \a Dynamic. 749 /// 750 /// Example: \include DenseBase_template_int_middleRows.cpp 751 /// Output: \verbinclude DenseBase_template_int_middleRows.out 752 /// 753 EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major) 754 /// 755 /// \sa block(Index,Index,NRowsType,NColsType), class Block 756 /// 757 template<int N> 758 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 759 typename NRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N) 760 { 761 return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols()); 762 } 763 764 /// This is the const version of middleRows<int>(). 765 template<int N> 766 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 767 typename ConstNRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N) const 768 { 769 return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols()); 770 } 771 772 773 774 /// \returns a block consisting of the left columns of \c *this. 775 /// 776 /// \param n the number of columns in the block 777 /// \tparam NColsType the type of the value handling the number of columns in the block, typically Index. 778 /// 779 /// Example: \include MatrixBase_leftCols_int.cpp 780 /// Output: \verbinclude MatrixBase_leftCols_int.out 781 /// 782 /// The number of columns \a n can also be specified at compile-time by passing Eigen::fix<N>, 783 /// or Eigen::fix<N>(n) as arguments. 784 /// See \link block(Index,Index,NRowsType,NColsType) block() \endlink for the details. 785 /// 786 EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major) 787 /// 788 /// \sa block(Index,Index,NRowsType,NColsType), class Block 789 /// 790 template<typename NColsType> 791 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 792 #ifndef EIGEN_PARSED_BY_DOXYGEN 793 typename NColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type 794 #else 795 typename NColsBlockXpr<...>::Type 796 #endif 797 leftCols(NColsType n) 798 { 799 return typename NColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type 800 (derived(), 0, 0, rows(), internal::get_runtime_value(n)); 801 } 802 803 /// This is the const version of leftCols(NColsType). 804 template<typename NColsType> 805 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 806 #ifndef EIGEN_PARSED_BY_DOXYGEN 807 const typename ConstNColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type 808 #else 809 const typename ConstNColsBlockXpr<...>::Type 810 #endif 811 leftCols(NColsType n) const 812 { 813 return typename ConstNColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type 814 (derived(), 0, 0, rows(), internal::get_runtime_value(n)); 815 } 816 817 /// \returns a block consisting of the left columns of \c *this. 818 /// 819 /// \tparam N the number of columns in the block as specified at compile-time 820 /// \param n the number of columns in the block as specified at run-time 821 /// 822 /// The compile-time and run-time information should not contradict. In other words, 823 /// \a n should equal \a N unless \a N is \a Dynamic. 824 /// 825 /// Example: \include MatrixBase_template_int_leftCols.cpp 826 /// Output: \verbinclude MatrixBase_template_int_leftCols.out 827 /// 828 EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major) 829 /// 830 /// \sa block(Index,Index,NRowsType,NColsType), class Block 831 /// 832 template<int N> 833 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 834 typename NColsBlockXpr<N>::Type leftCols(Index n = N) 835 { 836 return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n); 837 } 838 839 /// This is the const version of leftCols<int>(). 840 template<int N> 841 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 842 typename ConstNColsBlockXpr<N>::Type leftCols(Index n = N) const 843 { 844 return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n); 845 } 846 847 848 849 /// \returns a block consisting of the right columns of \c *this. 850 /// 851 /// \param n the number of columns in the block 852 /// \tparam NColsType the type of the value handling the number of columns in the block, typically Index. 853 /// 854 /// Example: \include MatrixBase_rightCols_int.cpp 855 /// Output: \verbinclude MatrixBase_rightCols_int.out 856 /// 857 /// The number of columns \a n can also be specified at compile-time by passing Eigen::fix<N>, 858 /// or Eigen::fix<N>(n) as arguments. 859 /// See \link block(Index,Index,NRowsType,NColsType) block() \endlink for the details. 860 /// 861 EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major) 862 /// 863 /// \sa block(Index,Index,NRowsType,NColsType), class Block 864 /// 865 template<typename NColsType> 866 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 867 #ifndef EIGEN_PARSED_BY_DOXYGEN 868 typename NColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type 869 #else 870 typename NColsBlockXpr<...>::Type 871 #endif 872 rightCols(NColsType n) 873 { 874 return typename NColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type 875 (derived(), 0, cols() - internal::get_runtime_value(n), rows(), internal::get_runtime_value(n)); 876 } 877 878 /// This is the const version of rightCols(NColsType). 879 template<typename NColsType> 880 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 881 #ifndef EIGEN_PARSED_BY_DOXYGEN 882 const typename ConstNColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type 883 #else 884 const typename ConstNColsBlockXpr<...>::Type 885 #endif 886 rightCols(NColsType n) const 887 { 888 return typename ConstNColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type 889 (derived(), 0, cols() - internal::get_runtime_value(n), rows(), internal::get_runtime_value(n)); 890 } 891 892 /// \returns a block consisting of the right columns of \c *this. 893 /// 894 /// \tparam N the number of columns in the block as specified at compile-time 895 /// \param n the number of columns in the block as specified at run-time 896 /// 897 /// The compile-time and run-time information should not contradict. In other words, 898 /// \a n should equal \a N unless \a N is \a Dynamic. 899 /// 900 /// Example: \include MatrixBase_template_int_rightCols.cpp 901 /// Output: \verbinclude MatrixBase_template_int_rightCols.out 902 /// 903 EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major) 904 /// 905 /// \sa block(Index,Index,NRowsType,NColsType), class Block 906 /// 907 template<int N> 908 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 909 typename NColsBlockXpr<N>::Type rightCols(Index n = N) 910 { 911 return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n); 912 } 913 914 /// This is the const version of rightCols<int>(). 915 template<int N> 916 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 917 typename ConstNColsBlockXpr<N>::Type rightCols(Index n = N) const 918 { 919 return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n); 920 } 921 922 923 924 /// \returns a block consisting of a range of columns of \c *this. 925 /// 926 /// \param startCol the index of the first column in the block 927 /// \param numCols the number of columns in the block 928 /// \tparam NColsType the type of the value handling the number of columns in the block, typically Index. 929 /// 930 /// Example: \include DenseBase_middleCols_int.cpp 931 /// Output: \verbinclude DenseBase_middleCols_int.out 932 /// 933 /// The number of columns \a n can also be specified at compile-time by passing Eigen::fix<N>, 934 /// or Eigen::fix<N>(n) as arguments. 935 /// See \link block(Index,Index,NRowsType,NColsType) block() \endlink for the details. 936 /// 937 EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major) 938 /// 939 /// \sa block(Index,Index,NRowsType,NColsType), class Block 940 /// 941 template<typename NColsType> 942 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 943 #ifndef EIGEN_PARSED_BY_DOXYGEN 944 typename NColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type 945 #else 946 typename NColsBlockXpr<...>::Type 947 #endif 948 middleCols(Index startCol, NColsType numCols) 949 { 950 return typename NColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type 951 (derived(), 0, startCol, rows(), internal::get_runtime_value(numCols)); 952 } 953 954 /// This is the const version of middleCols(Index,NColsType). 955 template<typename NColsType> 956 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 957 #ifndef EIGEN_PARSED_BY_DOXYGEN 958 const typename ConstNColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type 959 #else 960 const typename ConstNColsBlockXpr<...>::Type 961 #endif 962 middleCols(Index startCol, NColsType numCols) const 963 { 964 return typename ConstNColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type 965 (derived(), 0, startCol, rows(), internal::get_runtime_value(numCols)); 966 } 967 968 /// \returns a block consisting of a range of columns of \c *this. 969 /// 970 /// \tparam N the number of columns in the block as specified at compile-time 971 /// \param startCol the index of the first column in the block 972 /// \param n the number of columns in the block as specified at run-time 973 /// 974 /// The compile-time and run-time information should not contradict. In other words, 975 /// \a n should equal \a N unless \a N is \a Dynamic. 976 /// 977 /// Example: \include DenseBase_template_int_middleCols.cpp 978 /// Output: \verbinclude DenseBase_template_int_middleCols.out 979 /// 980 EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major) 981 /// 982 /// \sa block(Index,Index,NRowsType,NColsType), class Block 983 /// 984 template<int N> 985 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 986 typename NColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N) 987 { 988 return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n); 989 } 990 991 /// This is the const version of middleCols<int>(). 992 template<int N> 993 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 994 typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N) const 995 { 996 return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n); 997 } 998 999 1000 1001 /// \returns a fixed-size expression of a block of \c *this. 1002 /// 1003 /// The template parameters \a NRows and \a NCols are the number of 1004 /// rows and columns in the block. 1005 /// 1006 /// \param startRow the first row in the block 1007 /// \param startCol the first column in the block 1008 /// 1009 /// Example: \include MatrixBase_block_int_int.cpp 1010 /// Output: \verbinclude MatrixBase_block_int_int.out 1011 /// 1012 /// \note The usage of of this overload is discouraged from %Eigen 3.4, better used the generic 1013 /// block(Index,Index,NRowsType,NColsType), here is the one-to-one equivalence: 1014 /// \code 1015 /// mat.template block<NRows,NCols>(i,j) <--> mat.block(i,j,fix<NRows>,fix<NCols>) 1016 /// \endcode 1017 /// 1018 /// \note since block is a templated member, the keyword template has to be used 1019 /// if the matrix type is also a template parameter: \code m.template block<3,3>(1,1); \endcode 1020 /// 1021 EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 1022 /// 1023 /// \sa block(Index,Index,NRowsType,NColsType), class Block 1024 /// 1025 template<int NRows, int NCols> 1026 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1027 typename FixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol) 1028 { 1029 return typename FixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol); 1030 } 1031 1032 /// This is the const version of block<>(Index, Index). */ 1033 template<int NRows, int NCols> 1034 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1035 const typename ConstFixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol) const 1036 { 1037 return typename ConstFixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol); 1038 } 1039 1040 /// \returns an expression of a block of \c *this. 1041 /// 1042 /// \tparam NRows number of rows in block as specified at compile-time 1043 /// \tparam NCols number of columns in block as specified at compile-time 1044 /// \param startRow the first row in the block 1045 /// \param startCol the first column in the block 1046 /// \param blockRows number of rows in block as specified at run-time 1047 /// \param blockCols number of columns in block as specified at run-time 1048 /// 1049 /// This function is mainly useful for blocks where the number of rows is specified at compile-time 1050 /// and the number of columns is specified at run-time, or vice versa. The compile-time and run-time 1051 /// information should not contradict. In other words, \a blockRows should equal \a NRows unless 1052 /// \a NRows is \a Dynamic, and the same for the number of columns. 1053 /// 1054 /// Example: \include MatrixBase_template_int_int_block_int_int_int_int.cpp 1055 /// Output: \verbinclude MatrixBase_template_int_int_block_int_int_int_int.out 1056 /// 1057 /// \note The usage of of this overload is discouraged from %Eigen 3.4, better used the generic 1058 /// block(Index,Index,NRowsType,NColsType), here is the one-to-one complete equivalence: 1059 /// \code 1060 /// mat.template block<NRows,NCols>(i,j,rows,cols) <--> mat.block(i,j,fix<NRows>(rows),fix<NCols>(cols)) 1061 /// \endcode 1062 /// If we known that, e.g., NRows==Dynamic and NCols!=Dynamic, then the equivalence becomes: 1063 /// \code 1064 /// mat.template block<Dynamic,NCols>(i,j,rows,NCols) <--> mat.block(i,j,rows,fix<NCols>) 1065 /// \endcode 1066 /// 1067 EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 1068 /// 1069 /// \sa block(Index,Index,NRowsType,NColsType), class Block 1070 /// 1071 template<int NRows, int NCols> 1072 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1073 typename FixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol, 1074 Index blockRows, Index blockCols) 1075 { 1076 return typename FixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol, blockRows, blockCols); 1077 } 1078 1079 /// This is the const version of block<>(Index, Index, Index, Index). 1080 template<int NRows, int NCols> 1081 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1082 const typename ConstFixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol, 1083 Index blockRows, Index blockCols) const 1084 { 1085 return typename ConstFixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol, blockRows, blockCols); 1086 } 1087 1088 /// \returns an expression of the \a i-th column of \c *this. Note that the numbering starts at 0. 1089 /// 1090 /// Example: \include MatrixBase_col.cpp 1091 /// Output: \verbinclude MatrixBase_col.out 1092 /// 1093 EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major) 1094 /** 1095 * \sa row(), class Block */ 1096 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1097 ColXpr col(Index i) 1098 { 1099 return ColXpr(derived(), i); 1100 } 1101 1102 /// This is the const version of col(). 1103 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1104 ConstColXpr col(Index i) const 1105 { 1106 return ConstColXpr(derived(), i); 1107 } 1108 1109 /// \returns an expression of the \a i-th row of \c *this. Note that the numbering starts at 0. 1110 /// 1111 /// Example: \include MatrixBase_row.cpp 1112 /// Output: \verbinclude MatrixBase_row.out 1113 /// 1114 EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major) 1115 /** 1116 * \sa col(), class Block */ 1117 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1118 RowXpr row(Index i) 1119 { 1120 return RowXpr(derived(), i); 1121 } 1122 1123 /// This is the const version of row(). */ 1124 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1125 ConstRowXpr row(Index i) const 1126 { 1127 return ConstRowXpr(derived(), i); 1128 } 1129 1130 /// \returns an expression of a segment (i.e. a vector block) in \c *this with either dynamic or fixed sizes. 1131 /// 1132 /// \only_for_vectors 1133 /// 1134 /// \param start the first coefficient in the segment 1135 /// \param n the number of coefficients in the segment 1136 /// \tparam NType the type of the value handling the number of coefficients in the segment, typically Index. 1137 /// 1138 /// Example: \include MatrixBase_segment_int_int.cpp 1139 /// Output: \verbinclude MatrixBase_segment_int_int.out 1140 /// 1141 /// The number of coefficients \a n can also be specified at compile-time by passing Eigen::fix<N>, 1142 /// or Eigen::fix<N>(n) as arguments. 1143 /// See \link block(Index,Index,NRowsType,NColsType) block() \endlink for the details. 1144 /// 1145 /// \note Even in the case that the returned expression has dynamic size, in the case 1146 /// when it is applied to a fixed-size vector, it inherits a fixed maximal size, 1147 /// which means that evaluating it does not cause a dynamic memory allocation. 1148 /// 1149 /// \sa block(Index,Index,NRowsType,NColsType), fix<N>, fix<N>(int), class Block 1150 /// 1151 template<typename NType> 1152 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1153 #ifndef EIGEN_PARSED_BY_DOXYGEN 1154 typename FixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type 1155 #else 1156 typename FixedSegmentReturnType<...>::Type 1157 #endif 1158 segment(Index start, NType n) 1159 { 1160 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 1161 return typename FixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type 1162 (derived(), start, internal::get_runtime_value(n)); 1163 } 1164 1165 1166 /// This is the const version of segment(Index,NType). 1167 template<typename NType> 1168 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1169 #ifndef EIGEN_PARSED_BY_DOXYGEN 1170 const typename ConstFixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type 1171 #else 1172 const typename ConstFixedSegmentReturnType<...>::Type 1173 #endif 1174 segment(Index start, NType n) const 1175 { 1176 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 1177 return typename ConstFixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type 1178 (derived(), start, internal::get_runtime_value(n)); 1179 } 1180 1181 /// \returns an expression of the first coefficients of \c *this with either dynamic or fixed sizes. 1182 /// 1183 /// \only_for_vectors 1184 /// 1185 /// \param n the number of coefficients in the segment 1186 /// \tparam NType the type of the value handling the number of coefficients in the segment, typically Index. 1187 /// 1188 /// Example: \include MatrixBase_start_int.cpp 1189 /// Output: \verbinclude MatrixBase_start_int.out 1190 /// 1191 /// The number of coefficients \a n can also be specified at compile-time by passing Eigen::fix<N>, 1192 /// or Eigen::fix<N>(n) as arguments. 1193 /// See \link block(Index,Index,NRowsType,NColsType) block() \endlink for the details. 1194 /// 1195 /// \note Even in the case that the returned expression has dynamic size, in the case 1196 /// when it is applied to a fixed-size vector, it inherits a fixed maximal size, 1197 /// which means that evaluating it does not cause a dynamic memory allocation. 1198 /// 1199 /// \sa class Block, block(Index,Index) 1200 /// 1201 template<typename NType> 1202 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1203 #ifndef EIGEN_PARSED_BY_DOXYGEN 1204 typename FixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type 1205 #else 1206 typename FixedSegmentReturnType<...>::Type 1207 #endif 1208 head(NType n) 1209 { 1210 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 1211 return typename FixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type 1212 (derived(), 0, internal::get_runtime_value(n)); 1213 } 1214 1215 /// This is the const version of head(NType). 1216 template<typename NType> 1217 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1218 #ifndef EIGEN_PARSED_BY_DOXYGEN 1219 const typename ConstFixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type 1220 #else 1221 const typename ConstFixedSegmentReturnType<...>::Type 1222 #endif 1223 head(NType n) const 1224 { 1225 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 1226 return typename ConstFixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type 1227 (derived(), 0, internal::get_runtime_value(n)); 1228 } 1229 1230 /// \returns an expression of a last coefficients of \c *this with either dynamic or fixed sizes. 1231 /// 1232 /// \only_for_vectors 1233 /// 1234 /// \param n the number of coefficients in the segment 1235 /// \tparam NType the type of the value handling the number of coefficients in the segment, typically Index. 1236 /// 1237 /// Example: \include MatrixBase_end_int.cpp 1238 /// Output: \verbinclude MatrixBase_end_int.out 1239 /// 1240 /// The number of coefficients \a n can also be specified at compile-time by passing Eigen::fix<N>, 1241 /// or Eigen::fix<N>(n) as arguments. 1242 /// See \link block(Index,Index,NRowsType,NColsType) block() \endlink for the details. 1243 /// 1244 /// \note Even in the case that the returned expression has dynamic size, in the case 1245 /// when it is applied to a fixed-size vector, it inherits a fixed maximal size, 1246 /// which means that evaluating it does not cause a dynamic memory allocation. 1247 /// 1248 /// \sa class Block, block(Index,Index) 1249 /// 1250 template<typename NType> 1251 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1252 #ifndef EIGEN_PARSED_BY_DOXYGEN 1253 typename FixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type 1254 #else 1255 typename FixedSegmentReturnType<...>::Type 1256 #endif 1257 tail(NType n) 1258 { 1259 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 1260 return typename FixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type 1261 (derived(), this->size() - internal::get_runtime_value(n), internal::get_runtime_value(n)); 1262 } 1263 1264 /// This is the const version of tail(Index). 1265 template<typename NType> 1266 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1267 #ifndef EIGEN_PARSED_BY_DOXYGEN 1268 const typename ConstFixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type 1269 #else 1270 const typename ConstFixedSegmentReturnType<...>::Type 1271 #endif 1272 tail(NType n) const 1273 { 1274 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 1275 return typename ConstFixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type 1276 (derived(), this->size() - internal::get_runtime_value(n), internal::get_runtime_value(n)); 1277 } 1278 1279 /// \returns a fixed-size expression of a segment (i.e. a vector block) in \c *this 1280 /// 1281 /// \only_for_vectors 1282 /// 1283 /// \tparam N the number of coefficients in the segment as specified at compile-time 1284 /// \param start the index of the first element in the segment 1285 /// \param n the number of coefficients in the segment as specified at compile-time 1286 /// 1287 /// The compile-time and run-time information should not contradict. In other words, 1288 /// \a n should equal \a N unless \a N is \a Dynamic. 1289 /// 1290 /// Example: \include MatrixBase_template_int_segment.cpp 1291 /// Output: \verbinclude MatrixBase_template_int_segment.out 1292 /// 1293 /// \sa segment(Index,NType), class Block 1294 /// 1295 template<int N> 1296 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1297 typename FixedSegmentReturnType<N>::Type segment(Index start, Index n = N) 1298 { 1299 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 1300 return typename FixedSegmentReturnType<N>::Type(derived(), start, n); 1301 } 1302 1303 /// This is the const version of segment<int>(Index). 1304 template<int N> 1305 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1306 typename ConstFixedSegmentReturnType<N>::Type segment(Index start, Index n = N) const 1307 { 1308 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 1309 return typename ConstFixedSegmentReturnType<N>::Type(derived(), start, n); 1310 } 1311 1312 /// \returns a fixed-size expression of the first coefficients of \c *this. 1313 /// 1314 /// \only_for_vectors 1315 /// 1316 /// \tparam N the number of coefficients in the segment as specified at compile-time 1317 /// \param n the number of coefficients in the segment as specified at run-time 1318 /// 1319 /// The compile-time and run-time information should not contradict. In other words, 1320 /// \a n should equal \a N unless \a N is \a Dynamic. 1321 /// 1322 /// Example: \include MatrixBase_template_int_start.cpp 1323 /// Output: \verbinclude MatrixBase_template_int_start.out 1324 /// 1325 /// \sa head(NType), class Block 1326 /// 1327 template<int N> 1328 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1329 typename FixedSegmentReturnType<N>::Type head(Index n = N) 1330 { 1331 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 1332 return typename FixedSegmentReturnType<N>::Type(derived(), 0, n); 1333 } 1334 1335 /// This is the const version of head<int>(). 1336 template<int N> 1337 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1338 typename ConstFixedSegmentReturnType<N>::Type head(Index n = N) const 1339 { 1340 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 1341 return typename ConstFixedSegmentReturnType<N>::Type(derived(), 0, n); 1342 } 1343 1344 /// \returns a fixed-size expression of the last coefficients of \c *this. 1345 /// 1346 /// \only_for_vectors 1347 /// 1348 /// \tparam N the number of coefficients in the segment as specified at compile-time 1349 /// \param n the number of coefficients in the segment as specified at run-time 1350 /// 1351 /// The compile-time and run-time information should not contradict. In other words, 1352 /// \a n should equal \a N unless \a N is \a Dynamic. 1353 /// 1354 /// Example: \include MatrixBase_template_int_end.cpp 1355 /// Output: \verbinclude MatrixBase_template_int_end.out 1356 /// 1357 /// \sa tail(NType), class Block 1358 /// 1359 template<int N> 1360 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1361 typename FixedSegmentReturnType<N>::Type tail(Index n = N) 1362 { 1363 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 1364 return typename FixedSegmentReturnType<N>::Type(derived(), size() - n); 1365 } 1366 1367 /// This is the const version of tail<int>. 1368 template<int N> 1369 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1370 typename ConstFixedSegmentReturnType<N>::Type tail(Index n = N) const 1371 { 1372 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 1373 return typename ConstFixedSegmentReturnType<N>::Type(derived(), size() - n); 1374 } 1375 1376 /// \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this 1377 /// is col-major (resp. row-major). 1378 /// 1379 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1380 InnerVectorReturnType innerVector(Index outer) 1381 { return InnerVectorReturnType(derived(), outer); } 1382 1383 /// \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this 1384 /// is col-major (resp. row-major). Read-only. 1385 /// 1386 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1387 const ConstInnerVectorReturnType innerVector(Index outer) const 1388 { return ConstInnerVectorReturnType(derived(), outer); } 1389 1390 /// \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this 1391 /// is col-major (resp. row-major). 1392 /// 1393 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1394 InnerVectorsReturnType 1395 innerVectors(Index outerStart, Index outerSize) 1396 { 1397 return Block<Derived,Dynamic,Dynamic,true>(derived(), 1398 IsRowMajor ? outerStart : 0, IsRowMajor ? 0 : outerStart, 1399 IsRowMajor ? outerSize : rows(), IsRowMajor ? cols() : outerSize); 1400 1401 } 1402 1403 /// \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this 1404 /// is col-major (resp. row-major). Read-only. 1405 /// 1406 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1407 const ConstInnerVectorsReturnType 1408 innerVectors(Index outerStart, Index outerSize) const 1409 { 1410 return Block<const Derived,Dynamic,Dynamic,true>(derived(), 1411 IsRowMajor ? outerStart : 0, IsRowMajor ? 0 : outerStart, 1412 IsRowMajor ? outerSize : rows(), IsRowMajor ? cols() : outerSize); 1413 1414 } 1415 1416 /** \returns the i-th subvector (column or vector) according to the \c Direction 1417 * \sa subVectors() 1418 */ 1419 template<DirectionType Direction> 1420 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1421 typename internal::conditional<Direction==Vertical,ColXpr,RowXpr>::type 1422 subVector(Index i) 1423 { 1424 return typename internal::conditional<Direction==Vertical,ColXpr,RowXpr>::type(derived(),i); 1425 } 1426 1427 /** This is the const version of subVector(Index) */ 1428 template<DirectionType Direction> 1429 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 1430 typename internal::conditional<Direction==Vertical,ConstColXpr,ConstRowXpr>::type 1431 subVector(Index i) const 1432 { 1433 return typename internal::conditional<Direction==Vertical,ConstColXpr,ConstRowXpr>::type(derived(),i); 1434 } 1435 1436 /** \returns the number of subvectors (rows or columns) in the direction \c Direction 1437 * \sa subVector(Index) 1438 */ 1439 template<DirectionType Direction> 1440 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR 1441 Index subVectors() const 1442 { return (Direction==Vertical)?cols():rows(); }