Classes | |
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... | |
class | CMatrix |
This class is a "CSerializable" wrapper for "CMatrixFloat". More... | |
class | CMatrixB |
This class is a "CSerializable" wrapper for "CMatrixBool". More... | |
class | CMatrixD |
This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>". 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 |
This template class extends the class "CMatrixTemplate" with many common operations with numerical matrixes. More... | |
class | CMatrixTemplateObjects |
This template class extends the class "CMatrixTemplate" for storing "objects" at each matrix entry. More... | |
class | CPolygon |
A simple 2D polygon class, mainly for checking points falling inside it. More... | |
class | CQuaternion |
class | CSplineInterpolator1D |
A (persistent) sequence of (x,y) coordinates, allowing queries of intermediate points through spline interpolation, where possible. More... | |
class | CVectorTemplate |
This template class provides the basic functionality for a general 1D any-size, resizable container of numerical or non-numerical elements. More... | |
Typedefs | |
typedef CLevenbergMarquardtTempl < 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 CVectorTemplate< float > | CVectorFloat |
Declares a vector of float elements. | |
typedef CVectorTemplate< double > | CVectorDouble |
Declares a vector of double elements. | |
Enumerations | |
enum | TMatrixTextFileFormat { MATRIX_FORMAT_ENG = 0, MATRIX_FORMAT_FIXED = 1, MATRIX_FORMAT_INT = 2 } |
Selection of the number format in CMatrixTemplateNumeric::saveToTextFile. More... | |
Functions | |
bool MRPTDLLIMPEXP | isNan (float v) |
Returns true if value is Not-a-number (NAN). | |
bool MRPTDLLIMPEXP | isNan (double v) |
Returns true if value is Not-a-number (NAN). | |
bool MRPTDLLIMPEXP | isFinite (float v) |
Returns true if value is finite. | |
bool MRPTDLLIMPEXP | isFinite (double v) |
Returns true if value is finite. | |
template<class T > | |
std::ostream & | operator<< (std::ostream &ostrm, const CMatrixTemplate< T > &m) |
Textual output stream function. | |
template<class T > | |
size_t | size (const CMatrixTemplate< T > &m, int dim) |
Returns the size of the matrix in the i'th dimension: 1=rows, 2=columns (MATLAB-compatible function). | |
template<class T > | |
bool | operator== (const CMatrixTemplateNumeric< T > &m1, const CMatrixTemplateNumeric< T > &m2) |
Logical equal-to operator. | |
template<class T > | |
bool | operator!= (const CMatrixTemplateNumeric< T > &m1, const CMatrixTemplateNumeric< T > &m2) |
logical no-equal-to operator | |
template<class T > | |
CMatrixTemplateNumeric< T > | operator+ (const CMatrixTemplateNumeric< T > &m1, const CMatrixTemplateNumeric< T > &m2) |
binary addition operator | |
template<class T > | |
CMatrixTemplateNumeric< T > | operator- (const CMatrixTemplateNumeric< T > &m1, const CMatrixTemplateNumeric< T > &m2) |
binary subtraction operator | |
template<class T > | |
CMatrixTemplateNumeric< T > | operator* (const CMatrixTemplateNumeric< T > &m, const T &no) |
binary scalar multiplication operator | |
template<class T > | |
CMatrixTemplateNumeric< T > | operator* (const T &no, const CMatrixTemplateNumeric< T > &m) |
binary scalar multiplication operator | |
template<class T > | |
CMatrixTemplateNumeric< T > | operator* (const CMatrixTemplateNumeric< T > &m1, const CMatrixTemplateNumeric< T > &m2) |
binary matrix multiplication operator | |
template<class T > | |
CMatrixTemplateNumeric< T > | operator* (const CMatrixTemplateNumeric< T > &m1, const CVectorTemplate< T > &m2) |
Binary matrix multiplication operator, with one matrix being NxM and the second being a column matrix Mx1. | |
template<class T > | |
CMatrixTemplateNumeric< T > | operator/ (const CMatrixTemplateNumeric< T > &m, const T &no) |
binary scalar division operator | |
template<class T > | |
CMatrixTemplateNumeric< T > | operator/ (const T &no, const CMatrixTemplateNumeric< T > &m) |
binary scalar division operator | |
template<class T > | |
CMatrixTemplateNumeric< T > | operator/ (const CMatrixTemplateNumeric< T > &m1, const CMatrixTemplateNumeric< T > &m2) |
binary matrix division operator | |
template<class T > | |
CMatrixTemplateNumeric< T > | operator^ (const CMatrixTemplateNumeric< T > &m, const unsigned int &pow) |
binary power operator | |
template<class T > | |
CMatrixTemplateNumeric< T > | operator~ (const CMatrixTemplateNumeric< T > &m) |
unary transpose operator | |
template<class T > | |
CMatrixTemplateNumeric< T > | operator! (const CMatrixTemplateNumeric< T > &m) |
Unary inversion operator. | |
double MRPTDLLIMPEXP | normalPDF (double x, double mu, double std) |
Evaluates the univariate normal (Gaussian) distribution at a given point "x". | |
template<class T > | |
T | normalPDF (const CMatrixTemplateNumeric< T > &x, const CMatrixTemplateNumeric< T > &mu, const CMatrixTemplateNumeric< T > &cov) |
Evaluates the multivariate normal (Gaussian) distribution at a given point "x" ("x" and "mu" can be 1xN or Nx1 matrixes). | |
double MRPTDLLIMPEXP | erfc (double x) |
The complementary error function of a Normal distribution. | |
double MRPTDLLIMPEXP | erf (double x) |
The error function of a Normal distribution. | |
double MRPTDLLIMPEXP | normalQuantile (double p) |
Evaluates the Gaussian distribution quantile for the probability value p=[0,1]. | |
double MRPTDLLIMPEXP | normalCDF (double p) |
Evaluates the Gaussian cumulative density function. | |
double MRPTDLLIMPEXP | chiSquareQuantile (double P, unsigned int dim=1) |
The "quantile" of the Chi-Square distribution, for dimension "dim" and probability 0<P<1 An aproximation from the Wilson-Hilferty transformation is used. | |
void MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | idft2_real (const CMatrixFloat &in_real, const CMatrixFloat &in_imag, CMatrixFloat &out_data) |
Compute the 2D inverse Discrete Fourier Transform (DFT). | |
void MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | cross_correlation_FFT (const CMatrixFloat &A, const CMatrixFloat &B, CMatrixFloat &out_corr) |
Correlation of two matrixes using 2D FFT. | |
double MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | 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. | |
double MRPTDLLIMPEXP | distanceBetweenPoints (const double x1, const double y1, const double x2, const double y2) |
Returns the distance between 2 points in 2D. | |
double MRPTDLLIMPEXP | distanceBetweenPoints (const double x1, const double y1, const double z1, const double x2, const double y2, const double z2) |
Returns the distance between 3 points in 3D. | |
double MRPTDLLIMPEXP | distanceSqrBetweenPoints (const double x1, const double y1, const double x2, const double y2) |
Returns the square distance between 2 points in 2D. | |
double MRPTDLLIMPEXP | distanceSqrBetweenPoints (const double x1, const double y1, const double z1, const double x2, const double y2, const double z2) |
Returns the square distance between 3 points in 3D. | |
bool MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | 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. | |
double MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | 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<class T > | |
void | crossProduct3D (T x0, T y0, T z0, T x1, T y1, T z1, T &x_out, T &y_out, T &z_out) |
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) |
Computes the cross product of two 3D vectors, returning a vector normal to both. | |
bool MRPTDLLIMPEXP | loadVector (utils::CFileStream &f, std::vector< int > &d) |
Loads one row of a text file as a numerical std::vector. | |
bool MRPTDLLIMPEXP | loadVector (utils::CFileStream &f, std::vector< double > &d) |
Loads one row of a text file as a numerical std::vector. | |
template<class T > | |
size_t | countNonZero (const std::vector< T > &a) |
A template for counting how many elements in an array are non-Zero. | |
template<class T > | |
T | maximum (const std::vector< T > &v, unsigned int *maxIndex=NULL) |
Finds the maximum value (and the corresponding zero-based index) from a given vector. | |
template<class T > | |
T | norm_inf (const std::vector< T > &v, unsigned int *maxIndex=NULL) |
Compute the norm-infinite of a vector ($f[ ||{v}||_ $f]), ie the maximum absolute value of the elements. | |
template<class T > | |
T | norm (const std::vector< T > &v) |
Compute the 2-norm of the vector (the Euclidean distance to the origin). | |
template<class T > | |
T | minimum (const std::vector< T > &v, unsigned int *minIndex=NULL) |
Finds the maximum value (and the corresponding zero-based index) from a given vector. | |
template<class T > | |
void | minimum_maximum (const std::vector< T > &v, T &out_min, T &out_max, unsigned int *minIndex=NULL, unsigned int *maxIndex=NULL) |
Compute the minimum and maximum of a vector at once. | |
template<class T > | |
double | mean (const std::vector< T > &v) |
Computes the mean value of a vector. | |
template<class T > | |
T | sum (const std::vector< T > &v) |
Computes the sum of all the elements of a vector. | |
template<typename T , typename K > | |
void | linspace (T first, T last, size_t count, std::vector< K > &out_vector) |
Generates an equidistant sequence of numbers given the first one, the last one and the desired number of points. | |
template<class T > | |
std::vector< T > | 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 > | |
std::vector< T > | ones (size_t count) |
Generates a vector of all ones of the given length. | |
template<class T > | |
std::vector< T > | zeros (size_t count) |
Generates a vector of all zeros of the given length. | |
template<class T > | |
void | normalize (const std::vector< T > &v, std::vector< T > &out_v) |
Normalize a vector, such as its norm is the unity. | |
template<class T > | |
std::vector< T > | cumsum (const std::vector< T > &v) |
Computes the cumulative sum of all the elements of a vector. | |
template<class T > | |
void | cumsum (const std::vector< T > &v, std::vector< T > &out_cumsum) |
Computes the cumulative sum of all the elements of a vector, saving the result in a given vector. | |
template<class T > | |
double | stddev (const std::vector< T > &v, bool unbiased=true) |
Computes the standard deviation of a vector. | |
template<class T > | |
void | meanAndStd (const std::vector< T > &v, double &out_mean, double &out_std, bool unbiased=true) |
Computes the standard deviation of a vector. | |
template<class T > | |
void | weightedHistogram (const std::vector< T > &values, const std::vector< T > &weights, float binWidth, std::vector< float > &out_binCenters, std::vector< float > &out_binValues) |
Computes the weighted histogram for a vector of values and their corresponding weights. | |
uint64_t MRPTDLLIMPEXP | factorial64 (unsigned int n) |
Computes the factorial of an integer number and returns it as a 64-bit integer number. | |
double MRPTDLLIMPEXP | 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 > | |
void | wrapTo2PiInPlace (T &a) |
Modifies the given angle to translate it into the [0,2pi[ range. | |
template<class T > | |
T | wrapTo2Pi (T a) |
Modifies the given angle to translate it into the [0,2pi[ range. | |
template<class T > | |
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 T > | |
T | round2up (T val) |
Round up to the nearest power of two of a given number. | |
template<class T > | |
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 > | |
void | chol (const CMatrixTemplateNumeric< T > &in, CMatrixTemplateNumeric< T > &out) |
Cholesky factorization: in = out' ยท out Given a positive-definite symmetric matrix, this routine constructs its Cholesky decomposition. | |
template<class T > | |
double | correlate_matrix (const CMatrixTemplateNumeric< T > &a1, const CMatrixTemplateNumeric< T > &a2) |
Calculate the correlation between two matrices (by AJOGD @ JAN-2007). | |
template<class T > | |
void MRPTDLLIMPEXP | qr_decomposition (CMatrixTemplateNumeric< T > &A, CMatrixTemplateNumeric< T > &R, CMatrixTemplateNumeric< T > &Q, CVectorTemplate< T > &c, int &sing) |
Matrix QR decomposition. | |
template<class T > | |
void MRPTDLLIMPEXP | UpdateCholesky (CMatrixTemplateNumeric< T > &chol, CVectorTemplate< T > &r1Modification) |
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. | |
void MRPTDLLIMPEXP | computeEigenValues2x2 (const CMatrixFloat &in_matrix, float &min_eigenvalue, float &max_eigenvalue) |
Compute the two eigenvalues of a 2x2 matrix. | |
template<class T > | |
std::vector< T > | Exp (const std::vector< T > &v) |
Computes the 'exp' of all the elements of a vector. | |
template<class T > | |
std::vector< T > | Log (const std::vector< T > &v) |
Computes the 'log' of all the elements of a vector. | |
double MRPTDLLIMPEXP | averageLogLikelihood (const vector_double &logLikelihoods) |
A numerically-stable method to compute average likelihood values with strongly different ranges (unweighted likelihoods: compute the arithmetic mean). | |
double MRPTDLLIMPEXP | averageWrap2Pi (const vector_double &angles) |
Computes the average of a sequence of angles in radians taking into account the correct wrapping in the range ![]() ![]() | |
double MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | MATLAB_plotCovariance2D (const CMatrixFloat &cov22, const CVectorFloat &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). | |
void MRPTDLLIMPEXP | homogeneousMatrixInverse (const CMatrixDouble &M, CMatrixDouble &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 T > | |
size_t | countCommonElements (const std::vector< T > &a, const std::vector< T > &b) |
Counts the number of elements that appear in both vectors (comparison through the == operator) It is assumed that no repeated elements appear within each of the vectors. | |
template<typename T > | |
void MRPTDLLIMPEXP | estimateJacobian (const std::vector< T > &x, void(*functor)(const std::vector< T > &x, const std::vector< T > &y, std::vector< T > &out), const std::vector< T > &increments, const std::vector< T > &userParam, CMatrixTemplateNumeric< T > &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<class T > | |
vector_double | histogram (const std::vector< T > &v, double limit_min, double limit_max, size_t number_bins, bool do_normalization=false) |
Computes the normalized or normal histogram of a sequence of numbers given the number of bins and the limits. | |
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<class T > | |
std::vector< T > | Abs (const std::vector< T > &a) |
Absolute value of a vector. | |
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<class T > | |
T MRPTDLLIMPEXP | mahalanobisDistance (const std::vector< T > &X, const std::vector< T > &MU, const CMatrixTemplateNumeric< T > &COV_inv) |
Computes the mahalanobis distance of a vector X given the mean MU and the covariance *inverse* COV_inv
| |
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<class T > | |
std::vector< T > | operator+ (const std::vector< T > &a, T b) |
A template function for the operator + between a scalar and a std::vector. | |
template<class T > | |
std::vector< T > | operator- (const std::vector< T > &a, T b) |
A template function for the operator - between a scalar and a std::vector. | |
template<class T > | |
std::vector< T > | operator* (const std::vector< T > &a, T b) |
A template function for the operator * between a scalar and a std::vector. | |
template<class T > | |
std::vector< T > | operator/ (const std::vector< T > &a, T b) |
A template function for dividing a std::vector by a scalar number. | |
template<class T > | |
std::vector< T > | operator+ (const std::vector< T > &a, const std::vector< T > &b) |
A template function for adding std::vector's having the same number of elements. | |
template<class T > | |
std::vector< T > | operator- (const std::vector< T > &a, const std::vector< T > &b) |
A template function for substracting std::vector's having the same number of elements. | |
template<class T > | |
std::vector< T > | operator* (const std::vector< T > &a, const std::vector< T > &b) |
A template function for scalar product (element by element, like . | |
template<class T > | |
std::vector< T > | operator/ (const std::vector< T > &a, const std::vector< T > &b) |
A template function for scalar division (element by element, like . | |
template<class T > | |
void | operator+= (std::vector< T > &a, const std::vector< T > &b) |
A template for the operator += applied to std::vector's having the same number of elements. | |
template<class T > | |
void | operator-= (std::vector< T > &a, const std::vector< T > &b) |
A template for the operator -= applied to std::vector's having the same number of elements. | |
template<class T > | |
void | operator*= (std::vector< T > &a, const std::vector< T > &b) |
A template for the operator *= applied to std::vector's having the same number of elements. | |
template<class T > | |
void | operator/= (std::vector< T > &a, const std::vector< T > &b) |
A template for the operator /= applied to std::vector's having the same number of elements. | |
template<class T > | |
void | operator+= (std::vector< T > &a, T b) |
A template for the operator += applied to a std::vector and a scalar. | |
template<class T > | |
void | operator-= (std::vector< T > &a, T b) |
A template for the operator -= applied to a std::vector and a scalar. | |
template<class T > | |
void | operator*= (std::vector< T > &a, T b) |
A template for the operator *= applied to a std::vector and a scalar. | |
template<class T > | |
void | operator/= (std::vector< T > &a, T b) |
A template for the operator /= applied to a std::vector and a scalar. | |
Interpolation functions | |
template<class T > | |
T | interpolate (const T &x, const std::vector< T > &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 MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | spline (const double t, const std::vector< double > &x, const std::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). | |
double MRPTDLLIMPEXP | leastSquareLinearFit (const double t, const std::vector< double > &x, const std::vector< double > &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". | |
void MRPTDLLIMPEXP | leastSquareLinearFit (const std::vector< double > &ts, std::vector< double > &outs, const std::vector< double > &x, const std::vector< double > &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". |
typedef CLevenbergMarquardtTempl<double> mrpt::math::CLevenbergMarquardt |
The default name for the LM class is an instantiation for "double".
Definition at line 84 of file CLevenbergMarquardt.h.
typedef CMatrixTemplate<bool> mrpt::math::CMatrixBool |
Declares a matrix of booleans (non serializable).
Definition at line 819 of file CMatrixTemplateNumeric.h.
typedef CMatrixTemplateNumeric<double> mrpt::math::CMatrixDouble |
Declares a matrix of double numbers (non serializable).
For a serializable version, use math::CMatrixD
Definition at line 809 of file CMatrixTemplateNumeric.h.
typedef CMatrixTemplateNumeric<float> mrpt::math::CMatrixFloat |
Declares a matrix of float numbers (non serializable).
For a serializable version, use math::CMatrix
Definition at line 803 of file CMatrixTemplateNumeric.h.
typedef CMatrixTemplateNumeric<double> mrpt::math::CMatrixLongDouble |
Declares a matrix of "long doubles" (non serializable), or of "doubles" if the compiler does not support "long double".
Definition at line 830 of file CMatrixTemplateNumeric.h.
typedef CMatrixTemplateNumeric<unsigned int> mrpt::math::CMatrixUInt |
Declares a matrix of unsigned ints (non serializable).
Definition at line 814 of file CMatrixTemplateNumeric.h.
typedef CVectorTemplate<double> mrpt::math::CVectorDouble |
Declares a vector of double elements.
Definition at line 458 of file CVectorTemplate.h.
typedef CVectorTemplate<float> mrpt::math::CVectorFloat |
Declares a vector of float elements.
Definition at line 453 of file CVectorTemplate.h.
Selection of the number format in CMatrixTemplateNumeric::saveToTextFile.
MATRIX_FORMAT_ENG | engineering format 'e' |
MATRIX_FORMAT_FIXED | fixed floating point 'f' |
MATRIX_FORMAT_INT | intergers 'i' |
Definition at line 45 of file CMatrixTemplateNumeric.h.
std::vector<T> mrpt::math::Abs | ( | const std::vector< T > & | a | ) | [inline] |
double MRPTDLLIMPEXP 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:
See also the tutorial page.
double MRPTDLLIMPEXP mrpt::math::averageLogLikelihood | ( | const vector_double & | logLikelihoods | ) |
A numerically-stable method to compute average likelihood values with strongly different ranges (unweighted likelihoods: compute the arithmetic mean).
This method implements this equation:
See also the tutorial page.
double MRPTDLLIMPEXP 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 , for example, the mean of (2,-2) is
, not 0.
double MRPTDLLIMPEXP mrpt::math::chiSquareQuantile | ( | double | P, | |
unsigned int | dim = 1 | |||
) |
The "quantile" of the Chi-Square distribution, for dimension "dim" and probability 0<P<1 An aproximation from the Wilson-Hilferty transformation is used.
void mrpt::math::chol | ( | const CMatrixTemplateNumeric< T > & | in, | |
CMatrixTemplateNumeric< T > & | out | |||
) | [inline] |
Cholesky factorization: in = out' ยท out Given a positive-definite symmetric matrix, this routine constructs its Cholesky decomposition.
On input, only the upper triangle of "IN" need be given; it is not modified. The Cholesky factorization is returned in "out" in the upper triangle. (by AJOGD @ JAN-2007)
Definition at line 482 of file math/utils.h.
References mrpt::math::CMatrixTemplate< T >::getColCount(), mrpt::math::CMatrixTemplate< T >::getRowCount(), mrpt::math::CMatrixTemplateNumeric< T >::setSize(), sum(), and THROW_EXCEPTION.
void MRPTDLLIMPEXP 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.
void MRPTDLLIMPEXP 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 | |||
) |
double MRPTDLLIMPEXP 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.
void MRPTDLLIMPEXP mrpt::math::computeEigenValues2x2 | ( | const CMatrixFloat & | in_matrix, | |
float & | min_eigenvalue, | |||
float & | max_eigenvalue | |||
) |
Compute the two eigenvalues of a 2x2 matrix.
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 |
double mrpt::math::correlate_matrix | ( | const CMatrixTemplateNumeric< T > & | a1, | |
const CMatrixTemplateNumeric< T > & | a2 | |||
) | [inline] |
Calculate the correlation between two matrices (by AJOGD @ JAN-2007).
Definition at line 518 of file math/utils.h.
References mrpt::math::CMatrixTemplate< T >::getColCount(), mrpt::math::CMatrixTemplate< T >::getRowCount(), and THROW_EXCEPTION.
size_t mrpt::math::countCommonElements | ( | const std::vector< T > & | a, | |
const std::vector< T > & | b | |||
) | [inline] |
Counts the number of elements that appear in both vectors (comparison through the == operator) It is assumed that no repeated elements appear within each of the vectors.
Definition at line 684 of file math/utils.h.
size_t mrpt::math::countNonZero | ( | const std::vector< T > & | a | ) | [inline] |
A template for counting how many elements in an array are non-Zero.
Definition at line 82 of file math/utils.h.
void MRPTDLLIMPEXP mrpt::math::cross_correlation_FFT | ( | const CMatrixFloat & | A, | |
const CMatrixFloat & | B, | |||
CMatrixFloat & | out_corr | |||
) |
Correlation of two matrixes using 2D FFT.
void mrpt::math::crossProduct3D | ( | const std::vector< T > & | v0, | |
const std::vector< T > & | v1, | |||
std::vector< T > & | v_out | |||
) | [inline] |
Computes the cross product of two 3D vectors, returning a vector normal to both.
It uses the simple implementation:
Definition at line 282 of file geometry.h.
References ASSERT_.
void mrpt::math::crossProduct3D | ( | T | x0, | |
T | y0, | |||
T | z0, | |||
T | x1, | |||
T | y1, | |||
T | z1, | |||
T & | x_out, | |||
T & | y_out, | |||
T & | z_out | |||
) | [inline] |
Computes the cross product of two 3D vectors, returning a vector normal to both.
It uses the simple implementation:
Definition at line 260 of file geometry.h.
Referenced by generateAxisBaseFromDirection().
void mrpt::math::cumsum | ( | const std::vector< T > & | v, | |
std::vector< T > & | out_cumsum | |||
) | [inline] |
Computes the cumulative sum of all the elements of a vector, saving the result in a given vector.
Definition at line 276 of file math/utils.h.
std::vector<T> mrpt::math::cumsum | ( | const std::vector< T > & | v | ) | [inline] |
Computes the cumulative sum of all the elements of a vector.
Definition at line 261 of file math/utils.h.
void MRPTDLLIMPEXP 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.
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. |
void MRPTDLLIMPEXP 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.
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). |
double MRPTDLLIMPEXP mrpt::math::distanceBetweenPoints | ( | const double | x1, | |
const double | y1, | |||
const double | z1, | |||
const double | x2, | |||
const double | y2, | |||
const double | z2 | |||
) |
Returns the distance between 3 points in 3D.
double MRPTDLLIMPEXP mrpt::math::distanceBetweenPoints | ( | const double | x1, | |
const double | y1, | |||
const double | x2, | |||
const double | y2 | |||
) |
Returns the distance between 2 points in 2D.
double MRPTDLLIMPEXP 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.
double MRPTDLLIMPEXP mrpt::math::distanceSqrBetweenPoints | ( | const double | x1, | |
const double | y1, | |||
const double | z1, | |||
const double | x2, | |||
const double | y2, | |||
const double | z2 | |||
) |
Returns the square distance between 3 points in 3D.
double MRPTDLLIMPEXP mrpt::math::distanceSqrBetweenPoints | ( | const double | x1, | |
const double | y1, | |||
const double | x2, | |||
const double | y2 | |||
) |
Returns the square distance between 2 points in 2D.
double MRPTDLLIMPEXP mrpt::math::erf | ( | double | x | ) |
The error function of a Normal distribution.
double MRPTDLLIMPEXP mrpt::math::erfc | ( | double | x | ) |
The complementary error function of a Normal distribution.
void MRPTDLLIMPEXP mrpt::math::estimateJacobian | ( | const std::vector< T > & | x, | |
void(*)(const std::vector< T > &x, const std::vector< T > &y, std::vector< T > &out) | functor, | |||
const std::vector< T > & | increments, | |||
const std::vector< T > & | userParam, | |||
CMatrixTemplateNumeric< T > & | out_Jacobian | |||
) | [inline] |
Estimate the Jacobian of a multi-dimensional function around a point "x", using finite differences of a given size in each input dimension.
std::vector<T> mrpt::math::Exp | ( | const std::vector< T > & | v | ) | [inline] |
Computes the 'exp' of all the elements of a vector.
Definition at line 599 of file math/utils.h.
double MRPTDLLIMPEXP 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 MRPTDLLIMPEXP mrpt::math::factorial64 | ( | unsigned int | n | ) |
Computes the factorial of an integer number and returns it as a 64-bit integer number.
void MRPTDLLIMPEXP 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.
CMatrixTemplateNumeric<T> mrpt::math::generateAxisBaseFromDirection | ( | T | dx, | |
T | dy, | |||
T | dz | |||
) | [inline] |
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 is the input vector, then this function returns a matrix
such as:
And the three normal vectors are computed as:
If (dx!=0 or dy!=0):
otherwise (the direction vector is vertical):
And finally, the third vector is the cross product of the others:
Definition at line 205 of file geometry.h.
References crossProduct3D(), MRPT_TRY_END, MRPT_TRY_START, mrpt::utils::square(), and THROW_EXCEPTION.
vector_double mrpt::math::histogram | ( | const std::vector< T > & | v, | |
double | limit_min, | |||
double | limit_max, | |||
size_t | number_bins, | |||
bool | do_normalization = false | |||
) | [inline] |
Computes the normalized or normal histogram of a sequence of numbers given the number of bins and the limits.
Definition at line 766 of file math/utils.h.
References mrpt::math::CHistogram::add(), mrpt::math::CHistogram::getBinCount(), and mrpt::math::CHistogram::getBinRatio().
void MRPTDLLIMPEXP mrpt::math::homogeneousMatrixInverse | ( | const CMatrixDouble & | M, | |
CMatrixDouble & | 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.
void MRPTDLLIMPEXP 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).
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). |
void MRPTDLLIMPEXP mrpt::math::idft2_real | ( | const CMatrixFloat & | in_real, | |
const CMatrixFloat & | in_imag, | |||
CMatrixFloat & | out_data | |||
) |
Compute the 2D inverse Discrete Fourier Transform (DFT).
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. |
T mrpt::math::interpolate | ( | const T & | x, | |
const std::vector< T > & | ys, | |||
const T & | x0, | |||
const T & | x1 | |||
) | [inline] |
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.
Definition at line 718 of file math/utils.h.
References ASSERT_, MRPT_TRY_END, and MRPT_TRY_START.
double MRPTDLLIMPEXP 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).
bool MRPTDLLIMPEXP mrpt::math::isFinite | ( | double | v | ) |
Returns true if value is finite.
bool MRPTDLLIMPEXP mrpt::math::isFinite | ( | float | v | ) |
Returns true if value is finite.
bool MRPTDLLIMPEXP mrpt::math::isNan | ( | double | v | ) |
Returns true if value is Not-a-number (NAN).
bool MRPTDLLIMPEXP mrpt::math::isNan | ( | float | v | ) |
Returns true if value is Not-a-number (NAN).
void MRPTDLLIMPEXP mrpt::math::leastSquareLinearFit | ( | const std::vector< double > & | ts, | |
std::vector< double > & | outs, | |||
const std::vector< double > & | x, | |||
const std::vector< double > & | 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).
double MRPTDLLIMPEXP mrpt::math::leastSquareLinearFit | ( | const double | t, | |
const std::vector< double > & | x, | |||
const std::vector< double > & | 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).
std::vector<T> mrpt::math::linspace | ( | T | first, | |
T | last, | |||
size_t | count | |||
) | [inline] |
Generates an equidistant sequence of numbers given the first one, the last one and the desired number of points.
Definition at line 215 of file math/utils.h.
References linspace().
void mrpt::math::linspace | ( | T | first, | |
T | last, | |||
size_t | count, | |||
std::vector< K > & | out_vector | |||
) | [inline] |
Generates an equidistant sequence of numbers given the first one, the last one and the desired number of points.
Definition at line 196 of file math/utils.h.
Referenced by linspace().
std::vector<T>& mrpt::math::loadVector | ( | std::vector< T > & | v, | |
At(&) | theArray[N] | |||
) | [inline] |
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 );
Definition at line 785 of file math/utils.h.
References MRPT_COMPILE_TIME_ASSERT.
bool MRPTDLLIMPEXP mrpt::math::loadVector | ( | utils::CFileStream & | f, | |
std::vector< double > & | d | |||
) |
Loads one row of a text file as a numerical std::vector.
bool MRPTDLLIMPEXP mrpt::math::loadVector | ( | utils::CFileStream & | f, | |
std::vector< int > & | d | |||
) |
Loads one row of a text file as a numerical std::vector.
std::vector<T> mrpt::math::Log | ( | const std::vector< T > & | v | ) | [inline] |
Computes the 'log' of all the elements of a vector.
Definition at line 612 of file math/utils.h.
T MRPTDLLIMPEXP mrpt::math::mahalanobisDistance | ( | const std::vector< T > & | X, | |
const std::vector< T > & | MU, | |||
const CMatrixTemplateNumeric< T > & | COV_inv | |||
) | [inline] |
Computes the mahalanobis distance of a vector X given the mean MU and the covariance *inverse* COV_inv
.
std::string MRPTDLLIMPEXP mrpt::math::MATLAB_plotCovariance2D | ( | const CMatrixFloat & | cov22, | |
const CVectorFloat & | 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).
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 |
T mrpt::math::maximum | ( | const std::vector< T > & | v, | |
unsigned int * | maxIndex = NULL | |||
) | [inline] |
Finds the maximum value (and the corresponding zero-based index) from a given vector.
Definition at line 93 of file math/utils.h.
Referenced by weightedHistogram().
double mrpt::math::mean | ( | const std::vector< T > & | v | ) | [inline] |
Computes the mean value of a vector.
Definition at line 178 of file math/utils.h.
Referenced by mrpt::random::matrixRandomNormal(), and mrpt::random::vectorRandomNormal().
void mrpt::math::meanAndStd | ( | const std::vector< T > & | v, | |
double & | out_mean, | |||
double & | out_std, | |||
bool | unbiased = true | |||
) | [inline] |
Computes the standard deviation of a vector.
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. |
Definition at line 319 of file math/utils.h.
References mrpt::utils::square().
bool MRPTDLLIMPEXP 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:
T mrpt::math::minimum | ( | const std::vector< T > & | v, | |
unsigned int * | minIndex = NULL | |||
) | [inline] |
Finds the maximum value (and the corresponding zero-based index) from a given vector.
Definition at line 138 of file math/utils.h.
Referenced by weightedHistogram().
void mrpt::math::minimum_maximum | ( | const std::vector< T > & | v, | |
T & | out_min, | |||
T & | out_max, | |||
unsigned int * | minIndex = NULL , |
|||
unsigned int * | maxIndex = NULL | |||
) | [inline] |
double MRPTDLLIMPEXP 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.
double MRPTDLLIMPEXP 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.
T mrpt::math::norm | ( | const std::vector< T > & | v | ) | [inline] |
Compute the 2-norm of the vector (the Euclidean distance to the origin).
Definition at line 125 of file math/utils.h.
References mrpt::utils::square().
T mrpt::math::norm_inf | ( | const std::vector< T > & | v, | |
unsigned int * | maxIndex = NULL | |||
) | [inline] |
Compute the norm-infinite of a vector ($f[ ||{v}||_ $f]), ie the maximum absolute value of the elements.
Definition at line 103 of file math/utils.h.
double MRPTDLLIMPEXP 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
void mrpt::math::normalize | ( | const std::vector< T > & | v, | |
std::vector< T > & | out_v | |||
) | [inline] |
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 240 of file math/utils.h.
References mrpt::utils::square().
T mrpt::math::normalPDF | ( | const CMatrixTemplateNumeric< T > & | x, | |
const CMatrixTemplateNumeric< T > & | mu, | |||
const CMatrixTemplateNumeric< T > & | cov | |||
) | [inline] |
Evaluates the multivariate normal (Gaussian) distribution at a given point "x" ("x" and "mu" can be 1xN or Nx1 matrixes).
Definition at line 49 of file distributions.h.
References mrpt::math::CMatrixTemplateNumeric< T >::det(), mrpt::math::CMatrixTemplate< T >::getRowCount(), mrpt::math::CMatrixTemplateNumeric< T >::inv(), M_2PI, MRPT_TRY_END, and MRPT_TRY_START.
double MRPTDLLIMPEXP mrpt::math::normalPDF | ( | double | x, | |
double | mu, | |||
double | std | |||
) |
Evaluates the univariate normal (Gaussian) distribution at a given point "x".
double MRPTDLLIMPEXP 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.
std::vector<T> mrpt::math::ones | ( | size_t | count | ) | [inline] |
CMatrixTemplateNumeric<T> mrpt::math::operator! | ( | const CMatrixTemplateNumeric< T > & | m | ) | [inline] |
Unary inversion operator.
Definition at line 784 of file CMatrixTemplateNumeric.h.
References mrpt::math::CMatrixTemplateNumeric< T >::inv().
bool mrpt::math::operator!= | ( | const CMatrixTemplateNumeric< T > & | m1, | |
const CMatrixTemplateNumeric< T > & | m2 | |||
) | [inline] |
std::vector<T> mrpt::math::operator* | ( | const std::vector< T > & | a, | |
const std::vector< T > & | b | |||
) | [inline] |
A template function for scalar product (element by element, like .
* in MATLAB) of std::vector's having the same number of elements.
Definition at line 166 of file vector_ops.h.
References ASSERT_.
Referenced by mrpt::slam::CRawlogXXL::CRawlogXXL::const_iterator::getType(), and mrpt::slam::CRawlogXXL::CRawlogXXL::iterator::getType().
std::vector<T> mrpt::math::operator* | ( | const std::vector< T > & | a, | |
T | b | |||
) | [inline] |
A template function for the operator * between a scalar and a std::vector.
Definition at line 99 of file vector_ops.h.
CMatrixTemplateNumeric<T> mrpt::math::operator* | ( | const CMatrixTemplateNumeric< T > & | m1, | |
const CVectorTemplate< T > & | m2 | |||
) | [inline] |
Binary matrix multiplication operator, with one matrix being NxM and the second being a column matrix Mx1.
Definition at line 724 of file CMatrixTemplateNumeric.h.
References mrpt::math::CMatrixTemplate< T >::getRowCount().
CMatrixTemplateNumeric<T> mrpt::math::operator* | ( | const CMatrixTemplateNumeric< T > & | m1, | |
const CMatrixTemplateNumeric< T > & | m2 | |||
) | [inline] |
CMatrixTemplateNumeric<T> mrpt::math::operator* | ( | const T & | no, | |
const CMatrixTemplateNumeric< T > & | m | |||
) | [inline] |
CMatrixTemplateNumeric<T> mrpt::math::operator* | ( | const CMatrixTemplateNumeric< T > & | m, | |
const T & | no | |||
) | [inline] |
void mrpt::math::operator*= | ( | std::vector< T > & | a, | |
T | b | |||
) | [inline] |
A template for the operator *= applied to a std::vector and a scalar.
Definition at line 264 of file vector_ops.h.
void mrpt::math::operator*= | ( | std::vector< T > & | a, | |
const std::vector< T > & | b | |||
) | [inline] |
A template for the operator *= applied to std::vector's having the same number of elements.
Definition at line 216 of file vector_ops.h.
References ASSERT_.
std::vector<T> mrpt::math::operator+ | ( | const std::vector< T > & | a, | |
const std::vector< T > & | b | |||
) | [inline] |
A template function for adding std::vector's having the same number of elements.
Definition at line 132 of file vector_ops.h.
References ASSERT_.
std::vector<T> mrpt::math::operator+ | ( | const std::vector< T > & | a, | |
T | b | |||
) | [inline] |
A template function for the operator + between a scalar and a std::vector.
Definition at line 69 of file vector_ops.h.
CMatrixTemplateNumeric<T> mrpt::math::operator+ | ( | const CMatrixTemplateNumeric< T > & | m1, | |
const CMatrixTemplateNumeric< T > & | m2 | |||
) | [inline] |
void mrpt::math::operator+= | ( | std::vector< T > & | a, | |
T | b | |||
) | [inline] |
A template for the operator += applied to a std::vector and a scalar.
Definition at line 248 of file vector_ops.h.
void mrpt::math::operator+= | ( | std::vector< T > & | a, | |
const std::vector< T > & | b | |||
) | [inline] |
A template for the operator += applied to std::vector's having the same number of elements.
Definition at line 188 of file vector_ops.h.
References ASSERT_.
std::vector<T> mrpt::math::operator- | ( | const std::vector< T > & | a, | |
const std::vector< T > & | b | |||
) | [inline] |
A template function for substracting std::vector's having the same number of elements.
Definition at line 149 of file vector_ops.h.
References ASSERT_.
std::vector<T> mrpt::math::operator- | ( | const std::vector< T > & | a, | |
T | b | |||
) | [inline] |
A template function for the operator - between a scalar and a std::vector.
Definition at line 84 of file vector_ops.h.
CMatrixTemplateNumeric<T> mrpt::math::operator- | ( | const CMatrixTemplateNumeric< T > & | m1, | |
const CMatrixTemplateNumeric< T > & | m2 | |||
) | [inline] |
void mrpt::math::operator-= | ( | std::vector< T > & | a, | |
T | b | |||
) | [inline] |
A template for the operator -= applied to a std::vector and a scalar.
Definition at line 256 of file vector_ops.h.
void mrpt::math::operator-= | ( | std::vector< T > & | a, | |
const std::vector< T > & | b | |||
) | [inline] |
A template for the operator -= applied to std::vector's having the same number of elements.
Definition at line 202 of file vector_ops.h.
References ASSERT_.
std::vector<T> mrpt::math::operator/ | ( | const std::vector< T > & | a, | |
const std::vector< T > & | b | |||
) | [inline] |
A template function for scalar division (element by element, like .
/ in MATLAB) of std::vector's having the same number of elements.
Definition at line 177 of file vector_ops.h.
References ASSERT_.
std::vector<T> mrpt::math::operator/ | ( | const std::vector< T > & | a, | |
T | b | |||
) | [inline] |
A template function for dividing a std::vector by a scalar number.
Definition at line 114 of file vector_ops.h.
References THROW_EXCEPTION.
CMatrixTemplateNumeric<T> mrpt::math::operator/ | ( | const CMatrixTemplateNumeric< T > & | m1, | |
const CMatrixTemplateNumeric< T > & | m2 | |||
) | [inline] |
CMatrixTemplateNumeric<T> mrpt::math::operator/ | ( | const T & | no, | |
const CMatrixTemplateNumeric< T > & | m | |||
) | [inline] |
CMatrixTemplateNumeric<T> mrpt::math::operator/ | ( | const CMatrixTemplateNumeric< T > & | m, | |
const T & | no | |||
) | [inline] |
void mrpt::math::operator/= | ( | std::vector< T > & | a, | |
T | b | |||
) | [inline] |
A template for the operator /= applied to a std::vector and a scalar.
Definition at line 272 of file vector_ops.h.
References THROW_EXCEPTION.
void mrpt::math::operator/= | ( | std::vector< T > & | a, | |
const std::vector< T > & | b | |||
) | [inline] |
A template for the operator /= applied to std::vector's having the same number of elements.
Definition at line 230 of file vector_ops.h.
References ASSERT_, and THROW_EXCEPTION.
std::ostream& mrpt::math::operator<< | ( | std::ostream & | out, | |
std::vector< T > * | d | |||
) | [inline] |
A template function for printing out the contents of a std::vector variable.
Definition at line 57 of file vector_ops.h.
std::ostream& mrpt::math::operator<< | ( | std::ostream & | out, | |
const std::vector< T > & | d | |||
) | [inline] |
A template function for printing out the contents of a std::vector variable.
Definition at line 46 of file vector_ops.h.
std::ostream& mrpt::math::operator<< | ( | std::ostream & | ostrm, | |
const CMatrixTemplate< T > & | m | |||
) | [inline] |
Textual output stream function.
Use only for text output, for example: "std::cout << mat;"
Definition at line 823 of file CMatrixTemplate.h.
bool mrpt::math::operator== | ( | const CMatrixTemplateNumeric< T > & | m1, | |
const CMatrixTemplateNumeric< T > & | m2 | |||
) | [inline] |
Logical equal-to operator.
Definition at line 650 of file CMatrixTemplateNumeric.h.
References mrpt::math::CMatrixTemplate< T >::getColCount(), and mrpt::math::CMatrixTemplate< T >::getRowCount().
CMatrixTemplateNumeric<T> mrpt::math::operator^ | ( | const CMatrixTemplateNumeric< T > & | m, | |
const unsigned int & | pow | |||
) | [inline] |
CMatrixTemplateNumeric<T> mrpt::math::operator~ | ( | const CMatrixTemplateNumeric< T > & | m | ) | [inline] |
unary transpose operator
Definition at line 768 of file CMatrixTemplateNumeric.h.
References mrpt::math::CMatrixTemplate< T >::getColCount(), and mrpt::math::CMatrixTemplate< T >::getRowCount().
bool MRPTDLLIMPEXP 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.
void MRPTDLLIMPEXP mrpt::math::qr_decomposition | ( | CMatrixTemplateNumeric< T > & | A, | |
CMatrixTemplateNumeric< T > & | R, | |||
CMatrixTemplateNumeric< T > & | Q, | |||
CVectorTemplate< T > & | c, | |||
int & | sing | |||
) | [inline] |
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)
bool MRPTDLLIMPEXP 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.
T mrpt::math::round2up | ( | T | val | ) | [inline] |
Round up to the nearest power of two of a given number.
Definition at line 452 of file math/utils.h.
References THROW_EXCEPTION.
T mrpt::math::round_10power | ( | T | val, | |
int | power10 | |||
) | [inline] |
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 468 of file math/utils.h.
References mrpt::utils::round_long().
bool MRPTDLLIMPEXP 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.
bool MRPTDLLIMPEXP 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.
size_t mrpt::math::size | ( | const CMatrixTemplate< T > & | m, | |
int | dim | |||
) | [inline] |
Returns the size of the matrix in the i'th dimension: 1=rows, 2=columns (MATLAB-compatible function).
Definition at line 840 of file CMatrixTemplate.h.
References mrpt::math::CMatrixTemplate< T >::getColCount(), mrpt::math::CMatrixTemplate< T >::getRowCount(), and THROW_EXCEPTION_CUSTOM_MSG1.
Referenced by mrpt::math::CVectorTemplate< KFTYPE >::abs(), mrpt::math::CVectorTemplate< KFTYPE >::deconcatenate(), mrpt::math::CVectorTemplate< KFTYPE >::extract_vector(), mrpt::math::CVectorTemplate< KFTYPE >::find_max(), mrpt::math::CVectorTemplate< KFTYPE >::find_min(), mrpt::math::CVectorTemplate< KFTYPE >::find_min_max(), mrpt::vision::CMatchedFeatureList::get_type(), mrpt::vision::CFeatureList::get_type(), mrpt::math::CVectorTemplate< KFTYPE >::insert_vector(), mrpt::math::CVectorTemplate< KFTYPE >::likeMatrix(), mrpt::math::CVectorTemplate< KFTYPE >::mean(), mrpt::math::CVectorTemplate< KFTYPE >::operator*(), mrpt::math::CVectorTemplate< KFTYPE >::operator+(), mrpt::math::CVectorTemplate< KFTYPE >::operator+=(), mrpt::math::CVectorTemplate< KFTYPE >::operator-(), mrpt::math::CVectorTemplate< KFTYPE >::operator/(), mrpt::math::CVectorTemplate< KFTYPE >::operator~(), mrpt::math::CVectorTemplate< KFTYPE >::saveToTextFile(), mrpt::utils::multimap_serializable< mrpt::system::TTimeStamp, float >::write(), mrpt::utils::map_serializable< mrpt::system::TTimeStamp, CPose3D >::write(), mrpt::utils::list_searchable_serializable< T >::write(), mrpt::utils::deque_serializable< mrpt::slam::CMultiMetricMap >::write(), and mrpt::utils::vector_serializable< CPoint3D >::write().
double MRPTDLLIMPEXP mrpt::math::spline | ( | const double | t, | |
const std::vector< double > & | x, | |||
const std::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).
double mrpt::math::stddev | ( | const std::vector< T > & | v, | |
bool | unbiased = true | |||
) | [inline] |
Computes the standard deviation of a vector.
v | The set of data | |
unbiased | If set to true or false the std is normalized by "N-1" or "N", respectively. |
Definition at line 292 of file math/utils.h.
References mrpt::utils::square().
T mrpt::math::sum | ( | const std::vector< T > & | v | ) | [inline] |
Computes the sum of all the elements of a vector.
Definition at line 189 of file math/utils.h.
Referenced by chol(), and mrpt::math::CVectorTemplate< KFTYPE >::mean().
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.
void MRPTDLLIMPEXP mrpt::math::UpdateCholesky | ( | CMatrixTemplateNumeric< T > & | chol, | |
CVectorTemplate< T > & | r1Modification | |||
) | [inline] |
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.
void mrpt::math::weightedHistogram | ( | const std::vector< T > & | values, | |
const std::vector< T > & | weights, | |||
float | binWidth, | |||
std::vector< float > & | out_binCenters, | |||
std::vector< float > & | out_binValues | |||
) | [inline] |
Computes the weighted histogram for a vector of values and their corresponding weights.
values | [IN] The N values | |
weights | [IN] The weights for the corresponding N values | |
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. |
Definition at line 353 of file math/utils.h.
References ASSERT_, maximum(), minimum(), MRPT_TRY_END, MRPT_TRY_START, and mrpt::utils::round().
T mrpt::math::wrapTo2Pi | ( | T | a | ) | [inline] |
Modifies the given angle to translate it into the [0,2pi[ range.
Definition at line 423 of file math/utils.h.
References wrapTo2PiInPlace().
Referenced by wrapToPi().
void mrpt::math::wrapTo2PiInPlace | ( | T & | a | ) | [inline] |
Modifies the given angle to translate it into the [0,2pi[ range.
Definition at line 411 of file math/utils.h.
References M_2PI.
Referenced by wrapTo2Pi().
T mrpt::math::wrapToPi | ( | T | a | ) | [inline] |
Modifies the given angle to translate it into the ]-pi,pi] range.
Definition at line 434 of file math/utils.h.
References M_PI, and wrapTo2Pi().
Referenced by wrapToPiInPlace().
void mrpt::math::wrapToPiInPlace | ( | T & | a | ) | [inline] |
Modifies the given angle to translate it into the ]-pi,pi] range.
Definition at line 444 of file math/utils.h.
References wrapToPi().
std::vector<T> mrpt::math::zeros | ( | size_t | count | ) | [inline] |
Page generated by Doxygen 1.5.8 for MRPT 0.6.5 SVN: at Thu Feb 26 02:18:33 EST 2009 |