PlainObjectBase< Derived > Class Template Reference

Dense storage base class for matrices and arrays. More...

#include <PlainObjectBase.h>

Inherited by Array< Scalar, Dynamic, Dynamic, RowMajor, NumOfDerivativesAtCompileTime, OrderAtCompileTime >, Array< Scalar, 1, OrderAtCompileTime >, Array< Scalar, Dimension, Dynamic >, Array< Scalar, Dimension, Dynamic, ColMajor, Dimension, NumOfDerivativesAtCompileTime >, Array< Scalar, 1, Dynamic >, Array< Scalar, Dimension, 1 >, Array< Scalar, Rows, Cols, Options, MaxRows, MaxCols >, Array< RealScalar, Rows, Cols, Options, MaxRows, MaxCols >, Array< NonIntegerScalar, Rows, Cols, Options, MaxRows, MaxCols >, Array< typename traits< T >::Scalar, traits< T >::RowsAtCompileTime, traits< T >::ColsAtCompileTime, AutoAlign|(traits< T >::Flags &RowMajorBit ? RowMajor :ColMajor), traits< T >::MaxRowsAtCompileTime, traits< T >::MaxColsAtCompileTime >, Array< Scalar, 1, ExpressionType::ColsAtCompileTime, ExpressionType::PlainObject::Options|RowMajor, 1, ExpressionType::MaxColsAtCompileTime >, Array< Scalar, ExpressionType::RowsAtCompileTime, 1, ExpressionType::PlainObject::Options &~RowMajor, ExpressionType::MaxRowsAtCompileTime, 1 >, Array< Scalar, diag_size, 1, ExpressionType::PlainObject::Options &~RowMajor, max_diag_size, 1 >, Array< Index, 64, 1, DontAlign >, Matrix< Scalar, RowsAtCompileTime, 1, Options, MaxRowsAtCompileTime, 1 >, Matrix< Scalar, RowsAtCompileTime, ColsAtCompileTime >, Matrix< Scalar, DataRowsAtCompileTime, ColsAtCompileTime, Options &RowMajor?RowMajor:ColMajor >, , Matrix< float, 2, 2 >, Matrix< float, 2, 1 >, Matrix< float, 1, 2 >, Matrix< float, 3, 3 >, Matrix< float, 3, 1 >, Matrix< float, 1, 3 >, Matrix< float, 4, 4 >, Matrix< float, 4, 1 >, Matrix< float, 1, 4 >, Matrix< float, Dynamic, Dynamic >, Matrix< float, Dynamic, 1 >, Matrix< float, 1, Dynamic >, Matrix< float, 2, Dynamic >, Matrix< float, Dynamic, 2 >, Matrix< float, 3, Dynamic >, Matrix< float, Dynamic, 3 >, Matrix< float, 4, Dynamic >, Matrix< float, Dynamic, 4 >, Matrix< std::complex< float >, 2, 2 >, Matrix< std::complex< float >, 2, 1 >, Matrix< std::complex< float >, 1, 2 >, Matrix< std::complex< float >, 3, 3 >, Matrix< std::complex< float >, 3, 1 >, Matrix< std::complex< float >, 1, 3 >, Matrix< std::complex< float >, 4, 4 >, Matrix< std::complex< float >, 4, 1 >, Matrix< std::complex< float >, 1, 4 >, Matrix< std::complex< float >, Dynamic, Dynamic >, Matrix< std::complex< float >, Dynamic, 1 >, Matrix< std::complex< float >, 1, Dynamic >, Matrix< std::complex< float >, 2, Dynamic >, Matrix< std::complex< float >, Dynamic, 2 >, Matrix< std::complex< float >, 3, Dynamic >, Matrix< std::complex< float >, Dynamic, 3 >, Matrix< std::complex< float >, 4, Dynamic >, Matrix< std::complex< float >, Dynamic, 4 >, Matrix< std::complex< double >, 2, 2 >, Matrix< std::complex< double >, 2, 1 >, Matrix< std::complex< double >, 1, 2 >, Matrix< std::complex< double >, 3, 3 >, Matrix< std::complex< double >, 3, 1 >, Matrix< std::complex< double >, 1, 3 >, Matrix< std::complex< double >, 4, 4 >, Matrix< std::complex< double >, 4, 1 >, Matrix< std::complex< double >, 1, 4 >, Matrix< std::complex< double >, Dynamic, Dynamic >, Matrix< std::complex< double >, Dynamic, 1 >, Matrix< std::complex< double >, 1, Dynamic >, Matrix< std::complex< double >, 2, Dynamic >, Matrix< std::complex< double >, Dynamic, 2 >, Matrix< std::complex< double >, 3, Dynamic >, Matrix< std::complex< double >, Dynamic, 3 >, Matrix< std::complex< double >, 4, Dynamic >, Matrix< std::complex< double >, Dynamic, 4 >, , Matrix< IndexType, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1 >, Matrix< Index, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1 >, Matrix< typename traits< T >::Scalar, traits< T >::RowsAtCompileTime, traits< T >::ColsAtCompileTime, AutoAlign|(traits< T >::Flags &RowMajorBit ? RowMajor :ColMajor), traits< T >::MaxRowsAtCompileTime, traits< T >::MaxColsAtCompileTime >, Matrix< typename traits< T >::Scalar, Rows, Cols,(MaxRows==1 &&MaxCols!=1) ? RowMajor :ColMajor, MaxRows, MaxCols >, Matrix< typename traits< T >::Scalar, Rows, Cols,(MaxCols==1 &&MaxRows!=1) ? RowMajor :ColMajor, MaxRows, MaxCols >, Matrix< Scalar, 1, ExpressionType::ColsAtCompileTime, ExpressionType::PlainObject::Options|RowMajor, 1, ExpressionType::MaxColsAtCompileTime >, Matrix< Scalar, ExpressionType::RowsAtCompileTime, 1, ExpressionType::PlainObject::Options &~RowMajor, ExpressionType::MaxRowsAtCompileTime, 1 >, Matrix< Scalar, diag_size, 1, ExpressionType::PlainObject::Options &~RowMajor, max_diag_size, 1 >, Matrix< ComplexScalar, ColsAtCompileTime, 1, Options &(~RowMajor), MaxColsAtCompileTime, 1 >, Matrix< ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime >, Matrix< ComplexScalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 >, Matrix< Scalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 >, Matrix< Scalar, SizeMinusOne, 1, Options &~RowMajor, MaxSizeMinusOne, 1 >, Matrix< Scalar, 1, Size, Options|RowMajor, 1, MaxSize >, Matrix< Scalar, 3, 1 >, Matrix< Scalar, AmbientDimAtCompileTime, 1 >, Matrix< Scalar, 3, 3 >, Matrix< Scalar, Index(AmbientDimAtCompileTime)==Dynamic ? Dynamic :Index(AmbientDimAtCompileTime)+1, 1, Options >, Matrix< Scalar, 2, 1 >, Matrix< Scalar, AmbientDimAtCompileTime, 1, Options >, Matrix< Scalar, 2, 2 >, Matrix< Scalar, Dim, Dim >, Matrix< Scalar, Dim, 1 >, Matrix< typename RotationDerived::Scalar, Dim, Dim >, Matrix< typename RotationDerived::Scalar, Dim, 1 >, Matrix< Scalar, Dim, Dim, Options >, Matrix< ResultScalar, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime, 0, MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime >, Matrix< Scalar, Dynamic, 1 >, Matrix< Scalar, Dynamic, Dynamic >, Matrix< typename MatrixType::Scalar, MatrixType::RowsAtCompileTime, Dynamic, MatrixType::Options, MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime >, Matrix< typename MatrixType::Scalar, MatrixType::ColsAtCompileTime, Dynamic, MatrixType::Options, MatrixType::MaxColsAtCompileTime, MatrixType::MaxColsAtCompileTime >, Matrix< typename Rhs::Scalar, MatrixType::ColsAtCompileTime, Rhs::ColsAtCompileTime, Rhs::PlainObject::Options, MatrixType::MaxColsAtCompileTime, Rhs::MaxColsAtCompileTime >, Matrix< Index, 1, MatrixType::ColsAtCompileTime >, Matrix< Index, MatrixType::RowsAtCompileTime, 1 >, Matrix< Scalar, RowsAtCompileTime, RowsAtCompileTime, Options, MaxRowsAtCompileTime, MaxRowsAtCompileTime >, Matrix< Index, 1, EIGEN_SIZE_MIN_PREFER_DYNAMIC(ColsAtCompileTime, RowsAtCompileTime), RowMajor, 1, EIGEN_SIZE_MIN_PREFER_FIXED(MaxColsAtCompileTime, MaxRowsAtCompileTime)>, Matrix< typename MatrixType::Scalar, 1, MatrixType::RowsAtCompileTime, RowMajor, 1, MatrixType::MaxRowsAtCompileTime >, Matrix< Scalar, RowsAtCompileTime, RowsAtCompileTime,(MatrixType::Flags &RowMajorBit) ? RowMajor :ColMajor, MaxRowsAtCompileTime, MaxRowsAtCompileTime >, Matrix< Index, Dynamic, 1 >, Matrix< Scalar, Rows, Cols, Options, MRows, MCols >, Matrix< Scalar, 1, RowsAtCompileTime, RowMajor, 1, MaxRowsAtCompileTime >, Matrix< Scalar, ColsAtCompileTime, RowsAtCompileTime, Options, MaxColsAtCompileTime, MaxRowsAtCompileTime >, Matrix< Scalar, RowsAtCompileTime, RowsAtCompileTime, MatrixOptions, MaxRowsAtCompileTime, MaxRowsAtCompileTime >, Matrix< Scalar, ColsAtCompileTime, ColsAtCompileTime, MatrixOptions, MaxColsAtCompileTime, MaxColsAtCompileTime >, Matrix< Scalar, DiagSizeAtCompileTime, DiagSizeAtCompileTime, MatrixOptions, MaxDiagSizeAtCompileTime, MaxDiagSizeAtCompileTime >, Matrix< Scalar, 1, ColsAtCompileTime >, and Matrix< Scalar, RowsAtCompileTime, 1 >.

