1
// This file is part of Eigen, a lightweight C++ template library
4
// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
5
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
7
// Eigen is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU Lesser General Public
9
// License as published by the Free Software Foundation; either
10
// version 3 of the License, or (at your option) any later version.
12
// Alternatively, you can redistribute it and/or
13
// modify it under the terms of the GNU General Public License as
14
// published by the Free Software Foundation; either version 2 of
15
// the License, or (at your option) any later version.
17
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
20
// GNU General Public License for more details.
22
// You should have received a copy of the GNU Lesser General Public
23
// License and a copy of the GNU General Public License along with
24
// Eigen. If not, see <http://www.gnu.org/licenses/>.
26
#ifndef EIGEN_BLOCK2_H
27
#define EIGEN_BLOCK2_H
29
/** \returns a dynamic-size expression of a corner of *this.
31
* \param type the type of corner. Can be \a Eigen::TopLeft, \a Eigen::TopRight,
32
* \a Eigen::BottomLeft, \a Eigen::BottomRight.
33
* \param cRows the number of rows in the corner
34
* \param cCols the number of columns in the corner
36
* Example: \include MatrixBase_corner_enum_int_int.cpp
37
* Output: \verbinclude MatrixBase_corner_enum_int_int.out
39
* \note Even though the returned expression has dynamic size, in the case
40
* when it is applied to a fixed-size matrix, it inherits a fixed maximal size,
41
* which means that evaluating it does not cause a dynamic memory allocation.
43
* \sa class Block, block(Index,Index,Index,Index)
45
template<typename Derived>
46
inline Block<Derived> DenseBase<Derived>
47
::corner(CornerType type, Index cRows, Index cCols)
52
eigen_assert(false && "Bad corner type.");
54
return Block<Derived>(derived(), 0, 0, cRows, cCols);
56
return Block<Derived>(derived(), 0, cols() - cCols, cRows, cCols);
58
return Block<Derived>(derived(), rows() - cRows, 0, cRows, cCols);
60
return Block<Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
64
/** This is the const version of corner(CornerType, Index, Index).*/
65
template<typename Derived>
66
inline const Block<Derived>
67
DenseBase<Derived>::corner(CornerType type, Index cRows, Index cCols) const
72
eigen_assert(false && "Bad corner type.");
74
return Block<Derived>(derived(), 0, 0, cRows, cCols);
76
return Block<Derived>(derived(), 0, cols() - cCols, cRows, cCols);
78
return Block<Derived>(derived(), rows() - cRows, 0, cRows, cCols);
80
return Block<Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
84
/** \returns a fixed-size expression of a corner of *this.
86
* \param type the type of corner. Can be \a Eigen::TopLeft, \a Eigen::TopRight,
87
* \a Eigen::BottomLeft, \a Eigen::BottomRight.
89
* The template parameters CRows and CCols arethe number of rows and columns in the corner.
91
* Example: \include MatrixBase_template_int_int_corner_enum.cpp
92
* Output: \verbinclude MatrixBase_template_int_int_corner_enum.out
94
* \sa class Block, block(Index,Index,Index,Index)
96
template<typename Derived>
97
template<int CRows, int CCols>
98
inline Block<Derived, CRows, CCols>
99
DenseBase<Derived>::corner(CornerType type)
104
eigen_assert(false && "Bad corner type.");
106
return Block<Derived, CRows, CCols>(derived(), 0, 0);
108
return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols);
110
return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0);
112
return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
116
/** This is the const version of corner<int, int>(CornerType).*/
117
template<typename Derived>
118
template<int CRows, int CCols>
119
inline const Block<Derived, CRows, CCols>
120
DenseBase<Derived>::corner(CornerType type) const
125
eigen_assert(false && "Bad corner type.");
127
return Block<Derived, CRows, CCols>(derived(), 0, 0);
129
return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols);
131
return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0);
133
return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
137
#endif // EIGEN_BLOCK2_H