WPILibC++ 2023.4.3-108-ge5452e3
BlockMethods.h
Go to the documentation of this file.
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 */
14typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ColXpr;
15typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ConstColXpr;
16/// \internal expression type of a row */
17typedef Block<Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowXpr;
18typedef const Block<const Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowXpr;
19/// \internal expression type of a block of whole columns */
20typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ColsBlockXpr;
21typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ConstColsBlockXpr;
22/// \internal expression type of a block of whole rows */
23typedef Block<Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowsBlockXpr;
24typedef const Block<const Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowsBlockXpr;
25/// \internal expression type of a block of whole columns */
26template<int N> struct NColsBlockXpr { typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };
27template<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 */
29template<int N> struct NRowsBlockXpr { typedef Block<Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
30template<int N> struct ConstNRowsBlockXpr { typedef const Block<const Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
31/// \internal expression of a block */
32typedef Block<Derived> BlockXpr;
33typedef const Block<const Derived> ConstBlockXpr;
34/// \internal expression of a block of fixed sizes */
35template<int Rows, int Cols> struct FixedBlockXpr { typedef Block<Derived,Rows,Cols> Type; };
36template<int Rows, int Cols> struct ConstFixedBlockXpr { typedef Block<const Derived,Rows,Cols> Type; };
37
38typedef VectorBlock<Derived> SegmentReturnType;
39typedef const VectorBlock<const Derived> ConstSegmentReturnType;
40template<int Size> struct FixedSegmentReturnType { typedef VectorBlock<Derived, Size> Type; };
41template<int Size> struct ConstFixedSegmentReturnType { typedef const VectorBlock<const Derived, Size> Type; };
42
43/// \internal inner-vector
44typedef Block<Derived,IsRowMajor?1:Dynamic,IsRowMajor?Dynamic:1,true> InnerVectorReturnType;
45typedef Block<const Derived,IsRowMajor?1:Dynamic,IsRowMajor?Dynamic:1,true> ConstInnerVectorReturnType;
46
47/// \internal set of inner-vectors
48typedef Block<Derived,Dynamic,Dynamic,true> InnerVectorsReturnType;
49typedef 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///
86///
87/// \sa class Block, fix, fix<N>(int)
88///
89template<typename NRowsType, typename NColsType>
91#ifndef EIGEN_PARSED_BY_DOXYGEN
92typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
93#else
94typename FixedBlockXpr<...,...>::Type
95#endif
96block(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)
103template<typename NRowsType, typename NColsType>
105#ifndef EIGEN_PARSED_BY_DOXYGEN
106const typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
107#else
108const typename ConstFixedBlockXpr<...,...>::Type
109#endif
110block(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///
132///
133/// \sa block(Index,Index,NRowsType,NColsType), class Block
134///
135template<typename NRowsType, typename NColsType>
137#ifndef EIGEN_PARSED_BY_DOXYGEN
138typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
139#else
140typename FixedBlockXpr<...,...>::Type
141#endif
142topRightCorner(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).
149template<typename NRowsType, typename NColsType>
151#ifndef EIGEN_PARSED_BY_DOXYGEN
152const typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
153#else
154const typename ConstFixedBlockXpr<...,...>::Type
155#endif
156topRightCorner(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///
171///
172/// \sa class Block, block<int,int>(Index,Index)
173///
174template<int CRows, int CCols>
177{
178 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - CCols);
179}
180
181/// This is the const version of topRightCorner<int, int>().
182template<int CRows, int CCols>
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///
205///
206/// \sa class Block
207///
208template<int CRows, int 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).
216template<int CRows, int CCols>
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///
239///
240/// \sa block(Index,Index,NRowsType,NColsType), class Block
241///
242template<typename NRowsType, typename NColsType>
244#ifndef EIGEN_PARSED_BY_DOXYGEN
245typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
246#else
247typename FixedBlockXpr<...,...>::Type
248#endif
249topLeftCorner(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).
256template<typename NRowsType, typename NColsType>
258#ifndef EIGEN_PARSED_BY_DOXYGEN
259const typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
260#else
261const typename ConstFixedBlockXpr<...,...>::Type
262#endif
263topLeftCorner(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///
277///
278/// \sa block(Index,Index,NRowsType,NColsType), class Block
279///
280template<int CRows, int CCols>
283{
284 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0);
285}
286
287/// This is the const version of topLeftCorner<int, int>().
288template<int CRows, int CCols>
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///
311///
312/// \sa class Block
313///
314template<int CRows, int 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).
322template<int CRows, int CCols>
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///
345///
346/// \sa block(Index,Index,NRowsType,NColsType), class Block
347///
348template<typename NRowsType, typename NColsType>
350#ifndef EIGEN_PARSED_BY_DOXYGEN
351typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
352#else
353typename FixedBlockXpr<...,...>::Type
354#endif
355bottomRightCorner(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),
360}
361
362/// This is the const version of bottomRightCorner(NRowsType, NColsType).
363template<typename NRowsType, typename NColsType>
365#ifndef EIGEN_PARSED_BY_DOXYGEN
366const typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
367#else
368const typename ConstFixedBlockXpr<...,...>::Type
369#endif
370bottomRightCorner(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),
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///
385///
386/// \sa block(Index,Index,NRowsType,NColsType), class Block
387///
388template<int CRows, int CCols>
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>().
396template<int CRows, int CCols>
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///
419///
420/// \sa class Block
421///
422template<int CRows, int 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).
430template<int CRows, int CCols>
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///
453///
454/// \sa block(Index,Index,NRowsType,NColsType), class Block
455///
456template<typename NRowsType, typename NColsType>
458#ifndef EIGEN_PARSED_BY_DOXYGEN
459typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
460#else
461typename FixedBlockXpr<...,...>::Type
462#endif
463bottomLeftCorner(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,
468}
469
470/// This is the const version of bottomLeftCorner(NRowsType, NColsType).
471template<typename NRowsType, typename NColsType>
473#ifndef EIGEN_PARSED_BY_DOXYGEN
474typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
475#else
476typename ConstFixedBlockXpr<...,...>::Type
477#endif
478bottomLeftCorner(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,
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///
493///
494/// \sa block(Index,Index,NRowsType,NColsType), class Block
495///
496template<int CRows, int CCols>
499{
500 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, 0);
501}
502
503/// This is the const version of bottomLeftCorner<int, int>().
504template<int CRows, int CCols>
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///
527///
528/// \sa class Block
529///
530template<int CRows, int 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).
538template<int CRows, int CCols>
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///
560///
561/// \sa block(Index,Index,NRowsType,NColsType), class Block
562///
563template<typename NRowsType>
565#ifndef EIGEN_PARSED_BY_DOXYGEN
567#else
568typename NRowsBlockXpr<...>::Type
569#endif
570topRows(NRowsType n)
571{
573 (derived(), 0, 0, internal::get_runtime_value(n), cols());
574}
575
576/// This is the const version of topRows(NRowsType).
577template<typename NRowsType>
579#ifndef EIGEN_PARSED_BY_DOXYGEN
581#else
582const typename ConstNRowsBlockXpr<...>::Type
583#endif
584topRows(NRowsType n) const
585{
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///
602///
603/// \sa block(Index,Index,NRowsType,NColsType), class Block
604///
605template<int N>
608{
609 return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
610}
611
612/// This is the const version of topRows<int>().
613template<int N>
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///
635///
636/// \sa block(Index,Index,NRowsType,NColsType), class Block
637///
638template<typename NRowsType>
640#ifndef EIGEN_PARSED_BY_DOXYGEN
642#else
643typename NRowsBlockXpr<...>::Type
644#endif
645bottomRows(NRowsType n)
646{
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).
652template<typename NRowsType>
654#ifndef EIGEN_PARSED_BY_DOXYGEN
656#else
657const typename ConstNRowsBlockXpr<...>::Type
658#endif
659bottomRows(NRowsType n) const
660{
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///
677///
678/// \sa block(Index,Index,NRowsType,NColsType), class Block
679///
680template<int 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>().
688template<int N>
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///
711///
712/// \sa block(Index,Index,NRowsType,NColsType), class Block
713///
714template<typename NRowsType>
716#ifndef EIGEN_PARSED_BY_DOXYGEN
718#else
719typename NRowsBlockXpr<...>::Type
720#endif
721middleRows(Index startRow, NRowsType n)
722{
724 (derived(), startRow, 0, internal::get_runtime_value(n), cols());
725}
726
727/// This is the const version of middleRows(Index,NRowsType).
728template<typename NRowsType>
730#ifndef EIGEN_PARSED_BY_DOXYGEN
732#else
733const typename ConstNRowsBlockXpr<...>::Type
734#endif
735middleRows(Index startRow, NRowsType n) const
736{
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///
754///
755/// \sa block(Index,Index,NRowsType,NColsType), class Block
756///
757template<int N>
760{
761 return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
762}
763
764/// This is the const version of middleRows<int>().
765template<int N>
767typename 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///
787///
788/// \sa block(Index,Index,NRowsType,NColsType), class Block
789///
790template<typename NColsType>
792#ifndef EIGEN_PARSED_BY_DOXYGEN
794#else
795typename NColsBlockXpr<...>::Type
796#endif
797leftCols(NColsType n)
798{
800 (derived(), 0, 0, rows(), internal::get_runtime_value(n));
801}
802
803/// This is the const version of leftCols(NColsType).
804template<typename NColsType>
806#ifndef EIGEN_PARSED_BY_DOXYGEN
808#else
809const typename ConstNColsBlockXpr<...>::Type
810#endif
811leftCols(NColsType n) const
812{
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///
829///
830/// \sa block(Index,Index,NRowsType,NColsType), class Block
831///
832template<int N>
835{
836 return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
837}
838
839/// This is the const version of leftCols<int>().
840template<int N>
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///
862///
863/// \sa block(Index,Index,NRowsType,NColsType), class Block
864///
865template<typename NColsType>
867#ifndef EIGEN_PARSED_BY_DOXYGEN
869#else
870typename NColsBlockXpr<...>::Type
871#endif
872rightCols(NColsType n)
873{
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).
879template<typename NColsType>
881#ifndef EIGEN_PARSED_BY_DOXYGEN
883#else
884const typename ConstNColsBlockXpr<...>::Type
885#endif
886rightCols(NColsType n) const
887{
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///
904///
905/// \sa block(Index,Index,NRowsType,NColsType), class Block
906///
907template<int 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>().
915template<int N>
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///
938///
939/// \sa block(Index,Index,NRowsType,NColsType), class Block
940///
941template<typename NColsType>
943#ifndef EIGEN_PARSED_BY_DOXYGEN
945#else
946typename NColsBlockXpr<...>::Type
947#endif
948middleCols(Index startCol, NColsType numCols)
949{
951 (derived(), 0, startCol, rows(), internal::get_runtime_value(numCols));
952}
953
954/// This is the const version of middleCols(Index,NColsType).
955template<typename NColsType>
957#ifndef EIGEN_PARSED_BY_DOXYGEN
959#else
960const typename ConstNColsBlockXpr<...>::Type
961#endif
962middleCols(Index startCol, NColsType numCols) const
963{
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///
981///
982/// \sa block(Index,Index,NRowsType,NColsType), class Block
983///
984template<int N>
987{
988 return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
989}
990
991/// This is the const version of middleCols<int>().
992template<int N>
994typename 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///
1022///
1023/// \sa block(Index,Index,NRowsType,NColsType), class Block
1024///
1025template<int NRows, int NCols>
1028{
1029 return typename FixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol);
1030}
1031
1032/// This is the const version of block<>(Index, Index). */
1033template<int NRows, int NCols>
1035const 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///
1068///
1069/// \sa block(Index,Index,NRowsType,NColsType), class Block
1070///
1071template<int NRows, int NCols>
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).
1080template<int NRows, int NCols>
1082const 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///
1094/**
1095 * \sa row(), class Block */
1098{
1099 return ColXpr(derived(), i);
1100}
1101
1102/// This is the const version of col().
1104ConstColXpr 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///
1115/**
1116 * \sa col(), class Block */
1119{
1120 return RowXpr(derived(), i);
1121}
1122
1123/// This is the const version of row(). */
1125ConstRowXpr 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///
1151template<typename NType>
1153#ifndef EIGEN_PARSED_BY_DOXYGEN
1155#else
1156typename FixedSegmentReturnType<...>::Type
1157#endif
1158segment(Index start, NType n)
1159{
1162 (derived(), start, internal::get_runtime_value(n));
1163}
1164
1165
1166/// This is the const version of segment(Index,NType).
1167template<typename NType>
1169#ifndef EIGEN_PARSED_BY_DOXYGEN
1171#else
1172const typename ConstFixedSegmentReturnType<...>::Type
1173#endif
1174segment(Index start, NType n) const
1175{
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///
1201template<typename NType>
1203#ifndef EIGEN_PARSED_BY_DOXYGEN
1205#else
1206typename FixedSegmentReturnType<...>::Type
1207#endif
1208head(NType n)
1209{
1212 (derived(), 0, internal::get_runtime_value(n));
1213}
1214
1215/// This is the const version of head(NType).
1216template<typename NType>
1218#ifndef EIGEN_PARSED_BY_DOXYGEN
1220#else
1221const typename ConstFixedSegmentReturnType<...>::Type
1222#endif
1223head(NType n) const
1224{
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///
1250template<typename NType>
1252#ifndef EIGEN_PARSED_BY_DOXYGEN
1254#else
1255typename FixedSegmentReturnType<...>::Type
1256#endif
1257tail(NType n)
1258{
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).
1265template<typename NType>
1267#ifndef EIGEN_PARSED_BY_DOXYGEN
1269#else
1270const typename ConstFixedSegmentReturnType<...>::Type
1271#endif
1272tail(NType n) const
1273{
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///
1295template<int N>
1298{
1300 return typename FixedSegmentReturnType<N>::Type(derived(), start, n);
1301}
1302
1303/// This is the const version of segment<int>(Index).
1304template<int N>
1307{
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///
1327template<int N>
1330{
1332 return typename FixedSegmentReturnType<N>::Type(derived(), 0, n);
1333}
1334
1335/// This is the const version of head<int>().
1336template<int N>
1339{
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///
1359template<int N>
1362{
1364 return typename FixedSegmentReturnType<N>::Type(derived(), size() - n);
1365}
1366
1367/// This is the const version of tail<int>.
1368template<int N>
1371{
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///
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///
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///
1395innerVectors(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///
1408innerVectors(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 */
1419template<DirectionType Direction>
1423{
1425}
1426
1427/** This is the const version of subVector(Index) */
1428template<DirectionType Direction>
1432{
1434}
1435
1436/** \returns the number of subvectors (rows or columns) in the direction \c Direction
1437 * \sa subVector(Index)
1438 */
1439template<DirectionType Direction>
1442{ return (Direction==Vertical)?cols():rows(); }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ColXpr col(Index i)
This is the const version of col().
Definition: BlockMethods.h:1097
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE FixedSegmentReturnType< internal::get_fixed_value< NType >::value >::Type tail(NType n)
Definition: BlockMethods.h:1257
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::conditional< Direction==Vertical, ColXpr, RowXpr >::type subVector(Index i)
Definition: BlockMethods.h:1422
const Block< const Derived, 1, internal::traits< Derived >::ColsAtCompileTime, IsRowMajor > ConstRowXpr
Definition: BlockMethods.h:18
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index subVectors() const
Definition: BlockMethods.h:1441
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NRowsBlockXpr< internal::get_fixed_value< NRowsType >::value >::Type topRows(NRowsType n)
Definition: BlockMethods.h:570
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE FixedSegmentReturnType< internal::get_fixed_value< NType >::value >::Type segment(Index start, NType n)
Definition: BlockMethods.h:1158
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NRowsBlockXpr< internal::get_fixed_value< NRowsType >::value >::Type middleRows(Index startRow, NRowsType n)
Definition: BlockMethods.h:721
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE FixedBlockXpr< internal::get_fixed_value< NRowsType >::value, internal::get_fixed_value< NColsType >::value >::Type bottomRightCorner(NRowsType cRows, NColsType cCols)
Definition: BlockMethods.h:355
Block< Derived, Dynamic, internal::traits< Derived >::ColsAtCompileTime, IsRowMajor > RowsBlockXpr
Definition: BlockMethods.h:23
Block< Derived, internal::traits< Derived >::RowsAtCompileTime, Dynamic, !IsRowMajor > ColsBlockXpr
Definition: BlockMethods.h:20
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NColsBlockXpr< internal::get_fixed_value< NColsType >::value >::Type rightCols(NColsType n)
Definition: BlockMethods.h:872
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NRowsBlockXpr< internal::get_fixed_value< NRowsType >::value >::Type bottomRows(NRowsType n)
Definition: BlockMethods.h:645
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NColsBlockXpr< internal::get_fixed_value< NColsType >::value >::Type middleCols(Index startCol, NColsType numCols)
Definition: BlockMethods.h:948
Block< Derived, IsRowMajor?1:Dynamic, IsRowMajor?Dynamic:1, true > InnerVectorReturnType
Definition: BlockMethods.h:44
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE FixedBlockXpr< internal::get_fixed_value< NRowsType >::value, internal::get_fixed_value< NColsType >::value >::Type topRightCorner(NRowsType cRows, NColsType cCols)
Definition: BlockMethods.h:142
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE FixedBlockXpr< internal::get_fixed_value< NRowsType >::value, internal::get_fixed_value< NColsType >::value >::Type topLeftCorner(NRowsType cRows, NColsType cCols)
Definition: BlockMethods.h:249
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NColsBlockXpr< internal::get_fixed_value< NColsType >::value >::Type leftCols(NColsType n)
Definition: BlockMethods.h:797
Block< Derived > BlockXpr
Definition: BlockMethods.h:32
const Block< const Derived, internal::traits< Derived >::RowsAtCompileTime, Dynamic, !IsRowMajor > ConstColsBlockXpr
Definition: BlockMethods.h:21
Block< const Derived, IsRowMajor?1:Dynamic, IsRowMajor?Dynamic:1, true > ConstInnerVectorReturnType
Definition: BlockMethods.h:45
Block< Derived, 1, internal::traits< Derived >::ColsAtCompileTime, IsRowMajor > RowXpr
Definition: BlockMethods.h:17
Block< const Derived, Dynamic, Dynamic, true > ConstInnerVectorsReturnType
Definition: BlockMethods.h:49
VectorBlock< Derived > SegmentReturnType
Definition: BlockMethods.h:38
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE FixedBlockXpr< internal::get_fixed_value< NRowsType >::value, internal::get_fixed_value< NColsType >::value >::Type bottomLeftCorner(NRowsType cRows, NColsType cCols)
Definition: BlockMethods.h:463
Block< Derived, Dynamic, Dynamic, true > InnerVectorsReturnType
Definition: BlockMethods.h:48
const Block< const Derived, Dynamic, internal::traits< Derived >::ColsAtCompileTime, IsRowMajor > ConstRowsBlockXpr
Definition: BlockMethods.h:24
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE RowXpr row(Index i)
This is the const version of row(). *‍/.
Definition: BlockMethods.h:1118
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE InnerVectorsReturnType innerVectors(Index outerStart, Index outerSize)
Definition: BlockMethods.h:1395
const Block< const Derived, internal::traits< Derived >::RowsAtCompileTime, 1, !IsRowMajor > ConstColXpr
Definition: BlockMethods.h:15
const VectorBlock< const Derived > ConstSegmentReturnType
Definition: BlockMethods.h:39
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE InnerVectorReturnType innerVector(Index outer)
Definition: BlockMethods.h:1380
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE FixedBlockXpr< internal::get_fixed_value< NRowsType >::value, internal::get_fixed_value< NColsType >::value >::Type block(Index startRow, Index startCol, NRowsType blockRows, NColsType blockCols)
Definition: BlockMethods.h:96
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE FixedSegmentReturnType< internal::get_fixed_value< NType >::value >::Type head(NType n)
Definition: BlockMethods.h:1208
Block< Derived, internal::traits< Derived >::RowsAtCompileTime, 1, !IsRowMajor > ColXpr
Definition: BlockMethods.h:14
const Block< const Derived > ConstBlockXpr
Definition: BlockMethods.h:33
#define EIGEN_CONSTEXPR
Definition: Macros.h:797
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:986
#define EIGEN_STRONG_INLINE
Definition: Macros.h:927
#define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(COND)
Definition: SparseMatrixBase.h:160
#define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
Definition: SparseMatrixBase.h:159
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition: StaticAssert.h:142
type
Definition: core.h:575
@ Vertical
For Reverse, all columns are reversed; for PartialReduxExpr and VectorwiseOp, act on columns.
Definition: Constants.h:264
Type
Definition: Constants.h:471
EIGEN_CONSTEXPR Index size(const T &x)
Definition: Meta.h:479
EIGEN_DEVICE_FUNC Index get_runtime_value(const T &x)
Definition: IntegralConstant.h:156
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time,...
Definition: Constants.h:22
Definition: BlockMethods.h:36
Block< const Derived, Rows, Cols > Type
Definition: BlockMethods.h:36
Definition: BlockMethods.h:41
const VectorBlock< const Derived, Size > Type
Definition: BlockMethods.h:41
Definition: BlockMethods.h:27
const Block< const Derived, internal::traits< Derived >::RowsAtCompileTime, N, !IsRowMajor > Type
Definition: BlockMethods.h:27
Definition: BlockMethods.h:30
const Block< const Derived, N, internal::traits< Derived >::ColsAtCompileTime, IsRowMajor > Type
Definition: BlockMethods.h:30
Definition: BlockMethods.h:35
Block< Derived, Rows, Cols > Type
Definition: BlockMethods.h:35
Definition: BlockMethods.h:40
VectorBlock< Derived, Size > Type
Definition: BlockMethods.h:40
Definition: BlockMethods.h:26
Block< Derived, internal::traits< Derived >::RowsAtCompileTime, N, !IsRowMajor > Type
Definition: BlockMethods.h:26
Definition: BlockMethods.h:29
Block< Derived, N, internal::traits< Derived >::ColsAtCompileTime, IsRowMajor > Type
Definition: BlockMethods.h:29