Public Member Functions

void conservativeResize (Index rows, Index cols)
 
void conservativeResize (Index rows, NoChange_t)
 
void conservativeResize (Index size)
 
void conservativeResize (NoChange_t, Index cols)
 
template<typename OtherDerived>
void conservativeResizeLike (const DenseBase< OtherDerived > &other)
 
Scalar * data ()
 
const Scalar * data () const
 
template<typename OtherDerived>
Derived & lazyAssign (const DenseBase< OtherDerived > &other)
 
template<typename OtherDerived>
Derived & operator= (const EigenBase< OtherDerived > &other)
 
Derived & operator= (const PlainObjectBase &other)
 
template<typename OtherDerived>
 PlainObjectBase (const EigenBase< OtherDerived > &other)
 
void resize (Index rows, Index cols)
 
void resize (Index rows, NoChange_t)
 
void resize (Index size)
 
void resize (NoChange_t, Index cols)
 
template<typename OtherDerived>
void resizeLike (const EigenBase< OtherDerived > &_other)
 

Map

These are convenience functions returning Map objects. The Map() static functions return unaligned Map objects, while the AlignedMap() functions return aligned Map objects and thus should be called only with 16-byte-aligned data pointers.

See also
class Map
Derived & setConstant (Index size, const Scalar &value)
 
