The remaining template parameters are optional – in most cases you don't have to worry about them.

Template Parameters

_Options

A combination of either RowMajor or ColMajor, and of either AutoAlign or DontAlign. The former controls storage order, and defaults to column-major. The latter controls alignment, which is required for vectorization. It defaults to aligning matrices except for fixed sizes that aren't a multiple of the packet size.

This Matrix class handles dense, not sparse matrices and vectors. For sparse matrices and vectors, see the Sparse module.

Dense matrices and vectors are plain usual arrays of coefficients. All the coefficients are stored, in an ordinary contiguous array. This is unlike Sparse matrices and vectors where the coefficients are stored as a list of nonzero coefficients.

Fixed-size versus dynamic-size:

Fixed-size means that the numbers of rows and columns are known are compile-time. In this case, Eigen allocates the array of coefficients as a fixed-size array, as a class member. This makes sense for very small matrices, typically up to 4x4, sometimes up to 16x16. Larger matrices should be declared as dynamic-size even if one happens to know their size at compile-time.

Dynamic-size means that the numbers of rows or columns are not necessarily known at compile-time. In this case they are runtime variables, and the array of coefficients is allocated dynamically on the heap.

Note that dense matrices, be they Fixed-size or Dynamic-size, do not expand dynamically in the sense of a std::map. If you want this behavior, see the Sparse module.

_MaxRows and _MaxCols:

In most cases, one just leaves these parameters to the default values. These parameters mean the maximum size of rows and columns that the matrix may have. They are useful in cases when the exact numbers of rows and columns are not known are compile-time, but it is known at compile-time that they cannot exceed a certain value. This happens when taking dynamic-size blocks inside fixed-size matrices: in this case _MaxRows and _MaxCols are the dimensions of the original matrix, while _Rows and _Cols are Dynamic.

ABI and storage layout

The table below summarizes the ABI of some possible Matrix instances which is fixed thorough the lifetime of Eigen 3.

Public Member Functions

Constructs a vector or row-vector with given dimension. 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. More...

For dynamic-size matrices, creates an empty matrix of size 0. Does not allocate any array. Such a matrix is called a null matrix. This constructor is the unique way to create null matrices: resizing a matrix to 0 is not supported.

Constructs a vector or row-vector with given dimension. 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 is useful for dynamic-size vectors. For fixed-size vectors, it is redundant to pass these parameters, so one should use the default constructor Matrix() instead.

Warning

This constructor is disabled for fixed-size 1x1 matrices. For instance, calling Matrix<double,1,1>(1) will call the initialization constructor: Matrix(const Scalar&). For fixed-size 1x1 matrices it is therefore recommended to use the default constructor Matrix() instead, especially when using one of the non standard EIGEN_INITIALIZE_MATRICES_BY_{ZERO,NAN} macros (see Preprocessor directives).

This is useful for dynamic-size matrices. For fixed-size matrices, it is redundant to pass these parameters, so one should use the default constructor Matrix() instead.

Warning

This constructor is disabled for fixed-size 1x2 and 2x1 vectors. For instance, calling Matrix2f(2,1) will call the initialization constructor: Matrix(const Scalar& x, const Scalar& y). For fixed-size 1x2 or 2x1 vectors it is therefore recommended to use the default constructor Matrix() instead, especially when using one of the non standard EIGEN_INITIALIZE_MATRICES_BY_{ZERO,NAN} macros (see Preprocessor directives).

The expression must provide a (templated) evalTo(Derived& dst) const function which does the actual job. In practice, this allows any user to write its own special matrix without having to modify MatrixBase

Returns

a reference to *this.

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