BlockMethods.h File Reference

Go to the source code of this file.

Functions

template<int NRows, int NCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr< NRows, NCols >::Type block (Index startRow, Index startCol)
 
template<int NRows, int NCols>
const ConstFixedBlockXpr< NRows, NCols >::Type block (Index startRow, Index startCol) const
 This is the const version of block<>(Index, Index). *‍/. More...
 
template<int NRows, int NCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr< NRows, NCols >::Type block (Index startRow, Index startCol, Index blockRows, Index blockCols)
 
template<int NRows, int NCols>
const ConstFixedBlockXpr< NRows, NCols >::Type block (Index startRow, Index startCol, Index blockRows, Index blockCols) const
 This is the const version of block<>(Index, Index, Index, Index). More...
 
template<typename NRowsType , typename NColsType >
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<...,... >::Type block (Index startRow, Index startCol, NRowsType blockRows, NColsType blockCols)
 
template<typename NRowsType , typename NColsType >
const ConstFixedBlockXpr<...,... >::Type block (Index startRow, Index startCol, NRowsType blockRows, NColsType blockCols) const
 This is the const version of block(Index,Index,NRowsType,NColsType) More...
 
template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr< CRows, CCols >::Type bottomLeftCorner ()
 
template<int CRows, int CCols>
const ConstFixedBlockXpr< CRows, CCols >::Type bottomLeftCorner () const
 This is the const version of bottomLeftCorner<int, int>(). More...
 
template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr< CRows, CCols >::Type bottomLeftCorner (Index cRows, Index cCols)
 
template<int CRows, int CCols>
const ConstFixedBlockXpr< CRows, CCols >::Type bottomLeftCorner (Index cRows, Index cCols) const
 This is the const version of bottomLeftCorner<int, int>(Index, Index). More...
 
template<typename NRowsType , typename NColsType >
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<...,... >::Type bottomLeftCorner (NRowsType cRows, NColsType cCols)
 
template<typename NRowsType , typename NColsType >
ConstFixedBlockXpr<...,... >::Type bottomLeftCorner (NRowsType cRows, NColsType cCols) const
 This is the const version of bottomLeftCorner(NRowsType, NColsType). More...
 
template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr< CRows, CCols >::Type bottomRightCorner ()
 
template<int CRows, int CCols>
const ConstFixedBlockXpr< CRows, CCols >::Type bottomRightCorner () const
 This is the const version of bottomRightCorner<int, int>(). More...
 
template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr< CRows, CCols >::Type bottomRightCorner (Index cRows, Index cCols)
 
template<int CRows, int CCols>
const ConstFixedBlockXpr< CRows, CCols >::Type bottomRightCorner (Index cRows, Index cCols) const
 This is the const version of bottomRightCorner<int, int>(Index, Index). More...
 
template<typename NRowsType , typename NColsType >
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<...,... >::Type bottomRightCorner (NRowsType cRows, NColsType cCols)
 
template<typename NRowsType , typename NColsType >
const ConstFixedBlockXpr<...,... >::Type bottomRightCorner (NRowsType cRows, NColsType cCols) const
 This is the const version of bottomRightCorner(NRowsType, NColsType). More...
 
template<int N>
NRowsBlockXpr< N >::Type bottomRows (Index n=N)
 
template<int N>
ConstNRowsBlockXpr< N >::Type bottomRows (Index n=N) const
 This is the const version of bottomRows<int>(). More...
 
template<typename NRowsType >
NRowsBlockXpr<... >::Type bottomRows (NRowsType n)
 
template<typename NRowsType >
const ConstNRowsBlockXpr<... >::Type bottomRows (NRowsType n) const
 This is the const version of bottomRows(NRowsType). More...
 
ColXpr col (Index i) const
 This is the const version of col(). More...
 
template<int N>
FixedSegmentReturnType< N >::Type head (Index n=N)
 
template<int N>
ConstFixedSegmentReturnType< N >::Type head (Index n=N) const
 This is the const version of head<int>(). More...
 
template<typename NType >
FixedSegmentReturnType<... >::Type head (NType n)
 
template<typename NType >
const ConstFixedSegmentReturnType<... >::Type head (NType n) const
 This is the const version of head(NType). More...
 
InnerVectorReturnType innerVector (Index outer)
 
InnerVectorsReturnType innerVectors (Index outerStart, Index outerSize)
 
template<int N>
NColsBlockXpr< N >::Type leftCols (Index n=N)
 
template<int N>
ConstNColsBlockXpr< N >::Type leftCols (Index n=N) const
 This is the const version of leftCols<int>(). More...
 
template<typename NColsType >
NColsBlockXpr<... >::Type leftCols (NColsType n)
 
template<typename NColsType >
const ConstNColsBlockXpr<... >::Type leftCols (NColsType n) const
 This is the const version of leftCols(NColsType). More...
 
template<int N>
NColsBlockXpr< N >::Type middleCols (Index startCol, Index n=N)
 
template<int N>
ConstNColsBlockXpr< N >::Type middleCols (Index startCol, Index n=N) const
 This is the const version of middleCols<int>(). More...
 
template<typename NColsType >
NColsBlockXpr<... >::Type middleCols (Index startCol, NColsType numCols)
 
template<typename NColsType >
const ConstNColsBlockXpr<... >::Type middleCols (Index startCol, NColsType numCols) const
 This is the const version of middleCols(Index,NColsType). More...
 
template<int N>
NRowsBlockXpr< N >::Type middleRows (Index startRow, Index n=N)
 
template<int N>
ConstNRowsBlockXpr< N >::Type middleRows (Index startRow, Index n=N) const
 This is the const version of middleRows<int>(). More...
 
template<typename NRowsType >
NRowsBlockXpr<... >::Type middleRows (Index startRow, NRowsType n)
 
template<typename NRowsType >
const ConstNRowsBlockXpr<... >::Type middleRows (Index startRow, NRowsType n) const
 This is the const version of middleRows(Index,NRowsType). More...
 
template<int N>
NColsBlockXpr< N >::Type rightCols (Index n=N)
 
template<int N>
ConstNColsBlockXpr< N >::Type rightCols (Index n=N) const
 This is the const version of rightCols<int>(). More...
 
template<typename NColsType >
NColsBlockXpr<... >::Type rightCols (NColsType n)
 
template<typename NColsType >
const ConstNColsBlockXpr<... >::Type rightCols (NColsType n) const
 This is the const version of rightCols(NColsType). More...
 
RowXpr row (Index i) const
 This is the const version of row(). *‍/. More...
 
template<int N>
FixedSegmentReturnType< N >::Type segment (Index start, Index n=N)
 
template<int N>
ConstFixedSegmentReturnType< N >::Type segment (Index start, Index n=N) const
 This is the const version of segment<int>(Index). More...
 
template<typename NType >
FixedSegmentReturnType<... >::Type segment (Index start, NType n)
 
template<typename NType >
const ConstFixedSegmentReturnType<... >::Type segment (Index start, NType n) const
 This is the const version of segment(Index,NType). More...
 
template<DirectionType Direction>
std::conditional_t< Direction==Vertical, ColXpr, RowXpr > subVector (Index i)
 
template<DirectionType Direction>
std::conditional_t< Direction==Vertical, ConstColXpr, ConstRowXpr > subVector (Index i) const
 
template<DirectionType Direction>
EIGEN_CONSTEXPR Index subVectors () const
 
template<int N>
FixedSegmentReturnType< N >::Type tail (Index n=N)
 
template<int N>
ConstFixedSegmentReturnType< N >::Type tail (Index n=N) const
 This is the const version of tail<int>. More...
 
template<typename NType >
FixedSegmentReturnType<... >::Type tail (NType n)
 
template<typename NType >
const ConstFixedSegmentReturnType<... >::Type tail (NType n) const
 This is the const version of tail(Index). More...
 