Derived & setConstant (Index rows, Index cols, const Scalar &value)
 
Derived & setZero (Index size)
 
Derived & setZero (Index rows, Index cols)
 
Derived & setOnes (Index size)
 
Derived & setOnes (Index rows, Index cols)
 
Derived & setRandom (Index size)
 
Derived & setRandom (Index rows, Index cols)
 
template<typename OtherDerived>
Derived & _set (const DenseBase< OtherDerived > &other)
 Copies the value of the expression other into *this with automatic resizing.
 

Detailed Description

template<typename Derived>
class Eigen::PlainObjectBase< Derived >

Dense storage base class for matrices and arrays.

This class can be extended with the help of the plugin mechanism described on the page Customizing/Extending Eigen by defining the preprocessor symbol EIGEN_PLAINOBJECTBASE_PLUGIN.

See also
The class hierarchy

Constructor & Destructor Documentation

◆ PlainObjectBase()

template<typename Derived>
template<typename OtherDerived>
PlainObjectBase ( const EigenBase< OtherDerived > & other)
inline
See also
MatrixBase::operator=(const EigenBase<OtherDerived>&)

Member Function Documentation

◆ _set()

template<typename Derived>
template<typename OtherDerived>
Derived & _set ( const DenseBase< OtherDerived > & other)
inlineprotected

