Template Class MatrixBase

Inheritance Relationships

Base Type

Derived Types

Class Documentation

template<typename Scalar, class Derived>
class MatrixBase : public mrpt::math::MatrixVectorBase<Scalar, Derived>

Base CRTP class for all MRPT matrices.

See MatrixVectorBase

See also

CMatrixFixed

Subclassed by mrpt::math::CMatrixDynamic< NUMTYPE >, mrpt::math::CMatrixDynamic< double >, mrpt::math::CMatrixDynamic< mrpt::math::TPoint3D_data< double > >, mrpt::math::CMatrixFixed< double, DIM, DIM >, mrpt::math::CMatrixFixed< 2 >, mrpt::math::CMatrixFixed< 3 >

Operations that DO require <tt>\#include \<Eigen/Dense\></tt> in user code

inline auto col(Index_t colIdx)
inline auto col(Index_t colIdx) const
inline auto row(Index_t rowIdx)
inline auto row(Index_t rowIdx) const
template<typename VectorLike>
inline void extractRow(Index_t rowIdx, VectorLike &v) const
template<typename VectorLike>
inline VectorLike extractRow(Index_t rowIdx) const
template<typename VectorLike>
inline void extractColumn(Index_t colIdx, VectorLike &v) const
template<typename VectorLike>
inline VectorLike extractColumn(Index_t colIdx) const

Standalone operations (do NOT require <tt>\#include \<Eigen/Dense\></tt>)

Scalar det() const

Determinant of matrix.

Derived inverse() const

Returns the inverse of a general matrix using LU

Derived inverse_LLt() const

Returns the inverse of a symmetric matrix using LLt

matrix_dim_t rank(Scalar threshold = 0) const

Finds the rank of the matrix via LU decomposition. Uses Eigen’s default threshold unless threshold>0.

bool chol(Derived &U) const

Cholesky M=UT * U decomposition for symmetric matrix (upper-half of the matrix is actually ignored.

Returns:

false if Cholesky fails

bool eig(Derived &eVecs, std::vector<Scalar> &eVals, bool sorted = true) const

Computes the eigenvectors and eigenvalues for a square, general matrix. Use eig_symmetric() for symmetric matrices for better accuracy and performance. Eigenvectors are the columns of the returned matrix, and their order matches that of returned eigenvalues.

Parameters:
  • sorted[in] If true, eigenvalues (and eigenvectors) will be sorted in ascending order.

  • eVecs[out] The container where eigenvectors will be stored.

  • eVals[out] The container where eigenvalues will be stored.

Returns:

false if eigenvalues could not be determined.

bool eig_symmetric(Derived &eVecs, std::vector<Scalar> &eVals, bool sorted = true) const

Read: eig()

Note

This only uses the lower-triangular part of the matrix

Note

(Since MRPT 2.5.2) If sorted==true, the smallest eigenvalue is checked to be non-negative, and resetted to zero if found to be negative due to rounding errors in the internal Eigen3 routines.

Scalar maximumDiagonal() const

Returns the maximum value in the diagonal.

Scalar minimumDiagonal() const

Returns the minimum value in the diagonal.

Scalar trace() const

Returns the trace of the matrix (not necessarily square).

void unsafeRemoveColumns(const std::vector<std::size_t> &idxs)

Removes columns of the matrix. This “unsafe” version assumes indices sorted in ascending order.

void removeColumns(const std::vector<std::size_t> &idxsToRemove)

Removes columns of the matrix. Indices may be unsorted and duplicated

void unsafeRemoveRows(const std::vector<std::size_t> &idxs)

Removes rows of the matrix. This “unsafe” version assumes indices sorted in ascending order.

void removeRows(const std::vector<std::size_t> &idxsToRemove)

Removes rows of the matrix. Indices may be unsorted and duplicated

template<typename OtherMatrixOrVector>
inline void insertMatrix(const Index_t row_start, const Index_t col_start, const OtherMatrixOrVector &submat)

Copies the given input submatrix/vector into this matrix/vector, starting at the given top-left coordinates.

template<typename OtherMatrixOrVector>
inline void insertMatrixTransposed(const Index_t row_start, const Index_t col_start, const OtherMatrixOrVector &submat)

Like insertMatrix(), but inserts submat` (transposed)

template<size_type_t BLOCK_ROWS, size_type_t BLOCK_COLS>
inline CMatrixFixed<Scalar, BLOCK_ROWS, BLOCK_COLS> blockCopy(Index_t start_row = 0, Index_t start_col = 0) const

const blockCopy(): Returns a copy of the given block

inline CMatrixDynamic<Scalar> blockCopy(Index_t start_row, Index_t start_col, size_type_t BLOCK_ROWS, size_type_t BLOCK_COLS) const

const blockCopy(): Returns a copy of the given block (non templated version, dynamic sizes)

template<size_type_t BLOCK_ROWS, size_type_t BLOCK_COLS>
inline CMatrixFixed<Scalar, BLOCK_ROWS, BLOCK_COLS> extractMatrix(const Index_t start_row = 0, const Index_t start_col = 0) const
inline CMatrixDynamic<Scalar> extractMatrix(const size_type_t BLOCK_ROWS, const size_type_t BLOCK_COLS, const Index_t start_row, const Index_t start_col) const
template<typename MAT_A>
inline void matProductOf_AAt(const MAT_A &A)

this = A * AT

template<typename MAT_A>
inline void matProductOf_AtA(const MAT_A &A)

this = AT * A

Public Types

using Index_t = matrix_index_t
using size_type_t = matrix_dim_t

Public Functions

inline Derived &mbDerived()
inline const Derived &mbDerived() const
inline void setDiagonal(const size_type_t N, const Scalar value)

Resize to NxN, set all entries to zero, except the main diagonal which is set to value

inline void setDiagonal(const Scalar value)

Set all entries to zero, except the main diagonal which is set to value

inline void setDiagonal(const std::vector<Scalar> &diags)

Resizes to NxN, with N the length of the input vector, set all entries to zero, except the main diagonal which is set to values in the vector.

inline void setIdentity()
inline void setIdentity(const size_type_t N)
void matProductOf_AB(const Derived &A, const Derived &B)

this = A*B, with A & B of the same type of this. For products of different matrix types, use the regular * operator (which requires the <Eigen/Dense> header)

Public Static Functions

static inline Derived Identity()
static inline Derived Identity(const size_type_t N)