template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr< CRows, CCols >::Type topLeftCorner ()
 
template<int CRows, int CCols>
const ConstFixedBlockXpr< CRows, CCols >::Type topLeftCorner () const
 This is the const version of topLeftCorner<int, int>(). More...
 
template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr< CRows, CCols >::Type topLeftCorner (Index cRows, Index cCols)
 
template<int CRows, int CCols>
const ConstFixedBlockXpr< CRows, CCols >::Type topLeftCorner (Index cRows, Index cCols) const
 This is the const version of topLeftCorner<int, int>(Index, Index). More...
 
template<typename NRowsType , typename NColsType >
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<...,... >::Type topLeftCorner (NRowsType cRows, NColsType cCols)
 
template<typename NRowsType , typename NColsType >
const ConstFixedBlockXpr<...,... >::Type topLeftCorner (NRowsType cRows, NColsType cCols) const
 This is the const version of topLeftCorner(Index, Index). More...
 
template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr< CRows, CCols >::Type topRightCorner ()
 
template<int CRows, int CCols>
const ConstFixedBlockXpr< CRows, CCols >::Type topRightCorner () const
 This is the const version of topRightCorner<int, int>(). More...
 
template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr< CRows, CCols >::Type topRightCorner (Index cRows, Index cCols)
 
template<int CRows, int CCols>
const ConstFixedBlockXpr< CRows, CCols >::Type topRightCorner (Index cRows, Index cCols) const
 This is the const version of topRightCorner<int, int>(Index, Index). More...
 
template<typename NRowsType , typename NColsType >
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<...,... >::Type topRightCorner (NRowsType cRows, NColsType cCols)
 
template<typename NRowsType , typename NColsType >
const ConstFixedBlockXpr<...,... >::Type topRightCorner (NRowsType cRows, NColsType cCols) const
 This is the const version of topRightCorner(NRowsType, NColsType). More...
 
template<int N>
NRowsBlockXpr< N >::Type topRows (Index n=N)
 
template<int N>
ConstNRowsBlockXpr< N >::Type topRows (Index n=N) const
 This is the const version of topRows<int>(). More...
 
template<typename NRowsType >
NRowsBlockXpr<... >::Type topRows (NRowsType n)
 
template<typename NRowsType >
const ConstNRowsBlockXpr<... >::Type topRows (NRowsType n) const
 This is the const version of topRows(NRowsType). More...
 

Function Documentation

◆ block() [1/6]

template<int NRows, int NCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<NRows,NCols>::Type block ( Index  startRow,
Index  startCol 
)
inline
Returns
a fixed-size expression of a block of *this.

The template parameters NRows and NCols are the number of rows and columns in the block.

Parameters
startRowthe first row in the block
startColthe first column in the block

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.block<2,2>(1,1):" << endl << m.block<2,2>(1,1) << endl;
m.block<2,2>(1,1).setZero();
cout << "Now the matrix m is:" << endl << m << endl;
Matrix3f m
v setZero(3)
Matrix< int, 4, 4 > Matrix4i
4×4 matrix of type int.
Definition: Matrix.h:500

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is m.block<2,2>(1,1):
-6  1
-3  0
Now the matrix m is:
 7  9 -5 -3
-2  0  0  0
 6  0  0  9
 6  6  3  9
Note
The usage of of this overload is discouraged from Eigen 3.4, better used the generic block(Index,Index,NRowsType,NColsType), here is the one-to-one equivalence:
mat.template block<NRows,NCols>(i,j) <--> mat.block(i,j,fix<NRows>,fix<NCols>)
std::ptrdiff_t j
since block is a templated member, the keyword template has to be used if the matrix type is also a template parameter:
m.template block<3,3>(1,1);
m block< 3, 3 >(1, 0).setIdentity()
See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 1027 of file BlockMethods.h.

1028 {
1029  return typename FixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol);
1030 }

◆ block() [2/6]

template<int NRows, int NCols>
const ConstFixedBlockXpr<NRows,NCols>::Type block ( Index  startRow,
Index  startCol 
) const
inline

This is the const version of block<>(Index, Index). *‍/.

Definition at line 1035 of file BlockMethods.h.

1036 {
1037  return typename ConstFixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol);
1038 }

◆ block() [3/6]

template<int NRows, int NCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<NRows,NCols>::Type block ( Index  startRow,
Index  startCol,
Index  blockRows,
Index  blockCols 
)
inline
Returns
an expression of a block of *this.
Template Parameters
NRowsnumber of rows in block as specified at compile-time
NColsnumber of columns in block as specified at compile-time
Parameters
startRowthe first row in the block
startColthe first column in the block
blockRowsnumber of rows in block as specified at run-time
blockColsnumber of columns in block as specified at run-time

This function is mainly useful for blocks where the number of rows is specified at compile-time and the number of columns is specified at run-time, or vice versa. The compile-time and run-time information should not contradict. In other words, blockRows should equal NRows unless NRows is Dynamic, and the same for the number of columns.

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the block:" << endl << m.block<2, Dynamic>(1, 1, 2, 3) << endl;
m.block<2, Dynamic>(1, 1, 2, 3).setZero();
cout << "Now the matrix m is:" << endl << m << endl;
const int Dynamic
Definition: Constants.h:24

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is the block:
-6  1  0
-3  0  9
Now the matrix m is:
 7  9 -5 -3
-2  0  0  0
 6  0  0  0
 6  6  3  9
Note
The usage of of this overload is discouraged from Eigen 3.4, better used the generic block(Index,Index,NRowsType,NColsType), here is the one-to-one complete equivalence:
mat.template block<NRows,NCols>(i,j,rows,cols) <--> mat.block(i,j,fix<NRows>(rows),fix<NCols>(cols))
If we known that, e.g., NRows==Dynamic and NCols!=Dynamic, then the equivalence becomes:
mat.template block<Dynamic,NCols>(i,j,rows,NCols) <--> mat.block(i,j,rows,fix<NCols>)
See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 1073 of file BlockMethods.h.

1075 {
1076  return typename FixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol, blockRows, blockCols);
1077 }

◆ block() [4/6]

template<int NRows, int NCols>
const ConstFixedBlockXpr<NRows,NCols>::Type block ( Index  startRow,
Index  startCol,
Index  blockRows,
Index  blockCols 
) const
inline

This is the const version of block<>(Index, Index, Index, Index).

Definition at line 1082 of file BlockMethods.h.

1084 {
1085  return typename ConstFixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol, blockRows, blockCols);
1086 }

◆ block() [5/6]

template<typename NRowsType , typename NColsType >
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<...,...>::Type block ( Index  startRow,
Index  startCol,
NRowsType  blockRows,
NColsType  blockCols 
)
inline
Returns
an expression of a block in *this with either dynamic or fixed sizes.
Parameters
startRowthe first row in the block
startColthe first column in the block
blockRowsnumber of rows in the block, specified at either run-time or compile-time
blockColsnumber of columns in the block, specified at either run-time or compile-time
Template Parameters
NRowsTypethe type of the value handling the number of rows in the block, typically Index.
NColsTypethe type of the value handling the number of columns in the block, typically Index.

Example using runtime (aka dynamic) sizes:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.block(1, 1, 2, 2):" << endl << m.block(1, 1, 2, 2) << endl;
m.block(1, 1, 2, 2).setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is m.block(1, 1, 2, 2):
-6  1
-3  0
Now the matrix m is:
 7  9 -5 -3
-2  0  0  0
 6  0  0  9
 6  6  3  9

New in Eigen 3.4.:

The number of rows blockRows and columns blockCols can also be specified at compile-time by passing Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. In the later case, n plays the role of a runtime fallback value in case N equals Eigen::Dynamic. Here is an example with a fixed number of rows NRows and dynamic number of columns cols:

mat.block(i,j,fix<NRows>,cols)