Copies the value of the expression other into *this with automatic resizing.

*this might be resized to match the dimensions of other. If *this was a null matrix (not already initialized), it will be initialized.

Note that copying a row-vector into a vector (and conversely) is allowed. The resizing, if any, is then done in the appropriate way so that row-vectors remain row-vectors and vectors remain vectors.

See also
operator=(const MatrixBase<OtherDerived>&), _set_noalias()

Referenced by PlainObjectBase< Array >::operator=().

◆ conservativeResize() [1/4]

template<typename Derived>
void conservativeResize ( Index rows,
Index cols )
inline

Resizes the matrix to rows x cols while leaving old values untouched.

The method is intended for matrices of dynamic size. If you only want to change the number of rows and/or of columns, you can use conservativeResize(NoChange_t, Index) or conservativeResize(Index, NoChange_t).

Matrices are resized relative to the top-left element. In case values need to be appended to the matrix they will be uninitialized.

Referenced by PlainObjectBase< Array >::conservativeResize(), and PlainObjectBase< Array >::conservativeResize().

◆ conservativeResize() [2/4]

template<typename Derived>
void conservativeResize ( Index rows,
NoChange_t  )
inline

Resizes the matrix to rows x cols while leaving old values untouched.

As opposed to conservativeResize(Index rows, Index cols), this version leaves the number of columns unchanged.

In case the matrix is growing, new rows will be uninitialized.

◆ conservativeResize() [3/4]

template<typename Derived>
void conservativeResize ( Index size)
inline

Resizes the vector to size while retaining old values.

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.. This method does not work for partially dynamic matrices when the static dimension is anything other than 1. For example it will not work with Matrix<double, 2, Dynamic>.

When values are appended, they will be uninitialized.

◆ conservativeResize() [4/4]

template<typename Derived>
void conservativeResize ( NoChange_t ,
Index cols )
inline

Resizes the matrix to rows x cols while leaving old values untouched.

As opposed to conservativeResize(Index rows, Index cols), this version leaves the number of rows unchanged.

In case the matrix is growing, new columns will be uninitialized.

◆ conservativeResizeLike()

template<typename Derived>
template<typename OtherDerived>
void conservativeResizeLike ( const DenseBase< OtherDerived > & other)
inline

Resizes the matrix to rows x cols of other, while leaving old values untouched.

The method is intended for matrices of dynamic size. If you only want to change the number of rows and/or of columns, you can use conservativeResize(NoChange_t, Index) or conservativeResize(Index, NoChange_t).

Matrices are resized relative to the top-left element. In case values need to be appended to the matrix they will copied from other.

◆ data() [1/2]

template<typename Derived>
Scalar * data ( )
inline
Returns
a pointer to the data array of this matrix

◆ data() [2/2]

template<typename Derived>
const Scalar * data ( ) const
inline
Returns
a const pointer to the data array of this matrix

◆ lazyAssign()

template<typename Derived>
template<typename OtherDerived>
Derived & lazyAssign ( const DenseBase< OtherDerived > & other)
inline
See also
MatrixBase::lazyAssign()

◆ operator=() [1/2]

template<typename Derived>
template<typename OtherDerived>
Derived & operator= ( const EigenBase< OtherDerived > & other)
inline

◆ operator=() [2/2]

template<typename Derived>
Derived & operator= ( const PlainObjectBase< Derived > & other)
inline

This is a special case of the templated operator=. Its purpose is to prevent a default operator= from hiding the templated operator=.

◆ resize() [1/4]

template<typename Derived>
void resize ( Index rows,
Index cols )
inline

Resizes *this to a rows x cols matrix.

This method is intended for dynamic-size matrices, although it is legal to call it on any matrix as long as fixed dimensions are left unchanged. If you only want to change the number of rows and/or of columns, you can use resize(NoChange_t, Index), resize(Index, NoChange_t).

