UtiLite  0.3.1
A lite utilities library
Enumerations | Functions
include/utilite/UMath.h File Reference

Basic mathematics functions. More...

#include "utilite/UtiLiteExp.h"
#include <cmath>
#include <list>
#include <vector>

Go to the source code of this file.

Enumerations

enum  UXMatchMethod

Functions

template<class T >
uMax (const T *v, unsigned int size, unsigned int &index)
template<class T >
uMax (const std::vector< T > &v, unsigned int &index)
template<class T >
uMax (const T *v, unsigned int size)
template<class T >
uMax (const std::vector< T > &v)
template<class T >
uMin (const T *v, unsigned int size, unsigned int &index)
template<class T >
uMin (const std::vector< T > &v, unsigned int &index)
template<class T >
uMin (const T *v, unsigned int size)
template<class T >
uMin (const std::vector< T > &v)
template<class T >
void uMinMax (const T *v, unsigned int size, T &min, T &max, unsigned int &indexMin, unsigned int &indexMax)
template<class T >
void uMinMax (const std::vector< T > &v, T &min, T &max, unsigned int &indexMin, unsigned int &indexMax)
template<class T >
void uMinMax (const T *v, unsigned int size, T &min, T &max)
template<class T >
void uMinMax (const std::vector< T > &v, T &min, T &max)
template<class T >
int uSign (const T &v)
template<class T >
uSum (const std::list< T > &list)
template<class T >
uSum (const T *v, unsigned int size)
template<class T >
uSum (const std::vector< T > &v)
template<class T >
uSumSquared (const T *v, unsigned int size, T subtract=T())
template<class T >
uSumSquared (const std::vector< T > &v, T subtract=T())
template<class T >
uMean (const T *v, unsigned int size)
template<class T >
uMean (const std::list< T > &list)
template<class T >
uMean (const std::vector< T > &v)
template<class T >
uMeanSquaredError (const T *x, unsigned int sizeX, const T *y, unsigned int sizeY)
template<class T >
uMeanSquaredError (const std::vector< T > &x, const std::vector< T > &y)
template<class T >
uStdDev (const T *v, unsigned int size, T meanV)
template<class T >
uStdDev (const std::list< T > &list, const T &m)
template<class T >
uStdDev (const T *v, unsigned int size)
template<class T >
uStdDev (const std::vector< T > &v, const T &m)
template<class T >
uNorm (const std::vector< T > &v)
template<class T >
std::vector< T > uNormalize (const std::vector< T > &v)
template<class T >
std::list< unsigned int > uLocalMaxima (const T *v, unsigned int size)
template<class T >
std::list< unsigned int > uLocalMaxima (const std::vector< T > &v)
template<class T >
std::vector< T > uXMatch (const T *vA, const T *vB, unsigned int sizeA, unsigned int sizeB, UXMatchMethod method)
template<class T >
std::vector< T > uXMatch (const std::vector< T > &vA, const std::vector< T > &vB, UXMatchMethod method)
template<class T >
uXMatch (const T *vA, const T *vB, unsigned int sizeA, unsigned int sizeB, unsigned int index, UXMatchMethod method)
template<class T >
uXMatch (const std::vector< T > &vA, const std::vector< T > &vB, unsigned int index, UXMatchMethod method)
std::vector< float > uHamming (unsigned int L)

Detailed Description

Basic mathematics functions.


Enumeration Type Documentation

Enum of cross matching methods (cross-correlation, cross-covariance) : UXCorrRaw, UXCorrBiased, UXCorrUnbiased, UXCorrCoeff, UXCovRaw, UXCovBiased, UXCovUnbiased, UXCovCoeff.


Function Documentation

std::vector<float> uHamming ( unsigned int  L) [inline]

Return Hamming window of length L.

Parameters:
Lthe window length
Returns:
the Hamming window (values are between 0 and 1)
template<class T >
std::list<unsigned int> uLocalMaxima ( const T *  v,
unsigned int  size 
) [inline]

Find all local maxima.

template<class T >
std::list<unsigned int> uLocalMaxima ( const std::vector< T > &  v) [inline]

Find all local maxima.

template<class T >
T uMax ( const T *  v,
unsigned int  size,
unsigned int &  index 
) [inline]

Get the maximum of a vector.

