Main MRPT website > C++ reference
MRPT logo
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables

mrpt::math Namespace Reference


Detailed Description

This base provides a set of functions for maths stuff.

Namespaces

namespace  detail
namespace  jacobians
 

A collection of functions to compute jacobians of diverse transformations, etc (some functions are redirections to existing methods elsewhere, so this namespace is actually used with grouping purposes).


Classes

class  CArray
 A STL container (as wrapper) for arrays of constant size defined at compile time - Users will most likely prefer to use CArrayPOD and its derived classes instead. More...
class  CArray< T, 0 >
class  CArrayNumeric
 CArrayNumeric is an array for numeric types supporting several mathematical operations (actually, just a wrapper on Eigen::Matrix<T,N,1>). More...
class  CArrayFloat
 A partial specialization of CArrayNumeric for float numbers. More...
class  CArrayDouble
 A partial specialization of CArrayNumeric for double numbers. More...
class  CArrayInt
 A partial specialization of CArrayNumeric for int numbers. More...
class  CArrayUInt
 A partial specialization of CArrayNumeric for unsigned int numbers. More...
struct  CMatrixTemplateSize
 Auxiliary class used in CMatrixTemplate:size(), CMatrixTemplate::resize(), CMatrixFixedNumeric::size(), CMatrixFixedNumeric::resize(), to mimic the behavior of STL-containers. More...
class  CAStarAlgorithm
 This class is intended to efficiently solve graph-search problems using heuristics to determine the best path. More...
class  CBinaryRelation
 This class models a binary relation through the elements of any given set. More...
class  CGraphPartitioner
 Algorithms for finding the min-normalized-cut of a weighted undirected graph. More...
class  CHistogram
 This class provides an easy way of computing histograms for unidimensional real valued variables. More...
class  CLevenbergMarquardtTempl
 An implementation of the Levenberg-Marquardt algorithm for least-square minimization. More...
struct  CMatrixPtr
class  CMatrix
 This class is a "CSerializable" wrapper for "CMatrixFloat". More...
struct  CMatrixBPtr
class  CMatrixB
 This class is a "CSerializable" wrapper for "CMatrixBool". More...
struct  CMatrixDPtr
class  CMatrixD
 This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>". More...
class  CMatrixFixedNumeric
 A numeric matrix of compile-time fixed size. More...
class  CMatrixTemplate
 This template class provides the basic functionality for a general 2D any-size, resizable container of numerical or non-numerical elements. More...
class  CMatrixTemplateNumeric
 A matrix of dynamic size. More...
class  CMatrixTemplateObjects
 This template class extends the class "CMatrixTemplate" for storing "objects" at each matrix entry. More...
class  CMonteCarlo
 Montecarlo simulation for experiments in 1D. More...
struct  CPolygonPtr
class  CPolygon
 A wrapper of a TPolygon2D class, implementing CSerializable. More...
class  CQuaternion
 A quaternion, which can represent a 3D rotation as pair $ (r,\mathbf{u}) $, with a real part "r" and a 3D vector $ \mathbf{u} = (x,y,z) $, or alternatively, q = r + ix + jy + kz. More...
class  CExceptionNotDefPos
 Used in mrpt::math::CSparseMatrix. More...
class  CSparseMatrix
 A sparse matrix capable of efficient math operations (a wrapper around the CSparse library) The type of cells is fixed to "double". More...
class  CSparseMatrixTemplate
 A sparse matrix container (with cells of any type), with iterators. More...
class  CSparseSymmetricalMatrix
 A sparse matrix container for square symmetrical content around the main diagonal. More...
struct  CSplineInterpolator1DPtr
class  CSplineInterpolator1D
 A (persistent) sequence of (x,y) coordinates, allowing queries of intermediate points through spline interpolation, where possible. More...
class  CDijkstra
 The Dijkstra algorithm for finding the shortest path between a given source node in a (weighted) directed graph and all other nodes in the form of a tree. More...
class  TPolygonWithPlane
 Slightly heavyweight type to speed-up calculations with polygons in 3D. More...
class  CDirectedGraph
 A directed graph with the argument of the template specifying the type of the annotations in the edges. More...
class  CDirectedTree
 A special kind of graph in the form of a tree with directed edges and optional edge annotations of templatized type "TYPE_EDGES". More...
class  KDTreeCapable
 A base virtual class providing automatic, cached KD-tree-based look-up of points among data of arbitrary dimensionality. More...
struct  TPoint2D
 Lightweight 2D point. More...
struct  TPose2D
 Lightweight 2D pose. More...
struct  TPoint3Df
 Lightweight 3D point (float version). More...
struct  TPoint3D
 Lightweight 3D point. More...
struct  TPose3D
 Lightweight 3D pose (three spatial coordinates, plus three angular coordinates). More...
struct  TPose3DQuat
 Lightweight 3D pose (three spatial coordinates, plus a quaternion ). More...
struct  TSegment2D
 2D segment, consisting of two points. More...
struct  TSegment3D
 3D segment, consisting of two points. More...
struct  TLine2D
 2D line without bounds, represented by its equation $Ax+By+C=0$. More...
struct  TLine3D
 3D line, represented by a base point and a director vector. More...
struct  TPlane
 3D Plane, represented by its equation $Ax+By+Cz+D=0$ More...
class  TPolygon2D
 2D polygon, inheriting from std::vector<TPoint2D>. More...
class  TPolygon3D
 3D polygon, inheriting from std::vector<TPoint3D> More...
struct  TObject2D
 Standard type for storing any lightweight 2D type. More...
struct  TObject3D
 Standard object for storing any 3D lightweight object. More...
class  CMatrixRowAccessor
 A vector-like wrapper for a Matrix for accessing the elements of a given row with a [] operator. More...
class  CMatrixRowAccessorExtended
 A vector-like wrapper for a Matrix for accessing the elements of a given row with a [] operator, with offset and custom spacing. More...
class  CConstMatrixRowAccessor
 A vector-like wrapper for a const Matrix for accessing the elements of a given row with a [] operator. More...
class  CConstMatrixRowAccessorExtended
 A vector-like wrapper for a const Matrix for accessing the elements of a given row with a [] operator, with offset and custom spacing. More...
class  CMatrixColumnAccessor
 A vector-like wrapper for a Matrix for accessing the elements of a given column with a [] operator. More...
class  CMatrixColumnAccessorExtended
 A vector-like wrapper for a Matrix for accessing the elements of a given column with a [] operator, with offset and custom spacing. More...
class  CConstMatrixColumnAccessor
 A vector-like wrapper for a const Matrix for accessing the elements of a given column with a [] operator. More...
class  CConstMatrixColumnAccessorExtended
 A vector-like wrapper for a const Matrix for accessing the elements of a given column with a [] operator, with offset and custom spacing. More...
class  ModelSearch
 Model search implementations: RANSAC and genetic algorithm. More...
class  RANSAC_Template
 A generic RANSAC implementation with models as matrices. More...

Typedefs

typedef
CLevenbergMarquardtTempl
< vector_double
CLevenbergMarquardt
 The default name for the LM class is an instantiation for "double".
typedef CMatrixTemplateNumeric
< float > 
CMatrixFloat
 Declares a matrix of float numbers (non serializable).
typedef CMatrixTemplateNumeric
< double > 
CMatrixDouble
 Declares a matrix of double numbers (non serializable).
typedef CMatrixTemplateNumeric
< unsigned int > 
CMatrixUInt
 Declares a matrix of unsigned ints (non serializable).
typedef CMatrixTemplate< bool > CMatrixBool
 Declares a matrix of booleans (non serializable).
typedef CMatrixTemplateNumeric
< double > 
CMatrixLongDouble
 Declares a matrix of "long doubles" (non serializable), or of "doubles" if the compiler does not support "long double".
typedef CQuaternion< double > CQuaternionDouble
 A quaternion of data type "double".
typedef CQuaternion< float > CQuaternionFloat
 A quaternion of data type "float".
typedef mrpt::vector_float CVectorFloat
 This is just another name for mrpt::vector_float (Backward compatibility with MRPT <=0.9.2).
typedef mrpt::vector_double CVectorDouble
 This is just another name for mrpt::vector_double (Backward compatibility with MRPT <=0.9.2).
typedef TPlane TPlane3D
typedef RANSAC_Template< double > RANSAC
 The default instance of RANSAC, for double type.
Typedefs for common sizes

typedef CMatrixFixedNumeric
< double, 2, 2 > 
CMatrixDouble22
typedef CMatrixFixedNumeric
< double, 2, 3 > 
CMatrixDouble23
typedef CMatrixFixedNumeric
< double, 3, 2 > 
CMatrixDouble32
typedef CMatrixFixedNumeric
< double, 3, 3 > 
CMatrixDouble33
typedef CMatrixFixedNumeric
< double, 4, 4 > 
CMatrixDouble44
typedef CMatrixFixedNumeric
< double, 6, 6 > 
CMatrixDouble66
typedef CMatrixFixedNumeric
< double, 7, 7 > 
CMatrixDouble77
typedef CMatrixFixedNumeric
< double, 1, 3 > 
CMatrixDouble13
typedef CMatrixFixedNumeric
< double, 3, 1 > 
CMatrixDouble31
typedef CMatrixFixedNumeric
< double, 1, 2 > 
CMatrixDouble12
typedef CMatrixFixedNumeric
< double, 2, 1 > 
CMatrixDouble21
typedef CMatrixFixedNumeric
< double, 6, 1 > 
CMatrixDouble61
typedef CMatrixFixedNumeric
< double, 1, 6 > 
CMatrixDouble16
typedef CMatrixFixedNumeric
< double, 7, 1 > 
CMatrixDouble71
typedef CMatrixFixedNumeric
< double, 1, 7 > 
CMatrixDouble17
typedef CMatrixFixedNumeric
< double, 5, 1 > 
CMatrixDouble51
typedef CMatrixFixedNumeric
< double, 1, 5 > 
CMatrixDouble15
typedef CMatrixFixedNumeric
< float, 2, 2 > 
CMatrixFloat22
typedef CMatrixFixedNumeric
< float, 2, 3 > 
CMatrixFloat23
typedef CMatrixFixedNumeric
< float, 3, 2 > 
CMatrixFloat32
typedef CMatrixFixedNumeric
< float, 3, 3 > 
CMatrixFloat33
typedef CMatrixFixedNumeric
< float, 4, 4 > 
CMatrixFloat44
typedef CMatrixFixedNumeric
< float, 6, 6 > 
CMatrixFloat66
typedef CMatrixFixedNumeric
< float, 7, 7 > 
CMatrixFloat77
typedef CMatrixFixedNumeric
< float, 1, 3 > 
CMatrixFloat13
typedef CMatrixFixedNumeric
< float, 3, 1 > 
CMatrixFloat31
typedef CMatrixFixedNumeric
< float, 1, 2 > 
CMatrixFloat12
typedef CMatrixFixedNumeric
< float, 2, 1 > 
CMatrixFloat21
typedef CMatrixFixedNumeric
< float, 6, 1 > 
CMatrixFloat61
typedef CMatrixFixedNumeric
< float, 1, 6 > 
CMatrixFloat16
typedef CMatrixFixedNumeric
< float, 7, 1 > 
CMatrixFloat71
typedef CMatrixFixedNumeric
< float, 1, 7 > 
CMatrixFloat17
typedef CMatrixFixedNumeric
< float, 5, 1 > 
CMatrixFloat51
typedef CMatrixFixedNumeric
< float, 1, 5 > 
CMatrixFloat15

Enumerations

enum  TConstructorFlags_Quaternions { UNINITIALIZED_QUATERNION = 0 }
enum  TMatrixTextFileFormat { MATRIX_FORMAT_ENG = 0, MATRIX_FORMAT_FIXED = 1, MATRIX_FORMAT_INT = 2 }
enum  TConstructorFlags_Matrices { UNINITIALIZED_MATRIX = 0 }
 

For usage in one of the constructors of CMatrixFixedNumeric or CMatrixTemplate (and derived classes), if it's not required to fill it with zeros at the constructor to save time.

More...

Functions

template<class T , std::size_t N>
bool operator== (const CArray< T, N > &x, const CArray< T, N > &y)
template<class T , std::size_t N>
bool operator< (const CArray< T, N > &x, const CArray< T, N > &y)
template<class T , std::size_t N>
bool operator!= (const CArray< T, N > &x, const CArray< T, N > &y)
template<class T , std::size_t N>
bool operator> (const CArray< T, N > &x, const CArray< T, N > &y)
template<class T , std::size_t N>
bool operator<= (const CArray< T, N > &x, const CArray< T, N > &y)
template<class T , std::size_t N>
bool operator>= (const CArray< T, N > &x, const CArray< T, N > &y)
BASE_IMPEXP::mrpt::utils::CStream & operator>> (mrpt::utils::CStream &in, CMatrixPtr &pObj)
::mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &in, CMatrixBPtr &pObj)
BASE_IMPEXP::mrpt::utils::CStream & operator>> (mrpt::utils::CStream &in, CMatrixDPtr &pObj)
::mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &in, CPolygonPtr &pObj)
::mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &in, CSplineInterpolator1DPtr &pObj)
std::ostream BASE_IMPEXP & operator<< (std::ostream &o, const TPoint2D &p)
std::ostream BASE_IMPEXP & operator<< (std::ostream &o, const TPoint3D &p)
std::ostream BASE_IMPEXP & operator<< (std::ostream &o, const TPose2D &p)
std::ostream BASE_IMPEXP & operator<< (std::ostream &o, const TPose3D &p)
std::ostream BASE_IMPEXP & operator<< (std::ostream &o, const TPose3DQuat &p)
TPoint3D operator- (const TPoint3D &p1)
 Unary minus operator for 3D points.
bool operator== (const TPoint2D &p1, const TPoint2D &p2)
 Exact comparison between 2D points.
bool operator!= (const TPoint2D &p1, const TPoint2D &p2)
 Exact comparison between 2D points.
bool operator== (const TPoint3D &p1, const TPoint3D &p2)
 Exact comparison between 3D points.
bool operator!= (const TPoint3D &p1, const TPoint3D &p2)
 Exact comparison between 3D points.
bool operator== (const TPose2D &p1, const TPose2D &p2)
 Exact comparison between 2D poses, taking possible cycles into account.
bool operator!= (const TPose2D &p1, const TPose2D &p2)
 Exact comparison between 2D poses, taking possible cycles into account.
bool operator== (const TPose3D &p1, const TPose3D &p2)
 Exact comparison between 3D poses, taking possible cycles into account.
bool operator!= (const TPose3D &p1, const TPose3D &p2)
 Exact comparison between 3D poses, taking possible cycles into account.
bool operator== (const TSegment2D &s1, const TSegment2D &s2)
bool operator!= (const TSegment2D &s1, const TSegment2D &s2)
bool operator== (const TSegment3D &s1, const TSegment3D &s2)
bool operator!= (const TSegment3D &s1, const TSegment3D &s2)
BASE_IMPEXP mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &in, mrpt::math::TPoint2D &o)
 TPoint2D binary input.
BASE_IMPEXP mrpt::utils::CStreamoperator<< (mrpt::utils::CStream &out, const mrpt::math::TPoint2D &o)
 TPoint2D binary output.
BASE_IMPEXP mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &in, mrpt::math::TPoint3D &o)
 TPoint3D binary input.
BASE_IMPEXP mrpt::utils::CStreamoperator<< (mrpt::utils::CStream &out, const mrpt::math::TPoint3D &o)
 TPoint3D binary output.
BASE_IMPEXP mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &in, mrpt::math::TPose2D &o)
 TPose2D binary input.
BASE_IMPEXP mrpt::utils::CStreamoperator<< (mrpt::utils::CStream &out, const mrpt::math::TPose2D &o)
 TPose2D binary output.
BASE_IMPEXP mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &in, mrpt::math::TPose3D &o)
 TPose3D binary input.
BASE_IMPEXP mrpt::utils::CStreamoperator<< (mrpt::utils::CStream &out, const mrpt::math::TPose3D &o)
 TPose3D binary output.
mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &in, mrpt::math::TSegment2D &s)
 TSegment2D binary input.
mrpt::utils::CStreamoperator<< (mrpt::utils::CStream &out, const mrpt::math::TSegment2D &s)
 TSegment2D binary output.
mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &in, mrpt::math::TLine2D &l)
 TLine2D binary input.
mrpt::utils::CStreamoperator<< (mrpt::utils::CStream &out, const mrpt::math::TLine2D &l)
 TLine2D binary output.
BASE_IMPEXP mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &in, mrpt::math::TObject2D &o)
 TObject2D binary input.
BASE_IMPEXP mrpt::utils::CStreamoperator<< (mrpt::utils::CStream &out, const mrpt::math::TObject2D &o)
 TObject2D binary input.
mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &in, mrpt::math::TSegment3D &s)
 TSegment3D binary input.
mrpt::utils::CStreamoperator<< (mrpt::utils::CStream &out, const mrpt::math::TSegment3D &s)
 TSegment3D binary output.
mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &in, mrpt::math::TLine3D &l)
 TLine3D binary input.
mrpt::utils::CStreamoperator<< (mrpt::utils::CStream &out, const mrpt::math::TLine3D &l)
 TLine3D binary output.
mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &in, mrpt::math::TPlane &p)
 TPlane binary input.
mrpt::utils::CStreamoperator<< (mrpt::utils::CStream &out, const mrpt::math::TPlane &p)
 TPlane binary output.
BASE_IMPEXP mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &in, mrpt::math::TObject3D &o)
 TObject3D binary input.
BASE_IMPEXP mrpt::utils::CStreamoperator<< (mrpt::utils::CStream &out, const mrpt::math::TObject3D &o)
 TObject3D binary output.
template<class CONTAINER1 , class CONTAINER2 >
void cumsum (const CONTAINER1 &in_data, CONTAINER2 &out_cumsum)
 Computes the cumulative sum of all the elements, saving the result in another container.
template<class CONTAINER >
CONTAINER::value_type norm (const CONTAINER &v)
template<class CONTAINER >
CONTAINER::value_type norm_inf (const CONTAINER &v)
template<class MAT_A , class SKEW_3VECTOR , class MAT_OUT >
void multiply_A_skew3 (const MAT_A &A, const SKEW_3VECTOR &v, MAT_OUT &out)
 Only for vectors/arrays "v" of length3, compute out = A * Skew(v), where Skew(v) is the skew symmetric matric generated from v (see mrpt::math::skew_symmetric3).
template<class SKEW_3VECTOR , class MAT_A , class MAT_OUT >
void multiply_skew3_A (const SKEW_3VECTOR &v, const MAT_A &A, MAT_OUT &out)
 Only for vectors/arrays "v" of length3, compute out = Skew(v) * A, where Skew(v) is the skew symmetric matric generated from v (see mrpt::math::skew_symmetric3).
template<class CONTAINER >
CONTAINER & containerFromPoseOrPoint (CONTAINER &C, const mrpt::poses::CPoint2D &p)
template<class CONTAINER >
CONTAINER & containerFromPoseOrPoint (CONTAINER &C, const mrpt::poses::CPoint3D &p)
template<class CONTAINER >
CONTAINER & containerFromPoseOrPoint (CONTAINER &C, const mrpt::poses::CPose2D &p)
template<class CONTAINER >
CONTAINER & containerFromPoseOrPoint (CONTAINER &C, const mrpt::poses::CPose3D &p)
template<class CONTAINER >
CONTAINER & containerFromPoseOrPoint (CONTAINER &C, const mrpt::poses::CPose3DQuat &p)
template<class T >
wrapTo2Pi (T a)
 Modifies the given angle to translate it into the [0,2pi[ range.
template<typename MAT >
CMatrixRowAccessor< MAT > getRowAccessor (MAT &m, size_t rowIdx)
template<typename MAT >
CMatrixRowAccessorExtended< MAT > getRowAccessor (MAT &m, size_t rowIdx, size_t offset, size_t space=1)
template<typename MAT >
CConstMatrixRowAccessor< MAT > getRowAccessor (const MAT &m, size_t rowIdx)
template<typename MAT >
CConstMatrixRowAccessorExtended
< MAT > 
getRowAccessor (const MAT &m, size_t rowIdx, size_t offset, size_t space=1)
template<typename MAT >
CMatrixColumnAccessor< MAT > getColumnAccessor (MAT &m, size_t colIdx)
template<typename MAT >
CMatrixColumnAccessorExtended
< MAT > 
getColumnAccessor (MAT &m, size_t colIdx, size_t offset, size_t space=1)
template<typename MAT >
CConstMatrixColumnAccessor< MAT > getColumnAccessor (const MAT &m, size_t colIdx)
template<typename MAT >
CConstMatrixColumnAccessorExtended
< MAT > 
getColumnAccessor (const MAT &m, size_t colIdx, size_t offset, size_t space=1)
template<class CONTAINER >
vector_double histogram (const CONTAINER &v, double limit_min, double limit_max, size_t number_bins, bool do_normalization=false, vector_double *out_bin_centers=NULL)
 Computes the normalized or normal histogram of a sequence of numbers given the number of bins and the limits.
template<class CONTAINER >
CONTAINER cumsum (const CONTAINER &in_data)
 Computes the cumulative sum of all the elements.
template<class CONTAINER >
CONTAINER::value_type maximum (const CONTAINER &v)
template<class CONTAINER >
CONTAINER::value_type minimum (const CONTAINER &v)
template<typename T >
maximum (const std::vector< T > &v)
template<typename T >
minimum (const std::vector< T > &v)
template<class Derived >
const Eigen::MatrixBase
< Derived >::AdjointReturnType 
operator~ (const Eigen::MatrixBase< Derived > &m)
 Transpose operator for matrices.
template<class Derived >
Eigen::MatrixBase< Derived >
::PlainObject 
operator! (const Eigen::MatrixBase< Derived > &m)
 Unary inversion operator.
template<typename MAT_H , typename MAT_C , typename MAT_R >
void multiply_HCHt (const MAT_H &H, const MAT_C &C, MAT_R &R, bool accumResultInOutput)
 R = H * C * H^t (with C symmetric).
template<typename VECTOR_H , typename MAT_C >
MAT_C::value_type multiply_HCHt_scalar (const VECTOR_H &H, const MAT_C &C)
 r (a scalar) = H * C * H^t (with a vector H and a symmetric matrix C)
template<typename MAT_H , typename MAT_C , typename MAT_R >
void multiply_HtCH (const MAT_H &H, const MAT_C &C, MAT_R &R, bool accumResultInOutput)
 R = H^t * C * H (with C symmetric).
template<class MAT_IN , class VECTOR , class MAT_OUT >
void meanAndCovMat (const MAT_IN &v, VECTOR &out_mean, MAT_OUT &out_cov)
 Computes the mean vector and covariance from a list of samples in an NxM matrix, where each row is a sample, so the covariance is MxM.
template<class MATRIX >
Eigen::Matrix< typename
MATRIX::Scalar,
MATRIX::ColsAtCompileTime,
MATRIX::ColsAtCompileTime > 
cov (const MATRIX &v)
 Computes the covariance matrix from a list of samples in an NxM matrix, where each row is a sample, so the covariance is MxM.
template<class T >
std::ostream & operator<< (std::ostream &out, const std::vector< T > &d)
 A template function for printing out the contents of a std::vector variable.
template<class T >
std::ostream & operator<< (std::ostream &out, std::vector< T > *d)
 A template function for printing out the contents of a std::vector variable.
template<typename T , size_t N>
mrpt::utils::CStreamoperator<< (mrpt::utils::CStream &ostrm, const CArrayNumeric< T, N > &a)
 Binary dump of a CArrayNumeric<T,N> to a stream.
template<typename T , size_t N>
mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &istrm, CArrayNumeric< T, N > &a)
 Binary read of a CArrayNumeric<T,N> from a stream.
bool BASE_IMPEXP loadVector (utils::CFileStream &f, std::vector< int > &d)
 Loads one row of a text file as a numerical std::vector.
bool BASE_IMPEXP loadVector (utils::CFileStream &f, std::vector< double > &d)
 Loads one row of a text file as a numerical std::vector.
bool BASE_IMPEXP isNaN (float f) MRPT_NO_THROWS
 Returns true if the number is NaN.
bool BASE_IMPEXP isNaN (double f) MRPT_NO_THROWS
 Returns true if the number is NaN.
bool BASE_IMPEXP isFinite (float f) MRPT_NO_THROWS
 Returns true if the number is non infinity.
bool BASE_IMPEXP isFinite (double f) MRPT_NO_THROWS
 Returns true if the number is non infinity.
void BASE_IMPEXP medianFilter (const std::vector< double > &inV, std::vector< double > &outV, const int &winSize, const int &numberOfSigmas=2)
template<typename T , typename VECTOR >
void linspace (T first, T last, size_t count, VECTOR &out_vector)
 Generates an equidistant sequence of numbers given the first one, the last one and the desired number of points.
template<class T >
Eigen::Matrix< T,
Eigen::Dynamic, 1 > 
linspace (T first, T last, size_t count)
 Generates an equidistant sequence of numbers given the first one, the last one and the desired number of points.
template<class T , T STEP>
Eigen::Matrix< T,
Eigen::Dynamic, 1 > 
sequence (T first, size_t length)
 Generates a sequence of values [first,first+STEP,first+2*STEP,...].
template<class T , T STEP>
std::vector< T > sequenceStdVec (T first, size_t length)
 Generates a sequence of values [first,first+STEP,first+2*STEP,...].
template<class T >
Eigen::Matrix< T,
Eigen::Dynamic, 1 > 
ones (size_t count)
 Generates a vector of all ones of the given length.
template<class T >
Eigen::Matrix< T,
Eigen::Dynamic, 1 > 
zeros (size_t count)
 Generates a vector of all zeros of the given length.
template<class T >
void wrapTo2PiInPlace (T &a)
 Modifies the given angle to translate it into the [0,2pi[ range.
template<class T >
wrapToPi (T a)
 Modifies the given angle to translate it into the ]-pi,pi] range.
template<class T >
void wrapToPiInPlace (T &a)
 Modifies the given angle to translate it into the ]-pi,pi] range.
template<class VEC1 , class VEC2 >
void normalize (const VEC1 &v, VEC2 &out_v)
 Normalize a vector, such as its norm is the unity.
template<class VECTOR_OF_VECTORS , class MATRIXLIKE , class VECTORLIKE , class VECTORLIKE2 , class VECTORLIKE3 >
void covariancesAndMeanWeighted (const VECTOR_OF_VECTORS &elements, MATRIXLIKE &covariances, VECTORLIKE &means, const VECTORLIKE2 *weights_mean, const VECTORLIKE3 *weights_cov, const bool *elem_do_wrap2pi=NULL)
 Computes covariances and mean of any vector of containers, given optional weights for the different samples.
template<class VECTOR_OF_VECTORS , class MATRIXLIKE , class VECTORLIKE >
void covariancesAndMean (const VECTOR_OF_VECTORS &elements, MATRIXLIKE &covariances, VECTORLIKE &means, const bool *elem_do_wrap2pi=NULL)
 Computes covariances and mean of any vector of containers.
template<class VECTORLIKE1 , class VECTORLIKE2 >
void weightedHistogram (const VECTORLIKE1 &values, const VECTORLIKE1 &weights, float binWidth, VECTORLIKE2 &out_binCenters, VECTORLIKE2 &out_binValues)
 Computes the weighted histogram for a vector of values and their corresponding weights.
template<class VECTORLIKE1 , class VECTORLIKE2 >
void weightedHistogramLog (const VECTORLIKE1 &values, const VECTORLIKE1 &log_weights, float binWidth, VECTORLIKE2 &out_binCenters, VECTORLIKE2 &out_binValues)
 Computes the weighted histogram for a vector of values and their corresponding log-weights.
template<class VECTOR_OF_VECTORS , class VECTORLIKE >
void extractColumnFromVectorOfVectors (const size_t colIndex, const VECTOR_OF_VECTORS &data, VECTORLIKE &out_column)
 Extract a column from a vector of vectors, and store it in another vector.
uint64_t BASE_IMPEXP factorial64 (unsigned int n)
 Computes the factorial of an integer number and returns it as a 64-bit integer number.
double BASE_IMPEXP factorial (unsigned int n)
 Computes the factorial of an integer number and returns it as a double value (internally it uses logarithms for avoiding overflow).
template<class T >
round2up (T val)
 Round up to the nearest power of two of a given number.
template<class T >
round_10power (T val, int power10)
 Round a decimal number up to the given 10'th power (eg, to 1000,100,10, and also fractions) power10 means round up to: 1 -> 10, 2 -> 100, 3 -> 1000, ...
template<class T >
double correlate_matrix (const CMatrixTemplateNumeric< T > &a1, const CMatrixTemplateNumeric< T > &a2)
 Calculate the correlation between two matrices (by AJOGD @ JAN-2007).
double BASE_IMPEXP averageLogLikelihood (const vector_double &logLikelihoods)
 Matrix QR decomposition.
double BASE_IMPEXP averageWrap2Pi (const vector_double &angles)
 Computes the average of a sequence of angles in radians taking into account the correct wrapping in the range $ ]-\pi,\pi [ $, for example, the mean of (2,-2) is $ \pi $, not 0.
double BASE_IMPEXP averageLogLikelihood (const vector_double &logWeights, const vector_double &logLikelihoods)
 A numerically-stable method to average likelihood values with strongly different ranges (weighted likelihoods).
std::string BASE_IMPEXP MATLAB_plotCovariance2D (const CMatrixFloat &cov22, const vector_float &mean, const float &stdCount, const std::string &style=std::string("b"), const size_t &nEllipsePoints=30)
 Generates a string with the MATLAB commands required to plot an confidence interval (ellipse) for a 2D Gaussian ('float' version).
template<class MATRIXLIKE1 , class MATRIXLIKE2 >
void homogeneousMatrixInverse (const MATRIXLIKE1 &M, MATRIXLIKE2 &out_inverse_M)
 Efficiently compute the inverse of a 4x4 homogeneous matrix by only transposing the rotation 3x3 part and solving the translation with dot products.
template<class IN_ROTMATRIX , class IN_XYZ , class OUT_ROTMATRIX , class OUT_XYZ >
void homogeneousMatrixInverse (const IN_ROTMATRIX &in_R, const IN_XYZ &in_xyz, OUT_ROTMATRIX &out_R, OUT_XYZ &out_xyz)
template<class MATRIXLIKE >
void homogeneousMatrixInverse (MATRIXLIKE &M)
template<class VECTORLIKE , class VECTORLIKE2 , class VECTORLIKE3 , class MATRIXLIKE , class USERPARAM >
void estimateJacobian (const VECTORLIKE &x, void(*functor)(const VECTORLIKE &x, const USERPARAM &y, VECTORLIKE3 &out), 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.
template<typename T , typename At , size_t N>
std::vector< T > & loadVector (std::vector< T > &v, At(&theArray)[N])
 Assignment operator for initializing a std::vector from a C array (The vector will be automatically set to the correct size).
template<typename Derived , typename At , size_t N>
Eigen::EigenBase< Derived > & loadVector (Eigen::EigenBase< Derived > &v, At(&theArray)[N])
void unwrap2PiSequence (vector_double &x)
 Modify a sequence of angle values such as no consecutive values have a jump larger than PI in absolute value.
template<size_t N, typename T >
std::vector< T > make_vector (const T val1,...)
 A versatile template to build vectors on-the-fly in a style close to MATLAB's v=[a b c d ...] The first argument of the template is the vector length, and the second the type of the numbers.
template<class MATRIXLIKE >
size_t size (const MATRIXLIKE &m, int dim)
Statistics functions

double BASE_IMPEXP normalPDF (double x, double mu, double std)
 Evaluates the univariate normal (Gaussian) distribution at a given point "x".
template<class VECTORLIKE1 , class VECTORLIKE2 , class MATRIXLIKE >
MATRIXLIKE::value_type normalPDF (const VECTORLIKE1 &x, const VECTORLIKE2 &mu, const MATRIXLIKE &cov, const bool scaled_pdf=false)
 Evaluates the multivariate normal (Gaussian) distribution at a given point "x".
template<typename VECTORLIKE , typename MATRIXLIKE >
MATRIXLIKE::value_type normalPDF (const VECTORLIKE &d, const MATRIXLIKE &cov)
 Evaluates the multivariate normal (Gaussian) distribution at a given point given its distance vector "d" from the Gaussian mean.
template<typename VECTORLIKE1 , typename MATRIXLIKE1 , typename VECTORLIKE2 , typename MATRIXLIKE2 >
double KLD_Gaussians (const VECTORLIKE1 &mu0, const MATRIXLIKE1 &cov0, const VECTORLIKE2 &mu1, const MATRIXLIKE2 &cov1)
 Kullback-Leibler divergence (KLD) between two independent multivariate Gaussians.
double BASE_IMPEXP erfc (double x)
 The complementary error function of a Normal distribution.
double BASE_IMPEXP erf (double x)
 The error function of a Normal distribution.
double BASE_IMPEXP normalQuantile (double p)
 Evaluates the Gaussian distribution quantile for the probability value p=[0,1].
double BASE_IMPEXP normalCDF (double p)
 Evaluates the Gaussian cumulative density function.
double BASE_IMPEXP chi2inv (double P, unsigned int dim=1)
 The "quantile" of the Chi-Square distribution, for dimension "dim" and probability 0<P<1 (the inverse of chi2CDF) An aproximation from the Wilson-Hilferty transformation is used.
template<class T >
double noncentralChi2CDF (unsigned int degreesOfFreedom, T noncentrality, T arg)
double chi2CDF (unsigned int degreesOfFreedom, double arg)
double chi2PDF (unsigned int degreesOfFreedom, double arg, double accuracy=1e-7)
template<typename CONTAINER >
void condidenceIntervals (const CONTAINER &data, typename CONTAINER::value_type &out_mean, typename CONTAINER::value_type &out_lower_conf_interval, typename CONTAINER::value_type &out_upper_conf_interval, const double confidenceInterval=0.1, const size_t histogramNumBins=1000)
 Return the mean and the 10-90% confidence points (or with any other confidence value) of a set of samples by building the cummulative CDF of all the elements of the container.
Fourier functions

void BASE_IMPEXP fft_real (vector_float &in_realData, vector_float &out_FFT_Re, vector_float &out_FFT_Im, vector_float &out_FFT_Mag)
 Computes the FFT of a 2^N-size vector of real numbers, and returns the Re+Im+Magnitude parts.
void BASE_IMPEXP dft2_real (const CMatrixFloat &in_data, CMatrixFloat &out_real, CMatrixFloat &out_imag)
 Compute the 2D Discrete Fourier Transform (DFT) of a real matrix, returning the real and imaginary parts separately.
void BASE_IMPEXP idft2_real (const CMatrixFloat &in_real, const CMatrixFloat &in_imag, CMatrixFloat &out_data)
 Compute the 2D inverse Discrete Fourier Transform (DFT).
void BASE_IMPEXP dft2_complex (const CMatrixFloat &in_real, const CMatrixFloat &in_imag, CMatrixFloat &out_real, CMatrixFloat &out_imag)
 Compute the 2D Discrete Fourier Transform (DFT) of a complex matrix, returning the real and imaginary parts separately.
void BASE_IMPEXP idft2_complex (const CMatrixFloat &in_real, const CMatrixFloat &in_imag, CMatrixFloat &out_real, CMatrixFloat &out_imag)
 Compute the 2D inverse Discrete Fourier Transform (DFT).
void BASE_IMPEXP cross_correlation_FFT (const CMatrixFloat &A, const CMatrixFloat &B, CMatrixFloat &out_corr)
 Correlation of two matrixes using 2D FFT.
Simple intersection operations, relying basically on geometrical operations.

bool BASE_IMPEXP intersect (const TSegment3D &s1, const TSegment3D &s2, TObject3D &obj)
 Gets the intersection between two 3D segments.
bool BASE_IMPEXP intersect (const TSegment3D &s1, const TPlane &p2, TObject3D &obj)
 Gets the intersection between a 3D segment and a plane.
bool BASE_IMPEXP intersect (const TSegment3D &s1, const TLine3D &r2, TObject3D &obj)
 Gets the intersection between a 3D segment and a 3D line.
bool intersect (const TPlane &p1, const TSegment3D &s2, TObject3D &obj)
 Gets the intersection between a plane and a 3D segment.
bool BASE_IMPEXP intersect (const TPlane &p1, const TPlane &p2, TObject3D &obj)
 Gets the intersection between two planes.
bool BASE_IMPEXP intersect (const TPlane &p1, const TLine3D &p2, TObject3D &obj)
 Gets the intersection between a plane and a 3D line.
bool intersect (const TLine3D &r1, const TSegment3D &s2, TObject3D &obj)
 Gets the intersection between a 3D line and a 3D segment.
bool intersect (const TLine3D &r1, const TPlane &p2, TObject3D &obj)
 Gets the intersection between a 3D line and a plane.
bool BASE_IMPEXP intersect (const TLine3D &r1, const TLine3D &r2, TObject3D &obj)
 Gets the intersection between two 3D lines.
bool BASE_IMPEXP intersect (const TLine2D &r1, const TLine2D &r2, TObject2D &obj)
 Gets the intersection between two 2D lines.
bool BASE_IMPEXP intersect (const TLine2D &r1, const TSegment2D &s2, TObject2D &obj)
 Gets the intersection between a 2D line and a 2D segment.
bool intersect (const TSegment2D &s1, const TLine2D &r2, TObject2D &obj)
 Gets the intersection between a 2D line and a 2D segment.
bool BASE_IMPEXP intersect (const TSegment2D &s1, const TSegment2D &s2, TObject2D &obj)
 Gets the intersection between two 2D segments.
Angle retrieval methods. Methods which use TSegments will automatically use TLines' implicit constructors.

double BASE_IMPEXP getAngle (const TPlane &p1, const TPlane &p2)
 Computes the angle between two planes.
double BASE_IMPEXP getAngle (const TPlane &p1, const TLine3D &r2)
 Computes the angle between a plane and a 3D line or segment (implicit constructor will be used if passing a segment instead of a line).
double getAngle (const TLine3D &r1, const TPlane &p2)
 Computes the angle between a 3D line or segment and a plane (implicit constructor will be used if passing a segment instead of a line).
double BASE_IMPEXP getAngle (const TLine3D &r1, const TLine3D &r2)
 Computes the angle between two 3D lines or segments (implicit constructor will be used if passing a segment instead of a line).
double BASE_IMPEXP getAngle (const TLine2D &r1, const TLine2D &r2)
 Computes the angle between two 2D lines or segments (implicit constructor will be used if passing a segment instead of a line).
Creation of lines from poses.

void BASE_IMPEXP createFromPoseX (const CPose3D &p, TLine3D &r)
 Gets a 3D line corresponding to the X axis in a given pose.
void BASE_IMPEXP createFromPoseY (const CPose3D &p, TLine3D &r)
 Gets a 3D line corresponding to the Y axis in a given pose.
void BASE_IMPEXP createFromPoseZ (const CPose3D &p, TLine3D &r)
 Gets a 3D line corresponding to the Z axis in a given pose.
void BASE_IMPEXP createFromPoseAndVector (const CPose3D &p, const double(&vector)[3], TLine3D &r)
 Gets a 3D line corresponding to any arbitrary vector, in the base given by the pose.
void BASE_IMPEXP createFromPoseX (const TPose2D &p, TLine2D &r)
 Gets a 2D line corresponding to the X axis in a given pose.
void BASE_IMPEXP createFromPoseY (const TPose2D &p, TLine2D &r)
 Gets a 2D line corresponding to the Y axis in a given pose.
void BASE_IMPEXP createFromPoseAndVector (const TPose2D &p, const double(&vector)[2], TLine2D &r)
 Gets a 2D line corresponding to any arbitrary vector, in the base given the given pose.
Other line or plane related methods.

bool BASE_IMPEXP conformAPlane (const std::vector< TPoint3D > &points)
 Checks whether this polygon or set of points acceptably fits a plane.
bool BASE_IMPEXP conformAPlane (const std::vector< TPoint3D > &points, TPlane &p)
 Checks whether this polygon or set of points acceptably fits a plane, and if it's the case returns it in the second argument.
bool BASE_IMPEXP areAligned (const std::vector< TPoint2D > &points)
 Checks whether this set of points acceptably fits a 2D line.
bool BASE_IMPEXP areAligned (const std::vector< TPoint2D > &points, TLine2D &r)
 Checks whether this set of points acceptably fits a 2D line, and if it's the case returns it in the second argument.
bool BASE_IMPEXP areAligned (const std::vector< TPoint3D > &points)
 Checks whether this set of points acceptably fits a 3D line.
bool BASE_IMPEXP areAligned (const std::vector< TPoint3D > &points, TLine3D &r)
 Checks whether this set of points acceptably fits a 3D line, and if it's the case returns it in the second argument.
Projections

void project3D (const TPoint3D &point, const CPose3D &newXYpose, TPoint3D &newPoint)
 Uses the given pose 3D to project a point into a new base.
void project3D (const TSegment3D &segment, const CPose3D &newXYpose, TSegment3D &newSegment)
 Uses the given pose 3D to project a segment into a new base.
void BASE_IMPEXP project3D (const TLine3D &line, const CPose3D &newXYpose, TLine3D &newLine)
 Uses the given pose 3D to project a line into a new base.
void BASE_IMPEXP project3D (const TPlane &plane, const CPose3D &newXYpose, TPlane &newPlane)
 Uses the given pose 3D to project a plane into a new base.
void BASE_IMPEXP project3D (const TPolygon3D &polygon, const CPose3D &newXYpose, TPolygon3D &newPolygon)
 Uses the given pose 3D to project a polygon into a new base.
void BASE_IMPEXP project3D (const TObject3D &object, const CPose3D &newXYPose, TObject3D &newObject)
 Uses the given pose 3D to project any 3D object into a new base.
template<class T >
void project3D (const T &obj, const TPlane &newXYPlane, T &newObj)
 Projects any 3D object into the plane's base, using its inverse pose.
template<class T >
void project3D (const T &obj, const TPlane &newXYPlane, const TPoint3D &newOrigin, T &newObj)
 Projects any 3D object into the plane's base, using its inverse pose and forcing the position of the new coordinates origin.
template<class T >
void project3D (const std::vector< T > &objs, const CPose3D &newXYpose, std::vector< T > &newObjs)
 Projects a set of 3D objects into the plane's base.
void project2D (const TPoint2D &point, const CPose2D &newXpose, TPoint2D &newPoint)
 Uses the given pose 2D to project a point into a new base.
void project2D (const TSegment2D &segment, const CPose2D &newXpose, TSegment2D &newSegment)
 Uses the given pose 2D to project a segment into a new base.
void BASE_IMPEXP project2D (const TLine2D &line, const CPose2D &newXpose, TLine2D &newLine)
 Uses the given pose 2D to project a line into a new base.
void BASE_IMPEXP project2D (const TPolygon2D &polygon, const CPose2D &newXpose, TPolygon2D &newPolygon)
 Uses the given pose 2D to project a polygon into a new base.
void BASE_IMPEXP project2D (const TObject2D &object, const CPose2D &newXpose, TObject2D &newObject)
 Uses the given pose 2D to project any 2D object into a new base.
template<class T >
void project2D (const T &obj, const TLine2D &newXLine, T &newObj)
 Projects any 2D object into the line's base, using its inverse pose.
template<class T >
void project2D (const T &obj, const TLine2D &newXLine, const TPoint2D &newOrigin, T &newObj)
 Projects any 2D object into the line's base, using its inverse pose and forcing the position of the new coordinate origin.
template<class T >
void project2D (const std::vector< T > &objs, const CPose2D &newXpose, std::vector< T > &newObjs)
 Projects a set of 2D objects into the line's base.
Polygon intersections. These operations rely more on spatial reasoning than in raw numerical operations.

bool BASE_IMPEXP intersect (const TPolygon2D &p1, const TSegment2D &s2, TObject2D &obj)
 Gets the intersection between a 2D polygon and a 2D segment.
bool BASE_IMPEXP intersect (const TPolygon2D &p1, const TLine2D &r2, TObject2D &obj)
 Gets the intersection between a 2D polygon and a 2D line.
bool BASE_IMPEXP intersect (const TPolygon2D &p1, const TPolygon2D &p2, TObject2D &obj)
 Gets the intersection between two 2D polygons.
bool intersect (const TSegment2D &s1, const TPolygon2D &p2, TObject2D &obj)
 Gets the intersection between a 2D segment and a 2D polygon.
bool intersect (const TLine2D &r1, const TPolygon2D &p2, TObject2D &obj)
 Gets the intersection between a 2D line and a 2D polygon.
bool BASE_IMPEXP intersect (const TPolygon3D &p1, const TSegment3D &s2, TObject3D &obj)
 Gets the intersection between a 3D polygon and a 3D segment.
bool BASE_IMPEXP intersect (const TPolygon3D &p1, const TLine3D &r2, TObject3D &obj)
 Gets the intersection between a 3D polygon and a 3D line.
bool BASE_IMPEXP intersect (const TPolygon3D &p1, const TPlane &p2, TObject3D &obj)
 Gets the intersection between a 3D polygon and a plane.
bool BASE_IMPEXP intersect (const TPolygon3D &p1, const TPolygon3D &p2, TObject3D &obj)
 Gets the intersection between two 3D polygons.
bool intersect (const TSegment3D &s1, const TPolygon3D &p2, TObject3D &obj)
 Gets the intersection between a 3D segment and a 3D polygon.
bool intersect (const TLine3D &r1, const TPolygon3D &p2, TObject3D &obj)
 Gets the intersection between a 3D line and a 3D polygon.
bool intersect (const TPlane &p1, const TPolygon3D &p2, TObject3D &obj)
 Gets the intersection between a plane and a 3D polygon.
size_t BASE_IMPEXP intersect (const std::vector< TPolygon3D > &v1, const std::vector< TPolygon3D > &v2, CSparseMatrixTemplate< TObject3D > &objs)
 Gets the intersection between two sets of 3D polygons.
size_t BASE_IMPEXP intersect (const std::vector< TPolygon3D > &v1, const std::vector< TPolygon3D > &v2, std::vector< TObject3D > &objs)
 Gets the intersection between two sets of 3D polygons.
Other intersections

template<class T , class U , class O >
size_t intersect (const std::vector< T > &v1, const std::vector< U > &v2, CSparseMatrixTemplate< O > &objs)
 Gets the intersection between vectors of geometric objects and returns it in a sparse matrix of either TObject2D or TObject3D.
template<class T , class U , class O >
size_t intersect (const std::vector< T > &v1, const std::vector< U > &v2, std::vector< O > objs)
 Gets the intersection between vectors of geometric objects and returns it in a vector of either TObject2D or TObject3D.
bool BASE_IMPEXP intersect (const TObject2D &o1, const TObject2D &o2, TObject2D &obj)
 Gets the intersection between any pair of 2D objects.
bool BASE_IMPEXP intersect (const TObject3D &o1, const TObject3D &o2, TObject3D &obj)
 Gets the intersection between any pair of 3D objects.
Distances

double BASE_IMPEXP distance (const TPoint2D &p1, const TPoint2D &p2)
 Gets the distance between two points in a 2D space.
double BASE_IMPEXP distance (const TPoint3D &p1, const TPoint3D &p2)
 Gets the distance between two points in a 3D space.
double BASE_IMPEXP distance (const TLine2D &r1, const TLine2D &r2)
 Gets the distance between two lines in a 2D space.
double BASE_IMPEXP distance (const TLine3D &r1, const TLine3D &r2)
 Gets the distance between two lines in a 3D space.
double BASE_IMPEXP distance (const TPlane &p1, const TPlane &p2)
 Gets the distance between two planes.
double BASE_IMPEXP distance (const TPolygon2D &p1, const TPolygon2D &p2)
 Gets the distance between two polygons in a 2D space.
double BASE_IMPEXP distance (const TPolygon2D &p1, const TSegment2D &s2)
 Gets the distance between a polygon and a segment in a 2D space.
double distance (const TSegment2D &s1, const TPolygon2D &p2)
 Gets the distance between a segment and a polygon in a 2D space.
double BASE_IMPEXP distance (const TPolygon2D &p1, const TLine2D &l2)
 Gets the distance between a polygon and a line in a 2D space.
double distance (const TLine2D &l1, const TPolygon2D &p2)
double BASE_IMPEXP distance (const TPolygon3D &p1, const TPolygon3D &p2)
 Gets the distance between two polygons in a 3D space.
double BASE_IMPEXP distance (const TPolygon3D &p1, const TSegment3D &s2)
 Gets the distance between a polygon and a segment in a 3D space.
double distance (const TSegment3D &s1, const TPolygon3D &p2)
 Gets the distance between a segment and a polygon in a 3D space.
double BASE_IMPEXP distance (const TPolygon3D &p1, const TLine3D &l2)
 Gets the distance between a polygon and a line in a 3D space.
double distance (const TLine3D &l1, const TPolygon3D &p2)
 Gets the distance between a line and a polygon in a 3D space.
double BASE_IMPEXP distance (const TPolygon3D &po, const TPlane &pl)
 Gets the distance between a polygon and a plane.
double distance (const TPlane &pl, const TPolygon3D &po)
 Gets the distance between a plane and a polygon.
Bound checkers

void BASE_IMPEXP getRectangleBounds (const std::vector< TPoint2D > &poly, TPoint2D &pMin, TPoint2D &pMax)
 Gets the rectangular bounds of a 2D polygon or set of 2D points.
void BASE_IMPEXP getPrismBounds (const std::vector< TPoint3D > &poly, TPoint3D &pMin, TPoint3D &pMax)
 Gets the prism bounds of a 3D polygon or set of 3D points.
Creation of planes from poses

void BASE_IMPEXP createPlaneFromPoseXY (const CPose3D &pose, TPlane &plane)
 Given a pose, creates a plane orthogonal to its Z vector.
void BASE_IMPEXP createPlaneFromPoseXZ (const CPose3D &pose, TPlane &plane)
 Given a pose, creates a plane orthogonal to its Y vector.
void BASE_IMPEXP createPlaneFromPoseYZ (const CPose3D &pose, TPlane &plane)
 Given a pose, creates a plane orthogonal to its X vector.
void BASE_IMPEXP createPlaneFromPoseAndNormal (const CPose3D &pose, const double(&normal)[3], TPlane &plane)
 Given a pose and any vector, creates a plane orthogonal to that vector in the pose's coordinates.
void BASE_IMPEXP generateAxisBaseFromDirectionAndAxis (const double(&vec)[3], char coord, CMatrixDouble &matrix)
 Creates a rotation matrix so that the coordinate given (0 for x, 1 for y, 2 for z) corresponds to the vector.
Linear regression methods

double BASE_IMPEXP getRegressionLine (const std::vector< TPoint2D > &points, TLine2D &line)
 Using eigenvalues, gets the best fitting line for a set of 2D points.
double BASE_IMPEXP getRegressionLine (const std::vector< TPoint3D > &points, TLine3D &line)
 Using eigenvalues, gets the best fitting line for a set of 3D points.
double BASE_IMPEXP getRegressionPlane (const std::vector< TPoint3D > &points, TPlane &plane)
 Using eigenvalues, gets the best fitting plane for a set of 3D points.
Miscellaneous Geometry methods

void BASE_IMPEXP assemblePolygons (const std::vector< TSegment3D > &segms, std::vector< TPolygon3D > &polys)
 Tries to assemble a set of segments into a set of closed polygons.
void BASE_IMPEXP assemblePolygons (const std::vector< TSegment3D > &segms, std::vector< TPolygon3D > &polys, std::vector< TSegment3D > &remainder)
 Tries to assemble a set of segments into a set of closed polygons, returning the unused segments as another out parameter.
void BASE_IMPEXP assemblePolygons (const std::vector< TObject3D > &objs, std::vector< TPolygon3D > &polys)
 Extracts all the polygons, including those formed from segments, from the set of objects.
void BASE_IMPEXP assemblePolygons (const std::vector< TObject3D > &objs, std::vector< TPolygon3D > &polys, std::vector< TObject3D > &remainder)
 Extracts all the polygons, including those formed from segments, from the set of objects.
void BASE_IMPEXP assemblePolygons (const std::vector< TObject3D > &objs, std::vector< TPolygon3D > &polys, std::vector< TSegment3D > &remainder1, std::vector< TObject3D > &remainder2)
 Extracts all the polygons, including those formed from segments, from the set of objects.
void setEpsilon (double nE)
 Changes the value of the geometric epsilon.
double getEpsilon ()
 Gets the value of the geometric epsilon.
bool BASE_IMPEXP splitInConvexComponents (const TPolygon2D &poly, vector< TPolygon2D > &components)
 Splits a 2D polygon into convex components.
bool BASE_IMPEXP splitInConvexComponents (const TPolygon3D &poly, vector< TPolygon3D > &components)
 Splits a 3D polygon into convex components.
void BASE_IMPEXP getSegmentBisector (const TSegment2D &sgm, TLine2D &bis)
 Gets the bisector of a 2D segment.
void BASE_IMPEXP getSegmentBisector (const TSegment3D &sgm, TPlane &bis)
 Gets the bisector of a 3D segment.
void BASE_IMPEXP getAngleBisector (const TLine2D &l1, const TLine2D &l2, TLine2D &bis)
 Gets the bisector of two lines or segments (implicit constructor will be used if necessary).
void BASE_IMPEXP getAngleBisector (const TLine3D &l1, const TLine3D &l2, TLine3D &bis)
 Gets the bisector of two lines or segments (implicit constructor will be used if necessary).
bool BASE_IMPEXP traceRay (const vector< TPolygonWithPlane > &vec, const mrpt::poses::CPose3D &pose, double &dist)
 Fast ray tracing method using polygons' properties.
bool traceRay (const vector< TPolygon3D > &vec, const mrpt::poses::CPose3D &pose, double &dist)
 Fast ray tracing method using polygons' properties.
template<class T , class U , class V >
void crossProduct3D (const T &v0, const U &v1, V &vOut)
 Computes the cross product of two 3D vectors, returning a vector normal to both.
template<class T >
void crossProduct3D (const std::vector< T > &v0, const std::vector< T > &v1, std::vector< T > &v_out)
template<class VEC1 , class VEC2 >
Eigen::Matrix< double, 3, 1 > crossProduct3D (const VEC1 &v0, const VEC2 &v1)
template<class VECTOR , class MATRIX >
void skew_symmetric3 (const VECTOR &v, MATRIX &M)
 Computes the 3x3 skew symmetric matrix from a 3-vector or 3-array:

\[ M([x ~ y ~ z]^\top) = \left( \begin{array}{c c c} 0 & -z & y \\ z & 0 & -x \\ -y & x & 0 \end{array} \right) \]

.

template<class VECTOR >
mrpt::math::CMatrixDouble33 skew_symmetric3 (const VECTOR &v)
template<class VECTOR , class MATRIX >
void skew_symmetric3_neg (const VECTOR &v, MATRIX &M)
 Computes the negative version of a 3x3 skew symmetric matrix from a 3-vector or 3-array:

\[ -M([x ~ y ~ z]^\top) = \left( \begin{array}{c c c} 0 & z & -y \\ -z & 0 & x \\ y & -x & 0 \end{array} \right) \]

.

template<class VECTOR >
mrpt::math::CMatrixDouble33 skew_symmetric3_neg (const VECTOR &v)
template<class T , class U >
bool vectorsAreParallel2D (const T &v1, const U &v2)
 Returns true if two 2D vectors are parallel.
template<class T , class U >
bool vectorsAreParallel3D (const T &v1, const U &v2)
 Returns true if two 3D vectors are parallel.
double BASE_IMPEXP minimumDistanceFromPointToSegment (const double &Px, const double &Py, const double &x1, const double &y1, const double &x2, const double &y2, double &out_x, double &out_y)
 Computes the closest point from a given point to a segment, and returns that minimum distance.
double BASE_IMPEXP minimumDistanceFromPointToSegment (const double &Px, const double &Py, const double &x1, const double &y1, const double &x2, const double &y2, float &out_x, float &out_y)
 Computes the closest point from a given point to a segment, and returns that minimum distance.
void BASE_IMPEXP closestFromPointToSegment (const double &Px, const double &Py, const double &x1, const double &y1, const double &x2, const double &y2, double &out_x, double &out_y)
 Computes the closest point from a given point to a segment.
void BASE_IMPEXP closestFromPointToLine (const double &Px, const double &Py, const double &x1, const double &y1, const double &x2, const double &y2, double &out_x, double &out_y)
 Computes the closest point from a given point to a (infinite) line.
double BASE_IMPEXP closestSquareDistanceFromPointToLine (const double &Px, const double &Py, const double &x1, const double &y1, const double &x2, const double &y2)
 Returns the square distance from a point to a line.
template<typename T >
distanceBetweenPoints (const T x1, const T y1, const T x2, const T y2)
 Returns the distance between 2 points in 2D.
template<typename T >
distanceBetweenPoints (const T x1, const T y1, const T z1, const T x2, const T y2, const T z2)
 Returns the distance between 2 points in 3D.
template<typename T >
distanceSqrBetweenPoints (const T x1, const T y1, const T x2, const T y2)
 Returns the square distance between 2 points in 2D.
template<typename T >
distanceSqrBetweenPoints (const T x1, const T y1, const T z1, const T x2, const T y2, const T z2)
 Returns the square distance between 2 points in 3D.
bool BASE_IMPEXP SegmentsIntersection (const double &x1, const double &y1, const double &x2, const double &y2, const double &x3, const double &y3, const double &x4, const double &y4, double &ix, double &iy)
 Returns the intersection point, and if it exists, between two segments.
bool BASE_IMPEXP SegmentsIntersection (const double &x1, const double &y1, const double &x2, const double &y2, const double &x3, const double &y3, const double &x4, const double &y4, float &ix, float &iy)
 Returns the intersection point, and if it exists, between two segments.
bool BASE_IMPEXP pointIntoPolygon2D (const double &px, const double &py, unsigned int polyEdges, const double *poly_xs, const double *poly_ys)
 Returns true if the 2D point (px,py) falls INTO the given polygon.
template<typename T >
bool pointIntoQuadrangle (T x, T y, T v1x, T v1y, T v2x, T v2y, T v3x, T v3y, T v4x, T v4y)
 Specialized method to check whether a point (x,y) falls into a quadrangle.
double BASE_IMPEXP distancePointToPolygon2D (const double &px, const double &py, unsigned int polyEdges, const double *poly_xs, const double *poly_ys)
 Returns the closest distance of a given 2D point to a polygon, or "0" if the point is INTO the polygon or its perimeter.
bool BASE_IMPEXP minDistBetweenLines (const double &p1_x, const double &p1_y, const double &p1_z, const double &p2_x, const double &p2_y, const double &p2_z, const double &p3_x, const double &p3_y, const double &p3_z, const double &p4_x, const double &p4_y, const double &p4_z, double &x, double &y, double &z, double &dist)
 Calculates the minimum distance between a pair of lines.
bool BASE_IMPEXP RectanglesIntersection (const double &R1_x_min, const double &R1_x_max, const double &R1_y_min, const double &R1_y_max, const double &R2_x_min, const double &R2_x_max, const double &R2_y_min, const double &R2_y_max, const double &R2_pose_x, const double &R2_pose_y, const double &R2_pose_phi)
 Returns wether two rotated rectangles intersect.
template<class T >
CMatrixTemplateNumeric< T > generateAxisBaseFromDirection (T dx, T dy, T dz)
 Computes an axis base (a set of three 3D normal vectors) with the given vector being the first of them.
template<typename VECTOR_LIKE , typename Precision , typename MATRIX_LIKE >
void rodrigues_so3_exp (const VECTOR_LIKE &w, const Precision A, const Precision B, MATRIX_LIKE &R)
 Compute a rotation exponential using the Rodrigues Formula.
k-means algorithms

template<class LIST_OF_VECTORS1 , class LIST_OF_VECTORS2 >
double kmeans (const size_t k, const LIST_OF_VECTORS1 &points, std::vector< int > &assignments, LIST_OF_VECTORS2 *out_centers=NULL, const size_t attempts=3)
 k-means algorithm to cluster a list of N points of arbitrary dimensionality into exactly K clusters.
template<class LIST_OF_VECTORS1 , class LIST_OF_VECTORS2 >
double kmeanspp (const size_t k, const LIST_OF_VECTORS1 &points, std::vector< int > &assignments, LIST_OF_VECTORS2 *out_centers=NULL, const size_t attempts=3)
 k-means++ algorithm to cluster a list of N points of arbitrary dimensionality into exactly K clusters.
Container initializer from pose classes

template<class CONTAINER >
CONTAINER & containerFromPoseOrPoint (CONTAINER &C, const TPoint2D &p)
 Conversion of poses to MRPT containers (vector/matrix).
template<class CONTAINER >
CONTAINER & containerFromPoseOrPoint (CONTAINER &C, const TPoint3D &p)
template<class CONTAINER >
CONTAINER & containerFromPoseOrPoint (CONTAINER &C, const TPose2D &p)
template<class CONTAINER >
CONTAINER & containerFromPoseOrPoint (CONTAINER &C, const TPose3D &p)
template<class CONTAINER >
CONTAINER & containerFromPoseOrPoint (CONTAINER &C, const TPose3DQuat &p)
Generic container element-wise operations - Miscelaneous

template<class CONTAINER >
CONTAINER::value_type squareNorm_accum (const typename CONTAINER::value_type total, const CONTAINER &v)
 Accumulate the squared-norm of a vector/array/matrix into "total" (this function is compatible with std::accumulate).
template<size_t N, class T , class U >
squareNorm (const U &v)
 Compute the square norm of anything implementing [].
template<class CONTAINER1 , class CONTAINER2 >
CONTAINER1::value_type dotProduct (const CONTAINER1 &v1, const CONTAINER1 &v2)
 v1·v2: The dot product of two containers (vectors/arrays/matrices)
template<size_t N, class T , class U , class V >
dotProduct (const U &v1, const V &v2)
 v1·v2: The dot product of any two objects supporting []
template<class CONTAINER >
CONTAINER::value_type sum (const CONTAINER &v)
 Computes the sum of all the elements.
template<typename T >
sum (const std::vector< T > &v)
template<class CONTAINER , typename RET >
RET sumRetType (const CONTAINER &v)
 Computes the sum of all the elements, with a custom return type.
template<class CONTAINER >
double mean (const CONTAINER &v)
 Computes the mean value of a vector.
template<typename T >
void minimum_maximum (const std::vector< T > &V, T &curMin, T &curMax)
 Return the maximum and minimum values of a std::vector.
template<class Derived >
void minimum_maximum (const Eigen::MatrixBase< Derived > &V, typename Eigen::MatrixBase< Derived >::value_type &curMin, typename Eigen::MatrixBase< Derived >::value_type &curMax)
 Return the maximum and minimum values of a Eigen-based vector or matrix.
template<class CONTAINER1 , class CONTAINER2 >
size_t countCommonElements (const CONTAINER1 &a, const CONTAINER2 &b)
 Counts the number of elements that appear in both STL-like containers (comparison through the == operator) It is assumed that no repeated elements appear within each of the containers.
template<class CONTAINER >
void adjustRange (CONTAINER &m, const typename CONTAINER::value_type minVal, const typename CONTAINER::value_type maxVal)
 Adjusts the range of all the elements such as the minimum and maximum values being those supplied by the user.
template<class VECTORLIKE >
void meanAndStd (const VECTORLIKE &v, double &out_mean, double &out_std, bool unbiased=true)
 Computes the standard deviation of a vector.
template<class VECTORLIKE >
double stddev (const VECTORLIKE &v, bool unbiased=true)
 Computes the standard deviation of a vector.
template<class VECTOR_OF_VECTOR , class VECTORLIKE , class MATRIXLIKE >
void meanAndCovVec (const VECTOR_OF_VECTOR &v, VECTORLIKE &out_mean, MATRIXLIKE &out_cov)
 Computes the mean vector and covariance from a list of values given as a vector of vectors, where each row is a sample.
template<class VECTOR_OF_VECTOR >
Eigen::MatrixXd covVector (const VECTOR_OF_VECTOR &v)
 Computes the covariance matrix from a list of values given as a vector of vectors, where each row is a sample.
template<class CONT1 , class CONT2 >
double ncc_vector (const CONT1 &patch1, const CONT2 &patch2)
 Normalised Cross Correlation between two vector patches The Matlab code for this is a = a - mean2(a); b = b - mean2(b); r = sum(sum(a.
Operators for binary streaming of MRPT matrices

template<size_t NROWS, size_t NCOLS>
mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &in, CMatrixFixedNumeric< float, NROWS, NCOLS > &M)
 Read operator from a CStream.
template<size_t NROWS, size_t NCOLS>
mrpt::utils::CStreamoperator>> (mrpt::utils::CStream &in, CMatrixFixedNumeric< double, NROWS, NCOLS > &M)
 Read operator from a CStream.
template<size_t NROWS, size_t NCOLS>
mrpt::utils::CStreamoperator<< (mrpt::utils::CStream &out, const CMatrixFixedNumeric< float, NROWS, NCOLS > &M)
 Write operator for writing into a CStream.
template<size_t NROWS, size_t NCOLS>
mrpt::utils::CStreamoperator<< (mrpt::utils::CStream &out, const CMatrixFixedNumeric< double, NROWS, NCOLS > &M)
 Write operator for writing into a CStream.
Operators for text streaming of MRPT matrices

template<typename T , size_t NROWS, size_t NCOLS>
std::ostream & operator<< (std::ostream &s, const CMatrixFixedNumeric< T, NROWS, NCOLS > &m)
 Dumps the matrix to a text ostream, adding a final "\n" to Eigen's default output.
template<typename T >
std::ostream & operator<< (std::ostream &s, const CMatrixTemplateNumeric< T > &m)
 Dumps the matrix to a text ostream, adding a final "\n" to Eigen's default output.
template<typename T >
std::ostream & operator<< (std::ostream &s, const mrpt::dynamicsize_vector< T > &m)
 Dumps the vector as a row to a text ostream, with the format: "[v1 v2 v3... vN]".
Generic std::vector element-wise operations

template<typename T1 , typename T2 >
std::vector< T1 > & operator*= (std::vector< T1 > &a, const std::vector< T2 > &b)
 a*=b (element-wise multiplication)
template<typename T1 >
std::vector< T1 > & operator*= (std::vector< T1 > &a, const T1 b)
 a*=k (multiplication by a constant)
template<typename T1 , typename T2 >
std::vector< T1 > operator* (const std::vector< T1 > &a, const std::vector< T2 > &b)
 a*b (element-wise multiplication)
template<typename T1 , typename T2 >
std::vector< T1 > & operator+= (std::vector< T1 > &a, const std::vector< T2 > &b)
 a+=b (element-wise sum)
template<typename T1 >
std::vector< T1 > & operator+= (std::vector< T1 > &a, const T1 b)
 a+=b (sum a constant)
template<typename T1 , typename T2 >
std::vector< T1 > operator+ (const std::vector< T1 > &a, const std::vector< T2 > &b)
 a+b (element-wise sum)
template<typename T1 , typename T2 >
std::vector< T1 > operator- (const std::vector< T1 > &v1, const std::vector< T2 > &v2)
RANSAC detectors

template<typename NUMTYPE >
void BASE_IMPEXP ransac_detect_3D_planes (const Eigen::Matrix< NUMTYPE, Eigen::Dynamic, 1 > &x, const Eigen::Matrix< NUMTYPE, Eigen::Dynamic, 1 > &y, const Eigen::Matrix< NUMTYPE, Eigen::Dynamic, 1 > &z, std::vector< std::pair< size_t, TPlane > > &out_detected_planes, const double threshold, const size_t min_inliers_for_valid_plane=10)
 Fit a number of 3-D planes to a given point cloud, automatically determining the number of existing planes by means of the provided threshold and minimum number of supporting inliers.
template<typename NUMTYPE >
void BASE_IMPEXP ransac_detect_2D_lines (const Eigen::Matrix< NUMTYPE, Eigen::Dynamic, 1 > &x, const Eigen::Matrix< NUMTYPE, Eigen::Dynamic, 1 > &y, std::vector< std::pair< size_t, TLine2D > > &out_detected_lines, const double threshold, const size_t min_inliers_for_valid_line=5)
 Fit a number of 2-D lines to a given point cloud, automatically determining the number of existing lines by means of the provided threshold and minimum number of supporting inliers.
template<class POINTSMAP >
void ransac_detect_3D_planes (const POINTSMAP *points_map, std::vector< std::pair< size_t, TPlane > > &out_detected_planes, const double threshold, const size_t min_inliers_for_valid_plane)
 A stub for ransac_detect_3D_planes() with the points given as a mrpt::slam::CPointsMap.
SLERP (Spherical Linear Interpolation) functions

template<typename T >
void slerp (const CQuaternion< T > &q0, const CQuaternion< T > &q1, const double t, CQuaternion< T > &q)
 SLERP interpolation between two quaternions.
void BASE_IMPEXP slerp (const CPose3D &q0, const CPose3D &q1, const double t, CPose3D &p)
 SLERP interpolation between two 6D poses - like mrpt::math::slerp for quaternions, but interpolates the [X,Y,Z] coordinates as well.
void BASE_IMPEXP slerp (const CPose3DQuat &q0, const CPose3DQuat &q1, const double t, CPose3DQuat &p)
Gaussian PDF transformation functions

template<class VECTORLIKE1 , class MATLIKE1 , class USERPARAM , class VECTORLIKE2 , class VECTORLIKE3 , class MATLIKE2 >
void transform_gaussian_unscented (const VECTORLIKE1 &x_mean, const MATLIKE1 &x_cov, void(*functor)(const VECTORLIKE1 &x, const USERPARAM &fixed_param, VECTORLIKE3 &y), const USERPARAM &fixed_param, VECTORLIKE2 &y_mean, MATLIKE2 &y_cov, const bool *elem_do_wrap2pi=NULL, const double alpha=1e-3, const double K=0, const double beta=2.0)
 Scaled unscented transformation (SUT) for estimating the Gaussian distribution of a variable Y=f(X) for an arbitrary function f() provided by the user.
template<class VECTORLIKE1 , class MATLIKE1 , class USERPARAM , class VECTORLIKE2 , class VECTORLIKE3 , class MATLIKE2 >
void transform_gaussian_montecarlo (const VECTORLIKE1 &x_mean, const MATLIKE1 &x_cov, void(*functor)(const VECTORLIKE1 &x, const USERPARAM &fixed_param, VECTORLIKE3 &y), const USERPARAM &fixed_param, VECTORLIKE2 &y_mean, MATLIKE2 &y_cov, const size_t num_samples=1000, typename mrpt::aligned_containers< VECTORLIKE3 >::vector_t *out_samples_y=NULL)
 Simple Montecarlo-base estimation of the Gaussian distribution of a variable Y=f(X) for an arbitrary function f() provided by the user.
template<class VECTORLIKE1 , class MATLIKE1 , class USERPARAM , class VECTORLIKE2 , class VECTORLIKE3 , class MATLIKE2 >
void transform_gaussian_linear (const VECTORLIKE1 &x_mean, const MATLIKE1 &x_cov, void(*functor)(const VECTORLIKE1 &x, const USERPARAM &fixed_param, VECTORLIKE3 &y), const USERPARAM &fixed_param, VECTORLIKE2 &y_mean, MATLIKE2 &y_cov, const VECTORLIKE1 &x_increments)
 First order uncertainty propagation estimator of the Gaussian distribution of a variable Y=f(X) for an arbitrary function f() provided by the user.
Interpolation functions

template<class T , class VECTOR >
interpolate (const T &x, const VECTOR &ys, const T &x0, const T &x1)
 Interpolate a data sequence "ys" ranging from "x0" to "x1" (equally spaced), to obtain the approximation of the sequence at the point "x".
double BASE_IMPEXP interpolate2points (const double x, const double x0, const double y0, const double x1, const double y1, bool wrap2pi=false)
 Linear interpolation/extrapolation: evaluates at "x" the line (x0,y0)-(x1,y1).
double BASE_IMPEXP spline (const double t, const vector_double &x, const vector_double &y, bool wrap2pi=false)
 Interpolates the value of a function in a point "t" given 4 SORTED points where "t" is between the two middle points If wrap2pi is true, output "y" values are wrapped to ]-pi,pi] (It is assumed that input "y" values already are in the correct range).
template<typename NUMTYPE , class VECTORLIKE >
NUMTYPE leastSquareLinearFit (const NUMTYPE t, const VECTORLIKE &x, const VECTORLIKE &y, bool wrap2pi=false)
 Interpolates or extrapolates using a least-square linear fit of the set of values "x" and "y", evaluated at a single point "t".
template<class VECTORLIKE1 , class VECTORLIKE2 , class VECTORLIKE3 >
void leastSquareLinearFit (const VECTORLIKE1 &ts, VECTORLIKE2 &outs, const VECTORLIKE3 &x, const VECTORLIKE3 &y, bool wrap2pi=false)
 Interpolates or extrapolates using a least-square linear fit of the set of values "x" and "y", evaluated at a sequence of points "ts" and returned at "outs".
Probability density distributions (pdf) distance metrics

template<class VECTORLIKE1 , class VECTORLIKE2 , class MAT >
VECTORLIKE1::value_type mahalanobisDistance2 (const VECTORLIKE1 &X, const VECTORLIKE2 &MU, const MAT &COV)
 Computes the squared mahalanobis distance of a vector X given the mean MU and the covariance *inverse* COV_inv

\[ d^2 = (X-MU)^\top \Sigma^{-1} (X-MU) \]

.

template<class VECTORLIKE1 , class VECTORLIKE2 , class MAT >
VECTORLIKE1::value_type mahalanobisDistance (const VECTORLIKE1 &X, const VECTORLIKE2 &MU, const MAT &COV)
 Computes the mahalanobis distance of a vector X given the mean MU and the covariance *inverse* COV_inv

\[ d = \sqrt{ (X-MU)^\top \Sigma^{-1} (X-MU) } \]

.

template<class VECTORLIKE , class MAT1 , class MAT2 , class MAT3 >
VECTORLIKE::value_type mahalanobisDistance2 (const VECTORLIKE &mean_diffs, const MAT1 &COV1, const MAT2 &COV2, const MAT3 &CROSS_COV12)
 Computes the squared mahalanobis distance between two *non-independent* Gaussians, given the two covariance matrices and the vector with the difference of their means.
template<class VECTORLIKE , class MAT1 , class MAT2 , class MAT3 >
VECTORLIKE::value_type mahalanobisDistance (const VECTORLIKE &mean_diffs, const MAT1 &COV1, const MAT2 &COV2, const MAT3 &CROSS_COV12)
 Computes the mahalanobis distance between two *non-independent* Gaussians (or independent if CROSS_COV12=NULL), given the two covariance matrices and the vector with the difference of their means.
template<class VECTORLIKE , class MATRIXLIKE >
MATRIXLIKE::value_type mahalanobisDistance2 (const VECTORLIKE &delta_mu, const MATRIXLIKE &cov)
 Computes the squared mahalanobis distance between a point and a Gaussian, given the covariance matrix and the vector with the difference between the mean and the point.
template<class VECTORLIKE , class MATRIXLIKE >
MATRIXLIKE::value_type mahalanobisDistance (const VECTORLIKE &delta_mu, const MATRIXLIKE &cov)
 Computes the mahalanobis distance between a point and a Gaussian, given the covariance matrix and the vector with the difference between the mean and the point.
template<typename T >
productIntegralTwoGaussians (const std::vector< T > &mean_diffs, const CMatrixTemplateNumeric< T > &COV1, const CMatrixTemplateNumeric< T > &COV2)
 Computes the integral of the product of two Gaussians, with means separated by "mean_diffs" and covariances "COV1" and "COV2".
template<typename T , size_t DIM>
productIntegralTwoGaussians (const std::vector< T > &mean_diffs, const CMatrixFixedNumeric< T, DIM, DIM > &COV1, const CMatrixFixedNumeric< T, DIM, DIM > &COV2)
 Computes the integral of the product of two Gaussians, with means separated by "mean_diffs" and covariances "COV1" and "COV2".
template<typename T , class VECLIKE , class MATLIKE1 , class MATLIKE2 >
void productIntegralAndMahalanobisTwoGaussians (const VECLIKE &mean_diffs, const MATLIKE1 &COV1, const MATLIKE2 &COV2, T &maha2_out, T &intprod_out, const MATLIKE1 *CROSS_COV12=NULL)
 Computes both, the integral of the product of two Gaussians and their square Mahalanobis distance.
template<typename T , class VECLIKE , class MATRIXLIKE >
void mahalanobisDistance2AndLogPDF (const VECLIKE &diff_mean, const MATRIXLIKE &cov, T &maha2_out, T &log_pdf_out)
 Computes both, the logarithm of the PDF and the square Mahalanobis distance between a point (given by its difference wrt the mean) and a Gaussian.
template<typename T , class VECLIKE , class MATRIXLIKE >
void mahalanobisDistance2AndPDF (const VECLIKE &diff_mean, const MATRIXLIKE &cov, T &maha2_out, T &pdf_out)
 Computes both, the PDF and the square Mahalanobis distance between a point (given by its difference wrt the mean) and a Gaussian.

Variables

double BASE_IMPEXP geometryEpsilon
 Global epsilon to overcome small precision errors.
struct BASE_IMPEXP TSegment3D
struct BASE_IMPEXP TLine3D
class BASE_IMPEXP TPolygon3D
struct BASE_IMPEXP TObject3D
const unsigned char GEOMETRIC_TYPE_POINT = 0
 Object type identifier for TPoint2D or TPoint3D.
const unsigned char GEOMETRIC_TYPE_SEGMENT = 1
 Object type identifier for TSegment2D or TSegment3D.
const unsigned char GEOMETRIC_TYPE_LINE = 2
 Object type identifier for TLine2D or TLine3D.
const unsigned char GEOMETRIC_TYPE_POLYGON = 3
 Object type identifier for TPolygon2D or TPolygon3D.
const unsigned char GEOMETRIC_TYPE_PLANE = 4
 Object type identifier for TPlane.
const unsigned char GEOMETRIC_TYPE_UNDEFINED = 255
 Object type identifier for empty TObject2D or TObject3D.

Typedef Documentation

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

Definition at line 231 of file CLevenbergMarquardt.h.

Declares a matrix of booleans (non serializable).

See also:
CMatrixDouble, CMatrixFloat, CMatrixB

Definition at line 161 of file CMatrixTemplateNumeric.h.

Declares a matrix of double numbers (non serializable).

For a serializable version, use math::CMatrixD

See also:
CMatrixFloat, CMatrix, CMatrixD

Definition at line 151 of file CMatrixTemplateNumeric.h.

Definition at line 116 of file CMatrixFixedNumeric.h.

Definition at line 114 of file CMatrixFixedNumeric.h.

Definition at line 123 of file CMatrixFixedNumeric.h.

Definition at line 119 of file CMatrixFixedNumeric.h.

Definition at line 121 of file CMatrixFixedNumeric.h.

Definition at line 117 of file CMatrixFixedNumeric.h.

Definition at line 107 of file CMatrixFixedNumeric.h.

Definition at line 108 of file CMatrixFixedNumeric.h.

Definition at line 115 of file CMatrixFixedNumeric.h.

Definition at line 109 of file CMatrixFixedNumeric.h.

Definition at line 110 of file CMatrixFixedNumeric.h.

Definition at line 111 of file CMatrixFixedNumeric.h.

Definition at line 122 of file CMatrixFixedNumeric.h.

Definition at line 118 of file CMatrixFixedNumeric.h.

Definition at line 112 of file CMatrixFixedNumeric.h.

Definition at line 120 of file CMatrixFixedNumeric.h.

Definition at line 113 of file CMatrixFixedNumeric.h.

Declares a matrix of float numbers (non serializable).

For a serializable version, use math::CMatrix

See also:
CMatrixDouble, CMatrix, CMatrixD

Definition at line 145 of file CMatrixTemplateNumeric.h.

Definition at line 134 of file CMatrixFixedNumeric.h.

Definition at line 132 of file CMatrixFixedNumeric.h.

Definition at line 141 of file CMatrixFixedNumeric.h.

Definition at line 137 of file CMatrixFixedNumeric.h.

Definition at line 139 of file CMatrixFixedNumeric.h.

Definition at line 135 of file CMatrixFixedNumeric.h.

Definition at line 125 of file CMatrixFixedNumeric.h.

Definition at line 126 of file CMatrixFixedNumeric.h.

Definition at line 133 of file CMatrixFixedNumeric.h.

Definition at line 127 of file CMatrixFixedNumeric.h.

Definition at line 128 of file CMatrixFixedNumeric.h.

Definition at line 129 of file CMatrixFixedNumeric.h.

Definition at line 140 of file CMatrixFixedNumeric.h.

Definition at line 136 of file CMatrixFixedNumeric.h.

Definition at line 130 of file CMatrixFixedNumeric.h.

Definition at line 138 of file CMatrixFixedNumeric.h.

Definition at line 131 of file CMatrixFixedNumeric.h.

Declares a matrix of "long doubles" (non serializable), or of "doubles" if the compiler does not support "long double".

See also:
CMatrixDouble, CMatrixFloat

Definition at line 172 of file CMatrixTemplateNumeric.h.

Declares a matrix of unsigned ints (non serializable).

See also:
CMatrixDouble, CMatrixFloat

Definition at line 156 of file CMatrixTemplateNumeric.h.

A quaternion of data type "double".

Definition at line 349 of file CQuaternion.h.

A quaternion of data type "float".

Definition at line 350 of file CQuaternion.h.

This is just another name for mrpt::vector_double (Backward compatibility with MRPT <=0.9.2).

Definition at line 39 of file CVectorTemplate.h.

This is just another name for mrpt::vector_float (Backward compatibility with MRPT <=0.9.2).

Definition at line 38 of file CVectorTemplate.h.

The default instance of RANSAC, for double type.

Definition at line 91 of file ransac.h.

Definition at line 1063 of file lightweight_geom_data.h.


Enumeration Type Documentation

For usage in one of the constructors of CMatrixFixedNumeric or CMatrixTemplate (and derived classes), if it's not required to fill it with zeros at the constructor to save time.

Enumerator:
UNINITIALIZED_MATRIX 

Definition at line 99 of file math_frwds.h.

Enumerator:
UNINITIALIZED_QUATERNION 

Definition at line 40 of file CQuaternion.h.

Selection of the number format in CMatrixTemplate::saveToTextFile

Enumerator:
MATRIX_FORMAT_ENG 

engineering format 'e'

MATRIX_FORMAT_FIXED 

fixed floating point 'f'

MATRIX_FORMAT_INT 

intergers 'i'

Definition at line 90 of file math_frwds.h.


Function Documentation

template<class CONTAINER >
void mrpt::math::adjustRange ( CONTAINER &  m,
const typename CONTAINER::value_type  minVal,
const typename CONTAINER::value_type  maxVal 
)

Adjusts the range of all the elements such as the minimum and maximum values being those supplied by the user.

Definition at line 262 of file ops_containers.h.

References minimum_maximum().

bool BASE_IMPEXP mrpt::math::areAligned ( const std::vector< TPoint2D > &  points  ) 

Checks whether this set of points acceptably fits a 2D line.

See also:
geometryEpsilon
bool BASE_IMPEXP mrpt::math::areAligned ( const std::vector< TPoint2D > &  points,
TLine2D &  r 
)

Checks whether this set of points acceptably fits a 2D line, and if it's the case returns it in the second argument.

See also:
geometryEpsilon
bool BASE_IMPEXP mrpt::math::areAligned ( const std::vector< TPoint3D > &  points  ) 

Checks whether this set of points acceptably fits a 3D line.

See also:
geometryEpsilon
bool BASE_IMPEXP mrpt::math::areAligned ( const std::vector< TPoint3D > &  points,
TLine3D &  r 
)

Checks whether this set of points acceptably fits a 3D line, and if it's the case returns it in the second argument.

void BASE_IMPEXP mrpt::math::assemblePolygons ( const std::vector< TObject3D > &  objs,
std::vector< TPolygon3D > &  polys,
std::vector< TSegment3D > &  remainder1,
std::vector< TObject3D > &  remainder2 
)

Extracts all the polygons, including those formed from segments, from the set of objects.

void BASE_IMPEXP mrpt::math::assemblePolygons ( const std::vector< TSegment3D > &  segms,
std::vector< TPolygon3D > &  polys 
)

Tries to assemble a set of segments into a set of closed polygons.

void BASE_IMPEXP mrpt::math::assemblePolygons ( const std::vector< TSegment3D > &  segms,
std::vector< TPolygon3D > &  polys,
std::vector< TSegment3D > &  remainder 
)

Tries to assemble a set of segments into a set of closed polygons, returning the unused segments as another out parameter.

void BASE_IMPEXP mrpt::math::assemblePolygons ( const std::vector< TObject3D > &  objs,
std::vector< TPolygon3D > &  polys 
)

Extracts all the polygons, including those formed from segments, from the set of objects.

void BASE_IMPEXP mrpt::math::assemblePolygons ( const std::vector< TObject3D > &  objs,
std::vector< TPolygon3D > &  polys,
std::vector< TObject3D > &  remainder 
)

Extracts all the polygons, including those formed from segments, from the set of objects.

double BASE_IMPEXP mrpt::math::averageLogLikelihood ( const vector_double &  logLikelihoods  ) 

Matrix QR decomposition.

A = QR, where R is upper triangular and Q is orthogonal, that is, ~QQ = 1 If A is a LxM dimension matrix, this function only return the LxL upper triangular matrix R instead of LxM pseudo-upper triangular matrix (been L<=M) This function has been extracted from "Numerical Recipes in C". /param A is the original matrix to decompose /param c,Q. The orthogonal matrix Q is represented as a product of n-1 Householder matrices Q1,...Qn-1, where Qj = 1 - u[j] x u[j]/c[j] The i'th component of u[j] is zero for i = 1,...,j-1 while the nonzero components are returned in Q(i,j) for i=j,...,n /param R is the upper triangular matrix /param sign returns as true (1) is singularity is encountered during the decomposition, but the decomposition is still complete in this case; otherwise it returns false (0)If R = CHOL(A) is the original Cholesky factorization of A, then R1 = CHOLUPDATE(R,X) returns the upper triangular Cholesky factor of A + X*X', where X is a column vector of appropriate length. Compute the two eigenvalues of a 2x2 matrix.

Parameters:
in_matrx The 2x2 input matrix.
min_eigenvalue (out) The minimum eigenvalue of the matrix.
max_eigenvalue (out) The maximum eigenvalue of the matrix. by FAMD, MAR-2007 A numerically-stable method to compute average likelihood values with strongly different ranges (unweighted likelihoods: compute the arithmetic mean). This method implements this equation:

\[ return = - \log N + \log \sum_{i=1}^N e^{ll_i-ll_{max}} + ll_{max} \]

See also the tutorial page.

Referenced by mrpt::slam::PF_implementation< PARTICLE_TYPE, MYSELF >::PF_SLAM_particlesEvaluator_AuxPFOptimal(), and mrpt::slam::PF_implementation< PARTICLE_TYPE, MYSELF >::PF_SLAM_particlesEvaluator_AuxPFStandard().

double BASE_IMPEXP mrpt::math::averageLogLikelihood ( const vector_double &  logWeights,
const vector_double &  logLikelihoods 
)

A numerically-stable method to average likelihood values with strongly different ranges (weighted likelihoods).

This method implements this equation:

\[ return = \log \left( \frac{1}{\sum_i e^{lw_i}} \sum_i e^{lw_i} e^{ll_i} \right) \]

See also the tutorial page.

double BASE_IMPEXP mrpt::math::averageWrap2Pi ( const vector_double &  angles  ) 

Computes the average of a sequence of angles in radians taking into account the correct wrapping in the range $ ]-\pi,\pi [ $, for example, the mean of (2,-2) is $ \pi $, not 0.

double mrpt::math::chi2CDF ( unsigned int  degreesOfFreedom,
double  arg 
) [inline]

Cumulative chi square distribution.

Computes the cumulative density of a chi square distribution with degreesOfFreedom and tolerance accuracy at the given argument arg, i.e. the probability that a random number drawn from the distribution is below arg by calling noncentralChi2CDF(degreesOfFreedom, 0.0, arg, accuracy).

Note:
Function code from the Vigra project (http://hci.iwr.uni-heidelberg.de/vigra/); code under "MIT X11 License", GNU GPL-compatible.

Definition at line 175 of file distributions.h.

References noncentralChi2CDF().

double BASE_IMPEXP mrpt::math::chi2inv ( double  P,
unsigned int  dim = 1 
)

The "quantile" of the Chi-Square distribution, for dimension "dim" and probability 0<P<1 (the inverse of chi2CDF) An aproximation from the Wilson-Hilferty transformation is used.

Referenced by mrpt::slam::PF_implementation< PARTICLE_TYPE, MYSELF >::PF_SLAM_implementation_pfAuxiliaryPFStandardAndOptimal(), and mrpt::slam::PF_implementation< PARTICLE_TYPE, MYSELF >::PF_SLAM_implementation_pfStandardProposal().

double mrpt::math::chi2PDF ( unsigned int  degreesOfFreedom,
double  arg,
double  accuracy = 1e-7 
) [inline]

Chi square distribution.

Computes the density of a chi square distribution with degreesOfFreedom and tolerance accuracy at the given argument arg by calling noncentralChi2(degreesOfFreedom, 0.0, arg, accuracy).

Note:
Function code from the Vigra project (http://hci.iwr.uni-heidelberg.de/vigra/); code under "MIT X11 License", GNU GPL-compatible.

Definition at line 277 of file distributions.h.

References mrpt::math::detail::noncentralChi2CDF_exact().

void BASE_IMPEXP mrpt::math::closestFromPointToLine ( const double &  Px,
const double &  Py,
const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
double &  out_x,
double &  out_y 
)

Computes the closest point from a given point to a (infinite) line.

See also:
closestFromPointToSegment
void BASE_IMPEXP mrpt::math::closestFromPointToSegment ( const double &  Px,
const double &  Py,
const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
double &  out_x,
double &  out_y 
)

Computes the closest point from a given point to a segment.

See also:
closestFromPointToLine
double BASE_IMPEXP mrpt::math::closestSquareDistanceFromPointToLine ( const double &  Px,
const double &  Py,
const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2 
)

Returns the square distance from a point to a line.

template<typename CONTAINER >
void mrpt::math::condidenceIntervals ( const CONTAINER &  data,
typename CONTAINER::value_type out_mean,
typename CONTAINER::value_type out_lower_conf_interval,
typename CONTAINER::value_type out_upper_conf_interval,
const double  confidenceInterval = 0.1,
const size_t  histogramNumBins = 1000 
)

Return the mean and the 10-90% confidence points (or with any other confidence value) of a set of samples by building the cummulative CDF of all the elements of the container.

The container can be any MRPT container (CArray, matrices, vectors).

Parameters:
confidenceInterval A number in the range (0,1) such as the confidence interval will be [100*confidenceInterval, 100*(1-confidenceInterval)].

Definition at line 287 of file distributions.h.

References ASSERT_, cumsum(), distance(), histogram(), mean(), minimum_maximum(), MRPT_END, and MRPT_START.

bool BASE_IMPEXP mrpt::math::conformAPlane ( const std::vector< TPoint3D > &  points  ) 

Checks whether this polygon or set of points acceptably fits a plane.

See also:
TPolygon3D,geometryEpsilon
bool BASE_IMPEXP mrpt::math::conformAPlane ( const std::vector< TPoint3D > &  points,
TPlane &  p 
)

Checks whether this polygon or set of points acceptably fits a plane, and if it's the case returns it in the second argument.

See also:
TPolygon3D,geometryEpsilon
template<class CONTAINER >
CONTAINER & mrpt::math::containerFromPoseOrPoint ( CONTAINER &  C,
const TPoint2D &  p 
)

Conversion of poses to MRPT containers (vector/matrix).

Definition at line 135 of file ops_containers.h.

Referenced by containerFromPoseOrPoint().

template<class CONTAINER >
CONTAINER & mrpt::math::containerFromPoseOrPoint ( CONTAINER &  C,
const TPoint3D &  p 
)

Definition at line 140 of file ops_containers.h.

template<class CONTAINER >
CONTAINER & mrpt::math::containerFromPoseOrPoint ( CONTAINER &  C,
const TPose2D &  p 
)

Definition at line 145 of file ops_containers.h.

template<class CONTAINER >
CONTAINER & mrpt::math::containerFromPoseOrPoint ( CONTAINER &  C,
const TPose3D &  p 
)

Definition at line 150 of file ops_containers.h.

template<class CONTAINER >
CONTAINER & mrpt::math::containerFromPoseOrPoint ( CONTAINER &  C,
const TPose3DQuat &  p 
)

Definition at line 155 of file ops_containers.h.

template<class CONTAINER >
CONTAINER& mrpt::math::containerFromPoseOrPoint ( CONTAINER &  C,
const mrpt::poses::CPoint2D p 
) [inline]
template<class CONTAINER >
CONTAINER& mrpt::math::containerFromPoseOrPoint ( CONTAINER &  C,
const mrpt::poses::CPoint3D p 
) [inline]
template<class CONTAINER >
CONTAINER& mrpt::math::containerFromPoseOrPoint ( CONTAINER &  C,
const mrpt::poses::CPose2D p 
) [inline]
template<class CONTAINER >
CONTAINER& mrpt::math::containerFromPoseOrPoint ( CONTAINER &  C,
const mrpt::poses::CPose3D p 
) [inline]
template<class CONTAINER >
CONTAINER& mrpt::math::containerFromPoseOrPoint ( CONTAINER &  C,
const mrpt::poses::CPose3DQuat p 
) [inline]
template<class T >
double mrpt::math::correlate_matrix ( const CMatrixTemplateNumeric< T > &  a1,
const CMatrixTemplateNumeric< T > &  a2 
)

Calculate the correlation between two matrices (by AJOGD @ JAN-2007).

Definition at line 501 of file base/include/mrpt/math/utils.h.

References sqrt(), and THROW_EXCEPTION.

template<class CONTAINER1 , class CONTAINER2 >
size_t mrpt::math::countCommonElements ( const CONTAINER1 &  a,
const CONTAINER2 &  b 
)

Counts the number of elements that appear in both STL-like containers (comparison through the == operator) It is assumed that no repeated elements appear within each of the containers.

Definition at line 250 of file ops_containers.h.

template<class MATRIX >
Eigen::Matrix<typename MATRIX::Scalar,MATRIX::ColsAtCompileTime,MATRIX::ColsAtCompileTime> mrpt::math::cov ( const MATRIX &  v  )  [inline]

Computes the covariance matrix from a list of samples in an NxM matrix, where each row is a sample, so the covariance is MxM.

Parameters:
v The set of data, as a NxM matrix.
out_cov The output MxM matrix for the estimated covariance matrix.
See also:
math::mean,math::stddev, math::cov

Definition at line 230 of file ops_matrices.h.

References meanAndCovMat().

template<class VECTOR_OF_VECTORS , class MATRIXLIKE , class VECTORLIKE >
void mrpt::math::covariancesAndMean ( const VECTOR_OF_VECTORS &  elements,
MATRIXLIKE &  covariances,
VECTORLIKE &  means,
const bool *  elem_do_wrap2pi = NULL 
)

Computes covariances and mean of any vector of containers.

Parameters:
elements Any kind of vector of vectors/arrays, eg. std::vector<vector_double>, with all the input samples, each sample in a "row".
covariances Output estimated covariance; it can be a fixed/dynamic matrix or a matrixview.
means Output estimated mean; it can be vector_double/CArrayDouble, etc...
elem_do_wrap2pi If !=NULL; it must point to an array of "bool" of size()==dimension of each element, stating if it's needed to do a wrap to [-pi,pi] to each dimension.

Definition at line 332 of file base/include/mrpt/math/utils.h.

Referenced by transform_gaussian_montecarlo().

template<class VECTOR_OF_VECTORS , class MATRIXLIKE , class VECTORLIKE , class VECTORLIKE2 , class VECTORLIKE3 >
void mrpt::math::covariancesAndMeanWeighted ( const VECTOR_OF_VECTORS &  elements,
MATRIXLIKE &  covariances,
VECTORLIKE &  means,
const VECTORLIKE2 *  weights_mean,
const VECTORLIKE3 *  weights_cov,
const bool *  elem_do_wrap2pi = NULL 
) [inline]

Computes covariances and mean of any vector of containers, given optional weights for the different samples.

Parameters:
elements Any kind of vector of vectors/arrays, eg. std::vector<vector_double>, with all the input samples, each sample in a "row".
covariances Output estimated covariance; it can be a fixed/dynamic matrix or a matrixview.
means Output estimated mean; it can be vector_double/CArrayDouble, etc...
weights_mean If !=NULL, it must point to a vector of size()==number of elements, with normalized weights to take into account for the mean.
weights_cov If !=NULL, it must point to a vector of size()==number of elements, with normalized weights to take into account for the covariance.
elem_do_wrap2pi If !=NULL; it must point to an array of "bool" of size()==dimension of each element, stating if it's needed to do a wrap to [-pi,pi] to each dimension.
See also:
This method is used in mrpt::math::unscented_transform_gaussian

Definition at line 230 of file base/include/mrpt/math/utils.h.

References ASSERTDEB_, ASSERTMSG_, M_2PI, M_PI, and wrapToPi().

Referenced by transform_gaussian_unscented().

template<class VECTOR_OF_VECTOR >
Eigen::MatrixXd mrpt::math::covVector ( const VECTOR_OF_VECTOR &  v  )  [inline]

Computes the covariance matrix from a list of values given as a vector of vectors, where each row is a sample.

Parameters:
v The set of data, as a vector of N vectors of M elements.
out_cov The output MxM matrix for the estimated covariance matrix.
See also:
math::mean,math::stddev, math::cov, meanAndCovVec

Definition at line 370 of file ops_containers.h.

References meanAndCovVec().

void BASE_IMPEXP mrpt::math::createFromPoseAndVector ( const CPose3D &  p,
const double(&)  vector[3],
TLine3D &  r 
)

Gets a 3D line corresponding to any arbitrary vector, in the base given by the pose.

An implicit constructor is used if a TPose3D is given.

See also:
createFromPoseX,createFromPoseY,createFromPoseZ
void BASE_IMPEXP mrpt::math::createFromPoseAndVector ( const TPose2D &  p,
const double(&)  vector[2],
TLine2D &  r 
)

Gets a 2D line corresponding to any arbitrary vector, in the base given the given pose.

An implicit constructor is used if a CPose2D is given.

See also:
createFromPoseY,createFromPoseAndVector
void BASE_IMPEXP mrpt::math::createFromPoseX ( const TPose2D &  p,
TLine2D &  r 
)

Gets a 2D line corresponding to the X axis in a given pose.

An implicit constructor is used if a CPose2D is given.

See also:
createFromPoseY,createFromPoseAndVector
void BASE_IMPEXP mrpt::math::createFromPoseX ( const CPose3D &  p,
TLine3D &  r 
)

Gets a 3D line corresponding to the X axis in a given pose.

An implicit constructor is used if a TPose3D is given.

See also:
createFromPoseY,createFromPoseZ,createFromPoseAndVector
void BASE_IMPEXP mrpt::math::createFromPoseY ( const CPose3D &  p,
TLine3D &  r 
)

Gets a 3D line corresponding to the Y axis in a given pose.

An implicit constructor is used if a TPose3D is given.

See also:
createFromPoseX,createFromPoseZ,createFromPoseAndVector
void BASE_IMPEXP mrpt::math::createFromPoseY ( const TPose2D &  p,
TLine2D &  r 
)

Gets a 2D line corresponding to the Y axis in a given pose.

An implicit constructor is used if a CPose2D is given.

See also:
createFromPoseX,createFromPoseAndVector
void BASE_IMPEXP mrpt::math::createFromPoseZ ( const CPose3D &  p,
TLine3D &  r 
)

Gets a 3D line corresponding to the Z axis in a given pose.

An implicit constructor is used if a TPose3D is given.

See also:
createFromPoseX,createFromPoseY,createFromPoseAndVector
void BASE_IMPEXP mrpt::math::createPlaneFromPoseAndNormal ( const CPose3D &  pose,
const double(&)  normal[3],
TPlane &  plane 
)

Given a pose and any vector, creates a plane orthogonal to that vector in the pose's coordinates.

See also:
createPlaneFromPoseXY,createPlaneFromPoseXZ,createPlaneFromPoseYZ
void BASE_IMPEXP mrpt::math::createPlaneFromPoseXY ( const CPose3D &  pose,
TPlane &  plane 
)

Given a pose, creates a plane orthogonal to its Z vector.

See also:
createPlaneFromPoseXZ,createPlaneFromPoseYZ,createPlaneFromPoseAndNormal
void BASE_IMPEXP mrpt::math::createPlaneFromPoseXZ ( const CPose3D &  pose,
TPlane &  plane 
)

Given a pose, creates a plane orthogonal to its Y vector.

See also:
createPlaneFromPoseXY,createPlaneFromPoseYZ,createPlaneFromPoseAndNormal
void BASE_IMPEXP mrpt::math::createPlaneFromPoseYZ ( const CPose3D &  pose,
TPlane &  plane 
)

Given a pose, creates a plane orthogonal to its X vector.

See also:
createPlaneFromPoseXY,createPlaneFromPoseXZ,createPlaneFromPoseAndNormal
void BASE_IMPEXP mrpt::math::cross_correlation_FFT ( const CMatrixFloat &  A,
const CMatrixFloat &  B,
CMatrixFloat &  out_corr 
)

Correlation of two matrixes using 2D FFT.

template<class T , class U , class V >
void mrpt::math::crossProduct3D ( const T &  v0,
const U &  v1,
V &  vOut 
) [inline]

Computes the cross product of two 3D vectors, returning a vector normal to both.

It uses the simple implementation:

\[ v_out = \left( \begin{array}{c c c} \hat{i} ~ \hat{j} ~ \hat{k} \\ x0 ~ y0 ~ z0 \\ x1 ~ y1 ~ z1 \\ \end{array} \right) \]

Definition at line 770 of file geometry.h.

Referenced by generateAxisBaseFromDirection().

template<class T >
void mrpt::math::crossProduct3D ( const std::vector< T > &  v0,
const std::vector< T > &  v1,
std::vector< T > &  v_out 
) [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 778 of file geometry.h.

References ASSERT_.

template<class VEC1 , class VEC2 >
Eigen::Matrix<double,3,1> mrpt::math::crossProduct3D ( const VEC1 &  v0,
const VEC2 &  v1 
) [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 793 of file geometry.h.

template<class CONTAINER1 , class CONTAINER2 >
void mrpt::math::cumsum ( const CONTAINER1 &  in_data,
CONTAINER2 &  out_cumsum 
) [inline]

Computes the cumulative sum of all the elements, saving the result in another container.

This works for both matrices (even mixing their types) and vectores/arrays (even mixing types), and even to store the cumsum of any matrix into any vector/array, but not in opposite direction.

See also:
sum

Definition at line 91 of file ops_containers.h.

Referenced by condidenceIntervals(), and cumsum().

template<class CONTAINER >
CONTAINER mrpt::math::cumsum ( const CONTAINER &  in_data  )  [inline]

Computes the cumulative sum of all the elements.

See also:
sum

Definition at line 103 of file ops_containers.h.

References cumsum().

void BASE_IMPEXP mrpt::math::dft2_complex ( const CMatrixFloat &  in_real,
const CMatrixFloat &  in_imag,
CMatrixFloat &  out_real,
CMatrixFloat &  out_imag 
)

Compute the 2D Discrete Fourier Transform (DFT) of a complex matrix, returning the real and imaginary parts separately.

Parameters:
in_real The N_1xN_2 matrix with the real part.
in_imag The N_1xN_2 matrix with the imaginary part.
out_real The N_1xN_2 output matrix which will store the real values (user has not to initialize the size of this matrix).
out_imag The N_1xN_2 output matrix which will store the imaginary values (user has not to initialize the size of this matrix). If the dimensions of the matrix are powers of two, the fast fourier transform (FFT) is used instead of the general algorithm.
See also:
fft_real, idft2_complex,dft2_real
void BASE_IMPEXP mrpt::math::dft2_real ( const CMatrixFloat &  in_data,
CMatrixFloat &  out_real,
CMatrixFloat &  out_imag 
)

Compute the 2D Discrete Fourier Transform (DFT) of a real matrix, returning the real and imaginary parts separately.

Parameters:
in_data The N_1xN_2 matrix.
out_real The N_1xN_2 output matrix which will store the real values (user has not to initialize the size of this matrix).
out_imag The N_1xN_2 output matrix which will store the imaginary values (user has not to initialize the size of this matrix).
See also:
fft_real, ifft2_read, fft2_complex If the dimensions of the matrix are powers of two, the fast fourier transform (FFT) is used instead of the general algorithm.
double BASE_IMPEXP mrpt::math::distance ( const TPoint2D &  p1,
const TPoint2D &  p2 
)
double BASE_IMPEXP mrpt::math::distance ( const TPoint3D &  p1,
const TPoint3D &  p2 
)

Gets the distance between two points in a 3D space.

double BASE_IMPEXP mrpt::math::distance ( const TLine2D &  r1,
const TLine2D &  r2 
)

Gets the distance between two lines in a 2D space.

double BASE_IMPEXP mrpt::math::distance ( const TLine3D &  r1,
const TLine3D &  r2 
)

Gets the distance between two lines in a 3D space.

double BASE_IMPEXP mrpt::math::distance ( const TPlane &  p1,
const TPlane &  p2 
)

Gets the distance between two planes.

It will be zero if the planes are not parallel.

double BASE_IMPEXP mrpt::math::distance ( const TPolygon2D &  p1,
const TPolygon2D &  p2 
)

Gets the distance between two polygons in a 2D space.

double BASE_IMPEXP mrpt::math::distance ( const TPolygon2D &  p1,
const TSegment2D &  s2 
)

Gets the distance between a polygon and a segment in a 2D space.

double mrpt::math::distance ( const TSegment2D &  s1,
const TPolygon2D &  p2 
) [inline]

Gets the distance between a segment and a polygon in a 2D space.

Definition at line 564 of file geometry.h.

References distance().

double BASE_IMPEXP mrpt::math::distance ( const TPolygon2D &  p1,
const TLine2D &  l2 
)

Gets the distance between a polygon and a line in a 2D space.

double mrpt::math::distance ( const TLine2D &  l1,
const TPolygon2D &  p2 
) [inline]

Definition at line 571 of file geometry.h.

References distance().

double BASE_IMPEXP mrpt::math::distance ( const TPolygon3D &  p1,
const TPolygon3D &  p2 
)

Gets the distance between two polygons in a 3D space.

double BASE_IMPEXP mrpt::math::distance ( const TPolygon3D &  p1,
const TSegment3D &  s2 
)

Gets the distance between a polygon and a segment in a 3D space.

double mrpt::math::distance ( const TSegment3D &  s1,
const TPolygon3D &  p2 
) [inline]

Gets the distance between a segment and a polygon in a 3D space.

Definition at line 585 of file geometry.h.

References distance().

double BASE_IMPEXP mrpt::math::distance ( const TPolygon3D &  p1,
const TLine3D &  l2 
)

Gets the distance between a polygon and a line in a 3D space.

double mrpt::math::distance ( const TLine3D &  l1,
const TPolygon3D &  p2 
) [inline]

Gets the distance between a line and a polygon in a 3D space.

Definition at line 595 of file geometry.h.

References distance().

double BASE_IMPEXP mrpt::math::distance ( const TPolygon3D &  po,
const TPlane &  pl 
)

Gets the distance between a polygon and a plane.

double mrpt::math::distance ( const TPlane &  pl,
const TPolygon3D &  po 
) [inline]

Gets the distance between a plane and a polygon.

Definition at line 605 of file geometry.h.

References distance().

template<typename T >
T mrpt::math::distanceBetweenPoints ( const T  x1,
const T  y1,
const T  x2,
const T  y2 
)

Returns the distance between 2 points in 2D.

Definition at line 933 of file geometry.h.

References sqrt(), and square().

template<typename T >
T mrpt::math::distanceBetweenPoints ( const T  x1,
const T  y1,
const T  z1,
const T  x2,
const T  y2,
const T  z2 
)

Returns the distance between 2 points in 3D.

Definition at line 939 of file geometry.h.

References sqrt(), and square().

double BASE_IMPEXP mrpt::math::distancePointToPolygon2D ( const double &  px,
const double &  py,
unsigned int  polyEdges,
const double *  poly_xs,
const double *  poly_ys 
)

Returns the closest distance of a given 2D point to a polygon, or "0" if the point is INTO the polygon or its perimeter.

template<typename T >
T mrpt::math::distanceSqrBetweenPoints ( const T  x1,
const T  y1,
const T  x2,
const T  y2 
)

Returns the square distance between 2 points in 2D.

Definition at line 945 of file geometry.h.

References square().

template<typename T >
T mrpt::math::distanceSqrBetweenPoints ( const T  x1,
const T  y1,
const T  z1,
const T  x2,
const T  y2,
const T  z2 
)

Returns the square distance between 2 points in 3D.

Definition at line 951 of file geometry.h.

References square().

template<class CONTAINER1 , class CONTAINER2 >
CONTAINER1::value_type mrpt::math::dotProduct ( const CONTAINER1 &  v1,
const CONTAINER1 &  v2 
) [inline]

v1·v2: The dot product of two containers (vectors/arrays/matrices)

Definition at line 188 of file ops_containers.h.

template<size_t N, class T , class U , class V >
T mrpt::math::dotProduct ( const U &  v1,
const V &  v2 
) [inline]

v1·v2: The dot product of any two objects supporting []

Definition at line 195 of file ops_containers.h.

double BASE_IMPEXP mrpt::math::erf ( double  x  ) 

The error function of a Normal distribution.

Referenced by noncentralChi2CDF(), and mrpt::math::detail::noncentralChi2CDF_exact().

double BASE_IMPEXP mrpt::math::erfc ( double  x  ) 

The complementary error function of a Normal distribution.

template<class VECTORLIKE , class VECTORLIKE2 , class VECTORLIKE3 , class MATRIXLIKE , class USERPARAM >
void mrpt::math::estimateJacobian ( const VECTORLIKE &  x,
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, vector_double, CArrayNumeric<>, double [N], ... MATRIXLIKE: CMatrixTemplateNumeric, CMatrixFixedNumeric

Definition at line 742 of file base/include/mrpt/math/utils.h.

References ASSERT_, MRPT_END, and MRPT_START.

Referenced by mrpt::math::CLevenbergMarquardtTempl< VECTORTYPE, USERPARAM >::execute(), mrpt::math::jacobians::jacob_numeric_estimate(), and mrpt::bayes::CKalmanFilterCapable< 7, 3, 3, 7 >::runOneKalmanIteration().

template<class VECTOR_OF_VECTORS , class VECTORLIKE >
void mrpt::math::extractColumnFromVectorOfVectors ( const size_t  colIndex,
const VECTOR_OF_VECTORS &  data,
VECTORLIKE &  out_column 
) [inline]

Extract a column from a vector of vectors, and store it in another vector.

  • Input data can be: std::vector<vector_double>, std::deque<std::list<double> >, std::list<CArrayDouble<5> >, etc. etc.
  • Output is the sequence: data[0][idx],data[1][idx],data[2][idx], etc..

For the sake of generality, this function does NOT check the limits in the number of column, unless it's implemented in the [] operator of each of the "rows".

Definition at line 455 of file base/include/mrpt/math/utils.h.

double BASE_IMPEXP mrpt::math::factorial ( unsigned int  n  ) 

Computes the factorial of an integer number and returns it as a double value (internally it uses logarithms for avoiding overflow).

uint64_t BASE_IMPEXP mrpt::math::factorial64 ( unsigned int  n  ) 

Computes the factorial of an integer number and returns it as a 64-bit integer number.

void BASE_IMPEXP mrpt::math::fft_real ( vector_float &  in_realData,
vector_float &  out_FFT_Re,
vector_float &  out_FFT_Im,
vector_float &  out_FFT_Mag 
)

Computes the FFT of a 2^N-size vector of real numbers, and returns the Re+Im+Magnitude parts.

See also:
fft2_real
template<class T >
CMatrixTemplateNumeric<T> mrpt::math::generateAxisBaseFromDirection ( dx,
dy,
dz 
)

Computes an axis base (a set of three 3D normal vectors) with the given vector being the first of them.

NOTE: Make sure of passing all floats or doubles and that the template of the receiving matrix is of the same type!

If $ d = [ dx ~ dy ~ dz ] $ is the input vector, then this function returns a matrix $ M $ such as:

\[ M = \left( \begin{array}{c c c} v^1_x ~ v^2_x ~ v^3_x \\ v^1_y ~ v^2_y ~ v^3_y \\ v^1_z ~ v^2_z ~ v^3_z \end{array} \right) \]

And the three normal vectors are computed as:

\[ v^1 = \frac{d}{|d|} \]

If (dx!=0 or dy!=0):

\[ v^2 = \frac{[-dy ~ dx ~ 0 ]}{\sqrt{dx^2+dy^2}} \]

otherwise (the direction vector is vertical):

\[ v^2 = [1 ~ 0 ~ 0] \]

And finally, the third vector is the cross product of the others:

\[ v^3 = v^1 \times v^2 \]

Returns:
The 3x3 matrix (CMatrixTemplateNumeric<T>), containing one vector per column. Throws an std::exception on invalid input (i.e. null direction vector)

(JLB @ 18-SEP-2007)

Definition at line 1075 of file geometry.h.

References crossProduct3D(), sqrt(), square(), and THROW_EXCEPTION.

void BASE_IMPEXP mrpt::math::generateAxisBaseFromDirectionAndAxis ( const double(&)  vec[3],
char  coord,
CMatrixDouble &  matrix 
)

Creates a rotation matrix so that the coordinate given (0 for x, 1 for y, 2 for z) corresponds to the vector.

double BASE_IMPEXP mrpt::math::getAngle ( const TPlane &  p1,
const TPlane &  p2 
)

Computes the angle between two planes.

Referenced by getAngle().

double BASE_IMPEXP mrpt::math::getAngle ( const TPlane &  p1,
const TLine3D &  r2 
)

Computes the angle between a plane and a 3D line or segment (implicit constructor will be used if passing a segment instead of a line).

double mrpt::math::getAngle ( const TLine3D &  r1,
const TPlane &  p2 
) [inline]

Computes the angle between a 3D line or segment and a plane (implicit constructor will be used if passing a segment instead of a line).

Definition at line 194 of file geometry.h.

References getAngle().

double BASE_IMPEXP mrpt::math::getAngle ( const TLine3D &  r1,
const TLine3D &  r2 
)

Computes the angle between two 3D lines or segments (implicit constructor will be used if passing a segment instead of a line).

double BASE_IMPEXP mrpt::math::getAngle ( const TLine2D &  r1,
const TLine2D &  r2 
)

Computes the angle between two 2D lines or segments (implicit constructor will be used if passing a segment instead of a line).

void BASE_IMPEXP mrpt::math::getAngleBisector ( const TLine3D &  l1,
const TLine3D &  l2,
TLine3D &  bis 
)

Gets the bisector of two lines or segments (implicit constructor will be used if necessary).

Exceptions:
std::logic_error if the lines do not fit in a single plane.
void BASE_IMPEXP mrpt::math::getAngleBisector ( const TLine2D &  l1,
const TLine2D &  l2,
TLine2D &  bis 
)

Gets the bisector of two lines or segments (implicit constructor will be used if necessary).

template<typename MAT >
CMatrixColumnAccessor<MAT> mrpt::math::getColumnAccessor ( MAT &  m,
size_t  colIdx 
) [inline]

Definition at line 483 of file matrix_adaptors.h.

template<typename MAT >
CMatrixColumnAccessorExtended<MAT> mrpt::math::getColumnAccessor ( MAT &  m,
size_t  colIdx,
size_t  offset,
size_t  space = 1 
) [inline]

Definition at line 550 of file matrix_adaptors.h.

template<typename MAT >
CConstMatrixColumnAccessor<MAT> mrpt::math::getColumnAccessor ( const MAT &  m,
size_t  colIdx 
) [inline]

Definition at line 596 of file matrix_adaptors.h.

template<typename MAT >
CConstMatrixColumnAccessorExtended<MAT> mrpt::math::getColumnAccessor ( const MAT &  m,
size_t  colIdx,
size_t  offset,
size_t  space = 1 
) [inline]

Definition at line 646 of file matrix_adaptors.h.

double mrpt::math::getEpsilon (  )  [inline]

Gets the value of the geometric epsilon.

See also:
geometryEpsilon,setEpsilon

Definition at line 711 of file geometry.h.

References geometryEpsilon.

void BASE_IMPEXP mrpt::math::getPrismBounds ( const std::vector< TPoint3D > &  poly,
TPoint3D &  pMin,
TPoint3D &  pMax 
)

Gets the prism bounds of a 3D polygon or set of 3D points.

void BASE_IMPEXP mrpt::math::getRectangleBounds ( const std::vector< TPoint2D > &  poly,
TPoint2D &  pMin,
TPoint2D &  pMax 
)

Gets the rectangular bounds of a 2D polygon or set of 2D points.

double BASE_IMPEXP mrpt::math::getRegressionLine ( const std::vector< TPoint2D > &  points,
TLine2D &  line 
)

Using eigenvalues, gets the best fitting line for a set of 2D points.

Returns an estimation of the error.

See also:
spline, leastSquareLinearFit
double BASE_IMPEXP mrpt::math::getRegressionLine ( const std::vector< TPoint3D > &  points,
TLine3D &  line 
)

Using eigenvalues, gets the best fitting line for a set of 3D points.

Returns an estimation of the error.

See also:
spline, leastSquareLinearFit
double BASE_IMPEXP mrpt::math::getRegressionPlane ( const std::vector< TPoint3D > &  points,
TPlane &  plane 
)

Using eigenvalues, gets the best fitting plane for a set of 3D points.

Returns an estimation of the error.

See also:
spline, leastSquareLinearFit
template<typename MAT >
CMatrixRowAccessor<MAT> mrpt::math::getRowAccessor ( MAT &  m,
size_t  rowIdx 
) [inline]

Definition at line 260 of file matrix_adaptors.h.

template<typename MAT >
CMatrixRowAccessorExtended<MAT> mrpt::math::getRowAccessor ( MAT &  m,
size_t  rowIdx,
size_t  offset,
size_t  space = 1 
) [inline]

Definition at line 328 of file matrix_adaptors.h.

template<typename MAT >
CConstMatrixRowAccessor<MAT> mrpt::math::getRowAccessor ( const MAT &  m,
size_t  rowIdx 
) [inline]

Definition at line 375 of file matrix_adaptors.h.

template<typename MAT >
CConstMatrixRowAccessorExtended<MAT> mrpt::math::getRowAccessor ( const MAT &  m,
size_t  rowIdx,
size_t  offset,
size_t  space = 1 
) [inline]

Definition at line 426 of file matrix_adaptors.h.

void BASE_IMPEXP mrpt::math::getSegmentBisector ( const TSegment2D &  sgm,
TLine2D &  bis 
)

Gets the bisector of a 2D segment.

void BASE_IMPEXP mrpt::math::getSegmentBisector ( const TSegment3D &  sgm,
TPlane &  bis 
)

Gets the bisector of a 3D segment.

template<class CONTAINER >
vector_double mrpt::math::histogram ( const CONTAINER &  v,
double  limit_min,
double  limit_max,
size_t  number_bins,
bool  do_normalization = false,
vector_double *  out_bin_centers = NULL 
)

Computes the normalized or normal histogram of a sequence of numbers given the number of bins and the limits.

In any case this is a "linear" histogram, i.e. for matrices, all the elements are taken as if they were a plain sequence, not taking into account they were in columns or rows. If desired, out_bin_centers can be set to receive the bins centers.

Definition at line 68 of file ops_containers.h.

References mrpt::math::CHistogram::add(), mrpt::math::CHistogram::getHistogram(), and mrpt::math::CHistogram::getHistogramNormalized().

Referenced by condidenceIntervals().

template<class MATRIXLIKE1 , class MATRIXLIKE2 >
void mrpt::math::homogeneousMatrixInverse ( const MATRIXLIKE1 &  M,
MATRIXLIKE2 &  out_inverse_M 
)

Efficiently compute the inverse of a 4x4 homogeneous matrix by only transposing the rotation 3x3 part and solving the translation with dot products.

This is a generic template which works with: MATRIXLIKE: CMatrixTemplateNumeric, CMatrixFixedNumeric

Definition at line 636 of file base/include/mrpt/math/utils.h.

References ASSERT_, and size().

Referenced by mrpt::poses::CPoseOrPoint< CPoint3D >::getInverseHomogeneousMatrix().

template<class IN_ROTMATRIX , class IN_XYZ , class OUT_ROTMATRIX , class OUT_XYZ >
void mrpt::math::homogeneousMatrixInverse ( const IN_ROTMATRIX &  in_R,
const IN_XYZ &  in_xyz,
OUT_ROTMATRIX &  out_R,
OUT_XYZ &  out_xyz 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 688 of file base/include/mrpt/math/utils.h.

References ASSERT_, MRPT_END, MRPT_START, and size().

template<class MATRIXLIKE >
void mrpt::math::homogeneousMatrixInverse ( MATRIXLIKE &  M  )  [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 716 of file base/include/mrpt/math/utils.h.

References ASSERTDEB_, and size().

void BASE_IMPEXP mrpt::math::idft2_complex ( const CMatrixFloat &  in_real,
const CMatrixFloat &  in_imag,
CMatrixFloat &  out_real,
CMatrixFloat &  out_imag 
)

Compute the 2D inverse Discrete Fourier Transform (DFT).

Parameters:
in_real The N_1xN_2 input matrix with real values, where both dimensions MUST BE powers of 2.
in_imag The N_1xN_2 input matrix with imaginary values, where both dimensions MUST BE powers of 2.
out_real The N_1xN_2 output matrix for real part (user has not to initialize the size of this matrix).
out_imag The N_1xN_2 output matrix for imaginary part (user has not to initialize the size of this matrix).
See also:
fft_real, dft2_real,dft2_complex If the dimensions of the matrix are powers of two, the fast fourier transform (FFT) is used instead of the general algorithm.
void BASE_IMPEXP mrpt::math::idft2_real ( const CMatrixFloat &  in_real,
const CMatrixFloat &  in_imag,
CMatrixFloat &  out_data 
)

Compute the 2D inverse Discrete Fourier Transform (DFT).

Parameters:
in_real The N_1xN_2 input matrix with real values.
in_imag The N_1xN_2 input matrix with imaginary values.
out_data The N_1xN_2 output matrix (user has not to initialize the size of this matrix). Note that the real and imaginary parts of the FFT will NOT be checked to assure that they represent the transformation of purely real data. If the dimensions of the matrix are powers of two, the fast fourier transform (FFT) is used instead of the general algorithm.
See also:
fft_real, fft2_real
template<class T , class VECTOR >
T mrpt::math::interpolate ( const T &  x,
const VECTOR &  ys,
const T &  x0,
const T &  x1 
)

Interpolate a data sequence "ys" ranging from "x0" to "x1" (equally spaced), to obtain the approximation of the sequence at the point "x".

If the point "x" is out of the range [x0,x1], the closest extreme "ys" value is returned.

See also:
spline, interpolate2points

Definition at line 796 of file base/include/mrpt/math/utils.h.

References ASSERT_, MRPT_END, and MRPT_START.

double BASE_IMPEXP mrpt::math::interpolate2points ( const double  x,
const double  x0,
const double  y0,
const double  x1,
const double  y1,
bool  wrap2pi = false 
)

Linear interpolation/extrapolation: evaluates at "x" the line (x0,y0)-(x1,y1).

If wrap2pi is true, output is wrapped to ]-pi,pi] (It is assumed that input "y" values already are in the correct range).

See also:
spline, interpolate, leastSquareLinearFit
bool BASE_IMPEXP mrpt::math::intersect ( const TSegment3D &  s1,
const TLine3D &  r2,
TObject3D &  obj 
)

Gets the intersection between a 3D segment and a 3D line.

See also:
TObject3D
bool BASE_IMPEXP mrpt::math::intersect ( const TSegment3D &  s1,
const TPlane &  p2,
TObject3D &  obj 
)

Gets the intersection between a 3D segment and a plane.

See also:
TObject3D
bool mrpt::math::intersect ( const TPlane &  p1,
const TSegment3D &  s2,
TObject3D &  obj 
) [inline]

Gets the intersection between a plane and a 3D segment.

See also:
TObject3D

Definition at line 123 of file geometry.h.

References intersect().

bool BASE_IMPEXP mrpt::math::intersect ( const TPlane &  p1,
const TPlane &  p2,
TObject3D &  obj 
)

Gets the intersection between two planes.

See also:
TObject3D
bool BASE_IMPEXP mrpt::math::intersect ( const TPlane &  p1,
const TLine3D &  p2,
TObject3D &  obj 
)

Gets the intersection between a plane and a 3D line.

See also:
TObject3D
bool mrpt::math::intersect ( const TLine3D &  r1,
const TSegment3D &  s2,
TObject3D &  obj 
) [inline]

Gets the intersection between a 3D line and a 3D segment.

See also:
TObject3D

Definition at line 140 of file geometry.h.

References intersect().

bool mrpt::math::intersect ( const TLine3D &  r1,
const TPlane &  p2,
TObject3D &  obj 
) [inline]

Gets the intersection between a 3D line and a plane.

See also:
TObject3D

Definition at line 147 of file geometry.h.

References intersect().

bool BASE_IMPEXP mrpt::math::intersect ( const TLine3D &  r1,
const TLine3D &  r2,
TObject3D &  obj 
)

Gets the intersection between two 3D lines.

See also:
TObject3D
bool BASE_IMPEXP mrpt::math::intersect ( const TPolygon2D &  p1,
const TSegment2D &  s2,
TObject2D &  obj 
)

Gets the intersection between a 2D polygon and a 2D segment.

See also:
TObject2D
bool BASE_IMPEXP mrpt::math::intersect ( const TLine2D &  r1,
const TSegment2D &  s2,
TObject2D &  obj 
)

Gets the intersection between a 2D line and a 2D segment.

See also:
TObject2D
bool BASE_IMPEXP mrpt::math::intersect ( const TLine2D &  r1,
const TLine2D &  r2,
TObject2D &  obj 
)

Gets the intersection between two 2D lines.

See also:
TObject2D
bool mrpt::math::intersect ( const TSegment2D &  s1,
const TPolygon2D &  p2,
TObject2D &  obj 
) [inline]

Gets the intersection between a 2D segment and a 2D polygon.

See also:
TObject2D

Definition at line 423 of file geometry.h.

References intersect().

bool mrpt::math::intersect ( const TLine2D &  r1,
const TPolygon2D &  p2,
TObject2D &  obj 
) [inline]

Gets the intersection between a 2D line and a 2D polygon.

See also:
TObject2D

Definition at line 430 of file geometry.h.

References intersect().

bool mrpt::math::intersect ( const TSegment2D &  s1,
const TLine2D &  r2,
TObject2D &  obj 
) [inline]

Gets the intersection between a 2D line and a 2D segment.

See also:
TObject2D

Definition at line 169 of file geometry.h.

References intersect().

bool BASE_IMPEXP mrpt::math::intersect ( const TPolygon3D &  p1,
const TSegment3D &  s2,
TObject3D &  obj 
)

Gets the intersection between a 3D polygon and a 3D segment.

See also:
TObject3D
bool BASE_IMPEXP mrpt::math::intersect ( const TPolygon3D &  p1,
const TLine3D &  r2,
TObject3D &  obj 
)

Gets the intersection between a 3D polygon and a 3D line.

See also:
TObject3D
bool BASE_IMPEXP mrpt::math::intersect ( const TSegment2D &  s1,
const TSegment2D &  s2,
TObject2D &  obj 
)

Gets the intersection between two 2D segments.

See also:
TObject2D
bool BASE_IMPEXP mrpt::math::intersect ( const TPolygon3D &  p1,
const TPlane &  p2,
TObject3D &  obj 
)

Gets the intersection between a 3D polygon and a plane.

See also:
TObject3D
bool BASE_IMPEXP mrpt::math::intersect ( const TPolygon3D &  p1,
const TPolygon3D &  p2,
TObject3D &  obj 
)

Gets the intersection between two 3D polygons.

See also:
TObject3D
bool mrpt::math::intersect ( const TSegment3D &  s1,
const TPolygon3D &  p2,
TObject3D &  obj 
) [inline]

Gets the intersection between a 3D segment and a 3D polygon.

See also:
TObject3D

Definition at line 457 of file geometry.h.

References intersect().

bool mrpt::math::intersect ( const TLine3D &  r1,
const TPolygon3D &  p2,
TObject3D &  obj 
) [inline]

Gets the intersection between a 3D line and a 3D polygon.

See also:
TObject3D

Definition at line 464 of file geometry.h.

References intersect().

bool mrpt::math::intersect ( const TPlane &  p1,
const TPolygon3D &  p2,
TObject3D &  obj 
) [inline]

Gets the intersection between a plane and a 3D polygon.

See also:
TObject3D

Definition at line 471 of file geometry.h.

References intersect().

size_t BASE_IMPEXP mrpt::math::intersect ( const std::vector< TPolygon3D > &  v1,
const std::vector< TPolygon3D > &  v2,
CSparseMatrixTemplate< TObject3D > &  objs 
)

Gets the intersection between two sets of 3D polygons.

The intersection is returned as an sparse matrix with each pair of polygons' intersections, and the return value is the amount of intersections found.

See also:
TObject3D,CSparseMatrixTemplate
size_t BASE_IMPEXP mrpt::math::intersect ( const std::vector< TPolygon3D > &  v1,
const std::vector< TPolygon3D > &  v2,
std::vector< TObject3D > &  objs 
)

Gets the intersection between two sets of 3D polygons.

The intersection is returned as a vector with every intersection found, and the return value is the amount of intersections found.

See also:
TObject3D
template<class T , class U , class O >
size_t mrpt::math::intersect ( const std::vector< T > &  v1,
const std::vector< U > &  v2,
CSparseMatrixTemplate< O > &  objs 
)

Gets the intersection between vectors of geometric objects and returns it in a sparse matrix of either TObject2D or TObject3D.

See also:
TObject2D,TObject3D,CSparseMatrix

Definition at line 495 of file geometry.h.

References mrpt::math::CSparseMatrixTemplate< T >::clear(), mrpt::math::CSparseMatrixTemplate< T >::getNonNullElements(), intersect(), and mrpt::math::CSparseMatrixTemplate< T >::resize().

template<class T , class U , class O >
size_t mrpt::math::intersect ( const std::vector< T > &  v1,
const std::vector< U > &  v2,
std::vector< O >  objs 
)

Gets the intersection between vectors of geometric objects and returns it in a vector of either TObject2D or TObject3D.

See also:
TObject2D,TObject3D

Definition at line 508 of file geometry.h.

References intersect().

bool BASE_IMPEXP mrpt::math::intersect ( const TObject2D &  o1,
const TObject2D &  o2,
TObject2D &  obj 
)

Gets the intersection between any pair of 2D objects.

bool BASE_IMPEXP mrpt::math::intersect ( const TObject3D &  o1,
const TObject3D &  o2,
TObject3D &  obj 
)

Gets the intersection between any pair of 3D objects.

bool BASE_IMPEXP mrpt::math::intersect ( const TPolygon2D &  p1,
const TLine2D &  r2,
TObject2D &  obj 
)

Gets the intersection between a 2D polygon and a 2D line.

See also:
TObject2D
bool BASE_IMPEXP mrpt::math::intersect ( const TPolygon2D &  p1,
const TPolygon2D &  p2,
TObject2D &  obj 
)

Gets the intersection between two 2D polygons.

See also:
TObject2D
bool BASE_IMPEXP mrpt::math::intersect ( const TSegment3D &  s1,
const TSegment3D &  s2,
TObject3D &  obj 
)

Gets the intersection between two 3D segments.

See also:
TObject3D

Referenced by mrpt::opengl::CPolyhedron::getIntersection(), and intersect().

bool BASE_IMPEXP mrpt::math::isFinite ( float  f  ) 

Returns true if the number is non infinity.

bool BASE_IMPEXP mrpt::math::isFinite ( double  f  ) 

Returns true if the number is non infinity.

bool BASE_IMPEXP mrpt::math::isNaN ( double  f  ) 

Returns true if the number is NaN.

bool BASE_IMPEXP mrpt::math::isNaN ( float  f  ) 

Returns true if the number is NaN.

template<typename VECTORLIKE1 , typename MATRIXLIKE1 , typename VECTORLIKE2 , typename MATRIXLIKE2 >
double mrpt::math::KLD_Gaussians ( const VECTORLIKE1 &  mu0,
const MATRIXLIKE1 &  cov0,
const VECTORLIKE2 &  mu1,
const MATRIXLIKE2 &  cov1 
)

Kullback-Leibler divergence (KLD) between two independent multivariate Gaussians.

$ D_\mathrm{KL}(\mathcal{N}_0 \| \mathcal{N}_1) = { 1 \over 2 } ( \log_e ( { \det \Sigma_1 \over \det \Sigma_0 } ) + \mathrm{tr} ( \Sigma_1^{-1} \Sigma_0 ) + ( \mu_1 - \mu_0 )^\top \Sigma_1^{-1} ( \mu_1 - \mu_0 ) - N ) $

Definition at line 98 of file distributions.h.

References ASSERT_, log(), MRPT_END, MRPT_START, multiply_HCHt_scalar(), and size().

template<class LIST_OF_VECTORS1 , class LIST_OF_VECTORS2 >
double mrpt::math::kmeans ( const size_t  k,
const LIST_OF_VECTORS1 &  points,
std::vector< int > &  assignments,
LIST_OF_VECTORS2 *  out_centers = NULL,
const size_t  attempts = 3 
) [inline]

k-means algorithm to cluster a list of N points of arbitrary dimensionality into exactly K clusters.

The list of input points can be any template CONTAINER<POINT> with:

  • CONTAINER can be: Any STL container: std::vector,std::list,std::deque,...
  • POINT can be:
    • std::vector<double/float>
    • CArrayDouble<N> / CArrayFloat<N>
Parameters:
k [IN] Number of cluster to look for.
points [IN] The list of N input points. It can be any STL-like containers of std::vector<float/double>, for example a std::vector<vector_double>, a std::list<vector_float>, etc...
assignments [OUT] At output it will have a number [0,k-1] for each of the N input points.
out_centers [OUT] If not NULL, at output will have the centers of each group. Can be of any of the supported types of "points", but the basic coordinates should be float or double exactly as in "points".
attempts [IN] Number of attempts.
See also:
A more advanced algorithm, see: kmeanspp
Note:
Uses the kmeans++ implementation by David Arthur (2009, http://www.stanford.edu/~darthur/kmpp.zip).

Definition at line 136 of file kmeans.h.

References mrpt::math::detail::stub_kmeans().

template<class LIST_OF_VECTORS1 , class LIST_OF_VECTORS2 >
double mrpt::math::kmeanspp ( const size_t  k,
const LIST_OF_VECTORS1 &  points,
std::vector< int > &  assignments,
LIST_OF_VECTORS2 *  out_centers = NULL,
const size_t  attempts = 3 
) [inline]

k-means++ algorithm to cluster a list of N points of arbitrary dimensionality into exactly K clusters.

The list of input points can be any template CONTAINER<POINT> with:

  • CONTAINER can be: Any STL container: std::vector,std::list,std::deque,...
  • POINT can be:
    • std::vector<double/float>
    • CArrayDouble<N> / CArrayFloat<N>
Parameters:
k [IN] Number of cluster to look for.
points [IN] The list of N input points. It can be any STL-like containers of std::vector<float/double>, for example a std::vector<vector_double>, a std::list<vector_float>, etc...
assignments [OUT] At output it will have a number [0,k-1] for each of the N input points.
out_centers [OUT] If not NULL, at output will have the centers of each group. Can be of any of the supported types of "points", but the basic coordinates should be float or double exactly as in "points".
attempts [IN] Number of attempts.
See also:
The standard kmeans algorithm, see: kmeans
Note:
Uses the kmeans++ implementation by David Arthur (2009, http://www.stanford.edu/~darthur/kmpp.zip).

Definition at line 164 of file kmeans.h.

References mrpt::math::detail::stub_kmeans().

template<typename NUMTYPE , class VECTORLIKE >
NUMTYPE mrpt::math::leastSquareLinearFit ( const NUMTYPE  t,
const VECTORLIKE &  x,
const VECTORLIKE &  y,
bool  wrap2pi = false 
)

Interpolates or extrapolates using a least-square linear fit of the set of values "x" and "y", evaluated at a single point "t".

The vectors x and y must have size >=2, and all values of "x" must be different. If wrap2pi is true, output "y" values are wrapped to ]-pi,pi] (It is assumed that input "y" values already are in the correct range).

See also:
spline
getRegressionLine, getRegressionPlane

Definition at line 834 of file base/include/mrpt/math/utils.h.

References ASSERT_, MRPT_END, MRPT_START, and wrapToPi().

template<class VECTORLIKE1 , class VECTORLIKE2 , class VECTORLIKE3 >
void mrpt::math::leastSquareLinearFit ( const VECTORLIKE1 &  ts,
VECTORLIKE2 &  outs,
const VECTORLIKE3 &  x,
const VECTORLIKE3 &  y,
bool  wrap2pi = false 
)

Interpolates or extrapolates using a least-square linear fit of the set of values "x" and "y", evaluated at a sequence of points "ts" and returned at "outs".

If wrap2pi is true, output "y" values are wrapped to ]-pi,pi] (It is assumed that input "y" values already are in the correct range).

See also:
spline, getRegressionLine, getRegressionPlane

Definition at line 884 of file base/include/mrpt/math/utils.h.

References ASSERT_, MRPT_END, MRPT_START, and wrapToPi().

template<typename T , typename VECTOR >
void mrpt::math::linspace ( first,
last,
size_t  count,
VECTOR &  out_vector 
)

Generates an equidistant sequence of numbers given the first one, the last one and the desired number of points.

See also:
sequence

Definition at line 91 of file base/include/mrpt/math/utils.h.

Referenced by linspace().

template<class T >
Eigen::Matrix<T,Eigen::Dynamic,1> mrpt::math::linspace ( first,
last,
size_t  count 
) [inline]

Generates an equidistant sequence of numbers given the first one, the last one and the desired number of points.

See also:
sequence

Definition at line 111 of file base/include/mrpt/math/utils.h.

References linspace().

bool BASE_IMPEXP mrpt::math::loadVector ( utils::CFileStream &  f,
std::vector< int > &  d 
)

Loads one row of a text file as a numerical std::vector.

Returns:
false on EOF or invalid format. The body of the function is implemented in MATH.cpp
bool BASE_IMPEXP mrpt::math::loadVector ( utils::CFileStream &  f,
std::vector< double > &  d 
)

Loads one row of a text file as a numerical std::vector.

Returns:
false on EOF or invalid format. The body of the function is implemented in MATH.cpp
template<typename T , typename At , size_t N>
std::vector<T>& mrpt::math::loadVector ( std::vector< T > &  v,
At(&)  theArray[N] 
)

Assignment operator for initializing a std::vector from a C array (The vector will be automatically set to the correct size).

         vector_double  v;
  const double numbers[] = { 1,2,3,5,6,7,8,9,10 };
  loadVector( v, numbers );
Note:
This operator performs the appropiate type castings, if required.

Definition at line 946 of file base/include/mrpt/math/utils.h.

References MRPT_COMPILE_TIME_ASSERT.

template<typename Derived , typename At , size_t N>
Eigen::EigenBase<Derived>& mrpt::math::loadVector ( Eigen::EigenBase< Derived > &  v,
At(&)  theArray[N] 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 956 of file base/include/mrpt/math/utils.h.

References MRPT_COMPILE_TIME_ASSERT.

template<class VECTORLIKE1 , class VECTORLIKE2 , class MAT >
VECTORLIKE1::value_type mrpt::math::mahalanobisDistance ( const VECTORLIKE1 &  X,
const VECTORLIKE2 &  MU,
const MAT &  COV 
) [inline]

Computes the mahalanobis distance of a vector X given the mean MU and the covariance *inverse* COV_inv

\[ d = \sqrt{ (X-MU)^\top \Sigma^{-1} (X-MU) } \]

.

Definition at line 1000 of file base/include/mrpt/math/utils.h.

References mahalanobisDistance2(), and sqrt().

Referenced by mahalanobisDistance().

template<class VECTORLIKE , class MAT1 , class MAT2 , class MAT3 >
VECTORLIKE::value_type mrpt::math::mahalanobisDistance ( const VECTORLIKE &  mean_diffs,
const MAT1 &  COV1,
const MAT2 &  COV2,
const MAT3 &  CROSS_COV12 
) [inline]

Computes the mahalanobis distance between two *non-independent* Gaussians (or independent if CROSS_COV12=NULL), given the two covariance matrices and the vector with the difference of their means.

\[ d = \sqrt{ \Delta_\mu^\top (\Sigma_1 + \Sigma_2 - 2 \Sigma_12 )^{-1} \Delta_\mu } \]

Definition at line 1041 of file base/include/mrpt/math/utils.h.

References mahalanobisDistance(), and sqrt().

template<class VECTORLIKE , class MATRIXLIKE >
MATRIXLIKE::value_type mrpt::math::mahalanobisDistance ( const VECTORLIKE &  delta_mu,
const MATRIXLIKE &  cov 
) [inline]

Computes the mahalanobis distance between a point and a Gaussian, given the covariance matrix and the vector with the difference between the mean and the point.

\[ d^2 = \sqrt( \Delta_\mu^\top \Sigma^{-1} \Delta_\mu ) \]

Definition at line 1067 of file base/include/mrpt/math/utils.h.

References mahalanobisDistance2(), and sqrt().

template<class VECTORLIKE , class MATRIXLIKE >
MATRIXLIKE::value_type mrpt::math::mahalanobisDistance2 ( const VECTORLIKE &  delta_mu,
const MATRIXLIKE &  cov 
) [inline]

Computes the squared mahalanobis distance between a point and a Gaussian, given the covariance matrix and the vector with the difference between the mean and the point.

\[ d^2 = \Delta_\mu^\top \Sigma^{-1} \Delta_\mu \]

Definition at line 1055 of file base/include/mrpt/math/utils.h.

References ASSERTDEB_, and multiply_HCHt_scalar().

template<class VECTORLIKE , class MAT1 , class MAT2 , class MAT3 >
VECTORLIKE::value_type mrpt::math::mahalanobisDistance2 ( const VECTORLIKE &  mean_diffs,
const MAT1 &  COV1,
const MAT2 &  COV2,
const MAT3 &  CROSS_COV12 
)

Computes the squared mahalanobis distance between two *non-independent* Gaussians, given the two covariance matrices and the vector with the difference of their means.

\[ d^2 = \Delta_\mu^\top (\Sigma_1 + \Sigma_2 - 2 \Sigma_12 )^{-1} \Delta_\mu \]

Definition at line 1014 of file base/include/mrpt/math/utils.h.

References ASSERT_, MRPT_END, MRPT_START, multiply_HCHt_scalar(), and size().

template<class VECTORLIKE1 , class VECTORLIKE2 , class MAT >
VECTORLIKE1::value_type mrpt::math::mahalanobisDistance2 ( const VECTORLIKE1 &  X,
const VECTORLIKE2 &  MU,
const MAT &  COV 
)

Computes the squared mahalanobis distance of a vector X given the mean MU and the covariance *inverse* COV_inv

\[ d^2 = (X-MU)^\top \Sigma^{-1} (X-MU) \]

.

Definition at line 977 of file base/include/mrpt/math/utils.h.

References ASSERT_, MRPT_END, MRPT_START, multiply_HCHt_scalar(), and size().

Referenced by mahalanobisDistance().

template<typename T , class VECLIKE , class MATRIXLIKE >
void mrpt::math::mahalanobisDistance2AndLogPDF ( const VECLIKE &  diff_mean,
const MATRIXLIKE &  cov,
T &  maha2_out,
T &  log_pdf_out 
)

Computes both, the logarithm of the PDF and the square Mahalanobis distance between a point (given by its difference wrt the mean) and a Gaussian.

See also:
productIntegralTwoGaussians, mahalanobisDistance2, normalPDF, mahalanobisDistance2AndPDF

Definition at line 1148 of file base/include/mrpt/math/utils.h.

References ASSERTDEB_, log(), M_2PI, MRPT_END, MRPT_START, and multiply_HCHt_scalar().

Referenced by mahalanobisDistance2AndPDF().

template<typename T , class VECLIKE , class MATRIXLIKE >
void mrpt::math::mahalanobisDistance2AndPDF ( const VECLIKE &  diff_mean,
const MATRIXLIKE &  cov,
T &  maha2_out,
T &  pdf_out 
) [inline]

Computes both, the PDF and the square Mahalanobis distance between a point (given by its difference wrt the mean) and a Gaussian.

See also:
productIntegralTwoGaussians, mahalanobisDistance2, normalPDF

Definition at line 1172 of file base/include/mrpt/math/utils.h.

References exp(), and mahalanobisDistance2AndLogPDF().

template<size_t N, typename T >
std::vector<T> mrpt::math::make_vector ( const T  val1,
  ... 
)

A versatile template to build vectors on-the-fly in a style close to MATLAB's v=[a b c d ...] The first argument of the template is the vector length, and the second the type of the numbers.

Some examples:

    vector_double  = make_vector<4,double>(1.0,3.0,4.0,5.0);
    vector_float   = make_vector<2,float>(-8.12, 3e4);

Definition at line 1194 of file base/include/mrpt/math/utils.h.

References MRPT_COMPILE_TIME_ASSERT.

std::string BASE_IMPEXP mrpt::math::MATLAB_plotCovariance2D ( const CMatrixFloat &  cov22,
const vector_float &  mean,
const float &  stdCount,
const std::string &  style = std::string("b"),
const size_t &  nEllipsePoints = 30 
)

Generates a string with the MATLAB commands required to plot an confidence interval (ellipse) for a 2D Gaussian ('float' version).

Generates a string with the MATLAB commands required to plot an confidence interval (ellipse) for a 2D Gaussian ('double' version).

Parameters:
cov22 The 2x2 covariance matrix
mean The 2-length vector with the mean
stdCount How many "quantiles" to get into the area of the ellipse: 2: 95%, 3:99.97%,...
style A matlab style string, for colors, line styles,...
nEllipsePoints The number of points in the ellipse to generate
cov22 The 2x2 covariance matrix
mean The 2-length vector with the mean
stdCount How many "quantiles" to get into the area of the ellipse: 2: 95%, 3:99.97%,...
style A matlab style string, for colors, line styles,...
nEllipsePoints The number of points in the ellipse to generate
template<class CONTAINER >
CONTAINER::value_type mrpt::math::maximum ( const CONTAINER &  v  )  [inline]
template<typename T >
T mrpt::math::maximum ( const std::vector< T > &  v  )  [inline]

Definition at line 115 of file ops_containers.h.

References ASSERT_, and mrpt::utils::keep_max().

template<class CONTAINER >
double mrpt::math::mean ( const CONTAINER &  v  )  [inline]

Computes the mean value of a vector.

Returns:
The mean, as a double number.
See also:
math::stddev,math::meanAndStd

Definition at line 216 of file ops_containers.h.

References sum().

Referenced by condidenceIntervals(), and mrpt::slam::PF_implementation< PARTICLE_TYPE, MYSELF >::PF_SLAM_implementation_pfAuxiliaryPFStandardAndOptimal().

template<class MAT_IN , class VECTOR , class MAT_OUT >
void mrpt::math::meanAndCovMat ( const MAT_IN &  v,
VECTOR &  out_mean,
MAT_OUT &  out_cov 
)

Computes the mean vector and covariance from a list of samples in an NxM matrix, where each row is a sample, so the covariance is MxM.

Parameters:
v The set of data as a NxM matrix, of types: CMatrixTemplateNumeric or CMatrixFixedNumeric
out_mean The output M-vector for the estimated mean.
out_cov The output MxM matrix for the estimated covariance matrix, this can also be either a fixed-size of dynamic size matrix.
See also:
mrpt::math::meanAndCovVec, math::mean,math::stddev, math::cov

Definition at line 184 of file ops_matrices.h.

References ASSERTMSG_, and square().

Referenced by cov().

template<class VECTOR_OF_VECTOR , class VECTORLIKE , class MATRIXLIKE >
void mrpt::math::meanAndCovVec ( const VECTOR_OF_VECTOR &  v,
VECTORLIKE &  out_mean,
MATRIXLIKE &  out_cov 
)

Computes the mean vector and covariance from a list of values given as a vector of vectors, where each row is a sample.

Parameters:
v The set of data, as a vector of N vectors of M elements.
out_mean The output M-vector for the estimated mean.
out_cov The output MxM matrix for the estimated covariance matrix.
See also:
mrpt::math::meanAndCovMat, math::mean,math::stddev, math::cov

Definition at line 325 of file ops_containers.h.

References ASSERTMSG_, and square().

Referenced by covVector().

template<class VECTORLIKE >
void mrpt::math::meanAndStd ( const VECTORLIKE &  v,
double &  out_mean,
double &  out_std,
bool  unbiased = true 
)

Computes the standard deviation of a vector.

Parameters:
v The set of data
out_mean The output for the estimated mean
out_std The output for the estimated standard deviation
unbiased If set to true or false the std is normalized by "N-1" or "N", respectively.
See also:
math::mean,math::stddev

Definition at line 281 of file ops_containers.h.

References sqrt(), mrpt::utils::square(), and sum().

Referenced by stddev().

void BASE_IMPEXP mrpt::math::medianFilter ( const std::vector< double > &  inV,
std::vector< double > &  outV,
const int &  winSize,
const int &  numberOfSigmas = 2 
)
bool BASE_IMPEXP mrpt::math::minDistBetweenLines ( const double &  p1_x,
const double &  p1_y,
const double &  p1_z,
const double &  p2_x,
const double &  p2_y,
const double &  p2_z,
const double &  p3_x,
const double &  p3_y,
const double &  p3_z,
const double &  p4_x,
const double &  p4_y,
const double &  p4_z,
double &  x,
double &  y,
double &  z,
double &  dist 
)

Calculates the minimum distance between a pair of lines.

The lines are given by:

  • Line 1 = P1 + f (P2-P1)
  • Line 2 = P3 + f (P4-P3) The Euclidean distance is returned in "dist", and the mid point between the lines in (x,y,z)
    Returns:
    It returns false if there is no solution, i.e. lines are (almost, up to EPS) parallel.
template<class CONTAINER >
CONTAINER::value_type mrpt::math::minimum ( const CONTAINER &  v  )  [inline]
template<typename T >
T mrpt::math::minimum ( const std::vector< T > &  v  )  [inline]

Definition at line 122 of file ops_containers.h.

References ASSERT_, and mrpt::utils::keep_min().

template<class Derived >
void mrpt::math::minimum_maximum ( const Eigen::MatrixBase< Derived > &  V,
typename Eigen::MatrixBase< Derived >::value_type curMin,
typename Eigen::MatrixBase< Derived >::value_type curMax 
) [inline]

Return the maximum and minimum values of a Eigen-based vector or matrix.

Definition at line 239 of file ops_containers.h.

template<typename T >
void mrpt::math::minimum_maximum ( const std::vector< T > &  V,
T &  curMin,
T &  curMax 
) [inline]

Return the maximum and minimum values of a std::vector.

Definition at line 225 of file ops_containers.h.

References ASSERT_, mrpt::utils::keep_max(), and mrpt::utils::keep_min().

Referenced by adjustRange(), and condidenceIntervals().

double BASE_IMPEXP mrpt::math::minimumDistanceFromPointToSegment ( const double &  Px,
const double &  Py,
const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
double &  out_x,
double &  out_y 
)

Computes the closest point from a given point to a segment, and returns that minimum distance.

double BASE_IMPEXP mrpt::math::minimumDistanceFromPointToSegment ( const double &  Px,
const double &  Py,
const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
float &  out_x,
float &  out_y 
)

Computes the closest point from a given point to a segment, and returns that minimum distance.

template<class MAT_A , class SKEW_3VECTOR , class MAT_OUT >
void mrpt::math::multiply_A_skew3 ( const MAT_A &  A,
const SKEW_3VECTOR &  v,
MAT_OUT &  out 
)

Only for vectors/arrays "v" of length3, compute out = A * Skew(v), where Skew(v) is the skew symmetric matric generated from v (see mrpt::math::skew_symmetric3).

Definition at line 245 of file ops_matrices.h.

References ASSERT_EQUAL_, MRPT_END, MRPT_START, and size().

Referenced by multiply_A_skew3().

template<typename MAT_H , typename MAT_C , typename MAT_R >
void mrpt::math::multiply_HCHt ( const MAT_H &  H,
const MAT_C &  C,
MAT_R &  R,
bool  accumResultInOutput 
) [inline]

R = H * C * H^t (with C symmetric).

Definition at line 142 of file ops_matrices.h.

template<typename VECTOR_H , typename MAT_C >
MAT_C::value_type mrpt::math::multiply_HCHt_scalar ( const VECTOR_H &  H,
const MAT_C &  C 
)

r (a scalar) = H * C * H^t (with a vector H and a symmetric matrix C)

Definition at line 157 of file ops_matrices.h.

Referenced by KLD_Gaussians(), mahalanobisDistance2(), mahalanobisDistance2AndLogPDF(), and normalPDF().

template<typename MAT_H , typename MAT_C , typename MAT_R >
void mrpt::math::multiply_HtCH ( const MAT_H &  H,
const MAT_C &  C,
MAT_R &  R,
bool  accumResultInOutput 
)

R = H^t * C * H (with C symmetric).

Definition at line 164 of file ops_matrices.h.

template<class SKEW_3VECTOR , class MAT_A , class MAT_OUT >
void mrpt::math::multiply_skew3_A ( const SKEW_3VECTOR &  v,
const MAT_A &  A,
MAT_OUT &  out 
)

Only for vectors/arrays "v" of length3, compute out = Skew(v) * A, where Skew(v) is the skew symmetric matric generated from v (see mrpt::math::skew_symmetric3).

Definition at line 264 of file ops_matrices.h.

References ASSERT_EQUAL_, MRPT_END, MRPT_START, and size().

Referenced by multiply_skew3_A().

template<class CONT1 , class CONT2 >
double mrpt::math::ncc_vector ( const CONT1 &  patch1,
const CONT2 &  patch2 
)

Normalised Cross Correlation between two vector patches The Matlab code for this is a = a - mean2(a); b = b - mean2(b); r = sum(sum(a.

*b))/sqrt(sum(sum(a.*a))*sum(sum(b.*b)));

Definition at line 386 of file ops_containers.h.

References ASSERT_, ASSERTMSG_, sqrt(), and square().

template<class T >
double mrpt::math::noncentralChi2CDF ( unsigned int  degreesOfFreedom,
noncentrality,
arg 
)

Cumulative non-central chi square distribution (approximate).

Computes approximate values of the cumulative density of a chi square distribution with degreesOfFreedom, and noncentrality parameter noncentrality at the given argument arg, i.e. the probability that a random number drawn from the distribution is below arg It uses the approximate transform into a normal distribution due to Wilson and Hilferty (see Abramovitz, Stegun: "Handbook of Mathematical Functions", formula 26.3.32). The algorithm's running time is independent of the inputs. The accuracy is only about 0.1 for few degrees of freedom, but reaches about 0.001 above dof = 5.

Note:
Function code from the Vigra project (http://hci.iwr.uni-heidelberg.de/vigra/); code under "MIT X11 License", GNU GPL-compatible.

Definition at line 158 of file distributions.h.

References erf(), pow(), sqrt(), square(), and t().

Referenced by chi2CDF().

template<class CONTAINER >
CONTAINER::value_type mrpt::math::norm ( const CONTAINER &  v  )  [inline]
template<class CONTAINER >
CONTAINER::value_type mrpt::math::norm_inf ( const CONTAINER &  v  )  [inline]
double BASE_IMPEXP mrpt::math::normalCDF ( double  p  ) 

Evaluates the Gaussian cumulative density function.

The employed approximation is that from W. J. Cody freely available in http://www.netlib.org/specfun/erf

template<class VEC1 , class VEC2 >
void mrpt::math::normalize ( const VEC1 &  v,
VEC2 &  out_v 
)

Normalize a vector, such as its norm is the unity.

If the vector has a null norm, the output is a null vector.

Definition at line 205 of file base/include/mrpt/math/utils.h.

References sqrt(), and square().

double BASE_IMPEXP mrpt::math::normalPDF ( double  x,
double  mu,
double  std 
)

Evaluates the univariate normal (Gaussian) distribution at a given point "x".

template<class VECTORLIKE1 , class VECTORLIKE2 , class MATRIXLIKE >
MATRIXLIKE::value_type mrpt::math::normalPDF ( const VECTORLIKE1 &  x,
const VECTORLIKE2 &  mu,
const MATRIXLIKE &  cov,
const bool  scaled_pdf = false 
) [inline]

Evaluates the multivariate normal (Gaussian) distribution at a given point "x".

Parameters:
x A vector or column or row matrix with the point at which to evaluate the pdf.
mu A vector or column or row matrix with the Gaussian mean.
cov The covariance matrix of the Gaussian.
scaled_pdf If set to true, the PDF will be scaled to be in the range [0,1].

Definition at line 61 of file distributions.h.

References ASSERTDEB_, exp(), MRPT_END, MRPT_START, multiply_HCHt_scalar(), pow(), size(), and sqrt().

template<typename VECTORLIKE , typename MATRIXLIKE >
MATRIXLIKE::value_type mrpt::math::normalPDF ( const VECTORLIKE &  d,
const MATRIXLIKE &  cov 
)

Evaluates the multivariate normal (Gaussian) distribution at a given point given its distance vector "d" from the Gaussian mean.

Definition at line 80 of file distributions.h.

References ASSERTDEB_, exp(), MRPT_END, MRPT_START, multiply_HCHt_scalar(), pow(), and sqrt().

double BASE_IMPEXP mrpt::math::normalQuantile ( double  p  ) 

Evaluates the Gaussian distribution quantile for the probability value p=[0,1].

The employed approximation is that from Peter J. Acklam (pjacklam@online.no), freely available in http://home.online.no/~pjacklam.

template<class T >
Eigen::Matrix<T,Eigen::Dynamic,1> mrpt::math::ones ( size_t  count  )  [inline]

Generates a vector of all ones of the given length.

Definition at line 141 of file base/include/mrpt/math/utils.h.

template<class Derived >
Eigen::MatrixBase<Derived>::PlainObject mrpt::math::operator! ( const Eigen::MatrixBase< Derived > &  m  )  [inline]

Unary inversion operator.

Definition at line 133 of file ops_matrices.h.

bool mrpt::math::operator!= ( const TPoint2D &  p1,
const TPoint2D &  p2 
) [inline]

Exact comparison between 2D points.

Definition at line 592 of file lightweight_geom_data.h.

References mrpt::math::TPoint2D::x, and mrpt::math::TPoint2D::y.

bool mrpt::math::operator!= ( const TPoint3D &  p1,
const TPoint3D &  p2 
) [inline]

Exact comparison between 3D points.

Definition at line 604 of file lightweight_geom_data.h.

References mrpt::math::TPoint3D::x, mrpt::math::TPoint3D::y, and mrpt::math::TPoint3D::z.

bool mrpt::math::operator!= ( const TPose2D &  p1,
const TPose2D &  p2 
) [inline]

Exact comparison between 2D poses, taking possible cycles into account.

Definition at line 616 of file lightweight_geom_data.h.

References mrpt::math::TPose2D::phi, wrapTo2Pi(), mrpt::math::TPose2D::x, and mrpt::math::TPose2D::y.

bool mrpt::math::operator!= ( const TPose3D &  p1,
const TPose3D &  p2 
) [inline]

Exact comparison between 3D poses, taking possible cycles into account.

Definition at line 628 of file lightweight_geom_data.h.

References mrpt::math::TPose3D::pitch, mrpt::math::TPose3D::roll, wrapTo2Pi(), mrpt::math::TPose3D::x, mrpt::math::TPose3D::y, mrpt::math::TPose3D::yaw, and mrpt::math::TPose3D::z.

bool mrpt::math::operator!= ( const TSegment2D &  s1,
const TSegment2D &  s2 
) [inline]
bool mrpt::math::operator!= ( const TSegment3D &  s1,
const TSegment3D &  s2 
) [inline]
template<class T , std::size_t N>
bool mrpt::math::operator!= ( const CArray< T, N > &  x,
const CArray< T, N > &  y 
)

Definition at line 298 of file CArray.h.

template<typename T1 , typename T2 >
std::vector<T1> mrpt::math::operator* ( const std::vector< T1 > &  a,
const std::vector< T2 > &  b 
) [inline]

a*b (element-wise multiplication)

Definition at line 70 of file ops_vectors.h.

References ASSERT_EQUAL_.

template<typename T1 , typename T2 >
std::vector<T1>& mrpt::math::operator*= ( std::vector< T1 > &  a,
const std::vector< T2 > &  b 
) [inline]

a*=b (element-wise multiplication)

Definition at line 51 of file ops_vectors.h.

References ASSERT_EQUAL_.

template<typename T1 >
std::vector<T1>& mrpt::math::operator*= ( std::vector< T1 > &  a,
const T1  b 
) [inline]

a*=k (multiplication by a constant)

Definition at line 61 of file ops_vectors.h.

template<typename T1 , typename T2 >
std::vector<T1> mrpt::math::operator+ ( const std::vector< T1 > &  a,
const std::vector< T2 > &  b 
) [inline]

a+b (element-wise sum)

Definition at line 100 of file ops_vectors.h.

References ASSERT_EQUAL_.

template<typename T1 >
std::vector<T1>& mrpt::math::operator+= ( std::vector< T1 > &  a,
const T1  b 
) [inline]

a+=b (sum a constant)

Definition at line 91 of file ops_vectors.h.

template<typename T1 , typename T2 >
std::vector<T1>& mrpt::math::operator+= ( std::vector< T1 > &  a,
const std::vector< T2 > &  b 
) [inline]

a+=b (element-wise sum)

Definition at line 81 of file ops_vectors.h.

References ASSERT_EQUAL_.

TPoint3D mrpt::math::operator- ( const TPoint3D &  p1  )  [inline]

Unary minus operator for 3D points.

Definition at line 580 of file lightweight_geom_data.h.

References mrpt::math::TPoint3D::x, mrpt::math::TPoint3D::y, and mrpt::math::TPoint3D::z.

template<typename T1 , typename T2 >
std::vector<T1> mrpt::math::operator- ( const std::vector< T1 > &  v1,
const std::vector< T2 > &  v2 
) [inline]

Definition at line 110 of file ops_vectors.h.

References ASSERT_EQUAL_.

template<class T , std::size_t N>
bool mrpt::math::operator< ( const CArray< T, N > &  x,
const CArray< T, N > &  y 
)

Definition at line 294 of file CArray.h.

References internal::y.

template<size_t NROWS, size_t NCOLS>
mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const CMatrixFixedNumeric< float, NROWS, NCOLS > &  M 
)

Write operator for writing into a CStream.

The format is compatible with that of CMatrix & CMatrixD

Definition at line 78 of file ops_matrices.h.

template<size_t NROWS, size_t NCOLS>
mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const CMatrixFixedNumeric< double, NROWS, NCOLS > &  M 
)

Write operator for writing into a CStream.

The format is compatible with that of CMatrix & CMatrixD

Definition at line 85 of file ops_matrices.h.

template<typename T >
std::ostream& mrpt::math::operator<< ( std::ostream &  s,
const CMatrixTemplateNumeric< T > &  m 
) [inline]

Dumps the matrix to a text ostream, adding a final "\n" to Eigen's default output.

Definition at line 108 of file ops_matrices.h.

template<class T >
std::ostream& mrpt::math::operator<< ( std::ostream &  out,
const std::vector< T > &  d 
)

A template function for printing out the contents of a std::vector variable.

Definition at line 123 of file ops_vectors.h.

template<typename T , size_t N>
mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream ostrm,
const CArrayNumeric< T, N > &  a 
)

Binary dump of a CArrayNumeric<T,N> to a stream.

Definition at line 152 of file ops_vectors.h.

template<typename T >
std::ostream& mrpt::math::operator<< ( std::ostream &  s,
const mrpt::dynamicsize_vector< T > &  m 
) [inline]

Dumps the vector as a row to a text ostream, with the format: "[v1 v2 v3... vN]".

Definition at line 116 of file ops_matrices.h.

std::ostream BASE_IMPEXP& mrpt::math::operator<< ( std::ostream &  o,
const TPose2D &  p 
)
std::ostream BASE_IMPEXP& mrpt::math::operator<< ( std::ostream &  o,
const TPoint3D &  p 
)
std::ostream BASE_IMPEXP& mrpt::math::operator<< ( std::ostream &  o,
const TPose3DQuat &  p 
)
std::ostream BASE_IMPEXP& mrpt::math::operator<< ( std::ostream &  o,
const TPose3D &  p 
)
template<typename T , size_t NROWS, size_t NCOLS>
std::ostream& mrpt::math::operator<< ( std::ostream &  s,
const CMatrixFixedNumeric< T, NROWS, NCOLS > &  m 
) [inline]

Dumps the matrix to a text ostream, adding a final "\n" to Eigen's default output.

Definition at line 100 of file ops_matrices.h.

template<class T >
std::ostream& mrpt::math::operator<< ( std::ostream &  out,
std::vector< T > *  d 
)

A template function for printing out the contents of a std::vector variable.

Definition at line 138 of file ops_vectors.h.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TPoint2D o 
)

TPoint2D binary output.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TPoint3D o 
)

TPoint3D binary output.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TPose2D o 
)

TPose2D binary output.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TPose3D o 
)

TPose3D binary output.

mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TSegment2D s 
) [inline]

TSegment2D binary output.

Definition at line 2353 of file lightweight_geom_data.h.

References mrpt::math::TSegment2D::point1, and mrpt::math::TSegment2D::point2.

mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TLine2D l 
) [inline]

TLine2D binary output.

Definition at line 2366 of file lightweight_geom_data.h.

References mrpt::math::TLine2D::coefs.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TObject2D o 
)

TObject2D binary input.

mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TSegment3D s 
) [inline]

TSegment3D binary output.

Definition at line 2388 of file lightweight_geom_data.h.

References mrpt::math::TSegment3D::point1, and mrpt::math::TSegment3D::point2.

mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TLine3D l 
) [inline]

TLine3D binary output.

Definition at line 2401 of file lightweight_geom_data.h.

References mrpt::math::TLine3D::director, and mrpt::math::TLine3D::pBase.

mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TPlane p 
) [inline]

TPlane binary output.

Definition at line 2414 of file lightweight_geom_data.h.

References mrpt::math::TPlane::coefs.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator<< ( mrpt::utils::CStream out,
const mrpt::math::TObject3D o 
)

TObject3D binary output.

std::ostream BASE_IMPEXP& mrpt::math::operator<< ( std::ostream &  o,
const TPoint2D &  p 
)
template<class T , std::size_t N>
bool mrpt::math::operator<= ( const CArray< T, N > &  x,
const CArray< T, N > &  y 
)

Definition at line 306 of file CArray.h.

References internal::y.

bool mrpt::math::operator== ( const TSegment2D &  s1,
const TSegment2D &  s2 
) [inline]
bool mrpt::math::operator== ( const TPose2D &  p1,
const TPose2D &  p2 
) [inline]

Exact comparison between 2D poses, taking possible cycles into account.

Definition at line 610 of file lightweight_geom_data.h.

References mrpt::math::TPose2D::phi, wrapTo2Pi(), mrpt::math::TPose2D::x, and mrpt::math::TPose2D::y.

bool mrpt::math::operator== ( const TPoint3D &  p1,
const TPoint3D &  p2 
) [inline]

Exact comparison between 3D points.

Definition at line 598 of file lightweight_geom_data.h.

References mrpt::math::TPoint3D::x, mrpt::math::TPoint3D::y, and mrpt::math::TPoint3D::z.

bool mrpt::math::operator== ( const TPoint2D &  p1,
const TPoint2D &  p2 
) [inline]

Exact comparison between 2D points.

Definition at line 586 of file lightweight_geom_data.h.

References mrpt::math::TPoint2D::x, and mrpt::math::TPoint2D::y.

bool mrpt::math::operator== ( const TPose3D &  p1,
const TPose3D &  p2 
) [inline]