If the current number of coefficients of *this exactly matches the product rows * cols, then no memory allocation is performed and the current values are left unchanged. In all other cases, including shrinking, the data is reallocated and all previous values are lost.

Example:

MatrixXd m(2,3);
m << 1,2,3,4,5,6;
cout << "here's the 2x3 matrix m:" << endl << m << endl;
cout << "let's resize m to 3x2. This is a conservative resizing because 2*3==3*2." << endl;
m.resize(3,2);
cout << "here's the 3x2 matrix m:" << endl << m << endl;
cout << "now let's resize m to size 2x2. This is NOT a conservative resizing, so it becomes uninitialized:" << endl;
m.resize(2,2);
cout << m << endl;

Output:

here's the 2x3 matrix m:
1 2 3
4 5 6
let's resize m to 3x2. This is a conservative resizing because 2*3==3*2.
here's the 3x2 matrix m:
1 5
4 3
2 6
now let's resize m to size 2x2. This is NOT a conservative resizing, so it becomes uninitialized:
0 0
0 0
See also
resize(Index) for vectors, resize(NoChange_t, Index), resize(Index, NoChange_t)

Referenced by PlainObjectBase< Array >::resize(), PlainObjectBase< Array >::resize(), PlainObjectBase< Array >::resizeLike(), setConstant(), setConstant(), setOnes(), setOnes(), setRandom(), setRandom(), setZero(), and setZero().

◆ resize() [2/4]

template<typename Derived>
void resize ( Index rows,
NoChange_t  )
inline

Resizes the matrix, changing only the number of rows. For the parameter of type NoChange_t, just pass the special value NoChange as in the example below.

Example:

MatrixXd m(3,4);
m.resize(5, NoChange);
cout << "m: " << m.rows() << " rows, " << m.cols() << " cols" << endl;

Output:

m: 5 rows, 4 cols
See also
resize(Index,Index)

◆ resize() [3/4]

template<typename Derived>
void resize ( Index size)
inline

Resizes *this to a vector of length size

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.. This method does not work for partially dynamic matrices when the static dimension is anything other than 1. For example it will not work with Matrix<double, 2, Dynamic>.

Example:

VectorXd v(10);
v.resize(3);
RowVector3d w;
w.resize(3); // this is legal, but has no effect
cout << "v: " << v.rows() << " rows, " << v.cols() << " cols" << endl;
cout << "w: " << w.rows() << " rows, " << w.cols() << " cols" << endl;
void resize(Index rows, Index cols)
Definition PlainObjectBase.h:219

Output:

v: 3 rows, 1 cols
w: 1 rows, 3 cols
See also
resize(Index,Index), resize(NoChange_t, Index), resize(Index, NoChange_t)

◆ resize() [4/4]

template<typename Derived>
void resize ( NoChange_t ,
Index cols )
inline

Resizes the matrix, changing only the number of columns. For the parameter of type NoChange_t, just pass the special value NoChange as in the example below.

Example:

MatrixXd m(3,4);
m.resize(NoChange, 5);
cout << "m: " << m.rows() << " rows, " << m.cols() << " cols" << endl;

Output:

m: 3 rows, 5 cols
See also
resize(Index,Index)

◆ resizeLike()

template<typename Derived>
template<typename OtherDerived>
void resizeLike ( const EigenBase< OtherDerived > & _other)
inline

Resizes *this to have the same dimensions as other. Takes care of doing all the checking that's needed.

Note that copying a row-vector into a vector (and conversely) is allowed. The resizing, if any, is then done in the appropriate way so that row-vectors remain row-vectors and vectors remain vectors.

◆ setConstant() [1/2]

template<typename Derived>
Derived & setConstant ( Index rows,
Index cols,
const Scalar & value )
inline

Resizes to the given size, and sets all coefficients in this expression to the given value.

Parameters
rowsthe new number of rows
colsthe new number of columns
valuethe value to which all coefficients are set

Example:

MatrixXf m;
m.setConstant(3, 3, 5);
cout << m << endl;
Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > & setConstant(Index size, const Scalar &value)
Definition CwiseNullaryOp.h:348