This function thus fully covers the features offered by the following overloads block<NRows,NCols>(Index, Index), and block<NRows,NCols>(Index, Index, Index, Index) that are thus obsolete. Indeed, this generic version avoids redundancy, it preserves the argument order, and prevents the need to rely on the template keyword in templated code.

but with less redundancy and more consistency as it does not modify the argument order and seamlessly enable hybrid fixed/dynamic sizes.

Note
Even in the case that the returned expression has dynamic size, in the case when it is applied to a fixed-size matrix, it inherits a fixed maximal size, which means that evaluating it does not cause a dynamic memory allocation.
See also
class Block, fix, fix<N>(int)

Definition at line 96 of file BlockMethods.h.

97 {
98  return typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type(
99  derived(), startRow, startCol, internal::get_runtime_value(blockRows), internal::get_runtime_value(blockCols));
100 }
Index get_runtime_value(const T &x)

◆ block() [6/6]

template<typename NRowsType , typename NColsType >
const ConstFixedBlockXpr<...,...>::Type block ( Index  startRow,
Index  startCol,
NRowsType  blockRows,
NColsType  blockCols 
) const
inline

This is the const version of block(Index,Index,NRowsType,NColsType)

Definition at line 110 of file BlockMethods.h.

111 {
112  return typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type(
113  derived(), startRow, startCol, internal::get_runtime_value(blockRows), internal::get_runtime_value(blockCols));
114 }

◆ bottomLeftCorner() [1/6]

template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<CRows,CCols>::Type bottomLeftCorner ( )
inline
Returns
an expression of a fixed-size bottom-left corner of *this.

The template parameters CRows and CCols are the number of rows and columns in the corner.

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.bottomLeftCorner<2,2>():" << endl;
cout << m.bottomLeftCorner<2,2>() << endl;
m.bottomLeftCorner<2,2>().setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is m.bottomLeftCorner<2,2>():
 6 -3
 6  6
Now the matrix m is:
 7  9 -5 -3
-2 -6  1  0
 0  0  0  9
 0  0  3  9
See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 498 of file BlockMethods.h.

499 {
500  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, 0);
501 }

◆ bottomLeftCorner() [2/6]

template<int CRows, int CCols>
const ConstFixedBlockXpr<CRows,CCols>::Type bottomLeftCorner ( ) const
inline

This is the const version of bottomLeftCorner<int, int>().

Definition at line 506 of file BlockMethods.h.

507 {
508  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, 0);
509 }

◆ bottomLeftCorner() [3/6]

template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<CRows,CCols>::Type bottomLeftCorner ( Index  cRows,
Index  cCols 
)
inline
Returns
an expression of a bottom-left corner of *this.
Template Parameters
CRowsnumber of rows in corner as specified at compile-time
CColsnumber of columns in corner as specified at compile-time
Parameters
cRowsnumber of rows in corner as specified at run-time
cColsnumber of columns in corner as specified at run-time

This function is mainly useful for corners where the number of rows is specified at compile-time and the number of columns is specified at run-time, or vice versa. The compile-time and run-time information should not contradict. In other words, cRows should equal CRows unless CRows is Dynamic, and the same for the number of columns.

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.bottomLeftCorner<2,Dynamic>(2,2):" << endl;
cout << m.bottomLeftCorner<2,Dynamic>(2,2) << endl;
m.bottomLeftCorner<2,Dynamic>(2,2).setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is m.bottomLeftCorner<2,Dynamic>(2,2):
 6 -3
 6  6
Now the matrix m is:
 7  9 -5 -3
-2 -6  1  0
 0  0  0  9
 0  0  3  9
See also
class Block

Definition at line 532 of file BlockMethods.h.

533 {
534  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, 0, cRows, cCols);
535 }

◆ bottomLeftCorner() [4/6]

template<int CRows, int CCols>
const ConstFixedBlockXpr<CRows,CCols>::Type bottomLeftCorner ( Index  cRows,
Index  cCols 
) const
inline

This is the const version of bottomLeftCorner<int, int>(Index, Index).

Definition at line 540 of file BlockMethods.h.

541 {
542  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, 0, cRows, cCols);
543 }

◆ bottomLeftCorner() [5/6]

template<typename NRowsType , typename NColsType >
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<...,...>::Type bottomLeftCorner ( NRowsType  cRows,
NColsType  cCols 
)
inline
Returns
an expression of a bottom-left corner of *this with either dynamic or fixed sizes.
Parameters
cRowsthe number of rows in the corner
cColsthe number of columns in the corner
Template Parameters
NRowsTypethe type of the value handling the number of rows in the block, typically Index.
NColsTypethe type of the value handling the number of columns in the block, typically Index.

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.bottomLeftCorner(2, 2):" << endl;
cout << m.bottomLeftCorner(2, 2) << endl;
m.bottomLeftCorner(2, 2).setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is m.bottomLeftCorner(2, 2):
 6 -3
 6  6
Now the matrix m is:
 7  9 -5 -3
-2 -6  1  0
 0  0  0  9
 0  0  3  9

The number of rows blockRows and columns blockCols can also be specified at compile-time by passing Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See block() for the details.

See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 463 of file BlockMethods.h.

464 {
465  return typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
466  (derived(), rows() - internal::get_runtime_value(cRows), 0,
468 }

◆ bottomLeftCorner() [6/6]

template<typename NRowsType , typename NColsType >
ConstFixedBlockXpr<...,...>::Type bottomLeftCorner ( NRowsType  cRows,
NColsType  cCols 
) const
inline

This is the const version of bottomLeftCorner(NRowsType, NColsType).

Definition at line 478 of file BlockMethods.h.

479 {
480  return typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
481  (derived(), rows() - internal::get_runtime_value(cRows), 0,
483 }

◆ bottomRightCorner() [1/6]

template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<CRows,CCols>::Type bottomRightCorner ( )
inline
Returns
an expression of a fixed-size bottom-right corner of *this.

The template parameters CRows and CCols are the number of rows and columns in the corner.

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.bottomRightCorner<2,2>():" << endl;
cout << m.bottomRightCorner<2,2>() << endl;
m.bottomRightCorner<2,2>().setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is m.bottomRightCorner<2,2>():
0 9
3 9
Now the matrix m is:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  0
 6  6  0  0
See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 390 of file BlockMethods.h.

391 {
392  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, cols() - CCols);
393 }

◆ bottomRightCorner() [2/6]

template<int CRows, int CCols>
const ConstFixedBlockXpr<CRows,CCols>::Type bottomRightCorner ( ) const
inline

This is the const version of bottomRightCorner<int, int>().

Definition at line 398 of file BlockMethods.h.

399 {
400  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, cols() - CCols);
401 }

◆ bottomRightCorner() [3/6]

template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<CRows,CCols>::Type bottomRightCorner ( Index  cRows,
Index  cCols 
)
inline
Returns
an expression of a bottom-right corner of *this.
Template Parameters
CRowsnumber of rows in corner as specified at compile-time
CColsnumber of columns in corner as specified at compile-time
Parameters
cRowsnumber of rows in corner as specified at run-time
cColsnumber of columns in corner as specified at run-time

This function is mainly useful for corners where the number of rows is specified at compile-time and the number of columns is specified at run-time, or vice versa. The compile-time and run-time information should not contradict. In other words, cRows should equal CRows unless CRows is Dynamic, and the same for the number of columns.

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.bottomRightCorner<2,Dynamic>(2,2):" << endl;
cout << m.bottomRightCorner<2,Dynamic>(2,2) << endl;
m.bottomRightCorner<2,Dynamic>(2,2).setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is m.bottomRightCorner<2,Dynamic>(2,2):
0 9
3 9
Now the matrix m is:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  0
 6  6  0  0
See also
class Block

Definition at line 424 of file BlockMethods.h.

425 {
426  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
427 }

◆ bottomRightCorner() [4/6]

