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