Output:

5 5 5
5 5 5
5 5 5
See also
MatrixBase::setConstant(const Scalar&), setConstant(Index,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)

References resize(), and setConstant().

◆ setConstant() [2/2]

template<typename Derived>
Derived & setConstant ( Index size,
const Scalar & value )
inline

Resizes to the given size, and sets all coefficients in this expression to the given value.

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.

Example:

VectorXf v;
v.setConstant(3, 5);
cout << v << endl;

Output:

5
5
5
See also
MatrixBase::setConstant(const Scalar&), setConstant(Index,Index,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)

References resize(), and setConstant().

Referenced by setConstant(), setConstant(), setOnes(), setOnes(), setZero(), and setZero().

◆ setOnes() [1/2]

template<typename Derived>
Derived & setOnes ( Index rows,
Index cols )
inline

Resizes to the given size, and sets all coefficients in this expression to one.

Parameters
rowsthe new number of rows
colsthe new number of columns

Example:

MatrixXf m;
m.setOnes(3, 3);
cout << m << endl;
Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > & setOnes(Index size)
Definition CwiseNullaryOp.h:641

Output:

1 1 1
1 1 1
1 1 1
See also
MatrixBase::setOnes(), setOnes(Index), class CwiseNullaryOp, MatrixBase::Ones()

References resize(), and setConstant().

◆ setOnes() [2/2]

template<typename Derived>
Derived & setOnes ( Index size)
inline

Resizes to the given size, and sets all coefficients in this expression to one.

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.

Example:

VectorXf v;
v.setOnes(3);
cout << v << endl;

Output:

1
1
1
See also
MatrixBase::setOnes(), setOnes(Index,Index), class CwiseNullaryOp, MatrixBase::Ones()

References resize(), and setConstant().

◆ setRandom() [1/2]

template<typename Derived>
Derived & setRandom ( Index rows,
Index cols )
inline

Resizes to the given size, and sets all coefficients in this expression to random values.

Parameters
rowsthe new number of rows
colsthe new number of columns

Example:

MatrixXf m;
m.setRandom(3, 3);
cout << m << endl;
Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > & setRandom(Index size)
Definition Random.h:126

Output:

  0.68  0.597  -0.33
-0.211  0.823  0.536
 0.566 -0.605 -0.444
See also
MatrixBase::setRandom(), setRandom(Index), class CwiseNullaryOp, MatrixBase::Random()

References resize(), and setRandom().

◆ setRandom() [2/2]

template<typename Derived>
Derived & setRandom ( Index size)
inline

Resizes to the given size, and sets all coefficients in this expression to random values.

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.

Example:

VectorXf v;
v.setRandom(3);
cout << v << endl;

Output:

0.68
-0.211
0.566
See also
MatrixBase::setRandom(), setRandom(Index,Index), class CwiseNullaryOp, MatrixBase::Random()

References resize(), and setRandom().

Referenced by setRandom(), and setRandom().

◆ setZero() [1/2]

template<typename Derived>
Derived & setZero ( Index rows,
Index cols )
inline

Resizes to the given size, and sets all coefficients in this expression to zero.

Parameters
rowsthe new number of rows
colsthe new number of columns

Example:

MatrixXf m;
m.setZero(3, 3);
cout << m << endl;
Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > & setZero(Index size)
Definition CwiseNullaryOp.h:515

Output:

0 0 0
0 0 0
0 0 0
See also
DenseBase::setZero(), setZero(Index), class CwiseNullaryOp, DenseBase::Zero()

References resize(), and setConstant().

◆ setZero() [2/2]

template<typename Derived>
Derived & setZero ( Index size)
inline

Resizes to the given size, and sets all coefficients in this expression to zero.

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.

Example:

VectorXf v;
v.setZero(3);
cout << v << endl;

Output:

0
0
0
See also
DenseBase::setZero(), setZero(Index,Index), class CwiseNullaryOp, DenseBase::Zero()

References resize(), and setConstant().

Referenced by Transform< Scalar, Dim, Mode, Options >::makeAffine(), and Translation< Scalar, Dim >::operator*.


The documentation for this class was generated from the following files: