[mrpt-math]

Math C++ library: vectors and matrices, probability distributions, statistics, geometry, etc.

Library mrpt-math

This library is part of MRPT and can be installed in Debian-based systems with:

sudo apt install libmrpt-math-dev

Read also how to import MRPT into your CMake scripts.

The main classes and concepts associated with this library:

  • mrpt_math_vectors_matrices_grp: Vectors and matrices (compatible with the Eigen library).

  • mrpt_math_lwgeom_grp: TPose2D, TPose3D, TPoint3D, TLine3D, geometry functions, etc. (See also: [mrpt-poses])

Other important elements:

Library contents

// typedefs

typedef CLevenbergMarquardtTempl<mrpt::math::CVectorDouble> mrpt::math::CLevenbergMarquardt;

// enums

enum mrpt::math::TMatrixTextFileFormat;
enum mrpt::math::TRobustKernelType;

// structs

template <
    typename Scalar,
    int NROWS,
    int NCOLS,
    typename INFO,
    bool HAS_REMAP,
    typename INDEX_REMAP_MAP_IMPL = mrpt::containers::map_as_vector<size_t, size_t>
    >
struct mrpt::math::MatrixBlockSparseCols;

template <typename T>
struct mrpt::math::RobustKernel<rkPseudoHuber, T>;

template <typename T>
struct mrpt::math::RobustKernel<rkLeastSquares, T>;

template <TRobustKernelType KERNEL_TYPE, typename T = double>
struct mrpt::math::RobustKernel;

struct mrpt::math::matrix_size_t;

// classes

class mrpt::math::CAtan2LookUpTable;
class mrpt::math::CAtan2LookUpTableMultiRes;

template <typename T, typename U, bool UIsObject = false>
class mrpt::math::CBinaryRelation;

class mrpt::math::CHistogram;

template <typename VECTORTYPE = CVectorDouble, class USERPARAM = VECTORTYPE>
class mrpt::math::CLevenbergMarquardtTempl;

class mrpt::math::CMatrixB;
class mrpt::math::CMatrixD;

template <class T>
class mrpt::math::CMatrixDynamic;

class mrpt::math::CMatrixF;

template <typename T, std::size_t ROWS, std::size_t COLS>
class mrpt::math::CMatrixFixed;

template <typename T, typename NUM, typename OTHER>
class mrpt::math::CMonteCarlo;

template <class TDATA, size_t STATE_LEN>
class mrpt::math::CProbabilityDensityFunction;

template <class T>
class mrpt::math::CQuaternion;

class mrpt::math::CSparseMatrix;

template <class T>
class mrpt::math::CSparseMatrixTemplate;

template <class T>
class mrpt::math::CVectorDynamic;

template <
    class Derived,
    typename num_t = float,
    typename metric_t = nanoflann::L2_Simple_Adaptor<num_t, Derived>
    >
class mrpt::math::KDTreeCapable;

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

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

// global functions

void mrpt::math::setEpsilon(double nE);
double mrpt::math::getEpsilon();

template <class Derived>
const Derived& mrpt::math::mat2eig(const Eigen::EigenBase<Derived>& m);

template <
    class VECTORLIKE,
    class VECTORLIKE2,
    class VECTORLIKE3,
    class MATRIXLIKE,
    class USERPARAM
    >
void mrpt::math::estimateJacobian(
    const VECTORLIKE& x,
    const std::function<void(const VECTORLIKE&x, const USERPARAM&y, VECTORLIKE3&out)>& functor,
    const VECTORLIKE2& increments,
    const USERPARAM& userParam,
    MATRIXLIKE& out_Jacobian
    );

void mrpt::math::registerAllClasses_mrpt_math();

Typedefs

typedef CLevenbergMarquardtTempl<mrpt::math::CVectorDouble> mrpt::math::CLevenbergMarquardt

The default name for the LM class is an instantiation for “double”.

Global Functions

void mrpt::math::setEpsilon(double nE)

Changes the value of the geometric epsilon (default = 1e-5)

See also:

getEpsilon

double mrpt::math::getEpsilon()

Gets the value of the geometric epsilon (default = 1e-5)

See also:

setEpsilon

template <class Derived>
const Derived& mrpt::math::mat2eig(const Eigen::EigenBase<Derived>& m)

Returns an Eigen-compatible type, despite its argument already is an Eigen matrix, or an mrpt-math matrix/vector.

template <
    class VECTORLIKE,
    class VECTORLIKE2,
    class VECTORLIKE3,
    class MATRIXLIKE,
    class USERPARAM
    >
void mrpt::math::estimateJacobian(
    const VECTORLIKE& x,
    const std::function<void(const VECTORLIKE&x, const USERPARAM&y, VECTORLIKE3&out)>& functor,
    const VECTORLIKE2& increments,
    const USERPARAM& userParam,
    MATRIXLIKE& out_Jacobian
    )

Estimate the Jacobian of a multi-dimensional function around a point “x”, using finite differences of a given size in each input dimension.

The template argument USERPARAM is for the data can be passed to the functor. If it is not required, set to “int” or any other basic type.

This is a generic template which works with: VECTORLIKE: vector_float, CVectorDouble, CVectorFixed<>, double [N], … MATRIXLIKE: CMatrixDynamic, CMatrixFixed

void mrpt::math::registerAllClasses_mrpt_math()

Forces manual RTTI registration of all serializable classes in this namespace.

Should never be required to be explicitly called by users, except if building MRPT as a static library.