template<int CRows, int CCols>
const ConstFixedBlockXpr<CRows,CCols>::Type bottomRightCorner ( Index  cRows,
Index  cCols 
) const
inline

This is the const version of bottomRightCorner<int, int>(Index, Index).

Definition at line 432 of file BlockMethods.h.

433 {
434  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
435 }

◆ bottomRightCorner() [5/6]

template<typename NRowsType , typename NColsType >
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<...,...>::Type bottomRightCorner ( NRowsType  cRows,
NColsType  cCols 
)
inline
Returns
an expression of a bottom-right corner of *this with either dynamic or fixed sizes.
Parameters
cRowsthe number of rows in the corner
cColsthe number of columns in the corner
Template Parameters
NRowsTypethe type of the value handling the number of rows in the block, typically Index.
NColsTypethe type of the value handling the number of columns in the block, typically Index.

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.bottomRightCorner(2, 2):" << endl;
cout << m.bottomRightCorner(2, 2) << endl;
m.bottomRightCorner(2, 2).setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is m.bottomRightCorner(2, 2):
0 9
3 9
Now the matrix m is:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  0
 6  6  0  0

The number of rows blockRows and columns blockCols can also be specified at compile-time by passing Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See block() for the details.

See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 355 of file BlockMethods.h.

356 {
357  return typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
358  (derived(), rows() - internal::get_runtime_value(cRows), cols() - internal::get_runtime_value(cCols),
360 }

◆ bottomRightCorner() [6/6]

template<typename NRowsType , typename NColsType >
const ConstFixedBlockXpr<...,...>::Type bottomRightCorner ( NRowsType  cRows,
NColsType  cCols 
) const
inline

This is the const version of bottomRightCorner(NRowsType, NColsType).

Definition at line 370 of file BlockMethods.h.

371 {
372  return typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
373  (derived(), rows() - internal::get_runtime_value(cRows), cols() - internal::get_runtime_value(cCols),
375 }

◆ bottomRows() [1/4]

template<int N>
NRowsBlockXpr<N>::Type bottomRows ( Index  n = N)
inline
Returns
a block consisting of the bottom rows of *this.
Template Parameters
Nthe number of rows in the block as specified at compile-time
Parameters
nthe number of rows in the block as specified at run-time

The compile-time and run-time information should not contradict. In other words, n should equal N unless N is Dynamic.

Example:

Array44i a = Array44i::Random();
cout << "Here is the array a:" << endl << a << endl;
cout << "Here is a.bottomRows<2>():" << endl;
cout << a.bottomRows<2>() << endl;
a.bottomRows<2>().setZero();
cout << "Now the array a is:" << endl << a << endl;
Array< int, 4, 4 > Array44i
Definition: Array.h:344

Output:

Here is the array a:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is a.bottomRows<2>():
 6 -3  0  9
 6  6  3  9
Now the array a is:
 7  9 -5 -3
-2 -6  1  0
 0  0  0  0
 0  0  0  0
See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 682 of file BlockMethods.h.

683 {
684  return typename NRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
685 }
int n

◆ bottomRows() [2/4]

template<int N>
ConstNRowsBlockXpr<N>::Type bottomRows ( Index  n = N) const
inline

This is the const version of bottomRows<int>().

Definition at line 690 of file BlockMethods.h.

691 {
692  return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
693 }

◆ bottomRows() [3/4]

template<typename NRowsType >
NRowsBlockXpr<...>::Type bottomRows ( NRowsType  n)
inline
Returns
a block consisting of the bottom rows of *this.
Parameters
nthe number of rows in the block
Template Parameters
NRowsTypethe type of the value handling the number of rows in the block, typically Index.

Example:

Array44i a = Array44i::Random();
cout << "Here is the array a:" << endl << a << endl;
cout << "Here is a.bottomRows(2):" << endl;
cout << a.bottomRows(2) << endl;
a.bottomRows(2).setZero();
cout << "Now the array a is:" << endl << a << endl;

Output:

Here is the array a:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is a.bottomRows(2):
 6 -3  0  9
 6  6  3  9
Now the array a is:
 7  9 -5 -3
-2 -6  1  0
 0  0  0  0
 0  0  0  0

The number of rows n can also be specified at compile-time by passing Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See block() for the details.

See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 645 of file BlockMethods.h.

646 {
647  return typename NRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type
649 }

◆ bottomRows() [4/4]

template<typename NRowsType >
const ConstNRowsBlockXpr<...>::Type bottomRows ( NRowsType  n) const
inline

This is the const version of bottomRows(NRowsType).

Definition at line 659 of file BlockMethods.h.

660 {
661  return typename ConstNRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type
663 }

◆ col()

ConstColXpr col ( Index  i)
inline

This is the const version of col().

Returns
an expression of the i-th column of *this. Note that the numbering starts at 0.

Example:

Matrix3d m = Matrix3d::Identity();
m.col(1) = Vector3d(4,5,6);
cout << m << endl;
Matrix< double, 3, 3 > Matrix3d
3×3 matrix of type double.
Definition: Matrix.h:502
Matrix< double, 3, 1 > Vector3d
3×1 vector of type double.
Definition: Matrix.h:502

Output:

1 4 0
0 5 0
0 6 1
See also
row(), class Block

Definition at line 1097 of file BlockMethods.h.

1098 {
1099  return ColXpr(derived(), i);
1100 }

◆ head() [1/4]

template<int N>
FixedSegmentReturnType<N>::Type head ( Index  n = N)
inline
Returns
a fixed-size expression of the first coefficients of *this.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

Template Parameters
Nthe number of coefficients in the segment as specified at compile-time
Parameters
nthe number of coefficients in the segment as specified at run-time

The compile-time and run-time information should not contradict. In other words, n should equal N unless N is Dynamic.

Example:

RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.head(2):" << endl << v.head<2>() << endl;
v.head<2>().setZero();
cout << "Now the vector v is:" << endl << v << endl;
Array< int, Dynamic, 1 > v
Matrix< int, 1, 4 > RowVector4i
1×4 vector of type int.
Definition: Matrix.h:500

Output:

Here is the vector v:
 7 -2  6  6
Here is v.head(2):
 7 -2
Now the vector v is:
0 0 6 6
See also
head(NType), class Block

Definition at line 1329 of file BlockMethods.h.

1330 {
1332  return typename FixedSegmentReturnType<N>::Type(derived(), 0, n);
1333 }
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition: StaticAssert.h:36

◆ head() [2/4]

template<int N>
ConstFixedSegmentReturnType<N>::Type head ( Index  n = N) const
inline

This is the const version of head<int>().

Definition at line 1338 of file BlockMethods.h.

1339 {
1341  return typename ConstFixedSegmentReturnType<N>::Type(derived(), 0, n);
1342 }

◆ head() [3/4]

template<typename NType >
FixedSegmentReturnType<...>::Type head ( NType  n)
inline
Returns
an expression of the first coefficients of *this with either dynamic or fixed sizes.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

Parameters
nthe number of coefficients in the segment
Template Parameters
NTypethe type of the value handling the number of coefficients in the segment, typically Index.

Example:

RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.head(2):" << endl << v.head(2) << endl;
v.head(2).setZero();
cout << "Now the vector v is:" << endl << v << endl;

Output:

Here is the vector v:
 7 -2  6  6
Here is v.head(2):
 7 -2
Now the vector v is:
0 0 6 6

The number of coefficients n can also be specified at compile-time by passing Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See block() for the details.

Note
Even in the case that the returned expression has dynamic size, in the case when it is applied to a fixed-size vector, it inherits a fixed maximal size, which means that evaluating it does not cause a dynamic memory allocation.
See also
class Block, block(Index,Index)

Definition at line 1208 of file BlockMethods.h.

1209 {
1211  return typename FixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type
1212  (derived(), 0, internal::get_runtime_value(n));
1213 }

◆ head() [4/4]

template<typename NType >
const ConstFixedSegmentReturnType<...>::Type head ( NType  n) const
inline

This is the const version of head(NType).

Definition at line 1223 of file BlockMethods.h.

1224 {
1226  return typename ConstFixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type
1227  (derived(), 0, internal::get_runtime_value(n));
1228 }

◆ innerVector()

const ConstInnerVectorReturnType innerVector ( Index  outer)
inline
Returns
the outer -th column (resp. row) of the matrix *this if *this is col-major (resp. row-major).
the outer -th column (resp. row) of the matrix *this if *this is col-major (resp. row-major). Read-only.

Definition at line 1380 of file BlockMethods.h.

1381 { return InnerVectorReturnType(derived(), outer); }

◆ innerVectors()

const ConstInnerVectorsReturnType innerVectors ( Index  outerStart,
Index  outerSize 
)
inline
Returns
the outer -th column (resp. row) of the matrix *this if *this is col-major (resp. row-major).
the outer -th column (resp. row) of the matrix *this if *this is col-major (resp. row-major). Read-only.

Definition at line 1395 of file BlockMethods.h.

1396 {
1397  return Block<Derived,Dynamic,Dynamic,true>(derived(),
1398  IsRowMajor ? outerStart : 0, IsRowMajor ? 0 : outerStart,
1399  IsRowMajor ? outerSize : rows(), IsRowMajor ? cols() : outerSize);
1400 
1401 }

◆ leftCols() [1/4]

template<int N>
NColsBlockXpr<N>::Type leftCols ( Index  n = N)
inline
Returns
a block consisting of the left columns of *this.
Template Parameters
Nthe number of columns in the block as specified at compile-time
Parameters
nthe number of columns in the block as specified at run-time

The compile-time and run-time information should not contradict. In other words, n should equal N unless N is Dynamic.

Example:

Array44i a = Array44i::Random();
cout << "Here is the array a:" << endl << a << endl;
cout << "Here is a.leftCols<2>():" << endl;
cout << a.leftCols<2>() << endl;
a.leftCols<2>().setZero();
cout << "Now the array a is:" << endl << a << endl;

Output:

Here is the array a:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is a.leftCols<2>():
 7  9
-2 -6
 6 -3
 6  6
Now the array a is:
 0  0 -5 -3
 0  0  1  0
 0  0  0  9
 0  0  3  9
See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 834 of file BlockMethods.h.

835 {
836  return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
837 }

◆ leftCols() [2/4]

template<int N>
ConstNColsBlockXpr<N>::Type leftCols ( Index  n = N) const
inline

This is the const version of leftCols<int>().

Definition at line 842 of file BlockMethods.h.

843 {
844  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
845 }

◆ leftCols() [3/4]

template<typename NColsType >
NColsBlockXpr<...>::Type leftCols ( NColsType  n)
inline
Returns
a block consisting of the left columns of *this.
Parameters
nthe number of columns in the block
Template Parameters
NColsTypethe type of the value handling the number of columns in the block, typically Index.

Example:

Array44i a = Array44i::Random();
cout << "Here is the array a:" << endl << a << endl;
cout << "Here is a.leftCols(2):" << endl;
cout << a.leftCols(2) << endl;
a.leftCols(2).setZero();
cout << "Now the array a is:" << endl << a << endl;

Output:

Here is the array a:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is a.leftCols(2):
 7  9
-2 -6
 6 -3
 6  6
Now the array a is:
 0  0 -5 -3
 0  0  1  0
 0  0  0  9
 0  0  3  9

The number of columns n can also be specified at compile-time by passing Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See block() for the details.

See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 797 of file BlockMethods.h.

798 {
799  return typename NColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type
800  (derived(), 0, 0, rows(), internal::get_runtime_value(n));
801 }

◆ leftCols() [4/4]

template<typename NColsType >
const ConstNColsBlockXpr<...>::Type leftCols ( NColsType  n) const
inline

This is the const version of leftCols(NColsType).

Definition at line 811 of file BlockMethods.h.

812 {
813  return typename ConstNColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type
814  (derived(), 0, 0, rows(), internal::get_runtime_value(n));
815 }

◆ middleCols() [1/4]

template<int N>
NColsBlockXpr<N>::Type middleCols ( Index  startCol,
Index  n = N 
)
inline
Returns
a block consisting of a range of columns of *this.
Template Parameters
Nthe number of columns in the block as specified at compile-time
Parameters
startColthe index of the first column in the block
nthe number of columns in the block as specified at run-time

The compile-time and run-time information should not contradict. In other words, n should equal N unless N is Dynamic.

Example:

#include <Eigen/Core>
#include <iostream>
int main()
{
int const N = 5;
A.setRandom();
std::cout << "A =\n" << A << '\n' << std::endl;
std::cout << "A(:,1..3) =\n" << A.middleCols<3>(1) << std::endl;
return 0;
}
MatrixXcf A
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
int main(int, char **)
Definition: class_Block.cpp:18

Output:

A =
  7  -6   0   9 -10
 -2  -3   3   3  -5
  6   6  -3   5  -8
  6  -5   0  -8   6
  9   1   9   2  -7

A(:,1..3) =
-6  0  9
-3  3  3
 6 -3  5
-5  0 -8
 1  9  2
See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 986 of file BlockMethods.h.

987 {
988  return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
989 }

◆ middleCols() [2/4]

template<int N>
ConstNColsBlockXpr<N>::Type middleCols ( Index  startCol,
Index  n = N 
) const
inline

This is the const version of middleCols<int>().

Definition at line 994 of file BlockMethods.h.

995 {
996  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
997 }

◆ middleCols() [3/4]

template<typename NColsType >
NColsBlockXpr<...>::Type middleCols ( Index  startCol,
NColsType  numCols 
)
inline
Returns
a block consisting of a range of columns of *this.
Parameters
startColthe index of the first column in the block
numColsthe number of columns in the block
Template Parameters
NColsTypethe type of the value handling the number of columns in the block, typically Index.

Example:

#include <Eigen/Core>
#include <iostream>
int main()
{
int const N = 5;
A.setRandom();
std::cout << "A =\n" << A << '\n' << std::endl;
std::cout << "A(1..3,:) =\n" << A.middleCols(1,3) << std::endl;
return 0;
}

Output:

A =
  7  -6   0   9 -10
 -2  -3   3   3  -5
  6   6  -3   5  -8
  6  -5   0  -8   6
  9   1   9   2  -7

A(1..3,:) =
-6  0  9
-3  3  3
 6 -3  5
-5  0 -8
 1  9  2

The number of columns n can also be specified at compile-time by passing Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See block() for the details.

See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 948 of file BlockMethods.h.

949 {
950  return typename NColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type
951  (derived(), 0, startCol, rows(), internal::get_runtime_value(numCols));
952 }

◆ middleCols() [4/4]

template<typename NColsType >
const ConstNColsBlockXpr<...>::Type middleCols ( Index  startCol,
NColsType  numCols 
) const
inline

This is the const version of middleCols(Index,NColsType).

Definition at line 962 of file BlockMethods.h.

963 {
964  return typename ConstNColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type
965  (derived(), 0, startCol, rows(), internal::get_runtime_value(numCols));
966 }

◆ middleRows() [1/4]

template<int N>
NRowsBlockXpr<N>::Type middleRows ( Index  startRow,
Index  n = N 
)
inline
Returns
a block consisting of a range of rows of *this.
Template Parameters
Nthe number of rows in the block as specified at compile-time
Parameters
startRowthe index of the first row in the block
nthe number of rows in the block as specified at run-time

The compile-time and run-time information should not contradict. In other words, n should equal N unless N is Dynamic.

Example:

#include <Eigen/Core>
#include <iostream>
int main()
{
int const N = 5;
A.setRandom();
std::cout << "A =\n" << A << '\n' << std::endl;
std::cout << "A(1..3,:) =\n" << A.middleRows<3>(1) << std::endl;
return 0;
}

Output:

A =
  7  -6   0   9 -10
 -2  -3   3   3  -5
  6   6  -3   5  -8
  6  -5   0  -8   6
  9   1   9   2  -7

A(1..3,:) =
-2 -3  3  3 -5
 6  6 -3  5 -8
 6 -5  0 -8  6
See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 759 of file BlockMethods.h.

760 {
761  return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
762 }

◆ middleRows() [2/4]

template<int N>
ConstNRowsBlockXpr<N>::Type middleRows ( Index  startRow,
Index  n = N 
) const
inline

This is the const version of middleRows<int>().

Definition at line 767 of file BlockMethods.h.

768 {
769  return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
770 }

◆ middleRows() [3/4]

template<typename NRowsType >
NRowsBlockXpr<...>::Type middleRows ( Index  startRow,
NRowsType  n 
)
inline
Returns
a block consisting of a range of rows of *this.
Parameters
startRowthe index of the first row in the block
nthe number of rows in the block
Template Parameters
NRowsTypethe type of the value handling the number of rows in the block, typically Index.

Example:

#include <Eigen/Core>
#include <iostream>
int main()
{
int const N = 5;
A.setRandom();
std::cout << "A =\n" << A << '\n' << std::endl;
std::cout << "A(2..3,:) =\n" << A.middleRows(2,2) << std::endl;
return 0;
}

Output:

A =
  7  -6   0   9 -10
 -2  -3   3   3  -5
  6   6  -3   5  -8
  6  -5   0  -8   6
  9   1   9   2  -7

A(2..3,:) =
 6  6 -3  5 -8
 6 -5  0 -8  6

The number of rows n can also be specified at compile-time by passing Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See block() for the details.

See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 721 of file BlockMethods.h.

722 {
723  return typename NRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type
724  (derived(), startRow, 0, internal::get_runtime_value(n), cols());
725 }

◆ middleRows() [4/4]

template<typename NRowsType >
const ConstNRowsBlockXpr<...>::Type middleRows ( Index  startRow,
NRowsType  n 
) const
inline

This is the const version of middleRows(Index,NRowsType).

Definition at line 735 of file BlockMethods.h.

736 {
737  return typename ConstNRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type
738  (derived(), startRow, 0, internal::get_runtime_value(n), cols());
739 }

◆ rightCols() [1/4]

template<int N>
NColsBlockXpr<N>::Type rightCols ( Index  n = N)
inline
Returns
a block consisting of the right columns of *this.
Template Parameters
Nthe number of columns in the block as specified at compile-time
Parameters
nthe number of columns in the block as specified at run-time

The compile-time and run-time information should not contradict. In other words, n should equal N unless N is Dynamic.

Example:

Array44i a = Array44i::Random();
cout << "Here is the array a:" << endl << a << endl;
cout << "Here is a.rightCols<2>():" << endl;
cout << a.rightCols<2>() << endl;
a.rightCols<2>().setZero();
cout << "Now the array a is:" << endl << a << endl;

Output:

Here is the array a:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is a.rightCols<2>():
-5 -3
 1  0
 0  9
 3  9
Now the array a is:
 7  9  0  0
-2 -6  0  0
 6 -3  0  0
 6  6  0  0
See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 909 of file BlockMethods.h.

910 {
911  return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
912 }

◆ rightCols() [2/4]

template<int N>
ConstNColsBlockXpr<N>::Type rightCols ( Index  n = N) const
inline

This is the const version of rightCols<int>().

Definition at line 917 of file BlockMethods.h.

918 {
919  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
920 }

◆ rightCols() [3/4]

template<typename NColsType >
NColsBlockXpr<...>::Type rightCols ( NColsType  n)
inline
Returns
a block consisting of the right columns of *this.
Parameters
nthe number of columns in the block
Template Parameters
NColsTypethe type of the value handling the number of columns in the block, typically Index.

Example:

Array44i a = Array44i::Random();
cout << "Here is the array a:" << endl << a << endl;
cout << "Here is a.rightCols(2):" << endl;
cout << a.rightCols(2) << endl;
a.rightCols(2).setZero();
cout << "Now the array a is:" << endl << a << endl;

Output:

Here is the array a:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is a.rightCols(2):
-5 -3
 1  0
 0  9
 3  9
Now the array a is:
 7  9  0  0
-2 -6  0  0
 6 -3  0  0
 6  6  0  0

The number of columns n can also be specified at compile-time by passing Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See block() for the details.

See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 872 of file BlockMethods.h.

873 {
874  return typename NColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type
876 }

◆ rightCols() [4/4]

template<typename NColsType >
const ConstNColsBlockXpr<...>::Type rightCols ( NColsType  n) const
inline

This is the const version of rightCols(NColsType).

Definition at line 886 of file BlockMethods.h.

887 {
888  return typename ConstNColsBlockXpr<internal::get_fixed_value<NColsType>::value>::Type
890 }

◆ row()

ConstRowXpr row ( Index  i)
inline

This is the const version of row(). *‍/.

Returns
an expression of the i-th row of *this. Note that the numbering starts at 0.

Example:

Matrix3d m = Matrix3d::Identity();
m.row(1) = Vector3d(4,5,6);
cout << m << endl;

Output:

1 0 0
4 5 6
0 0 1
See also
col(), class Block

Definition at line 1118 of file BlockMethods.h.

1119 {
1120  return RowXpr(derived(), i);
1121 }

◆ segment() [1/4]

template<int N>
FixedSegmentReturnType<N>::Type segment ( Index  start,
Index  n = N 
)
inline
Returns
a fixed-size expression of a segment (i.e. a vector block) in *this

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

Template Parameters
Nthe number of coefficients in the segment as specified at compile-time
Parameters
startthe index of the first element in the segment
nthe number of coefficients in the segment as specified at compile-time

The compile-time and run-time information should not contradict. In other words, n should equal N unless N is Dynamic.

Example:

RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.segment<2>(1):" << endl << v.segment<2>(1) << endl;
v.segment<2>(2).setZero();
cout << "Now the vector v is:" << endl << v << endl;

Output:

Here is the vector v:
 7 -2  6  6
Here is v.segment<2>(1):
-2  6
Now the vector v is:
 7 -2  0  0
See also
segment(Index,NType), class Block

Definition at line 1297 of file BlockMethods.h.

1298 {
1300  return typename FixedSegmentReturnType<N>::Type(derived(), start, n);
1301 }

◆ segment() [2/4]

template<int N>
ConstFixedSegmentReturnType<N>::Type segment ( Index  start,
Index  n = N 
) const
inline

This is the const version of segment<int>(Index).

Definition at line 1306 of file BlockMethods.h.

1307 {
1309  return typename ConstFixedSegmentReturnType<N>::Type(derived(), start, n);
1310 }

◆ segment() [3/4]

template<typename NType >
FixedSegmentReturnType<...>::Type segment ( Index  start,
NType  n 
)
inline
Returns
an expression of a segment (i.e. a vector block) in *this with either dynamic or fixed sizes.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

Parameters
startthe first coefficient in the segment
nthe number of coefficients in the segment
Template Parameters
NTypethe type of the value handling the number of coefficients in the segment, typically Index.

Example:

RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.segment(1, 2):" << endl << v.segment(1, 2) << endl;
v.segment(1, 2).setZero();
cout << "Now the vector v is:" << endl << v << endl;

Output:

Here is the vector v:
 7 -2  6  6
Here is v.segment(1, 2):
-2  6
Now the vector v is:
7 0 0 6

The number of coefficients n can also be specified at compile-time by passing Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See block() for the details.

Note
Even in the case that the returned expression has dynamic size, in the case when it is applied to a fixed-size vector, it inherits a fixed maximal size, which means that evaluating it does not cause a dynamic memory allocation.
See also
block(Index,Index,NRowsType,NColsType), fix<N>, fix<N>(int), class Block

Definition at line 1158 of file BlockMethods.h.

1159 {
1161  return typename FixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type
1162  (derived(), start, internal::get_runtime_value(n));
1163 }

◆ segment() [4/4]

template<typename NType >
const ConstFixedSegmentReturnType<...>::Type segment ( Index  start,
NType  n 
) const
inline

This is the const version of segment(Index,NType).

Definition at line 1174 of file BlockMethods.h.

1175 {
1177  return typename ConstFixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type
1178  (derived(), start, internal::get_runtime_value(n));
1179 }

◆ subVector() [1/2]

template<DirectionType Direction>
std::conditional_t<Direction==Vertical,ColXpr,RowXpr> subVector ( Index  i)
inline
Returns
the i-th subvector (column or vector) according to the Direction
See also
subVectors()

Definition at line 1422 of file BlockMethods.h.

1423 {
1424  return std::conditional_t<Direction==Vertical,ColXpr,RowXpr>(derived(),i);
1425 }

◆ subVector() [2/2]

template<DirectionType Direction>
std::conditional_t<Direction==Vertical,ConstColXpr,ConstRowXpr> subVector ( Index  i) const
inline

This is the const version of subVector(Index)

Definition at line 1431 of file BlockMethods.h.

1432 {
1433  return std::conditional_t<Direction==Vertical,ConstColXpr,ConstRowXpr>(derived(),i);
1434 }

◆ subVectors()

template<DirectionType Direction>
EIGEN_CONSTEXPR Index subVectors ( ) const
inline
Returns
the number of subvectors (rows or columns) in the direction Direction
See also
subVector(Index)

Definition at line 1441 of file BlockMethods.h.

1442 { return (Direction==Vertical)?cols():rows(); }
@ Vertical
Definition: Constants.h:266

◆ tail() [1/4]

template<int N>
FixedSegmentReturnType<N>::Type tail ( Index  n = N)
inline
Returns
a fixed-size expression of the last coefficients of *this.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

Template Parameters
Nthe number of coefficients in the segment as specified at compile-time
Parameters
nthe number of coefficients in the segment as specified at run-time

The compile-time and run-time information should not contradict. In other words, n should equal N unless N is Dynamic.

Example:

RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.tail(2):" << endl << v.tail<2>() << endl;
v.tail<2>().setZero();
cout << "Now the vector v is:" << endl << v << endl;

Output:

Here is the vector v:
 7 -2  6  6
Here is v.tail(2):
6 6
Now the vector v is:
 7 -2  0  0
See also
tail(NType), class Block

Definition at line 1361 of file BlockMethods.h.

1362 {
1364  return typename FixedSegmentReturnType<N>::Type(derived(), size() - n);
1365 }

◆ tail() [2/4]

template<int N>
ConstFixedSegmentReturnType<N>::Type tail ( Index  n = N) const
inline

This is the const version of tail<int>.

Definition at line 1370 of file BlockMethods.h.

1371 {
1373  return typename ConstFixedSegmentReturnType<N>::Type(derived(), size() - n);
1374 }

◆ tail() [3/4]

template<typename NType >
FixedSegmentReturnType<...>::Type tail ( NType  n)
inline
Returns
an expression of a last coefficients of *this with either dynamic or fixed sizes.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

Parameters
nthe number of coefficients in the segment
Template Parameters
NTypethe type of the value handling the number of coefficients in the segment, typically Index.

Example:

RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.tail(2):" << endl << v.tail(2) << endl;
v.tail(2).setZero();
cout << "Now the vector v is:" << endl << v << endl;

Output:

Here is the vector v:
 7 -2  6  6
Here is v.tail(2):
6 6
Now the vector v is:
 7 -2  0  0

The number of coefficients n can also be specified at compile-time by passing Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See block() for the details.

Note
Even in the case that the returned expression has dynamic size, in the case when it is applied to a fixed-size vector, it inherits a fixed maximal size, which means that evaluating it does not cause a dynamic memory allocation.
See also
class Block, block(Index,Index)

Definition at line 1257 of file BlockMethods.h.

1258 {
1260  return typename FixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type
1262 }

◆ tail() [4/4]

template<typename NType >
const ConstFixedSegmentReturnType<...>::Type tail ( NType  n) const
inline

This is the const version of tail(Index).

Definition at line 1272 of file BlockMethods.h.

1273 {
1275  return typename ConstFixedSegmentReturnType<internal::get_fixed_value<NType>::value>::Type
1277 }

◆ topLeftCorner() [1/6]

template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<CRows,CCols>::Type topLeftCorner ( )
inline
Returns
an expression of a fixed-size top-left corner of *this.

The template parameters CRows and CCols are the number of rows and columns in the corner.

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.topLeftCorner<2,2>():" << endl;
cout << m.topLeftCorner<2,2>() << endl;
m.topLeftCorner<2,2>().setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is m.topLeftCorner<2,2>():
 7  9
-2 -6
Now the matrix m is:
 0  0 -5 -3
 0  0  1  0
 6 -3  0  9
 6  6  3  9
See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 282 of file BlockMethods.h.

283 {
284  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0);
285 }

◆ topLeftCorner() [2/6]

template<int CRows, int CCols>
const ConstFixedBlockXpr<CRows,CCols>::Type topLeftCorner ( ) const
inline

This is the const version of topLeftCorner<int, int>().

Definition at line 290 of file BlockMethods.h.

291 {
292  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0);
293 }

