class mrpt::math::CMatrixF

Overview

This class is a “CSerializable” wrapper for “CMatrixFloat”.

For a complete introduction to Matrices and vectors in MRPT, see: https://www.mrpt.org/Matrices_vectors_arrays_and_Linear_Algebra_MRPT_and_Eigen_classes

#include <mrpt/math/CMatrixF.h>

class CMatrixF:
    public mrpt::serialization::CSerializable,
    public mrpt::math::CMatrixDynamic
{
public:
    // typedefs

    typedef typename vec_t::iterator iterator;
    typedef typename vec_t::const_iterator const_iterator;
    typedef T Scalar;
    typedef int Index;
    typedef T& reference;
    typedef const T& const_reference;
    typedef int size_type;
    typedef std::ptrdiff_t difference_type;
    typedef Eigen::Matrix<T, RowsAtCompileTime, ColsAtCompileTime, StorageOrder, RowsAtCompileTime, ColsAtCompileTime> eigen_t;

    // fields

    static constexpr static int RowsAtCompileTime = -1;
    static constexpr static int ColsAtCompileTime = -1;
    static constexpr static int SizeAtCompileTime = -1;
    static constexpr static int is_mrpt_type = 1;
    static constexpr static int StorageOrder = 1;

    // construction

    CMatrixF();
    CMatrixF(size_t row, size_t col);
    CMatrixF(const CMatrixFloat& m);
    CMatrixF(const CMatrixDynamic<double>& m);

    template <typename OtherDerived>
    CMatrixF(const Eigen::MatrixBase<OtherDerived>& other);

    // methods

    iterator begin();
    const_iterator begin() const;
    iterator end();
    const_iterator end() const;
    const_iterator cbegin() const;
    const_iterator cend() const;

    template <class OTHERMAT>
    CMatrixF& operator = (const OTHERMAT& m);

    template <typename OtherDerived>
    CMatrixF& operator = (const Eigen::MatrixBase<OtherDerived>& other);

    template <class MAT>
    void setFromMatrixLike(const MAT& m);

    void resize(
        size_t row,
        size_t col
        );

    CMatrixDynamic& derived();
    const CMatrixDynamic& derived() const;

    void conservativeResize(
        size_t row,
        size_t col
        );

    template <typename VECTOR>
    void setRow(
        const Index row,
        const VECTOR& v
        );

    template <typename VECTOR>
    void setCol(
        const Index col,
        const VECTOR& v
        );

    template <
        typename EIGEN_MATRIX = eigen_t,
        typename EIGEN_MAP = Eigen::Map<const EIGEN_MATRIX, MRPT_MAX_ALIGN_BYTES, Eigen::InnerStride<1>>
        >
    EIGEN_MAP asEigen() const;

    CMatrixDynamic<float> cast_float() const;
    CMatrixDynamic<double> cast_double() const;
};

Inherited Members

