Main MRPT website > C++ reference
MRPT logo
Namespaces | Files | Functions
Vector and matrices mathematical operations and other utilities

Detailed Description

Collaboration diagram for Vector and matrices mathematical operations and other utilities:

Namespaces

 mrpt
 This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
 

Files

file  ops_containers.h
 This file implements several operations that operate element-wise on individual or pairs of containers.
 

Functions

template<class Derived >
const Eigen::MatrixBase< Derived >::AdjointReturnType mrpt::math::operator~ (const Eigen::MatrixBase< Derived > &m)
 Transpose operator for matrices. More...
 
template<class Derived >
Eigen::MatrixBase< Derived >::PlainObject mrpt::math::operator! (const Eigen::MatrixBase< Derived > &m)
 Unary inversion operator. More...
 
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. More...
 
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. More...
 
template<typename T , size_t N>
mrpt::utils::CStreammrpt::math::operator<< (mrpt::utils::CStream &ostrm, const CArrayNumeric< T, N > &a)
 Binary dump of a CArrayNumeric<T,N> to a stream. More...
 
template<typename T , size_t N>
mrpt::utils::CStreammrpt::math::operator>> (mrpt::utils::CStream &istrm, CArrayNumeric< T, N > &a)
 Binary read of a CArrayNumeric<T,N> from a stream. More...
 
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. More...
 
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. More...
 
bool BASE_IMPEXP mrpt::math::isNaN (float f) MRPT_NO_THROWS
 Returns true if the number is NaN. More...
 
bool BASE_IMPEXP mrpt::math::isNaN (double f) MRPT_NO_THROWS
 Returns true if the number is NaN. More...
 
bool BASE_IMPEXP mrpt::math::isFinite (float f) MRPT_NO_THROWS
 Returns true if the number is non infinity. More...
 
bool BASE_IMPEXP mrpt::math::isFinite (double f) MRPT_NO_THROWS
 Returns true if the number is non infinity. More...
 
void BASE_IMPEXP mrpt::math::medianFilter (const std::vector< double > &inV, std::vector< double > &outV, const int &winSize, const int &numberOfSigmas=2)
 
template<typename T , typename VECTOR >
void mrpt::math::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. More...
 
template<class T >
Eigen::Matrix< T, Eigen::Dynamic, 1 > mrpt::math::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. More...
 
template<class T , T STEP>
Eigen::Matrix< T, Eigen::Dynamic, 1 > mrpt::math::sequence (T first, size_t length)
 Generates a sequence of values [first,first+STEP,first+2*STEP,...]. More...
 
template<class T , T STEP>
std::vector< T > mrpt::math::sequenceStdVec (T first, size_t length)
 Generates a sequence of values [first,first+STEP,first+2*STEP,...]. More...
 
template<class T >
Eigen::Matrix< T, Eigen::Dynamic, 1 > mrpt::math::ones (size_t count)
 Generates a vector of all ones of the given length. More...
 
template<class T >
Eigen::Matrix< T, Eigen::Dynamic, 1 > mrpt::math::zeros (size_t count)
 Generates a vector of all zeros of the given length. More...
 
template<class T >
void mrpt::math::wrapTo2PiInPlace (T &a)
 Modifies the given angle to translate it into the [0,2pi[ range. More...
 
template<class T >
mrpt::math::wrapTo2Pi (T a)
 Modifies the given angle to translate it into the [0,2pi[ range. More...
 
template<class T >
mrpt::math::wrapToPi (T a)
 Modifies the given angle to translate it into the ]-pi,pi] range. More...
 
template<class T >
void mrpt::math::wrapToPiInPlace (T &a)
 Modifies the given angle to translate it into the ]-pi,pi] range. More...
 
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. More...
 
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. More...
 
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. More...
 
template<class VECTOR_OF_VECTORS , class VECTORLIKE >
void mrpt::math::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. More...
 
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. More...
 
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). More...
 
template<class T >
mrpt::math::round2up (T val)
 Round up to the nearest power of two of a given number. More...
 
template<class T >
mrpt::math::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, ... More...
 
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) More...
 
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. More...
 
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)
 