Parameters:
vthe array
sizethe size of the array
indexthe index of the maximum value in the vector.
Returns:
the maximum value of the array
template<class T >
T uMax ( const std::vector< T > &  v,
unsigned int &  index 
) [inline]

Get the maximum of a vector.

Parameters:
vthe array
indexthe index of the maximum value in the vector.
Returns:
the maximum value of the array
template<class T >
T uMax ( const T *  v,
unsigned int  size 
) [inline]

Get the maximum of a vector.

Parameters:
vthe array
sizethe size of the array
Returns:
the maximum value of the array
template<class T >
T uMax ( const std::vector< T > &  v) [inline]

Get the maximum of a vector.

Parameters:
vthe array
Returns:
the maximum value of the array
template<class T >
T uMean ( const T *  v,
unsigned int  size 
) [inline]

Compute the mean of an array.

Parameters:
vthe array
sizethe size of the array
Returns:
the mean
template<class T >
T uMean ( const std::list< T > &  list) [inline]

Get the mean of a list. Provided for convenience.

Parameters:
listthe list
Returns:
the mean
template<class T >
T uMean ( const std::vector< T > &  v) [inline]

Get the mean of a vector. Provided for convenience.

Parameters:
vthe vector
Returns:
the mean
template<class T >
T uMeanSquaredError ( const T *  x,
unsigned int  sizeX,
const T *  y,
unsigned int  sizeY 
) [inline]

Compute mean squared error between two arrays: mean((x-y).^2).

Parameters:
xthe first array
sizeXthe size of the array x
ythe second array
sizeYthe size of the array y (must be same size as x)
Returns:
the mean squared error (return -1 if error cannot be computed)
template<class T >
T uMeanSquaredError ( const std::vector< T > &  x,
const std::vector< T > &  y 
) [inline]

Compute mean squared error between two arrays: mean((x-y).^2).

Parameters:
xthe first array
ythe second array (must be same size as x)
Returns:
the mean squared error (return -1 if error cannot be computed)
template<class T >
T uMin ( const T *  v,
unsigned int  size,
unsigned int &  index 
) [inline]

Get the minimum of a vector.

Parameters:
vthe array
sizethe size of the array
indexthe index of the minimum value in the vector.
Returns:
the minimum value of the array
template<class T >
T uMin ( const std::vector< T > &  v,
unsigned int &  index 
) [inline]

Get the minimum of a vector.

Parameters:
vthe array
indexthe index of the minimum value in the vector.
Returns:
the minimum value of the array
template<class T >
T uMin ( const T *  v,
unsigned int  size 
) [inline]

Get the minimum of a vector.

Parameters:
vthe array
sizethe size of the array
Returns:
the minimum value of the array
template<class T >
T uMin ( const std::vector< T > &  v) [inline]

Get the minimum of a vector.

Parameters:
vthe array
Returns:
the minimum value of the array
template<class T >
void uMinMax ( const T *  v,
unsigned int  size,
T &  min,
T &  max,
unsigned int &  indexMin,
unsigned int &  indexMax 
) [inline]

Get the minimum and maximum of a vector.

Parameters:
vthe array
sizethe size of the array
minreference to output minimum
maxreference to output maximum
minreference to output minimum index
maxreference to output maximum index
template<class T >
void uMinMax ( const std::vector< T > &  v,
T &  min,
T &  max,
unsigned int &  indexMin,
unsigned int &  indexMax 
) [inline]

Get the minimum and maximum of a vector.

Parameters:
vthe array
minreference to output minimum
maxreference to output maximum
minreference to output minimum index
maxreference to output maximum index
template<class T >
void uMinMax ( const T *  v,
unsigned int  size,
T &  min,
T &  max 
) [inline]

Get the minimum and maximum of a vector.

Parameters:
vthe array
sizethe size of the array
minreference to output minimum
maxreference to output maximum
template<class T >
void uMinMax ( const std::vector< T > &  v,
T &  min,
T &  max 
) [inline]

Get the minimum and maximum of a vector.

Parameters:
vthe array
minreference to output minimum
maxreference to output maximum
template<class T >
T uNorm ( const std::vector< T > &  v) [inline]

Get the norm of the vector : return sqrt(x1*x1 + x2*x2 + x3*x3 + ...)

Returns:
the norm of the vector
template<class T >
std::vector<T> uNormalize ( const std::vector< T > &  v) [inline]

