Classes | Typedefs | Functions
BlockMethods.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ConstFixedBlockXpr< Rows, Cols >
 
struct  ConstFixedSegmentReturnType< Size >
 
struct  ConstNColsBlockXpr< N >
 
struct  ConstNRowsBlockXpr< N >
 
struct  FixedBlockXpr< Rows, Cols >
 
struct  FixedSegmentReturnType< Size >
 
struct  NColsBlockXpr< N >
 
struct  NRowsBlockXpr< N >
 

Typedefs

typedef Block< Derived > BlockXpr
 
typedef Block< Derived, internal::traits< Derived >::RowsAtCompileTime, Dynamic,!IsRowMajor > ColsBlockXpr
 
typedef Block< Derived, internal::traits< Derived >::RowsAtCompileTime, 1,!IsRowMajor > ColXpr
 
typedef const Block< const Derived > ConstBlockXpr
 
typedef const Block< const Derived, internal::traits< Derived >::RowsAtCompileTime, Dynamic,!IsRowMajor > ConstColsBlockXpr
 
typedef const Block< const Derived, internal::traits< Derived >::RowsAtCompileTime, 1,!IsRowMajor > ConstColXpr
 
typedef const Block< const Derived, Dynamic, internal::traits< Derived >::ColsAtCompileTime, IsRowMajor > ConstRowsBlockXpr
 
typedef const Block< const Derived, 1, internal::traits< Derived >::ColsAtCompileTime, IsRowMajor > ConstRowXpr
 
typedef const VectorBlock< const Derived > ConstSegmentReturnType
 
typedef Block< Derived, Dynamic, internal::traits< Derived >::ColsAtCompileTime, IsRowMajor > RowsBlockXpr
 
typedef Block< Derived, 1, internal::traits< Derived >::ColsAtCompileTime, IsRowMajor > RowXpr
 
typedef VectorBlock< Derived > SegmentReturnType
 

Functions

EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC BlockXpr block (Index startRow, Index startCol, Index blockRows, Index blockCols) const
 This is the const version of block(Index,Index,Index,Index). */. More...
 
template<int NRows, int NCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC FixedBlockXpr< NRows, NCols >::Type block (Index startRow, Index startCol)
 
template<int NRows, int NCols>
EIGEN_DEVICE_FUNC const ConstFixedBlockXpr< NRows, NCols >::Type block (Index startRow, Index startCol) const
 This is the const version of block<>(Index, Index). */. More...
 
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC BlockXpr bottomLeftCorner (Index cRows, Index cCols) const
 This is the const version of bottomLeftCorner(Index, Index). More...
 
template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC FixedBlockXpr< CRows, CCols >::Type bottomLeftCorner ()
 
template<int CRows, int CCols>
EIGEN_DEVICE_FUNC const ConstFixedBlockXpr< CRows, CCols >::Type bottomLeftCorner () const
 This is the const version of bottomLeftCorner<int, int>(). More...
 
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC BlockXpr bottomRightCorner (Index cRows, Index cCols) const
 This is the const version of bottomRightCorner(Index, Index). More...
 
template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC FixedBlockXpr< CRows, CCols >::Type bottomRightCorner ()
 
template<int CRows, int CCols>
EIGEN_DEVICE_FUNC const ConstFixedBlockXpr< CRows, CCols >::Type bottomRightCorner () const
 This is the const version of bottomRightCorner<int, int>(). More...
 
EIGEN_DEVICE_FUNC RowsBlockXpr bottomRows (Index n) const
 This is the const version of bottomRows(Index). More...
 
EIGEN_DEVICE_FUNC ColXpr col (Index i) const
 This is the const version of col(). More...
 
EIGEN_DEVICE_FUNC SegmentReturnType head (Index n) const
 This is the const version of head(Index). More...
 
EIGEN_DEVICE_FUNC ColsBlockXpr leftCols (Index n) const
 This is the const version of leftCols(Index). More...
 
EIGEN_DEVICE_FUNC ColsBlockXpr middleCols (Index startCol, Index numCols) const
 This is the const version of middleCols(Index,Index). More...
 
EIGEN_DEVICE_FUNC RowsBlockXpr middleRows (Index startRow, Index n) const
 This is the const version of middleRows(Index,Index). More...
 
EIGEN_DEVICE_FUNC ColsBlockXpr rightCols (Index n) const
 This is the const version of rightCols(Index). More...
 
EIGEN_DEVICE_FUNC RowXpr row (Index i) const
 This is the const version of row(). */. More...
 
EIGEN_DEVICE_FUNC SegmentReturnType segment (Index start, Index n) const
 This is the const version of segment(Index,Index). More...
 
