1c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This file is part of Eigen, a lightweight C++ template library
2c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// for linear algebra.
3c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath//
4c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
5c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
6c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath//
7c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This Source Code Form is subject to the terms of the Mozilla
8c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Public License v. 2.0. If a copy of the MPL was not distributed
9c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
11c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
12c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#ifndef EIGEN_PARSED_BY_DOXYGEN
13c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
14c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \internal expression type of a column */
15c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtypedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ColXpr;
16c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtypedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ConstColXpr;
17c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \internal expression type of a row */
18c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtypedef Block<Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowXpr;
19c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtypedef const Block<const Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowXpr;
20c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \internal expression type of a block of whole columns */
21c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtypedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ColsBlockXpr;
22c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtypedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ConstColsBlockXpr;
23c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \internal expression type of a block of whole rows */
24c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtypedef Block<Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowsBlockXpr;
25c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtypedef const Block<const Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowsBlockXpr;
26c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \internal expression type of a block of whole columns */
27c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int N> struct NColsBlockXpr { typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };
28c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int N> struct ConstNColsBlockXpr { typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };
29c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \internal expression type of a block of whole rows */
30c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int N> struct NRowsBlockXpr { typedef Block<Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
31c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int N> struct ConstNRowsBlockXpr { typedef const Block<const Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
32c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
337faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztypedef VectorBlock<Derived> SegmentReturnType;
347faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztypedef const VectorBlock<const Derived> ConstSegmentReturnType;
357faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int Size> struct FixedSegmentReturnType { typedef VectorBlock<Derived, Size> Type; };
367faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int Size> struct ConstFixedSegmentReturnType { typedef const VectorBlock<const Derived, Size> Type; };
37c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
38c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#endif // not EIGEN_PARSED_BY_DOXYGEN
39c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
40c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a dynamic-size expression of a block in *this.
41c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
42c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param startRow the first row in the block
43c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param startCol the first column in the block
44c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param blockRows the number of rows in the block
45c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param blockCols the number of columns in the block
46c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
47c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_block_int_int_int_int.cpp
48c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_block_int_int_int_int.out
49c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
50c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \note Even though the returned expression has dynamic size, in the case
51c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * when it is applied to a fixed-size matrix, it inherits a fixed maximal size,
52c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * which means that evaluating it does not cause a dynamic memory allocation.
53c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
54c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index)
55c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
56c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline Block<Derived> block(Index startRow, Index startCol, Index blockRows, Index blockCols)
57c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
58c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<Derived>(derived(), startRow, startCol, blockRows, blockCols);
59c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
60c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
61c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of block(Index,Index,Index,Index). */
62c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline const Block<const Derived> block(Index startRow, Index startCol, Index blockRows, Index blockCols) const
63c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
64c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<const Derived>(derived(), startRow, startCol, blockRows, blockCols);
65c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
66c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
67c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
68c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
69c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
70c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a dynamic-size expression of a top-right corner of *this.
71c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
72c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param cRows the number of rows in the corner
73c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param cCols the number of columns in the corner
74c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
75c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_topRightCorner_int_int.cpp
76c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_topRightCorner_int_int.out
77c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
78c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
79c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
80c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline Block<Derived> topRightCorner(Index cRows, Index cCols)
81c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
82c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<Derived>(derived(), 0, cols() - cCols, cRows, cCols);
83c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
84c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
85c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of topRightCorner(Index, Index).*/
86c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline const Block<const Derived> topRightCorner(Index cRows, Index cCols) const
87c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
88c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<const Derived>(derived(), 0, cols() - cCols, cRows, cCols);
89c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
90c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
91c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a fixed-size top-right corner of *this.
92c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
937faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam CRows the number of rows in the corner
947faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam CCols the number of columns in the corner
95c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
96c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_template_int_int_topRightCorner.cpp
97c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_template_int_int_topRightCorner.out
98c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
997faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \sa class Block, block<int,int>(Index,Index)
100c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
101c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int CRows, int CCols>
102c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline Block<Derived, CRows, CCols> topRightCorner()
103c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
104c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols);
105c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
106c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
107c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of topRightCorner<int, int>().*/
108c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int CRows, int CCols>
109c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline const Block<const Derived, CRows, CCols> topRightCorner() const
110c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
111c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<const Derived, CRows, CCols>(derived(), 0, cols() - CCols);
112c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
113c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
1147faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** \returns an expression of a top-right corner of *this.
1157faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
1167faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam CRows number of rows in corner as specified at compile-time
1177faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam CCols number of columns in corner as specified at compile-time
1187faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param  cRows number of rows in corner as specified at run-time
1197faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param  cCols number of columns in corner as specified at run-time
1207faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
1217faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * This function is mainly useful for corners where the number of rows is specified at compile-time
1227faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time
1237faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * information should not contradict. In other words, \a cRows should equal \a CRows unless
1247faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \a CRows is \a Dynamic, and the same for the number of columns.
1257faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
1267faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Example: \include MatrixBase_template_int_int_topRightCorner_int_int.cpp
1277faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Output: \verbinclude MatrixBase_template_int_int_topRightCorner_int_int.out
1287faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
1297faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \sa class Block
1307faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  */
1317faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int CRows, int CCols>
1327faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline Block<Derived, CRows, CCols> topRightCorner(Index cRows, Index cCols)
1337faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
1347faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return Block<Derived, CRows, CCols>(derived(), 0, cols() - cCols, cRows, cCols);
1357faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
1367faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
1377faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** This is the const version of topRightCorner<int, int>(Index, Index).*/
1387faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int CRows, int CCols>
1397faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline const Block<const Derived, CRows, CCols> topRightCorner(Index cRows, Index cCols) const
1407faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
1417faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return Block<const Derived, CRows, CCols>(derived(), 0, cols() - cCols, cRows, cCols);
1427faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
143c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
144c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
145c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
146c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a dynamic-size expression of a top-left corner of *this.
147c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
148c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param cRows the number of rows in the corner
149c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param cCols the number of columns in the corner
150c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
151c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_topLeftCorner_int_int.cpp
152c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_topLeftCorner_int_int.out
153c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
154c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
155c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
156c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline Block<Derived> topLeftCorner(Index cRows, Index cCols)
157c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
158c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<Derived>(derived(), 0, 0, cRows, cCols);
159c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
160c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
161c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of topLeftCorner(Index, Index).*/
162c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline const Block<const Derived> topLeftCorner(Index cRows, Index cCols) const
163c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
164c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<const Derived>(derived(), 0, 0, cRows, cCols);
165c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
166c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
167c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a fixed-size top-left corner of *this.
168c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
169c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The template parameters CRows and CCols are the number of rows and columns in the corner.
170c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
171c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_template_int_int_topLeftCorner.cpp
172c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_template_int_int_topLeftCorner.out
173c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
174c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
175c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
176c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int CRows, int CCols>
177c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline Block<Derived, CRows, CCols> topLeftCorner()
178c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
179c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<Derived, CRows, CCols>(derived(), 0, 0);
180c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
181c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
182c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of topLeftCorner<int, int>().*/
183c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int CRows, int CCols>
184c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline const Block<const Derived, CRows, CCols> topLeftCorner() const
185c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
186c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<const Derived, CRows, CCols>(derived(), 0, 0);
187c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
188c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
1897faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** \returns an expression of a top-left corner of *this.
1907faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
1917faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam CRows number of rows in corner as specified at compile-time
1927faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam CCols number of columns in corner as specified at compile-time
1937faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param  cRows number of rows in corner as specified at run-time
1947faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param  cCols number of columns in corner as specified at run-time
1957faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
1967faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * This function is mainly useful for corners where the number of rows is specified at compile-time
1977faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time
1987faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * information should not contradict. In other words, \a cRows should equal \a CRows unless
1997faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \a CRows is \a Dynamic, and the same for the number of columns.
2007faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
2017faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Example: \include MatrixBase_template_int_int_topLeftCorner_int_int.cpp
2027faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Output: \verbinclude MatrixBase_template_int_int_topLeftCorner_int_int.out
2037faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
2047faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \sa class Block
2057faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  */
2067faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int CRows, int CCols>
2077faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline Block<Derived, CRows, CCols> topLeftCorner(Index cRows, Index cCols)
2087faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
2097faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return Block<Derived, CRows, CCols>(derived(), 0, 0, cRows, cCols);
2107faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
2117faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
2127faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** This is the const version of topLeftCorner<int, int>(Index, Index).*/
2137faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int CRows, int CCols>
2147faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline const Block<const Derived, CRows, CCols> topLeftCorner(Index cRows, Index cCols) const
2157faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
2167faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return Block<const Derived, CRows, CCols>(derived(), 0, 0, cRows, cCols);
2177faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
2187faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
219c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
220c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
221c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a dynamic-size expression of a bottom-right corner of *this.
222c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
223c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param cRows the number of rows in the corner
224c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param cCols the number of columns in the corner
225c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
226c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_bottomRightCorner_int_int.cpp
227c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_bottomRightCorner_int_int.out
228c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
229c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
230c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
231c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline Block<Derived> bottomRightCorner(Index cRows, Index cCols)
232c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
233c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
234c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
235c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
236c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of bottomRightCorner(Index, Index).*/
237c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline const Block<const Derived> bottomRightCorner(Index cRows, Index cCols) const
238c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
239c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<const Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
240c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
241c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
242c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a fixed-size bottom-right corner of *this.
243c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
244c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The template parameters CRows and CCols are the number of rows and columns in the corner.
245c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
246c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_template_int_int_bottomRightCorner.cpp
247c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_template_int_int_bottomRightCorner.out
248c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
249c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
250c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
251c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int CRows, int CCols>
252c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline Block<Derived, CRows, CCols> bottomRightCorner()
253c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
254c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
255c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
256c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
257c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of bottomRightCorner<int, int>().*/
258c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int CRows, int CCols>
259c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline const Block<const Derived, CRows, CCols> bottomRightCorner() const
260c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
261c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<const Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
262c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
263c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
2647faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** \returns an expression of a bottom-right corner of *this.
2657faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
2667faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam CRows number of rows in corner as specified at compile-time
2677faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam CCols number of columns in corner as specified at compile-time
2687faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param  cRows number of rows in corner as specified at run-time
2697faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param  cCols number of columns in corner as specified at run-time
2707faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
2717faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * This function is mainly useful for corners where the number of rows is specified at compile-time
2727faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time
2737faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * information should not contradict. In other words, \a cRows should equal \a CRows unless
2747faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \a CRows is \a Dynamic, and the same for the number of columns.
2757faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
2767faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Example: \include MatrixBase_template_int_int_bottomRightCorner_int_int.cpp
2777faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Output: \verbinclude MatrixBase_template_int_int_bottomRightCorner_int_int.out
2787faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
2797faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \sa class Block
2807faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  */
2817faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int CRows, int CCols>
2827faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline Block<Derived, CRows, CCols> bottomRightCorner(Index cRows, Index cCols)
2837faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
2847faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return Block<Derived, CRows, CCols>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
2857faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
2867faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
2877faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** This is the const version of bottomRightCorner<int, int>(Index, Index).*/
2887faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int CRows, int CCols>
2897faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline const Block<const Derived, CRows, CCols> bottomRightCorner(Index cRows, Index cCols) const
2907faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
2917faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return Block<const Derived, CRows, CCols>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
2927faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
2937faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
294c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
295c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
296c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a dynamic-size expression of a bottom-left corner of *this.
297c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
298c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param cRows the number of rows in the corner
299c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param cCols the number of columns in the corner
300c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
301c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_bottomLeftCorner_int_int.cpp
302c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_bottomLeftCorner_int_int.out
303c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
304c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
305c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
306c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline Block<Derived> bottomLeftCorner(Index cRows, Index cCols)
307c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
308c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<Derived>(derived(), rows() - cRows, 0, cRows, cCols);
309c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
310c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
311c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of bottomLeftCorner(Index, Index).*/
312c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline const Block<const Derived> bottomLeftCorner(Index cRows, Index cCols) const
313c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
314c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<const Derived>(derived(), rows() - cRows, 0, cRows, cCols);
315c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
316c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
317c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a fixed-size bottom-left corner of *this.
318c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
319c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The template parameters CRows and CCols are the number of rows and columns in the corner.
320c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
321c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_template_int_int_bottomLeftCorner.cpp
322c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_template_int_int_bottomLeftCorner.out
323c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
324c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
325c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
326c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int CRows, int CCols>
327c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline Block<Derived, CRows, CCols> bottomLeftCorner()
328c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
329c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0);
330c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
331c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
332c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of bottomLeftCorner<int, int>().*/
333c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int CRows, int CCols>
334c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline const Block<const Derived, CRows, CCols> bottomLeftCorner() const
335c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
336c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<const Derived, CRows, CCols>(derived(), rows() - CRows, 0);
337c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
338c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
3397faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** \returns an expression of a bottom-left corner of *this.
3407faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
3417faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam CRows number of rows in corner as specified at compile-time
3427faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam CCols number of columns in corner as specified at compile-time
3437faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param  cRows number of rows in corner as specified at run-time
3447faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param  cCols number of columns in corner as specified at run-time
3457faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
3467faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * This function is mainly useful for corners where the number of rows is specified at compile-time
3477faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time
3487faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * information should not contradict. In other words, \a cRows should equal \a CRows unless
3497faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \a CRows is \a Dynamic, and the same for the number of columns.
3507faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
3517faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Example: \include MatrixBase_template_int_int_bottomLeftCorner_int_int.cpp
3527faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Output: \verbinclude MatrixBase_template_int_int_bottomLeftCorner_int_int.out
3537faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
3547faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \sa class Block
3557faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  */
3567faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int CRows, int CCols>
3577faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline Block<Derived, CRows, CCols> bottomLeftCorner(Index cRows, Index cCols)
3587faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
3597faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return Block<Derived, CRows, CCols>(derived(), rows() - cRows, 0, cRows, cCols);
3607faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
3617faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
3627faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** This is the const version of bottomLeftCorner<int, int>(Index, Index).*/
3637faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int CRows, int CCols>
3647faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline const Block<const Derived, CRows, CCols> bottomLeftCorner(Index cRows, Index cCols) const
3657faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
3667faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return Block<const Derived, CRows, CCols>(derived(), rows() - cRows, 0, cRows, cCols);
3677faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
3687faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
369c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
370c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
371c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a block consisting of the top rows of *this.
372c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
373c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param n the number of rows in the block
374c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
375c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_topRows_int.cpp
376c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_topRows_int.out
377c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
378c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
379c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
380c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline RowsBlockXpr topRows(Index n)
381c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
382c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return RowsBlockXpr(derived(), 0, 0, n, cols());
383c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
384c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
385c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of topRows(Index).*/
386c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline ConstRowsBlockXpr topRows(Index n) const
387c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
388c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return ConstRowsBlockXpr(derived(), 0, 0, n, cols());
389c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
390c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
391c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a block consisting of the top rows of *this.
392c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
3937faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam N the number of rows in the block as specified at compile-time
3947faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param n the number of rows in the block as specified at run-time
3957faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
3967faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * The compile-time and run-time information should not contradict. In other words,
3977faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \a n should equal \a N unless \a N is \a Dynamic.
398c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
399c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_template_int_topRows.cpp
400c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_template_int_topRows.out
401c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
402c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
403c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
404c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int N>
4057faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename NRowsBlockXpr<N>::Type topRows(Index n = N)
406c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
4077faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
408c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
409c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
410c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of topRows<int>().*/
411c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int N>
4127faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename ConstNRowsBlockXpr<N>::Type topRows(Index n = N) const
413c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
4147faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
415c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
416c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
417c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
418c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
419c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a block consisting of the bottom rows of *this.
420c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
421c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param n the number of rows in the block
422c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
423c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_bottomRows_int.cpp
424c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_bottomRows_int.out
425c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
426c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
427c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
428c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline RowsBlockXpr bottomRows(Index n)
429c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
430c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return RowsBlockXpr(derived(), rows() - n, 0, n, cols());
431c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
432c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
433c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of bottomRows(Index).*/
434c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline ConstRowsBlockXpr bottomRows(Index n) const
435c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
436c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return ConstRowsBlockXpr(derived(), rows() - n, 0, n, cols());
437c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
438c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
439c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a block consisting of the bottom rows of *this.
440c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
4417faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam N the number of rows in the block as specified at compile-time
4427faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param n the number of rows in the block as specified at run-time
4437faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
4447faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * The compile-time and run-time information should not contradict. In other words,
4457faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \a n should equal \a N unless \a N is \a Dynamic.
446c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
447c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_template_int_bottomRows.cpp
448c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_template_int_bottomRows.out
449c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
450c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
451c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
452c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int N>
4537faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename NRowsBlockXpr<N>::Type bottomRows(Index n = N)
454c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
4557faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename NRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
456c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
457c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
458c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of bottomRows<int>().*/
459c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int N>
4607faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename ConstNRowsBlockXpr<N>::Type bottomRows(Index n = N) const
461c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
4627faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
463c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
464c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
465c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
466c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
467c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a block consisting of a range of rows of *this.
468c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
469c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param startRow the index of the first row in the block
4707faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param n the number of rows in the block
471c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
472c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include DenseBase_middleRows_int.cpp
473c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude DenseBase_middleRows_int.out
474c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
475c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
476c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
4777faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline RowsBlockXpr middleRows(Index startRow, Index n)
478c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
4797faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return RowsBlockXpr(derived(), startRow, 0, n, cols());
480c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
481c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
482c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of middleRows(Index,Index).*/
4837faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline ConstRowsBlockXpr middleRows(Index startRow, Index n) const
484c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
4857faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return ConstRowsBlockXpr(derived(), startRow, 0, n, cols());
486c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
487c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
488c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a block consisting of a range of rows of *this.
489c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
4907faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam N the number of rows in the block as specified at compile-time
491c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param startRow the index of the first row in the block
4927faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param n the number of rows in the block as specified at run-time
4937faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
4947faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * The compile-time and run-time information should not contradict. In other words,
4957faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \a n should equal \a N unless \a N is \a Dynamic.
496c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
497c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include DenseBase_template_int_middleRows.cpp
498c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude DenseBase_template_int_middleRows.out
499c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
500c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
501c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
502c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int N>
5037faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename NRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N)
504c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
5057faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
506c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
507c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
508c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of middleRows<int>().*/
509c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int N>
5107faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename ConstNRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N) const
511c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
5127faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
513c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
514c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
515c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
516c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
517c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a block consisting of the left columns of *this.
518c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
519c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param n the number of columns in the block
520c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
521c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_leftCols_int.cpp
522c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_leftCols_int.out
523c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
524c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
525c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
526c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline ColsBlockXpr leftCols(Index n)
527c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
528c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return ColsBlockXpr(derived(), 0, 0, rows(), n);
529c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
530c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
531c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of leftCols(Index).*/
532c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline ConstColsBlockXpr leftCols(Index n) const
533c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
534c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return ConstColsBlockXpr(derived(), 0, 0, rows(), n);
535c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
536c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
537c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a block consisting of the left columns of *this.
538c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
5397faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam N the number of columns in the block as specified at compile-time
5407faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param n the number of columns in the block as specified at run-time
5417faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
5427faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * The compile-time and run-time information should not contradict. In other words,
5437faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \a n should equal \a N unless \a N is \a Dynamic.
544c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
545c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_template_int_leftCols.cpp
546c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_template_int_leftCols.out
547c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
548c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
549c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
550c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int N>
5517faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename NColsBlockXpr<N>::Type leftCols(Index n = N)
552c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
5537faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
554c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
555c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
556c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of leftCols<int>().*/
557c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int N>
5587faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename ConstNColsBlockXpr<N>::Type leftCols(Index n = N) const
559c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
5607faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
561c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
562c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
563c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
564c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
565c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a block consisting of the right columns of *this.
566c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
567c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param n the number of columns in the block
568c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
569c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_rightCols_int.cpp
570c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_rightCols_int.out
571c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
572c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
573c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
574c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline ColsBlockXpr rightCols(Index n)
575c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
576c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return ColsBlockXpr(derived(), 0, cols() - n, rows(), n);
577c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
578c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
579c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of rightCols(Index).*/
580c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline ConstColsBlockXpr rightCols(Index n) const
581c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
582c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return ConstColsBlockXpr(derived(), 0, cols() - n, rows(), n);
583c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
584c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
585c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a block consisting of the right columns of *this.
586c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
5877faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam N the number of columns in the block as specified at compile-time
5887faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param n the number of columns in the block as specified at run-time
5897faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
5907faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * The compile-time and run-time information should not contradict. In other words,
5917faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \a n should equal \a N unless \a N is \a Dynamic.
592c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
593c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_template_int_rightCols.cpp
594c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_template_int_rightCols.out
595c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
596c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
597c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
598c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int N>
5997faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename NColsBlockXpr<N>::Type rightCols(Index n = N)
600c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
6017faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
602c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
603c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
604c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of rightCols<int>().*/
605c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int N>
6067faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename ConstNColsBlockXpr<N>::Type rightCols(Index n = N) const
607c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
6087faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
609c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
610c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
611c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
612c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
613c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a block consisting of a range of columns of *this.
614c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
615c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param startCol the index of the first column in the block
616c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param numCols the number of columns in the block
617c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
618c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include DenseBase_middleCols_int.cpp
619c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude DenseBase_middleCols_int.out
620c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
621c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
622c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
623c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline ColsBlockXpr middleCols(Index startCol, Index numCols)
624c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
625c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return ColsBlockXpr(derived(), 0, startCol, rows(), numCols);
626c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
627c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
628c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of middleCols(Index,Index).*/
629c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline ConstColsBlockXpr middleCols(Index startCol, Index numCols) const
630c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
631c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return ConstColsBlockXpr(derived(), 0, startCol, rows(), numCols);
632c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
633c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
634c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a block consisting of a range of columns of *this.
635c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
6367faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam N the number of columns in the block as specified at compile-time
637c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param startCol the index of the first column in the block
6387faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param n the number of columns in the block as specified at run-time
6397faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
6407faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * The compile-time and run-time information should not contradict. In other words,
6417faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \a n should equal \a N unless \a N is \a Dynamic.
642c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
643c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include DenseBase_template_int_middleCols.cpp
644c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude DenseBase_template_int_middleCols.out
645c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
646c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
647c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
648c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int N>
6497faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename NColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N)
650c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
6517faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
652c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
653c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
654c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of middleCols<int>().*/
655c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int N>
6567faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N) const
657c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
6587faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
659c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
660c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
661c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
662c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
663c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns a fixed-size expression of a block in *this.
664c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
665c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The template parameters \a BlockRows and \a BlockCols are the number of
666c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * rows and columns in the block.
667c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
668c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param startRow the first row in the block
669c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param startCol the first column in the block
670c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
671c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_block_int_int.cpp
672c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_block_int_int.out
673c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
674c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \note since block is a templated member, the keyword template has to be used
675c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * if the matrix type is also a template parameter: \code m.template block<3,3>(1,1); \endcode
676c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
677c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Block, block(Index,Index,Index,Index)
678c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
679c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int BlockRows, int BlockCols>
680c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline Block<Derived, BlockRows, BlockCols> block(Index startRow, Index startCol)
681c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
682c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<Derived, BlockRows, BlockCols>(derived(), startRow, startCol);
683c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
684c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
685c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of block<>(Index, Index). */
686c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<int BlockRows, int BlockCols>
687c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline const Block<const Derived, BlockRows, BlockCols> block(Index startRow, Index startCol) const
688c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
689c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Block<const Derived, BlockRows, BlockCols>(derived(), startRow, startCol);
690c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
691c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
6927faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** \returns an expression of a block in *this.
6937faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
6947faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam BlockRows number of rows in block as specified at compile-time
6957faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam BlockCols number of columns in block as specified at compile-time
6967faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param  startRow  the first row in the block
6977faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param  startCol  the first column in the block
6987faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param  blockRows number of rows in block as specified at run-time
6997faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param  blockCols number of columns in block as specified at run-time
7007faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
7017faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * This function is mainly useful for blocks where the number of rows is specified at compile-time
7027faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time
7037faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * information should not contradict. In other words, \a blockRows should equal \a BlockRows unless
7047faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \a BlockRows is \a Dynamic, and the same for the number of columns.
7057faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
7067faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Example: \include MatrixBase_template_int_int_block_int_int_int_int.cpp
7077faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Output: \verbinclude MatrixBase_template_int_int_block_int_int_int_int.cpp
7087faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
7097faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \sa class Block, block(Index,Index,Index,Index)
7107faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  */
7117faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int BlockRows, int BlockCols>
7127faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline Block<Derived, BlockRows, BlockCols> block(Index startRow, Index startCol,
7137faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez                                                  Index blockRows, Index blockCols)
7147faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
7157faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return Block<Derived, BlockRows, BlockCols>(derived(), startRow, startCol, blockRows, blockCols);
7167faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
7177faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
7187faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** This is the const version of block<>(Index, Index, Index, Index). */
7197faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int BlockRows, int BlockCols>
7207faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline const Block<const Derived, BlockRows, BlockCols> block(Index startRow, Index startCol,
7217faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez                                                              Index blockRows, Index blockCols) const
7227faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
7237faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return Block<const Derived, BlockRows, BlockCols>(derived(), startRow, startCol, blockRows, blockCols);
7247faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
7257faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
726c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of the \a i-th column of *this. Note that the numbering starts at 0.
727c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
728c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_col.cpp
729c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_col.out
730c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
731c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa row(), class Block */
732c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline ColXpr col(Index i)
733c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
734c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return ColXpr(derived(), i);
735c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
736c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
737c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of col(). */
738c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline ConstColXpr col(Index i) const
739c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
740c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return ConstColXpr(derived(), i);
741c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
742c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
743c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of the \a i-th row of *this. Note that the numbering starts at 0.
744c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
745c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_row.cpp
746c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_row.out
747c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
748c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa col(), class Block */
749c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline RowXpr row(Index i)
750c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
751c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return RowXpr(derived(), i);
752c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
753c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
754c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is the const version of row(). */
755c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline ConstRowXpr row(Index i) const
756c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
757c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return ConstRowXpr(derived(), i);
758c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
759c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
7607faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** \returns a dynamic-size expression of a segment (i.e. a vector block) in *this.
7617faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
7627faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \only_for_vectors
7637faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
7647faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param start the first coefficient in the segment
7657faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param n the number of coefficients in the segment
7667faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
7677faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Example: \include MatrixBase_segment_int_int.cpp
7687faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Output: \verbinclude MatrixBase_segment_int_int.out
7697faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
7707faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \note Even though the returned expression has dynamic size, in the case
7717faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * when it is applied to a fixed-size vector, it inherits a fixed maximal size,
7727faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * which means that evaluating it does not cause a dynamic memory allocation.
7737faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
7747faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \sa class Block, segment(Index)
7757faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  */
7767faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline SegmentReturnType segment(Index start, Index n)
7777faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
7787faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
7797faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return SegmentReturnType(derived(), start, n);
7807faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
7817faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
7827faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
7837faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** This is the const version of segment(Index,Index).*/
7847faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline ConstSegmentReturnType segment(Index start, Index n) const
7857faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
7867faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
7877faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return ConstSegmentReturnType(derived(), start, n);
7887faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
7897faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
7907faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** \returns a dynamic-size expression of the first coefficients of *this.
7917faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
7927faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \only_for_vectors
7937faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
7947faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param n the number of coefficients in the segment
7957faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
7967faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Example: \include MatrixBase_start_int.cpp
7977faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Output: \verbinclude MatrixBase_start_int.out
7987faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
7997faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \note Even though the returned expression has dynamic size, in the case
8007faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * when it is applied to a fixed-size vector, it inherits a fixed maximal size,
8017faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * which means that evaluating it does not cause a dynamic memory allocation.
8027faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
8037faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \sa class Block, block(Index,Index)
8047faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  */
8057faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline SegmentReturnType head(Index n)
8067faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
8077faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
8087faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return SegmentReturnType(derived(), 0, n);
8097faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
8107faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
8117faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** This is the const version of head(Index).*/
8127faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline ConstSegmentReturnType head(Index n) const
8137faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
8147faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
8157faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return ConstSegmentReturnType(derived(), 0, n);
8167faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
8177faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
8187faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** \returns a dynamic-size expression of the last coefficients of *this.
8197faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
8207faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \only_for_vectors
8217faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
8227faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param n the number of coefficients in the segment
8237faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
8247faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Example: \include MatrixBase_end_int.cpp
8257faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Output: \verbinclude MatrixBase_end_int.out
8267faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
8277faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \note Even though the returned expression has dynamic size, in the case
8287faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * when it is applied to a fixed-size vector, it inherits a fixed maximal size,
8297faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * which means that evaluating it does not cause a dynamic memory allocation.
8307faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
8317faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \sa class Block, block(Index,Index)
8327faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  */
8337faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline SegmentReturnType tail(Index n)
8347faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
8357faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
8367faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return SegmentReturnType(derived(), this->size() - n, n);
8377faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
8387faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
8397faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** This is the const version of tail(Index).*/
8407faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline ConstSegmentReturnType tail(Index n) const
8417faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
8427faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
8437faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return ConstSegmentReturnType(derived(), this->size() - n, n);
8447faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
8457faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
8467faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** \returns a fixed-size expression of a segment (i.e. a vector block) in \c *this
8477faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
8487faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \only_for_vectors
8497faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
8507faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam N the number of coefficients in the segment as specified at compile-time
8517faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param start the index of the first element in the segment
8527faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param n the number of coefficients in the segment as specified at compile-time
8537faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
8547faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * The compile-time and run-time information should not contradict. In other words,
8557faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \a n should equal \a N unless \a N is \a Dynamic.
8567faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
8577faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Example: \include MatrixBase_template_int_segment.cpp
8587faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Output: \verbinclude MatrixBase_template_int_segment.out
8597faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
8607faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \sa class Block
8617faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  */
8627faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int N>
8637faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename FixedSegmentReturnType<N>::Type segment(Index start, Index n = N)
8647faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
8657faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
8667faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename FixedSegmentReturnType<N>::Type(derived(), start, n);
8677faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
8687faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
8697faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** This is the const version of segment<int>(Index).*/
8707faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int N>
8717faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename ConstFixedSegmentReturnType<N>::Type segment(Index start, Index n = N) const
8727faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
8737faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
8747faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename ConstFixedSegmentReturnType<N>::Type(derived(), start, n);
8757faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
8767faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
8777faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** \returns a fixed-size expression of the first coefficients of *this.
8787faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
8797faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \only_for_vectors
8807faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
8817faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam N the number of coefficients in the segment as specified at compile-time
8827faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param  n the number of coefficients in the segment as specified at run-time
8837faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
8847faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * The compile-time and run-time information should not contradict. In other words,
8857faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \a n should equal \a N unless \a N is \a Dynamic.
8867faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
8877faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Example: \include MatrixBase_template_int_start.cpp
8887faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Output: \verbinclude MatrixBase_template_int_start.out
8897faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
8907faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \sa class Block
8917faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  */
8927faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int N>
8937faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename FixedSegmentReturnType<N>::Type head(Index n = N)
8947faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
8957faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
8967faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename FixedSegmentReturnType<N>::Type(derived(), 0, n);
8977faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
8987faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
8997faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** This is the const version of head<int>().*/
9007faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int N>
9017faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename ConstFixedSegmentReturnType<N>::Type head(Index n = N) const
9027faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
9037faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
9047faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename ConstFixedSegmentReturnType<N>::Type(derived(), 0, n);
9057faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
9067faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
9077faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** \returns a fixed-size expression of the last coefficients of *this.
9087faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
9097faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \only_for_vectors
9107faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
9117faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \tparam N the number of coefficients in the segment as specified at compile-time
9127faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param  n the number of coefficients in the segment as specified at run-time
9137faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
9147faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * The compile-time and run-time information should not contradict. In other words,
9157faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \a n should equal \a N unless \a N is \a Dynamic.
9167faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
9177faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Example: \include MatrixBase_template_int_end.cpp
9187faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * Output: \verbinclude MatrixBase_template_int_end.out
9197faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  *
9207faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \sa class Block
9217faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  */
9227faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int N>
9237faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename FixedSegmentReturnType<N>::Type tail(Index n = N)
9247faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
9257faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
9267faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename FixedSegmentReturnType<N>::Type(derived(), size() - n);
9277faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
9287faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez
9297faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** This is the const version of tail<int>.*/
9307faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandeztemplate<int N>
9317faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezinline typename ConstFixedSegmentReturnType<N>::Type tail(Index n = N) const
9327faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez{
9337faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
9347faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return typename ConstFixedSegmentReturnType<N>::Type(derived(), size() - n);
9357faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez}
936