Exact comparison between 3D poses, taking possible cycles into account.

Definition at line 622 of file lightweight_geom_data.h.

References mrpt::math::TPose3D::pitch, mrpt::math::TPose3D::roll, wrapTo2Pi(), mrpt::math::TPose3D::x, mrpt::math::TPose3D::y, mrpt::math::TPose3D::yaw, and mrpt::math::TPose3D::z.

bool mrpt::math::operator== ( const TSegment3D &  s1,
const TSegment3D &  s2 
) [inline]
template<class T , std::size_t N>
bool mrpt::math::operator== ( const CArray< T, N > &  x,
const CArray< T, N > &  y 
)
template<class T , std::size_t N>
bool mrpt::math::operator> ( const CArray< T, N > &  x,
const CArray< T, N > &  y 
)

Definition at line 302 of file CArray.h.

template<class T , std::size_t N>
bool mrpt::math::operator>= ( const CArray< T, N > &  x,
const CArray< T, N > &  y 
)

Definition at line 310 of file CArray.h.

::mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
CMatrixBPtr &  pObj 
)
BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TPose2D o 
)

TPose2D binary input.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TObject2D o 
)

TObject2D binary input.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TPose3D o 
)

TPose3D binary input.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TObject3D o 
)

TObject3D binary input.