EIGEN_DEVICE_FUNC SegmentReturnType tail (Index n) const
 This is the const version of tail(Index). More...
 
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC BlockXpr topLeftCorner (Index cRows, Index cCols) const
 This is the const version of topLeftCorner(Index, Index). More...
 
template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC FixedBlockXpr< CRows, CCols >::Type topLeftCorner ()
 
template<int CRows, int CCols>
EIGEN_DEVICE_FUNC const ConstFixedBlockXpr< CRows, CCols >::Type topLeftCorner () const
 This is the const version of topLeftCorner<int, int>(). More...
 
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC BlockXpr topRightCorner (Index cRows, Index cCols) const
 This is the const version of topRightCorner(Index, Index). More...
 
template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC FixedBlockXpr< CRows, CCols >::Type topRightCorner ()
 
template<int CRows, int CCols>
EIGEN_DEVICE_FUNC const ConstFixedBlockXpr< CRows, CCols >::Type topRightCorner () const
 This is the const version of topRightCorner<int, int>(). More...
 
EIGEN_DEVICE_FUNC RowsBlockXpr topRows (Index n) const
 This is the const version of topRows(Index). More...
 

Typedef Documentation

typedef Block<Derived> BlockXpr

Definition at line 32 of file BlockMethods.h.

typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ColsBlockXpr

Definition at line 20 of file BlockMethods.h.

typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ColXpr

Definition at line 14 of file BlockMethods.h.

typedef const Block<const Derived> ConstBlockXpr

Definition at line 33 of file BlockMethods.h.

typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ConstColsBlockXpr

Definition at line 21 of file BlockMethods.h.

typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ConstColXpr

Definition at line 15 of file BlockMethods.h.

typedef const Block<const Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowsBlockXpr

Definition at line 24 of file BlockMethods.h.

typedef const Block<const Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowXpr

Definition at line 18 of file BlockMethods.h.

typedef const VectorBlock<const Derived> ConstSegmentReturnType

Definition at line 39 of file BlockMethods.h.

typedef Block<Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowsBlockXpr

Definition at line 23 of file BlockMethods.h.

typedef Block<Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowXpr

Definition at line 17 of file BlockMethods.h.

typedef VectorBlock<Derived> SegmentReturnType

Definition at line 38 of file BlockMethods.h.

Function Documentation

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

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

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

Returns
a dynamic-size expression of a block in *this.
Parameters
startRowthe first row in the block
startColthe first column in the block
blockRowsthe number of rows in the block
blockColsthe number of columns in the block

Example:

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:

Note
Even though 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, block(Index,Index)
Returns
an expression of a block in *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;

Output:

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;
See also
class Block, block(Index,Index,Index,Index)

Definition at line 64 of file BlockMethods.h.

template<int NRows, int NCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC FixedBlockXpr<NRows,NCols>::Type block ( Index  startRow,
Index  startCol 
)
inline
Returns
a fixed-size expression of a block in *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;

Output:

Note
since block is a templated member, the keyword template has to be used if the matrix type is also a template parameter:
1 m.template block<3,3>(1,1);
See also
class Block, block(Index,Index,Index,Index)

Definition at line 780 of file BlockMethods.h.

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

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

Definition at line 788 of file BlockMethods.h.

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

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

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

Returns
a dynamic-size expression of a bottom-left corner of *this.
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.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:

 
See also
class Block, block(Index,Index,Index,Index)
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:

 
See also
class Block

Definition at line 348 of file BlockMethods.h.

template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC 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:

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

Definition at line 373 of file BlockMethods.h.

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

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

Definition at line 381 of file BlockMethods.h.

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

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

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

Returns
a dynamic-size expression of a bottom-right corner of *this.
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.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:

 
See also
class Block, block(Index,Index,Index,Index)
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:

 
See also
class Block

Definition at line 263 of file BlockMethods.h.

template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC 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:

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

Definition at line 288 of file BlockMethods.h.

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

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

Definition at line 296 of file BlockMethods.h.

EIGEN_DEVICE_FUNC ConstNRowsBlockXpr< N >::Type bottomRows ( Index  n = N)
inline

This is the const version of bottomRows(Index).

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

Returns
a block consisting of the bottom rows of *this.
Parameters
nthe number of rows in the block

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:

 
See also
class Block, block(Index,Index,Index,Index)
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;

Output:

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

Definition at line 488 of file BlockMethods.h.

EIGEN_DEVICE_FUNC 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;

Output:

 
See also
row(), class Block

Definition at line 838 of file BlockMethods.h.

EIGEN_DEVICE_FUNC ConstFixedSegmentReturnType< N >::Type head ( Index  n = N)
inline

This is the const version of head(Index).

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