◆ topLeftCorner() [3/6]

template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<CRows,CCols>::Type topLeftCorner ( Index  cRows,
Index  cCols 
)
inline
Returns
an expression of a top-left corner of *this.
Template Parameters
CRowsnumber of rows in corner as specified at compile-time
CColsnumber of columns in corner as specified at compile-time
Parameters
cRowsnumber of rows in corner as specified at run-time
cColsnumber of columns in corner as specified at run-time

This function is mainly useful for corners where the number of rows is specified at compile-time and the number of columns is specified at run-time, or vice versa. The compile-time and run-time information should not contradict. In other words, cRows should equal CRows unless CRows is Dynamic, and the same for the number of columns.

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.topLeftCorner<2,Dynamic>(2,2):" << endl;
cout << m.topLeftCorner<2,Dynamic>(2,2) << endl;
m.topLeftCorner<2,Dynamic>(2,2).setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is m.topLeftCorner<2,Dynamic>(2,2):
 7  9
-2 -6
Now the matrix m is:
 0  0 -5 -3
 0  0  1  0
 6 -3  0  9
 6  6  3  9
See also
class Block

Definition at line 316 of file BlockMethods.h.

317 {
318  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0, cRows, cCols);
319 }

◆ topLeftCorner() [4/6]

template<int CRows, int CCols>
const ConstFixedBlockXpr<CRows,CCols>::Type topLeftCorner ( Index  cRows,
Index  cCols 
) const
inline