template<class MATRIXLIKE >
void mrpt::math::homogeneousMatrixInverse (MATRIXLIKE &M)
 
template<class VECTORLIKE , class VECTORLIKE2 , class VECTORLIKE3 , class MATRIXLIKE , class USERPARAM >
void mrpt::math::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. More...
 
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). More...
 
template<typename Derived , typename At , size_t N>
Eigen::EigenBase< Derived > & mrpt::math::loadVector (Eigen::EigenBase< Derived > &v, At(&theArray)[N])
 
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. More...
 
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. More...
 

Operators for binary streaming of MRPT matrices

template<size_t NROWS, size_t NCOLS>
mrpt::utils::CStreammrpt::math::operator>> (mrpt::utils::CStream &in, CMatrixFixedNumeric< float, NROWS, NCOLS > &M)
 Read operator from a CStream. More...
 
template<size_t NROWS, size_t NCOLS>
mrpt::utils::CStreammrpt::math::operator>> (mrpt::utils::CStream &in, CMatrixFixedNumeric< double, NROWS, NCOLS > &M)
 Read operator from a CStream. More...
 
template<size_t NROWS, size_t NCOLS>
mrpt::utils::CStreammrpt::math::operator<< (mrpt::utils::CStream &out, const CMatrixFixedNumeric< float, NROWS, NCOLS > &M)
 Write operator for writing into a CStream. More...
 
template<size_t NROWS, size_t NCOLS>
mrpt::utils::CStreammrpt::math::operator<< (mrpt::utils::CStream &out, const CMatrixFixedNumeric< double, NROWS, NCOLS > &M)
 Write operator for writing into a CStream. More...
 

Operators for text streaming of MRPT matrices

template<typename T , size_t NROWS, size_t NCOLS>
std::ostream & mrpt::math::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. More...
 
template<typename T >
std::ostream & mrpt::math::operator<< (std::ostream &s, const CMatrixTemplateNumeric< T > &m)
 Dumps the matrix to a text ostream, adding a final "\n" to Eigen's default output. More...
 
template<typename T >
std::ostream & mrpt::math::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]". More...
 

Generic std::vector element-wise operations

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

Function Documentation

◆ correlate_matrix()

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 512 of file base/include/mrpt/math/utils.h.

References THROW_EXCEPTION.

◆ estimateJacobian()

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 718 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().

◆ extractColumnFromVectorOfVectors()

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 466 of file base/include/mrpt/math/utils.h.

◆ factorial()

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).

◆ factorial64()

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.

◆ homogeneousMatrixInverse() [1/3]

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 611 of file base/include/mrpt/math/utils.h.

References ASSERT_, MRPT_END, MRPT_START, and mrpt::math::size().

Referenced by mrpt::poses::CPoseOrPoint< CPoint3D >::getInverseHomogeneousMatrix(), and mrpt::slam::detail::project3DPointsFromDepthImageInto().

◆ homogeneousMatrixInverse() [2/3]

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 663 of file base/include/mrpt/math/utils.h.

References ASSERT_, MRPT_END, MRPT_START, and mrpt::math::size().

◆ homogeneousMatrixInverse() [3/3]

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 692 of file base/include/mrpt/math/utils.h.

References ASSERTDEB_, and mrpt::math::size().

◆ isFinite() [1/2]

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

Returns true if the number is non infinity.

◆ isFinite() [2/2]

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

Returns true if the number is non infinity.

◆ isNaN() [1/2]

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

Returns true if the number is NaN.

◆ isNaN() [2/2]

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

Returns true if the number is NaN.

◆ linspace() [1/2]

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 101 of file base/include/mrpt/math/utils.h.

Referenced by mrpt::math::linspace().

◆ linspace() [2/2]

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 121 of file base/include/mrpt/math/utils.h.

References mrpt::math::linspace().

◆ loadVector() [1/4]

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

◆ loadVector() [2/4]

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

◆ loadVector() [3/4]

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).

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 773 of file base/include/mrpt/math/utils.h.

References MRPT_COMPILE_TIME_ASSERT.

◆ loadVector() [4/4]

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 783 of file base/include/mrpt/math/utils.h.

References MRPT_COMPILE_TIME_ASSERT.