template<size_t NROWS, size_t NCOLS>
mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
CMatrixFixedNumeric< float, NROWS, NCOLS > &  M 
)

Read operator from a CStream.

The format is compatible with that of CMatrix & CMatrixD

Definition at line 59 of file ops_matrices.h.

References ASSERTMSG_, mrpt::format(), and mrpt::utils::CStream::ReadObject().

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TPoint3D o 
)

TPoint3D binary input.

BASE_IMPEXP mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TPoint2D o 
)

TPoint2D binary input.

::mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
CSplineInterpolator1DPtr &  pObj 
)
mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TLine3D l 
) [inline]

TLine3D binary input.

Definition at line 2395 of file lightweight_geom_data.h.

References mrpt::math::TLine3D::director, and mrpt::math::TLine3D::pBase.

mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TSegment2D s 
) [inline]

TSegment2D binary input.

Definition at line 2347 of file lightweight_geom_data.h.

References mrpt::math::TSegment2D::point1, and mrpt::math::TSegment2D::point2.

mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TSegment3D s 
) [inline]

TSegment3D binary input.

Definition at line 2382 of file lightweight_geom_data.h.

References mrpt::math::TSegment3D::point1, and mrpt::math::TSegment3D::point2.

mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TPlane p 
) [inline]

TPlane binary input.

Definition at line 2408 of file lightweight_geom_data.h.

References mrpt::math::TPlane::coefs.

template<size_t NROWS, size_t NCOLS>
mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
CMatrixFixedNumeric< double, NROWS, NCOLS > &  M 
)

Read operator from a CStream.

The format is compatible with that of CMatrix & CMatrixD

Definition at line 68 of file ops_matrices.h.

References ASSERTMSG_, mrpt::format(), and mrpt::utils::CStream::ReadObject().

::mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
CPolygonPtr &  pObj 
)
template<typename T , size_t N>
mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream istrm,
CArrayNumeric< T, N > &  a 
)

Binary read of a CArrayNumeric<T,N> from a stream.

Definition at line 161 of file ops_vectors.h.

References ASSERTMSG_, mrpt::format(), and mrpt::utils::CStream::ReadBufferFixEndianness().

BASE_IMPEXP ::mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
CMatrixPtr &  pObj 
)
BASE_IMPEXP ::mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
CMatrixDPtr &  pObj 
)
mrpt::utils::CStream& mrpt::math::operator>> ( mrpt::utils::CStream in,
mrpt::math::TLine2D l 
) [inline]

TLine2D binary input.

Definition at line 2360 of file lightweight_geom_data.h.

References mrpt::math::TLine2D::coefs.

template<class Derived >
const Eigen::MatrixBase<Derived>::AdjointReturnType mrpt::math::operator~ ( const Eigen::MatrixBase< Derived > &  m  )  [inline]

Transpose operator for matrices.

Definition at line 127 of file ops_matrices.h.

bool BASE_IMPEXP mrpt::math::pointIntoPolygon2D ( const double &  px,
const double &  py,
unsigned int  polyEdges,
const double *  poly_xs,
const double *  poly_ys 
)

Returns true if the 2D point (px,py) falls INTO the given polygon.

See also:
pointIntoQuadrangle
template<typename T >
bool mrpt::math::pointIntoQuadrangle ( x,
y,
v1x,
v1y,
v2x,
v2y,
v3x,
v3y,
v4x,
v4y 
)

Specialized method to check whether a point (x,y) falls into a quadrangle.

See also:
pointIntoPolygon2D

Definition at line 982 of file geometry.h.

References mrpt::utils::sign(), and wrapToPi().

template<typename T , class VECLIKE , class MATLIKE1 , class MATLIKE2 >
void mrpt::math::productIntegralAndMahalanobisTwoGaussians ( const VECLIKE &  mean_diffs,
const MATLIKE1 &  COV1,
const MATLIKE2 &  COV2,
T &  maha2_out,
T &  intprod_out,
const MATLIKE1 *  CROSS_COV12 = NULL 
)

Computes both, the integral of the product of two Gaussians and their square Mahalanobis distance.

See also:
productIntegralTwoGaussians, mahalanobisDistance2

Definition at line 1121 of file base/include/mrpt/math/utils.h.

References ASSERT_, exp(), M_2PI, pow(), and sqrt().

template<typename T , size_t DIM>
T mrpt::math::productIntegralTwoGaussians ( const std::vector< T > &  mean_diffs,
const CMatrixFixedNumeric< T, DIM, DIM > &  COV1,
const CMatrixFixedNumeric< T, DIM, DIM > &  COV2 
)

Computes the integral of the product of two Gaussians, with means separated by "mean_diffs" and covariances "COV1" and "COV2".

\[ D = \frac{1}{(2 \pi)^{0.5 N} \sqrt{} } \exp( \Delta_\mu^\top (\Sigma_1 + \Sigma_2)^{-1} \Delta_\mu) \]

Definition at line 1099 of file base/include/mrpt/math/utils.h.

References ASSERT_, exp(), M_2PI, pow(), sqrt(), and UNINITIALIZED_MATRIX.

template<typename T >
T mrpt::math::productIntegralTwoGaussians ( const std::vector< T > &  mean_diffs,
const CMatrixTemplateNumeric< T > &  COV1,
const CMatrixTemplateNumeric< T > &  COV2 
)

Computes the integral of the product of two Gaussians, with means separated by "mean_diffs" and covariances "COV1" and "COV2".

\[ D = \frac{1}{(2 \pi)^{0.5 N} \sqrt{} } \exp( \Delta_\mu^\top (\Sigma_1 + \Sigma_2 - 2 \Sigma_12)^{-1} \Delta_\mu) \]

Definition at line 1076 of file base/include/mrpt/math/utils.h.

References ASSERT_, exp(), M_2PI, pow(), and sqrt().

void mrpt::math::project2D ( const TSegment2D &  segment,
const CPose2D &  newXpose,
TSegment2D &  newSegment 
) [inline]

Uses the given pose 2D to project a segment into a new base.

Definition at line 354 of file geometry.h.

References mrpt::math::TSegment2D::point1, mrpt::math::TSegment2D::point2, and project2D().

void mrpt::math::project2D ( const TPoint2D &  point,
const CPose2D &  newXpose,
TPoint2D &  newPoint 
) [inline]

Uses the given pose 2D to project a point into a new base.

Definition at line 348 of file geometry.h.

Referenced by project2D().

template<class T >
void mrpt::math::project2D ( const T &  obj,
const TLine2D &  newXLine,
const TPoint2D &  newOrigin,
T &  newObj 
)

Projects any 2D object into the line's base, using its inverse pose and forcing the position of the new coordinate origin.

If the object is exactly inside the line, this projection will zero its Y coordinate.

Definition at line 384 of file geometry.h.

References mrpt::math::TLine2D::getAsPose2DForcingOrigin(), and project2D().

void BASE_IMPEXP mrpt::math::project2D ( const TLine2D &  line,
const CPose2D &  newXpose,
TLine2D &  newLine 
)

Uses the given pose 2D to project a line into a new base.

void BASE_IMPEXP mrpt::math::project2D ( const TPolygon2D &  polygon,
const CPose2D &  newXpose,
TPolygon2D &  newPolygon 
)

Uses the given pose 2D to project a polygon into a new base.

template<class T >
void mrpt::math::project2D ( const T &  obj,
const TLine2D &  newXLine,
T &  newObj 
)

Projects any 2D object into the line's base, using its inverse pose.

If the object is exactly inside the line, this projection will zero its Y coordinate.

Definition at line 375 of file geometry.h.

References mrpt::math::TLine2D::getAsPose2D(), and project2D().

template<class T >
void mrpt::math::project2D ( const std::vector< T > &  objs,
const CPose2D &  newXpose,
std::vector< T > &  newObjs 
)

Projects a set of 2D objects into the line's base.

Definition at line 393 of file geometry.h.

References project2D().

void BASE_IMPEXP mrpt::math::project2D ( const TObject2D &  object,
const CPose2D &  newXpose,
TObject2D &  newObject 
)

Uses the given pose 2D to project any 2D object into a new base.

void mrpt::math::project3D ( const TSegment3D &  segment,
const CPose3D &  newXYpose,
TSegment3D &  newSegment 
) [inline]

Uses the given pose 3D to project a segment into a new base.

Definition at line 296 of file geometry.h.

References mrpt::math::TSegment3D::point1, mrpt::math::TSegment3D::point2, and project3D().

void BASE_IMPEXP mrpt::math::project3D ( const TLine3D &  line,
const CPose3D &  newXYpose,
TLine3D &  newLine 
)

Uses the given pose 3D to project a line into a new base.

void BASE_IMPEXP mrpt::math::project3D ( const TObject3D &  object,
const CPose3D &  newXYPose,
TObject3D &  newObject 
)

Uses the given pose 3D to project any 3D object into a new base.

void mrpt::math::project3D ( const TPoint3D &  point,
const CPose3D &  newXYpose,
TPoint3D &  newPoint 
) [inline]

Uses the given pose 3D to project a point into a new base.

Definition at line 290 of file geometry.h.

References mrpt::poses::CPose3D::composePoint(), mrpt::math::TPoint3D::x, mrpt::math::TPoint3D::y, and mrpt::math::TPoint3D::z.

Referenced by project3D().

void BASE_IMPEXP mrpt::math::project3D ( const TPlane &  plane,
const CPose3D &  newXYpose,
TPlane &  newPlane 
)

Uses the given pose 3D to project a plane into a new base.

template<class T >
void mrpt::math::project3D ( const std::vector< T > &  objs,
const CPose3D &  newXYpose,
std::vector< T > &  newObjs 
)

Projects a set of 3D objects into the plane's base.

Definition at line 339 of file geometry.h.

References project3D().

void BASE_IMPEXP mrpt::math::project3D ( const TPolygon3D &  polygon,
const CPose3D &  newXYpose,
TPolygon3D &  newPolygon 
)

Uses the given pose 3D to project a polygon into a new base.

template<class T >
void mrpt::math::project3D ( const T &  obj,
const TPlane &  newXYPlane,
T &  newObj 
)

Projects any 3D object into the plane's base, using its inverse pose.

If the object is exactly inside the plane, this projection will zero its Z coordinates.

Definition at line 320 of file geometry.h.

References project3D().

template<class T >
void mrpt::math::project3D ( const T &  obj,
const TPlane &  newXYPlane,
const TPoint3D &  newOrigin,
T &  newObj 
)

Projects any 3D object into the plane's base, using its inverse pose and forcing the position of the new coordinates origin.

If the object is exactly inside the plane, this projection will zero its Z coordinates.

Definition at line 329 of file geometry.h.

References project3D().

template<typename NUMTYPE >
void BASE_IMPEXP mrpt::math::ransac_detect_2D_lines ( const Eigen::Matrix< NUMTYPE, Eigen::Dynamic, 1 > &  x,
const Eigen::Matrix< NUMTYPE, Eigen::Dynamic, 1 > &  y,
std::vector< std::pair< size_t, TLine2D > > &  out_detected_lines,
const double  threshold,
const size_t  min_inliers_for_valid_line = 5 
)

Fit a number of 2-D lines to a given point cloud, automatically determining the number of existing lines by means of the provided threshold and minimum number of supporting inliers.

Parameters:
out_detected_lines The output list of pairs: number of supporting inliers, detected line.
threshold The maximum distance between a point and a temptative line such as the point is considered an inlier.
min_inliers_for_valid_line The minimum number of supporting inliers to consider a line as valid.
template<class POINTSMAP >
void mrpt::math::ransac_detect_3D_planes ( const POINTSMAP *  points_map,
std::vector< std::pair< size_t, TPlane > > &  out_detected_planes,
const double  threshold,
const size_t  min_inliers_for_valid_plane 
) [inline]

A stub for ransac_detect_3D_planes() with the points given as a mrpt::slam::CPointsMap.

Definition at line 77 of file ransac_applications.h.

References ransac_detect_3D_planes().

template<typename NUMTYPE >
void BASE_IMPEXP mrpt::math::ransac_detect_3D_planes ( const Eigen::Matrix< NUMTYPE, Eigen::Dynamic, 1 > &  x,
const Eigen::Matrix< NUMTYPE, Eigen::Dynamic, 1 > &  y,
const Eigen::Matrix< NUMTYPE, Eigen::Dynamic, 1 > &  z,
std::vector< std::pair< size_t, TPlane > > &  out_detected_planes,
const double  threshold,
const size_t  min_inliers_for_valid_plane = 10 
)