This is the const version of topLeftCorner<int, int>(Index, Index).

Definition at line 324 of file BlockMethods.h.

325 {
326  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0, cRows, cCols);
327 }

◆ topLeftCorner() [5/6]

template<typename NRowsType , typename NColsType >
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<...,...>::Type topLeftCorner ( NRowsType  cRows,
NColsType  cCols 
)
inline
Returns
an expression of a top-left corner of *this with either dynamic or fixed sizes.
Parameters
cRowsthe number of rows in the corner
cColsthe number of columns in the corner
Template Parameters
NRowsTypethe type of the value handling the number of rows in the block, typically Index.
NColsTypethe type of the value handling the number of columns in the block, typically Index.

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.topLeftCorner(2, 2):" << endl;
cout << m.topLeftCorner(2, 2) << endl;
m.topLeftCorner(2, 2).setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is m.topLeftCorner(2, 2):
 7  9
-2 -6
Now the matrix m is:
 0  0 -5 -3
 0  0  1  0
 6 -3  0  9
 6  6  3  9

The number of rows blockRows and columns blockCols can also be specified at compile-time by passing Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See block() for the details.

See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 249 of file BlockMethods.h.

250 {
251  return typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
252  (derived(), 0, 0, internal::get_runtime_value(cRows), internal::get_runtime_value(cCols));
253 }