Normalize the vector : [x1 x2 x3 ...] ./ uNorm([x1 x2 x3 ...])

Returns:
the vector normalized
template<class T >
int uSign ( const T &  v) [inline]

Get the sign of value.

Parameters:
vthe value
Returns:
-1 if v<0, otherwise 1
template<class T >
T uStdDev ( const T *  v,
unsigned int  size,
meanV 
) [inline]

Compute the standard deviation of an array.

Parameters:
vthe array
sizethe size of the array
meanVthe mean of the array
Returns:
the std dev
See also:
mean()
template<class T >
T uStdDev ( const std::list< T > &  list,
const T &  m 
) [inline]

Get the standard deviation of a list. Provided for convenience.

Parameters:
listthe list
mthe mean of the list
Returns:
the std dev
See also:
mean()
template<class T >
T uStdDev ( const T *  v,
unsigned int  size 
) [inline]

Compute the standard deviation of an array.

Parameters:
vthe array
sizethe size of the array
Returns:
the std dev
template<class T >
T uStdDev ( const std::vector< T > &  v,
const T &  m 
) [inline]

Get the standard deviation of a vector. Provided for convenience.

Parameters:
vthe vector
mthe mean of the vector
Returns:
the std dev
See also:
mean()
template<class T >
T uSum ( const std::list< T > &  list) [inline]

Get the sum of all values contained in a list. Provided for convenience.

Parameters:
listthe list
Returns:
the sum of values of the list
template<class T >
T uSum ( const T *  v,
unsigned int  size 
) [inline]

Get the sum of all values contained in an array: sum(x).

Parameters:
vthe array
sizethe size of the array
Returns:
the sum of values of the array
template<class T >
T uSum ( const std::vector< T > &  v) [inline]

Get the sum of all values contained in a vector. Provided for convenience.

Parameters:
vthe vector
Returns:
the sum of values of the vector
template<class T >
T uSumSquared ( const T *  v,
unsigned int  size,
subtract = T() 
) [inline]

Get the sum of all squared values contained in an array: sum(x.^2).

Parameters:
vthe array
sizethe size of the array
subtractan optional value to remove to v before squaring v: sum((x-sub).^2)
Returns:
the sum of values of the array
template<class T >
T uSumSquared ( const std::vector< T > &  v,
subtract = T() 
) [inline]

Get the sum of all squared values contained in an array: sum(x.^2).

Parameters:
vthe array
subtractan optional value to remove to v before squaring v: sum((x-sub).^2)
Returns:
the sum of values of the array
template<class T >
std::vector<T> uXMatch ( const T *  vA,
const T *  vB,
unsigned int  sizeA,
unsigned int  sizeB,
UXMatchMethod  method 
) [inline]

Do a full cross-correlation or cross-covariance between 2 arrays.

Parameters:
vAthe first array
vBthe second array
sizeAthe size of the first array
sizeBthe size of the second array
methodsee UXMatchMethod
Returns:
the resulting correlation/covariance vector of size = sizeA + sizeB - 1
template<class T >
std::vector<T> uXMatch ( const std::vector< T > &  vA,
const std::vector< T > &  vB,
UXMatchMethod  method 
) [inline]

Do a full cross-correlation or cross-covariance between 2 arrays.

Parameters:
vAthe first array
vBthe second array
methodsee UXMatchMethod
Returns:
the resulting correlation/covariance vector of size = sizeA + sizeB - 1
template<class T >
T uXMatch ( const T *  vA,
const T *  vB,
unsigned int  sizeA,
unsigned int  sizeB,
unsigned int  index,
UXMatchMethod  method 
) [inline]

Do a cross correlation between 2 arrays at a specified index.

Parameters:
vAthe first array
vBthe second array
sizeAthe size of the first array
sizeBthe size of the second array
indexthe index to correlate
methodsee UXMatchMethod
Returns:
the resulting correlation value
template<class T >
T uXMatch ( const std::vector< T > &  vA,
const std::vector< T > &  vB,
unsigned int  index,
UXMatchMethod  method 
) [inline]

Do a cross correlation between 2 arrays at a specified index.

Parameters:
vAthe first array
vBthe second array
sizeAthe size of the first array
sizeBthe size of the second array
indexthe index to correlate
methodsee UXMatchMethod
Returns:
the resulting correlation value
 All Classes Files Functions Variables Enumerations Friends Defines