Fit a number of 3-D planes to a given point cloud, automatically determining the number of existing planes by means of the provided threshold and minimum number of supporting inliers.

Parameters:
out_detected_planes The output list of pairs: number of supporting inliers, detected plane.
threshold The maximum distance between a point and a temptative plane such as the point is considered an inlier.
min_inliers_for_valid_plane The minimum number of supporting inliers to consider a plane as valid.

Referenced by ransac_detect_3D_planes().

bool BASE_IMPEXP mrpt::math::RectanglesIntersection ( const double &  R1_x_min,
const double &  R1_x_max,
const double &  R1_y_min,
const double &  R1_y_max,
const double &  R2_x_min,
const double &  R2_x_max,
const double &  R2_y_min,
const double &  R2_y_max,
const double &  R2_pose_x,
const double &  R2_pose_y,
const double &  R2_pose_phi 
)

Returns wether two rotated rectangles intersect.

The first rectangle is not rotated and given by (R1_x_min,R1_x_max)-(R1_y_min,R1_y_max). The second rectangle is given is a similar way, but it is internally rotated according to the given coordinates translation (R2_pose_x,R2_pose_y,R2_pose_phi(radians)), relative to the coordinates system of rectangle 1.

template<typename VECTOR_LIKE , typename Precision , typename MATRIX_LIKE >
void mrpt::math::rodrigues_so3_exp ( const VECTOR_LIKE &  w,
const Precision  A,
const Precision  B,
MATRIX_LIKE &  R 
) [inline]

Compute a rotation exponential using the Rodrigues Formula.

The rotation axis is given by $\vec{w}$, and the rotation angle must be computed using $ \theta = |\vec{w}|$. This is provided as a separate function primarily to allow fast and rough matrix exponentials using fast and rough approximations to A and B.

Parameters:
w Vector about which to rotate.
A $\frac{\sin \theta}{\theta}$
B $\frac{1 - \cos \theta}{\theta^2}$
R Matrix to hold the return value.
See also:
CPose3D
Note:
Method from TooN (C) Tom Drummond (GNU GPL)

Definition at line 1129 of file geometry.h.

References ASSERT_EQUAL_.

template<class T >
T mrpt::math::round2up ( val  ) 

Round up to the nearest power of two of a given number.

Definition at line 474 of file base/include/mrpt/math/utils.h.

References THROW_EXCEPTION.

template<class T >
T mrpt::math::round_10power ( val,
int  power10 
)

Round a decimal number up to the given 10'th power (eg, to 1000,100,10, and also fractions) power10 means round up to: 1 -> 10, 2 -> 100, 3 -> 1000, ...

-1 -> 0.1, -2 -> 0.01, ...

Definition at line 490 of file base/include/mrpt/math/utils.h.

References pow(), mrpt::utils::round_long(), and t().

bool BASE_IMPEXP mrpt::math::SegmentsIntersection ( const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
const double &  x3,
const double &  y3,
const double &  x4,
const double &  y4,
double &  ix,
double &  iy 
)

Returns the intersection point, and if it exists, between two segments.

bool BASE_IMPEXP mrpt::math::SegmentsIntersection ( const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
const double &  x3,
const double &  y3,
const double &  x4,
const double &  y4,
float &  ix,
float &  iy 
)

Returns the intersection point, and if it exists, between two segments.

template<class T , T STEP>
Eigen::Matrix<T,Eigen::Dynamic,1> mrpt::math::sequence ( first,
size_t  length 
) [inline]

Generates a sequence of values [first,first+STEP,first+2*STEP,...].

See also:
linspace, sequenceStdVec

Definition at line 120 of file base/include/mrpt/math/utils.h.

template<class T , T STEP>
std::vector<T> mrpt::math::sequenceStdVec ( first,
size_t  length 
) [inline]

Generates a sequence of values [first,first+STEP,first+2*STEP,...].

See also:
linspace, sequence

Definition at line 131 of file base/include/mrpt/math/utils.h.

void mrpt::math::setEpsilon ( double  nE  )  [inline]

Changes the value of the geometric epsilon.

See also:
geometryEpsilon,getEpsilon

Definition at line 704 of file geometry.h.

References geometryEpsilon.

template<class MATRIXLIKE >
size_t mrpt::math::size ( const MATRIXLIKE &  m,
int  dim 
) [inline]

Returns the size of the matrix in the i'th dimension: 1=rows, 2=columns (MATLAB-compatible function)

Note:
Template argument MATRIXLIKE can be: CMatrixTemplate, CMatrixTemplateNumeric, CMatrixFixedNumeric

Definition at line 63 of file bits.h.

References THROW_EXCEPTION_CUSTOM_MSG1.

Referenced by PlainObjectBase< Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > >::_resize_to_match(), internal::apply_rotation_in_the_plane(), internal::llt_inplace< Lower >::blocked(), internal::partial_lu_impl< Scalar, StorageOrder >::blocked_lu(), MatrixBase< Derived >::blueNorm(), DenseCoeffsBase< Derived, ReadOnlyAccessors >::coeff(), DenseCoeffsBase< Derived, WriteAccessors >::coeffRef(), PartialPivLU< _MatrixType >::compute(), LLT< _MatrixType, _UpLo >::compute(), LDLT< _MatrixType, _UpLo >::compute(), HouseholderQR< _MatrixType >::compute(), FullPivLU< _MatrixType >::compute(), FullPivHouseholderQR< _MatrixType >::compute(), ColPivHouseholderQR< _MatrixType >::compute(), RealSchur< MatrixType >::computeNormOfT(), mrpt::poses::CPose3D::CPose3D(), EigenSolver< _MatrixType >::doComputeEigenvectors(), MatrixBase< Derived >::dot(), end(), internal::transposition_matrix_product_retval< TranspositionType, MatrixType, Side, Transposed >::evalTo(), mrpt::poses::CPose3DQuat::fromString(), mrpt::poses::CPose3D::fromString(), mrpt::poses::CPose2D::fromString(), mrpt::poses::CPoint< CPoint3D >::fromString(), mrpt::opengl::CPointCloudColoured::getPoint(), mrpt::opengl::CPointCloud::getPoint(), mrpt::opengl::CPointCloudColoured::getPointf(), mrpt::opengl::CPointCloud::getPointf(), mrpt::math::CPolygon::GetVertex_x(), mrpt::math::CPolygon::GetVertex_y(), HessenbergDecomposition< MatrixType >::HessenbergDecomposition(), MatrixBase< Derived >::hnormalized(), homogeneousMatrixInverse(), internal::householder_qr_inplace_blocked(), internal::householder_qr_inplace_unblocked(), DenseBase< TriangularProduct< Mode, true, Lhs, false, Rhs, true > >::innerSize(), mrpt::vision::CFeatureList::kdtree_get_point_count(), KLD_Gaussians(), mahalanobisDistance2(), MatrixBase< Derived >::makeHouseholder(), MatrixBase< Derived >::makeHouseholderInPlace(), FullPivHouseholderQR< _MatrixType >::matrixQ(), maximum(), DenseBase< Derived >::mean(), mean(), meanAndStdAll(), minimum(), multiply_A_skew3(), multiply_skew3_A(), DenseBase< TriangularProduct< Mode, true, Lhs, false, Rhs, true > >::nonZeros(), normalize(), normalPDF(), DenseCoeffsBase< Derived, WriteAccessors >::operator()(), DenseCoeffsBase< Derived, ReadOnlyAccessors >::operator()(), DenseCoeffsBase< Derived, WriteAccessors >::operator[](), DenseCoeffsBase< Derived, ReadOnlyAccessors >::operator[](), mrpt::opengl::CPointCloudColoured::operator[](), mrpt::opengl::CPointCloud::operator[](), Map< PlainObjectType, MapOptions, StrideType >::outerStride(), DenseCoeffsBase< Derived, ReadOnlyAccessors >::packet(), internal::parallelize_gemm(), RealSchur< MatrixType >::performFrancisQRStep(), internal::permute_symm_to_fullsymm(), internal::permute_symm_to_symm(), DenseBase< Derived >::prod(), push_back(), LDLT< _MatrixType, _UpLo >::reconstructedMatrix(), std::vector< T, EIGEN_ALIGNED_ALLOCATOR< T > >::resize(), PlainObjectBase< Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > >::resize(), internal::selfadjoint_rank2_update_selector< Scalar, Index, UType, VType, Upper >::run(), internal::selfadjoint_rank2_update_selector< Scalar, Index, UType, VType, Lower >::run(), internal::product_selfadjoint_matrix< Scalar, Index, LhsStorageOrder, false, ConjugateLhs, RhsStorageOrder, true, ConjugateRhs, ColMajor >::run(), internal::product_selfadjoint_matrix< Scalar, Index, LhsStorageOrder, true, ConjugateLhs, RhsStorageOrder, false, ConjugateRhs, ColMajor >::run(), internal::redux_impl< Func, Derived, LinearVectorizedTraversal, NoUnrolling >::run(), internal::gemv_selector< OnTheRight, ColMajor, false >::run(), internal::general_matrix_vector_product< Index, LhsScalar, ColMajor, ConjugateLhs, RhsScalar, ConjugateRhs >::run(), internal::setIdentity_impl< Derived, true >::run(), internal::assign_impl< Derived1, Derived2, LinearVectorizedTraversal, CompleteUnrolling >::run(), internal::assign_impl< Derived1, Derived2, LinearVectorizedTraversal, NoUnrolling >::run(), internal::assign_impl< Derived1, Derived2, LinearTraversal, NoUnrolling >::run(), LDLT< _MatrixType, _UpLo >::solveInPlace(), RealSchur< MatrixType >::splitOffTwoRows(), MatrixBase< Derived >::stableNorm(), DenseBase< Derived >::sum(), DenseBase< Derived >::tail(), internal::llt_inplace< Lower >::unblocked(), internal::ldlt_inplace< Lower >::unblocked(), internal::partial_lu_impl< Scalar, StorageOrder >::unblocked_lu(), mrpt::math::CPolygon::verticesCount(), and DenseCoeffsBase< Derived, WriteAccessors >::writePacket().

template<class VECTOR >
mrpt::math::CMatrixDouble33 mrpt::math::skew_symmetric3 ( const VECTOR &  v  )  [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 820 of file geometry.h.

References skew_symmetric3(), and UNINITIALIZED_MATRIX.

template<class VECTOR , class MATRIX >
void mrpt::math::skew_symmetric3 ( const VECTOR &  v,
MATRIX &  M 
) [inline]

Computes the 3x3 skew symmetric matrix from a 3-vector or 3-array:

\[ M([x ~ y ~ z]^\top) = \left( \begin{array}{c c c} 0 & -z & y \\ z & 0 & -x \\ -y & x & 0 \end{array} \right) \]

.

Definition at line 811 of file geometry.h.

References ASSERT_.

Referenced by skew_symmetric3().

template<class VECTOR , class MATRIX >
void mrpt::math::skew_symmetric3_neg ( const VECTOR &  v,
MATRIX &  M 
) [inline]

Computes the negative version of a 3x3 skew symmetric matrix from a 3-vector or 3-array:

\[ -M([x ~ y ~ z]^\top) = \left( \begin{array}{c c c} 0 & z & -y \\ -z & 0 & x \\ y & -x & 0 \end{array} \right) \]

.

Definition at line 836 of file geometry.h.

References ASSERT_.

Referenced by skew_symmetric3_neg().

template<class VECTOR >
mrpt::math::CMatrixDouble33 mrpt::math::skew_symmetric3_neg ( const VECTOR &  v  )  [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 845 of file geometry.h.

References skew_symmetric3_neg(), and UNINITIALIZED_MATRIX.

template<typename T >
void mrpt::math::slerp ( const CQuaternion< T > &  q0,
const CQuaternion< T > &  q1,
const double  t,
CQuaternion< T > &  q 
)

SLERP interpolation between two quaternions.

Parameters:
[in] q0 The quaternion for t=0
[in] q1 The quaternion for t=1
[in] t A "time" parameter, in the range [0,1].
[out] q The output, interpolated quaternion.
Template Parameters:
T The type of the quaternion (e.g. float, double).
Exceptions:
std::exception Only in Debug, if t is not in the valid range.
See also:
http://en.wikipedia.org/wiki/Slerp

Definition at line 52 of file slerp.h.

References abs(), ASSERTDEB_, sin(), sqrt(), and square().

void BASE_IMPEXP mrpt::math::slerp ( const CPose3D &  q0,
const CPose3D &  q1,
const double  t,
CPose3D &  p 
)

SLERP interpolation between two 6D poses - like mrpt::math::slerp for quaternions, but interpolates the [X,Y,Z] coordinates as well.

Parameters:
[in] p0 The pose for t=0
[in] p1 The pose for t=1
[in] t A "time" parameter, in the range [0,1].
[out] p The output, interpolated pose.
Exceptions:
std::exception Only in Debug, if t is not in the valid range.
void BASE_IMPEXP mrpt::math::slerp ( const CPose3DQuat &  q0,
const CPose3DQuat &  q1,
const double  t,
CPose3DQuat &  p 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

double BASE_IMPEXP mrpt::math::spline ( const double  t,
const vector_double &  x,
const vector_double &  y,
bool  wrap2pi = false 
)

Interpolates the value of a function in a point "t" given 4 SORTED points where "t" is between the two middle points If wrap2pi is true, output "y" values are wrapped to ]-pi,pi] (It is assumed that input "y" values already are in the correct range).

See also:
leastSquareLinearFit
bool BASE_IMPEXP mrpt::math::splitInConvexComponents ( const TPolygon2D &  poly,
vector< TPolygon2D > &  components 
)

Splits a 2D polygon into convex components.

bool BASE_IMPEXP mrpt::math::splitInConvexComponents ( const TPolygon3D &  poly,
vector< TPolygon3D > &  components 
)

Splits a 3D polygon into convex components.

Exceptions:
std::logic_error if the polygon can't be fit into a plane.
template<size_t N, class T , class U >
T mrpt::math::squareNorm ( const U &  v  )  [inline]

Compute the square norm of anything implementing [].

See also:
norm

Definition at line 179 of file ops_containers.h.

References square().

template<class CONTAINER >
CONTAINER::value_type mrpt::math::squareNorm_accum ( const typename CONTAINER::value_type  total,
const CONTAINER &  v 
)

Accumulate the squared-norm of a vector/array/matrix into "total" (this function is compatible with std::accumulate).

Definition at line 172 of file ops_containers.h.

template<class VECTORLIKE >
double mrpt::math::stddev ( const VECTORLIKE &  v,
bool  unbiased = true 
) [inline]

Computes the standard deviation of a vector.

Parameters:
v The set of data
unbiased If set to true or false the std is normalized by "N-1" or "N", respectively.
See also:
math::mean,math::meanAndStd

Definition at line 311 of file ops_containers.h.

References meanAndStd().

template<class CONTAINER >
CONTAINER::value_type mrpt::math::sum ( const CONTAINER &  v  )  [inline]
template<typename T >
T mrpt::math::sum ( const std::vector< T > &  v  )  [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 207 of file ops_containers.h.

template<class CONTAINER , typename RET >
RET mrpt::math::sumRetType ( const CONTAINER &  v  )  [inline]

Computes the sum of all the elements, with a custom return type.

See also:
sum, cumsum

Definition at line 211 of file ops_containers.h.

bool mrpt::math::traceRay ( const vector< TPolygon3D > &  vec,
const mrpt::poses::CPose3D pose,
double &  dist 
) [inline]

Fast ray tracing method using polygons' properties.

See also:
CRenderizable::rayTrace

Definition at line 752 of file geometry.h.

References mrpt::math::TPolygonWithPlane::getPlanes(), and traceRay().

bool BASE_IMPEXP mrpt::math::traceRay ( const vector< TPolygonWithPlane > &  vec,
const mrpt::poses::CPose3D pose,
double &  dist 
)

Fast ray tracing method using polygons' properties.

See also:
CRenderizable::rayTrace

Referenced by traceRay().

template<class VECTORLIKE1 , class MATLIKE1 , class USERPARAM , class VECTORLIKE2 , class VECTORLIKE3 , class MATLIKE2 >
void mrpt::math::transform_gaussian_linear ( const VECTORLIKE1 &  x_mean,
const MATLIKE1 &  x_cov,
void(*)(const VECTORLIKE1 &x, const USERPARAM &fixed_param, VECTORLIKE3 &y)  functor,
const USERPARAM &  fixed_param,
VECTORLIKE2 &  y_mean,
MATLIKE2 &  y_cov,
const VECTORLIKE1 &  x_increments 
)

First order uncertainty propagation estimator of the Gaussian distribution of a variable Y=f(X) for an arbitrary function f() provided by the user.

The user must supply the function in "functor" which takes points in the X space and returns the mapped point in Y, optionally using an extra, constant parameter ("fixed_param") which remains constant. The Jacobians are estimated numerically using the vector of small increments "x_increments".

See also:
The example in MRPT/samples/unscented_transform_test
transform_gaussian_unscented, transform_gaussian_montecarlo

Definition at line 144 of file transform_gaussian.h.

References mrpt::math::jacobians::jacob_numeric_estimate(), MRPT_END, and MRPT_START.

template<class VECTORLIKE1 , class MATLIKE1 , class USERPARAM , class VECTORLIKE2 , class VECTORLIKE3 , class MATLIKE2 >
void mrpt::math::transform_gaussian_montecarlo ( const VECTORLIKE1 &  x_mean,
const MATLIKE1 &  x_cov,
void(*)(const VECTORLIKE1 &x, const USERPARAM &fixed_param, VECTORLIKE3 &y)  functor,
const USERPARAM &  fixed_param,
VECTORLIKE2 &  y_mean,
MATLIKE2 &  y_cov,
const size_t  num_samples = 1000,
typename mrpt::aligned_containers< VECTORLIKE3 >::vector_t *  out_samples_y = NULL 
)

Simple Montecarlo-base estimation of the Gaussian distribution of a variable Y=f(X) for an arbitrary function f() provided by the user.

The user must supply the function in "functor" which takes points in the X space and returns the mapped point in Y, optionally using an extra, constant parameter ("fixed_param") which remains constant.

Parameters:
out_samples_y If !=NULL, this vector will contain, upon return, the sequence of random samples generated and propagated through the functor().
See also:
The example in MRPT/samples/unscented_transform_test
transform_gaussian_unscented, transform_gaussian_linear

Definition at line 115 of file transform_gaussian.h.

References covariancesAndMean(), mrpt::random::CRandomGenerator::drawGaussianMultivariateMany(), MRPT_END, MRPT_START, and mrpt::random::randomGenerator.

template<class VECTORLIKE1 , class MATLIKE1 , class USERPARAM , class VECTORLIKE2 , class VECTORLIKE3 , class MATLIKE2 >
void mrpt::math::transform_gaussian_unscented ( const VECTORLIKE1 &  x_mean,
const MATLIKE1 &  x_cov,
void(*)(const VECTORLIKE1 &x, const USERPARAM &fixed_param, VECTORLIKE3 &y)  functor,
const USERPARAM &  fixed_param,
VECTORLIKE2 &  y_mean,
MATLIKE2 &  y_cov,
const bool *  elem_do_wrap2pi = NULL,
const double  alpha = 1e-3,
const double  K = 0,
const double  beta = 2.0 
)

Scaled unscented transformation (SUT) for estimating the Gaussian distribution of a variable Y=f(X) for an arbitrary function f() provided by the user.

The user must supply the function in "functor" which takes points in the X space and returns the mapped point in Y, optionally using an extra, constant parameter ("fixed_param") which remains constant.

The parameters alpha, K and beta are the common names of the SUT method, and the default values are those recommended in most papers.

Parameters:
elem_do_wrap2pi If !=NULL; it must point to an array of "bool" of size()==dimension of each element, stating if it's needed to do a wrap to [-pi,pi] to each dimension.
See also:
The example in MRPT/samples/unscented_transform_test
transform_gaussian_montecarlo, transform_gaussian_linear

Definition at line 56 of file transform_gaussian.h.

References covariancesAndMeanWeighted(), MRPT_END, MRPT_START, row(), and sqrt().

void mrpt::math::unwrap2PiSequence ( vector_double &  x  ) 

Modify a sequence of angle values such as no consecutive values have a jump larger than PI in absolute value.

See also:
wrapToPi
template<class T , class U >
bool mrpt::math::vectorsAreParallel2D ( const T &  v1,
const U &  v2 
) [inline]

Returns true if two 2D vectors are parallel.

The arguments may be points, arrays, etc.

Definition at line 855 of file geometry.h.

References abs(), and geometryEpsilon.

template<class T , class U >
bool mrpt::math::vectorsAreParallel3D ( const T &  v1,
const U &  v2 
) [inline]

Returns true if two 3D vectors are parallel.

The arguments may be points, arrays, etc.

Definition at line 863 of file geometry.h.

References abs(), and geometryEpsilon.

template<class VECTORLIKE1 , class VECTORLIKE2 >
void mrpt::math::weightedHistogram ( const VECTORLIKE1 &  values,
const VECTORLIKE1 &  weights,
float  binWidth,
VECTORLIKE2 &  out_binCenters,
VECTORLIKE2 &  out_binValues 
)

Computes the weighted histogram for a vector of values and their corresponding weights.

Parameters:
values [IN] The N values
weights [IN] The weights for the corresponding N values (don't need to be normalized)
binWidth [IN] The desired width of the bins
out_binCenters [OUT] The centers of the M bins generated to cover from the minimum to the maximum value of "values" with the given "binWidth"
out_binValues [OUT] The ratio of values at each given bin, such as the whole vector sums up the unity.
See also:
weightedHistogramLog

Definition at line 347 of file base/include/mrpt/math/utils.h.

References ASSERT_, ASSERTDEB_, maximum(), minimum(), and mrpt::utils::round().

template<class VECTORLIKE1 , class VECTORLIKE2 >
void mrpt::math::weightedHistogramLog ( const VECTORLIKE1 &  values,
const VECTORLIKE1 &  log_weights,
float  binWidth,
VECTORLIKE2 &  out_binCenters,
VECTORLIKE2 &  out_binValues 
)

Computes the weighted histogram for a vector of values and their corresponding log-weights.

Parameters:
values [IN] The N values
weights [IN] The log-weights for the corresponding N values (don't need to be normalized)
binWidth [IN] The desired width of the bins
out_binCenters [OUT] The centers of the M bins generated to cover from the minimum to the maximum value of "values" with the given "binWidth"
out_binValues [OUT] The ratio of values at each given bin, such as the whole vector sums up the unity.
See also:
weightedHistogram

Definition at line 401 of file base/include/mrpt/math/utils.h.

References ASSERT_, ASSERTDEB_, exp(), maximum(), minimum(), and mrpt::utils::round().

template<class T >
T mrpt::math::wrapTo2Pi ( a  )  [inline]

Modifies the given angle to translate it into the [0,2pi[ range.

Note:
Take care of not instancing this template for integer numbers, since it only works for float, double and long double.
See also:
wrapToPi, wrapTo2Pi, unwrap2PiSequence

Definition at line 174 of file base/include/mrpt/math/utils.h.

References wrapTo2PiInPlace().

Referenced by operator!=(), operator==(), and wrapToPi().

template<class T >
void mrpt::math::wrapTo2PiInPlace ( T &  a  )  [inline]

Modifies the given angle to translate it into the [0,2pi[ range.

Note:
Take care of not instancing this template for integer numbers, since it only works for float, double and long double.
See also:
wrapToPi, wrapTo2Pi, unwrap2PiSequence

Definition at line 162 of file base/include/mrpt/math/utils.h.

References M_2PI.

Referenced by wrapTo2Pi().

template<class T >
T mrpt::math::wrapToPi ( a  )  [inline]

Modifies the given angle to translate it into the ]-pi,pi] range.

Note:
Take care of not instancing this template for integer numbers, since it only works for float, double and long double.
See also:
wrapTo2Pi, wrapToPiInPlace, unwrap2PiSequence

Definition at line 185 of file base/include/mrpt/math/utils.h.

References M_PI, and wrapTo2Pi().

Referenced by covariancesAndMeanWeighted(), leastSquareLinearFit(), pointIntoQuadrangle(), and wrapToPiInPlace().

template<class T >
void mrpt::math::wrapToPiInPlace ( T &  a  )  [inline]

Modifies the given angle to translate it into the ]-pi,pi] range.

Note:
Take care of not instancing this template for integer numbers, since it only works for float, double and long double.
See also:
wrapToPi,wrapTo2Pi, unwrap2PiSequence

Definition at line 195 of file base/include/mrpt/math/utils.h.

References wrapToPi().

template<class T >
Eigen::Matrix<T,Eigen::Dynamic,1> mrpt::math::zeros ( size_t  count  )  [inline]

Generates a vector of all zeros of the given length.

Definition at line 149 of file base/include/mrpt/math/utils.h.


Variable Documentation

const unsigned char mrpt::math::GEOMETRIC_TYPE_LINE = 2
const unsigned char mrpt::math::GEOMETRIC_TYPE_PLANE = 4
const unsigned char mrpt::math::GEOMETRIC_TYPE_POINT = 0
const unsigned char mrpt::math::GEOMETRIC_TYPE_POLYGON = 3
const unsigned char mrpt::math::GEOMETRIC_TYPE_SEGMENT = 1
const unsigned char mrpt::math::GEOMETRIC_TYPE_UNDEFINED = 255
double BASE_IMPEXP mrpt::math::geometryEpsilon

Global epsilon to overcome small precision errors.

Referenced by getEpsilon(), setEpsilon(), vectorsAreParallel2D(), and vectorsAreParallel3D().

struct BASE_IMPEXP mrpt::math::TLine3D

Definition at line 633 of file lightweight_geom_data.h.

struct BASE_IMPEXP mrpt::math::TObject3D

Definition at line 635 of file lightweight_geom_data.h.

class BASE_IMPEXP mrpt::math::TPolygon3D
struct BASE_IMPEXP mrpt::math::TSegment3D



Page generated by Doxygen 1.7.1 for MRPT 0.9.4 SVN: at Mon Jan 10 23:33:19 UTC 2011