◆ topLeftCorner() [6/6]

template<typename NRowsType , typename NColsType >
const ConstFixedBlockXpr<...,...>::Type topLeftCorner ( NRowsType  cRows,
NColsType  cCols 
) const
inline

This is the const version of topLeftCorner(Index, Index).

Definition at line 263 of file BlockMethods.h.

264 {
265  return typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
266  (derived(), 0, 0, internal::get_runtime_value(cRows), internal::get_runtime_value(cCols));
267 }

◆ topRightCorner() [1/6]

template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<CRows,CCols>::Type topRightCorner ( )
inline
Returns
an expression of a fixed-size top-right corner of *this.
Template Parameters
CRowsthe number of rows in the corner
CColsthe number of columns in the corner

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.topRightCorner<2,2>():" << endl;
cout << m.topRightCorner<2,2>() << endl;
m.topRightCorner<2,2>().setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is m.topRightCorner<2,2>():
-5 -3
 1  0
Now the matrix m is:
 7  9  0  0
-2 -6  0  0
 6 -3  0  9
 6  6  3  9
See also
class Block, block<int,int>(Index,Index)

Definition at line 176 of file BlockMethods.h.

177 {
178  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - CCols);
179 }

◆ topRightCorner() [2/6]

template<int CRows, int CCols>
const ConstFixedBlockXpr<CRows,CCols>::Type topRightCorner ( ) const
inline

