Eigen  3.2.7
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PlainObjectBase< Derived > Class Template Reference

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
+ Inheritance diagram for PlainObjectBase< Derived >:

Public Member Functions

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

Static Public Member Functions

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
static ConstMapType Map (const Scalar *data)
 
static MapType Map (Scalar *data)
 
static ConstMapType Map (const Scalar *data, Index size)
 
static MapType Map (Scalar *data, Index size)
 
static ConstMapType Map (const Scalar *data, Index rows, Index cols)
 
static MapType Map (Scalar *data, Index rows, Index cols)
 
static ConstAlignedMapType MapAligned (const Scalar *data)
 
static AlignedMapType MapAligned (Scalar *data)
 
static ConstAlignedMapType MapAligned (const Scalar *data, Index size)
 
static AlignedMapType MapAligned (Scalar *data, Index size)
 
static ConstAlignedMapType MapAligned (const Scalar *data, Index rows, Index cols)
 
static AlignedMapType MapAligned (Scalar *data, Index rows, Index cols)
 
template<int Outer, int Inner>
static StridedConstMapType
< Stride< Outer, Inner >
>::type 
Map (const Scalar *data, const Stride< Outer, Inner > &stride)
 
template<int Outer, int Inner>
static StridedMapType< Stride
< Outer, Inner > >::type 
Map (Scalar *data, const Stride< Outer, Inner > &stride)
 
template<int Outer, int Inner>
static StridedConstMapType
< Stride< Outer, Inner >
>::type 
Map (const Scalar *data, Index size, const Stride< Outer, Inner > &stride)
 
template<int Outer, int Inner>
static StridedMapType< Stride
< Outer, Inner > >::type 
Map (Scalar *data, Index size, const Stride< Outer, Inner > &stride)
 
template<int Outer, int Inner>
static StridedConstMapType
< Stride< Outer, Inner >
>::type 
Map (const Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
 
template<int Outer, int Inner>
static StridedMapType< Stride
< Outer, Inner > >::type 
Map (Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
 
template<int Outer, int Inner>
static
StridedConstAlignedMapType
< Stride< Outer, Inner >
>::type 
MapAligned (const Scalar *data, const Stride< Outer, Inner > &stride)
 
template<int Outer, int Inner>
static StridedAlignedMapType
< Stride< Outer, Inner >
>::type 
MapAligned (Scalar *data, const Stride< Outer, Inner > &stride)
 
template<int Outer, int Inner>
static
StridedConstAlignedMapType
< Stride< Outer, Inner >
>::type 
MapAligned (const Scalar *data, Index size, const Stride< Outer, Inner > &stride)
 
template<int Outer, int Inner>
static StridedAlignedMapType
< Stride< Outer, Inner >
>::type 
MapAligned (Scalar *data, Index size, const Stride< Outer, Inner > &stride)
 
template<int Outer, int Inner>
static
StridedConstAlignedMapType
< Stride< Outer, Inner >
>::type 
MapAligned (const Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
 
template<int Outer, int Inner>
static StridedAlignedMapType
< Stride< Outer, Inner >
>::type 
MapAligned (Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
 

Protected Member Functions

template<typename OtherDerived >
Derived & _set (const DenseBase< OtherDerived > &other)
 Copies the value of the expression other into *this with automatic resizing. More...
 

Constructor & Destructor Documentation

PlainObjectBase ( const PlainObjectBase< Derived > &  other)
inline

Copy constructor

PlainObjectBase ( const EigenBase< OtherDerived > &  other)
inline
See Also
MatrixBase::operator=(const EigenBase<OtherDerived>&)

Member Function Documentation

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 Array< Index, 64, 1, DontAlign >::operator=(), and PlainObjectBase< Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > >::operator=().

void conservativeResize ( Index  nbRows,
Index  nbCols 
)
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< Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > >::conservativeResize().

void conservativeResize ( Index  nbRows,
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.

void conservativeResize ( NoChange_t  ,
Index  nbCols 
)
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.

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.

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.

const Scalar* data ( ) const
inline
Scalar* data ( )
inline
Returns
a pointer to the data array of this matrix
Derived& lazyAssign ( const DenseBase< OtherDerived > &  other)
inline
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=.

Referenced by Array< Index, 64, 1, DontAlign >::operator=().

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

void resize ( Index  nbRows,
Index  nbCols 
)
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:
6.91e-310 2.12e-314
4.94e-324 4.94e-323
See Also
resize(Index) for vectors, resize(NoChange_t, Index), resize(Index, NoChange_t)

Referenced by SparseLU< _MatrixType, _OrderingType >::analyzePattern(), Array< Index, 64, 1, DontAlign >::Array(), HessenbergDecomposition< MatrixType >::compute(), Tridiagonalization< _MatrixType >::compute(), SelfAdjointEigenSolver< _MatrixType >::compute(), HessenbergDecomposition< MatrixType >::HessenbergDecomposition(), PlainObjectBase< Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > >::resize(), and PlainObjectBase< Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > >::resizeLike().

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

Output:

v: 3 rows, 1 cols
w: 1 rows, 3 cols
See Also
resize(Index,Index), resize(NoChange_t, Index), resize(Index, NoChange_t)
void resize ( NoChange_t  ,
Index  nbCols 
)
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)
void resize ( Index  nbRows,
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)
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.

Derived & setConstant ( Index  size,
const Scalar &  val 
)
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&)

Referenced by SparseQR< MatrixType, OrderingType >::factorize(), SparseLU< _MatrixType, _OrderingType >::factorize(), and AlignedBox< _Scalar, _AmbientDim >::setEmpty().

Derived & setConstant ( Index  nbRows,
Index  nbCols,
const Scalar &  val 
)
inline

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

Parameters
nbRowsthe new number of rows
nbColsthe new number of columns
valthe value to which all coefficients are set

Example:

m.setConstant(3, 3, 5);
cout << m << endl;

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&)
Derived & setOnes ( Index  newSize)
inline

Resizes to the given newSize, 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()
Derived & setOnes ( Index  nbRows,
Index  nbCols 
)
inline

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

Parameters
nbRowsthe new number of rows
nbColsthe new number of columns

Example:

m.setOnes(3, 3);
cout << m << endl;

Output:

1 1 1
1 1 1
1 1 1
See Also
MatrixBase::setOnes(), setOnes(Index), class CwiseNullaryOp, MatrixBase::Ones()
Derived & setRandom ( Index  newSize)
inline

Resizes to the given newSize, 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()
Derived & setRandom ( Index  nbRows,
Index  nbCols 
)
inline

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

Parameters
nbRowsthe new number of rows
nbColsthe new number of columns

Example:

m.setRandom(3, 3);
cout << m << endl;

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()
Derived & setZero ( Index  newSize)
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()

Referenced by SparseQR< MatrixType, OrderingType >::factorize(), SparseLU< _MatrixType, _OrderingType >::factorize(), and Translation< Scalar, Dim >::operator*().

Derived & setZero ( Index  nbRows,
Index  nbCols 
)
inline

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

Parameters
nbRowsthe new number of rows
nbColsthe new number of columns

Example:

m.setZero(3, 3);
cout << m << endl;

Output:

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

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