public:
    // methods

    void setConstant(const Scalar value);
    void setConstant(size_t nrows, size_t ncols, const Scalar value);
    void setConstant(size_t nrows, const Scalar value);
    void assign(const std::size_t N, const Scalar value);
    void setZero();
    void setZero(size_t nrows, size_t ncols);
    void setZero(size_t nrows);
    static Derived Constant(const Scalar value);
    static Derived Constant(size_t nrows, size_t ncols, const Scalar value);
    static Derived Zero();
    static Derived Zero(size_t nrows, size_t ncols);
    auto block(int start_row, int start_col, int BLOCK_ROWS, int BLOCK_COLS);
    auto block(int start_row, int start_col, int BLOCK_ROWS, int BLOCK_COLS) const;
    auto transpose();
    auto transpose() const;
    auto array();
    auto array() const;
    auto operator - () const;

    template <typename S2, class D2>
    auto operator + (const MatrixVectorBase<S2, D2>& m2) const;

    template <typename S2, class D2>
    void operator += (const MatrixVectorBase<S2, D2>& m2);

    template <typename S2, class D2>
    auto operator - (const MatrixVectorBase<S2, D2>& m2) const;

    template <typename S2, class D2>
    void operator -= (const MatrixVectorBase<S2, D2>& m2);

    template <typename S2, class D2>
    auto operator * (const MatrixVectorBase<S2, D2>& m2) const;

    auto operator * (const Scalar s) const;

    template <int N>
    CMatrixFixed<Scalar, N, 1> tail() const;

    template <int N>
    CMatrixFixed<Scalar, N, 1> head() const;

    Scalar& coeffRef(int r, int c);
    const Scalar& coeff(int r, int c) const;
    Scalar minCoeff(std::size_t& outIndexOfMin) const;
    Scalar minCoeff(std::size_t& rowIdx, std::size_t& colIdx) const;
    Scalar maxCoeff(std::size_t& outIndexOfMax) const;
    Scalar maxCoeff(std::size_t& rowIdx, std::size_t& colIdx) const;
    void operator += (Scalar s);
    void operator -= (Scalar s);
    void operator *= (Scalar s);
    CMatrixDynamic<Scalar> operator * (const CMatrixDynamic<Scalar>& v);
    Derived operator + (const Derived& m2) const;
    void operator += (const Derived& m2);
    Derived operator - (const Derived& m2) const;
    void operator -= (const Derived& m2);
    Derived operator * (const Derived& m2) const;
    Scalar dot(const MatrixVectorBase<Scalar, Derived>& v) const;

    template <typename OTHERMATVEC>
    bool operator == (const OTHERMATVEC& o) const;

    template <typename OTHERMATVEC>
    bool operator != (const OTHERMATVEC& o) const;

    Derived& mvbDerived();
    const Derived& mvbDerived() const;
    auto col(int colIdx);
    auto col(int colIdx) const;
    auto row(int rowIdx);
    auto row(int rowIdx) const;

    template <typename VECTOR_LIKE>
    void extractRow(int rowIdx, VECTOR_LIKE& v) const;

    template <typename VECTOR_LIKE>
    VECTOR_LIKE extractRow(int rowIdx) const;

    template <typename VECTOR_LIKE>
    void extractColumn(int colIdx, VECTOR_LIKE& v) const;

    template <typename VECTOR_LIKE>
    VECTOR_LIKE extractColumn(int colIdx) const;

    template <int BLOCK_ROWS, int BLOCK_COLS>
    CMatrixFixed<Scalar, BLOCK_ROWS, BLOCK_COLS> extractMatrix(
        const int start_row = 0,
        const int start_col = 0
        ) const;

    CMatrixDynamic<Scalar> extractMatrix(
        const int BLOCK_ROWS,
        const int BLOCK_COLS,
        const int start_row,
        const int start_col
        ) const;

    Derived& mbDerived();
    const Derived& mbDerived() const;
    void setIdentity();
    void setIdentity(const std::size_t N);
    static Derived Identity();
    static Derived Identity(const std::size_t N);
    CMatrixDynamic& operator = (const CMatrixDynamic<T>& m);

    template <typename U>
    CMatrixDynamic& operator = (const CMatrixDynamic<U>& m);

    template <class Derived>
    CMatrixDynamic& operator = (const Eigen::MatrixBase<Derived>& m);

    template <std::size_t ROWS, std::size_t COLS>
    CMatrixDynamic& operator = (const CMatrixFixed<T, ROWS, COLS>& m);

    template <typename V, size_t N>
    CMatrixDynamic& operator = (V(&) theArray [N]);

    CMatrixDynamic& operator = (CMatrixDynamic&& m);

Construction

CMatrixF()

Constructor

CMatrixF(size_t row, size_t col)

Constructor.

CMatrixF(const CMatrixFloat& m)

Copy constructor.

CMatrixF(const CMatrixDynamic<double>& m)

Copy constructor.

template <typename OtherDerived>
CMatrixF(const Eigen::MatrixBase<OtherDerived>& other)

Constructor from any other Eigen class.

Methods

template <class OTHERMAT>
CMatrixF& operator = (const OTHERMAT& m)

Assignment operator for float matrixes.

template <typename OtherDerived>
CMatrixF& operator = (const Eigen::MatrixBase<OtherDerived>& other)

Assignment operator from any other Eigen class.