This is the const version of topRightCorner<int, int>().

Definition at line 184 of file BlockMethods.h.

185 {
186  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - CCols);
187 }

◆ topRightCorner() [3/6]

template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<CRows,CCols>::Type topRightCorner ( Index  cRows,
Index  cCols 
)
inline
Returns
an expression of a top-right corner of *this.
Template Parameters
CRowsnumber of rows in corner as specified at compile-time
CColsnumber of columns in corner as specified at compile-time
Parameters
cRowsnumber of rows in corner as specified at run-time
cColsnumber of columns in corner as specified at run-time

This function is mainly useful for corners where the number of rows is specified at compile-time and the number of columns is specified at run-time, or vice versa. The compile-time and run-time information should not contradict. In other words, cRows should equal CRows unless CRows is Dynamic, and the same for the number of columns.

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.topRightCorner<2,Dynamic>(2,2):" << endl;
cout << m.topRightCorner<2,Dynamic>(2,2) << endl;
m.topRightCorner<2,Dynamic>(2,2).setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is m.topRightCorner<2,Dynamic>(2,2):
-5 -3
 1  0
Now the matrix m is:
 7  9  0  0
-2 -6  0  0
 6 -3  0  9
 6  6  3  9
See also
class Block

Definition at line 210 of file BlockMethods.h.

211 {
212  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - cCols, cRows, cCols);
213 }

◆ topRightCorner() [4/6]

template<int CRows, int CCols>
const ConstFixedBlockXpr<CRows,CCols>::Type topRightCorner ( Index  cRows,
Index  cCols 
) const
inline

This is the const version of topRightCorner<int, int>(Index, Index).

Definition at line 218 of file BlockMethods.h.

219 {
220  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - cCols, cRows, cCols);
221 }

◆ topRightCorner() [5/6]

template<typename NRowsType , typename NColsType >
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL FixedBlockXpr<...,...>::Type topRightCorner ( NRowsType  cRows,
NColsType  cCols 
)
inline
Returns
a expression of a top-right corner of *this with either dynamic or fixed sizes.
Parameters
cRowsthe number of rows in the corner
cColsthe number of columns in the corner
Template Parameters
NRowsTypethe type of the value handling the number of rows in the block, typically Index.
NColsTypethe type of the value handling the number of columns in the block, typically Index.

Example with dynamic sizes:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.topRightCorner(2, 2):" << endl;
cout << m.topRightCorner(2, 2) << endl;
m.topRightCorner(2, 2).setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is m.topRightCorner(2, 2):
-5 -3
 1  0
Now the matrix m is:
 7  9  0  0
-2 -6  0  0
 6 -3  0  9
 6  6  3  9

The number of rows blockRows and columns blockCols can also be specified at compile-time by passing Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See block() for the details.

See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 142 of file BlockMethods.h.

143 {
144  return typename FixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
146 }

◆ topRightCorner() [6/6]

template<typename NRowsType , typename NColsType >
const ConstFixedBlockXpr<...,...>::Type topRightCorner ( NRowsType  cRows,
NColsType  cCols 
) const
inline

This is the const version of topRightCorner(NRowsType, NColsType).

Definition at line 156 of file BlockMethods.h.

157 {
158  return typename ConstFixedBlockXpr<internal::get_fixed_value<NRowsType>::value,internal::get_fixed_value<NColsType>::value>::Type
160 }

◆ topRows() [1/4]

template<int N>
NRowsBlockXpr<N>::Type topRows ( Index  n = N)
inline
Returns
a block consisting of the top rows of *this.
Template Parameters
Nthe number of rows in the block as specified at compile-time
Parameters
nthe number of rows in the block as specified at run-time

The compile-time and run-time information should not contradict. In other words, n should equal N unless N is Dynamic.

Example:

Array44i a = Array44i::Random();
cout << "Here is the array a:" << endl << a << endl;
cout << "Here is a.topRows<2>():" << endl;
cout << a.topRows<2>() << endl;
a.topRows<2>().setZero();
cout << "Now the array a is:" << endl << a << endl;

Output:

Here is the array a:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is a.topRows<2>():
 7  9 -5 -3
-2 -6  1  0
Now the array a is:
 0  0  0  0
 0  0  0  0
 6 -3  0  9
 6  6  3  9
See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 607 of file BlockMethods.h.

608 {
609  return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
610 }

◆ topRows() [2/4]

template<int N>
ConstNRowsBlockXpr<N>::Type topRows ( Index  n = N) const
inline

This is the const version of topRows<int>().

Definition at line 615 of file BlockMethods.h.

616 {
617  return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
618 }

◆ topRows() [3/4]

template<typename NRowsType >
NRowsBlockXpr<...>::Type topRows ( NRowsType  n)
inline
Returns
a block consisting of the top rows of *this.
Parameters
nthe number of rows in the block
Template Parameters
NRowsTypethe type of the value handling the number of rows in the block, typically Index.

Example:

Array44i a = Array44i::Random();
cout << "Here is the array a:" << endl << a << endl;
cout << "Here is a.topRows(2):" << endl;
cout << a.topRows(2) << endl;
a.topRows(2).setZero();
cout << "Now the array a is:" << endl << a << endl;

Output:

Here is the array a:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is a.topRows(2):
 7  9 -5 -3
-2 -6  1  0
Now the array a is:
 0  0  0  0
 0  0  0  0
 6 -3  0  9
 6  6  3  9

The number of rows n can also be specified at compile-time by passing Eigen::fix<N>, or Eigen::fix<N>(n) as arguments. See block() for the details.

See also
block(Index,Index,NRowsType,NColsType), class Block

Definition at line 570 of file BlockMethods.h.

571 {
572  return typename NRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type
573  (derived(), 0, 0, internal::get_runtime_value(n), cols());
574 }

◆ topRows() [4/4]

template<typename NRowsType >
const ConstNRowsBlockXpr<...>::Type topRows ( NRowsType  n) const
inline

This is the const version of topRows(NRowsType).

Definition at line 584 of file BlockMethods.h.

585 {
586  return typename ConstNRowsBlockXpr<internal::get_fixed_value<NRowsType>::value>::Type
587  (derived(), 0, 0, internal::get_runtime_value(n), cols());
588 }