Returns
a dynamic-size expression of the first coefficients of *this.
Parameters
nthe number of coefficients in the segment

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:

Note
Even though 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)
Returns
a fixed-size expression of the first coefficients of *this.
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;

Output:

See also
class Block

Definition at line 919 of file BlockMethods.h.

EIGEN_DEVICE_FUNC ConstNColsBlockXpr< N >::Type leftCols ( Index  n = N)
inline

This is the const version of leftCols(Index).

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

Returns
a block consisting of the left columns of *this.
Parameters
nthe number of columns in the block

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:

 
See also
class Block, block(Index,Index,Index,Index)
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:

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

Definition at line 602 of file BlockMethods.h.

EIGEN_DEVICE_FUNC ConstNColsBlockXpr< N >::Type middleCols ( Index  startCol,
Index  n = N 
)
inline

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

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

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

Example:

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

Output:

 
See also
class Block, block(Index,Index,Index,Index)
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>
using namespace Eigen;
using namespace std;
int main(void)
{
int const N = 5;
MatrixXi A(N,N);
A.setRandom();
cout << "A =\n" << A << '\n' << endl;
cout << "A(:,1..3) =\n" << A.middleCols<3>(1) << endl;
return 0;
}

Output:

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

Definition at line 715 of file BlockMethods.h.

EIGEN_DEVICE_FUNC ConstNRowsBlockXpr< N >::Type middleRows ( Index  startRow,
Index  n = N 
)
inline

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

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

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

Example:

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

Output:

 
See also
class Block, block(Index,Index,Index,Index)
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>
using namespace Eigen;
using namespace std;
int main(void)
{
int const N = 5;
MatrixXi A(N,N);
A.setRandom();
cout << "A =\n" << A << '\n' << endl;
cout << "A(1..3,:) =\n" << A.middleRows<3>(1) << endl;
return 0;
}

Output:

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

Definition at line 545 of file BlockMethods.h.

EIGEN_DEVICE_FUNC ConstNColsBlockXpr< N >::Type rightCols ( Index  n = N)
inline

This is the const version of rightCols(Index).

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

Returns
a block consisting of the right columns of *this.
Parameters
nthe number of columns in the block

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:

 
See also
class Block, block(Index,Index,Index,Index)
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:

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

Definition at line 658 of file BlockMethods.h.

EIGEN_DEVICE_FUNC 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:

 
See also
col(), class Block

Definition at line 859 of file BlockMethods.h.

EIGEN_DEVICE_FUNC ConstFixedSegmentReturnType< N >::Type segment ( Index  start,
Index  n = N 
)
inline

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

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

Returns
a dynamic-size expression of a segment (i.e. a vector block) in *this.
Parameters
startthe first coefficient in the segment
nthe number of coefficients in the segment

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:

Note
Even though 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, segment(Index)
Returns
a fixed-size expression of a segment (i.e. a vector block) in *this
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:

See also
class Block

Definition at line 888 of file BlockMethods.h.

EIGEN_DEVICE_FUNC ConstFixedSegmentReturnType< N >::Type tail ( Index  n = N)
inline

This is the const version of tail(Index).

This is the const version of tail<int>.

Returns
a dynamic-size expression of the last coefficients of *this.
Parameters
nthe number of coefficients in the segment

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:

Note
Even though 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)
Returns
a fixed-size expression of the last coefficients of *this.
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:

See also
class Block

Definition at line 949 of file BlockMethods.h.

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

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

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

Returns
a dynamic-size expression of a top-left corner of *this.
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.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:

 
See also
class Block, block(Index,Index,Index,Index)
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:

 
See also
class Block

Definition at line 178 of file BlockMethods.h.

template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC 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:

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

Definition at line 203 of file BlockMethods.h.

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

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

Definition at line 211 of file BlockMethods.h.

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

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

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

Returns
a dynamic-size expression of a top-right corner of *this.
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:

 
See also
class Block, block(Index,Index,Index,Index)
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:

 
See also
class Block

Definition at line 92 of file BlockMethods.h.

template<int CRows, int CCols>
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC 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:

 
See also
class Block, block<int,int>(Index,Index)

Definition at line 118 of file BlockMethods.h.

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

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

Definition at line 126 of file BlockMethods.h.

EIGEN_DEVICE_FUNC ConstNRowsBlockXpr< N >::Type topRows ( Index  n = N)
inline

This is the const version of topRows(Index).

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

Returns
a block consisting of the top rows of *this.
Parameters
nthe number of rows in the block

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:

 
See also
class Block, block(Index,Index,Index,Index)
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:

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

Definition at line 432 of file BlockMethods.h.



gtsam
Author(s):
autogenerated on Sat May 8 2021 02:51:28