◆ make_vector()

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 807 of file base/include/mrpt/math/utils.h.

References MRPT_COMPILE_TIME_ASSERT.

◆ medianFilter()

void BASE_IMPEXP mrpt::math::medianFilter ( const std::vector< double > &  inV,
std::vector< double > &  outV,
const int &  winSize,
const int &  numberOfSigmas = 2 
)

◆ normalize()

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 215 of file base/include/mrpt/math/utils.h.

References mrpt::utils::square().

◆ ones()

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 151 of file base/include/mrpt/math/utils.h.

◆ operator!()

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

Unary inversion operator.

Definition at line 143 of file ops_matrices.h.

◆ operator*()

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 79 of file ops_vectors.h.

References ASSERT_EQUAL_.

◆ operator*=() [1/2]

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 60 of file ops_vectors.h.

References ASSERT_EQUAL_.

◆ operator*=() [2/2]

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 70 of file ops_vectors.h.

◆ operator+()

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 109 of file ops_vectors.h.

References ASSERT_EQUAL_.

◆ operator+=() [1/2]

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 90 of file ops_vectors.h.

References ASSERT_EQUAL_.

◆ operator+=() [2/2]

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 100 of file ops_vectors.h.

◆ operator-()

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 119 of file ops_vectors.h.

References ASSERT_EQUAL_.

◆ operator<<() [1/8]

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 88 of file ops_matrices.h.

◆ operator<<() [2/8]

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 95 of file ops_matrices.h.

◆ operator<<() [3/8]

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 110 of file ops_matrices.h.

◆ operator<<() [4/8]

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 118 of file ops_matrices.h.

◆ operator<<() [5/8]

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 126 of file ops_matrices.h.

◆ operator<<() [6/8]

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 132 of file ops_vectors.h.

◆ operator<<() [7/8]

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 147 of file ops_vectors.h.

◆ operator<<() [8/8]

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 161 of file ops_vectors.h.

◆ operator>>() [1/3]

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 69 of file ops_matrices.h.

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

◆ operator>>() [2/3]

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 78 of file ops_matrices.h.

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

◆ operator>>() [3/3]

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 170 of file ops_vectors.h.

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

◆ operator~()

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

Transpose operator for matrices.

Definition at line 137 of file ops_matrices.h.

◆ round2up()

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

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

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

References THROW_EXCEPTION.

◆ round_10power()

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 501 of file base/include/mrpt/math/utils.h.

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

◆ sequence()

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 130 of file base/include/mrpt/math/utils.h.

◆ sequenceStdVec()

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 141 of file base/include/mrpt/math/utils.h.

◆ unwrap2PiSequence()

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

◆ weightedHistogram()

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 358 of file base/include/mrpt/math/utils.h.

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

◆ weightedHistogramLog()

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 412 of file base/include/mrpt/math/utils.h.

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

◆ wrapTo2Pi()

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 184 of file base/include/mrpt/math/utils.h.

References mrpt::math::wrapTo2PiInPlace().

Referenced by mrpt::math::operator!=(), mrpt::math::operator==(), and mrpt::math::wrapToPi().

◆ wrapTo2PiInPlace()

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 172 of file base/include/mrpt/math/utils.h.

References M_2PI.

Referenced by mrpt::mrpt::math::wrapTo2Pi().

◆ wrapToPi()

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 195 of file base/include/mrpt/math/utils.h.

References M_PI, and mrpt::math::wrapTo2Pi().

Referenced by mrpt::graphs::detail::graph_ops< graph_t >::auxEuclid2Dist(), mrpt::math::covariancesAndMeanWeighted(), mrpt::math::leastSquareLinearFit(), and mrpt::math::wrapToPiInPlace().

◆ 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 205 of file base/include/mrpt/math/utils.h.

References mrpt::math::wrapToPi().

Referenced by mrpt::graphs::detail::graph_ops< graph_t >::auxMaha2Dist().

◆ zeros()

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 159 of file base/include/mrpt/math/utils.h.




Page generated by Doxygen 1.8.14 for MRPT 1.0.2 SVN: at lun oct 28 00:52:41 CET 2019 Hosted on:
SourceForge.net Logo