Xenomai  3.0.8
Collaboration diagram for Math API:

Functions

int a4l_math_polyfit (unsigned r_dim, double *r, double orig, const unsigned dim, double *x, double *y)
 Calculate the polynomial fit. More...
 
void a4l_math_mean (double *pmean, double *val, unsigned nr)
 Calculate the aritmetic mean of an array of values. More...
 
void a4l_math_stddev (double *pstddev, double mean, double *val, unsigned nr)
 Calculate the standard deviation of an array of values. More...
 
void a4l_math_stddev_of_mean (double *pstddevm, double mean, double *val, unsigned nr)
 Calculate the standard deviation of the mean. More...
 

Detailed Description

Function Documentation

◆ a4l_math_mean()

void a4l_math_mean ( double *  pmean,
double *  val,
unsigned  nr 
)

Calculate the aritmetic mean of an array of values.

Parameters
[out]pmeanPointer to the resulting value
[in]valArray of input values
[in]nrNumber of array elements

◆ a4l_math_polyfit()

int a4l_math_polyfit ( unsigned  r_dim,
double *  r,
double  orig,
const unsigned  dim,
double *  x,
double *  y 
)

Calculate the polynomial fit.

Parameters
[in]r_dimNumber of elements of the resulting polynomial
[out]rPolynomial
[in]orig
[in]dimNumber of elements in the polynomials
[in]xPolynomial
[in]yPolynomial

Operation:

We are looking for Res such that A.Res = Y, with A the Vandermonde matrix made from the X vector.

Using the least square method, this means finding Res such that: A^t.A.Res = A^tY

If we write A = Q.R with Q^t.Q = 1, and R non singular, this can be reduced to: R.Res = Q^t.Y

mat_qr() gives us R and Q^t.Y from A and Y

We can then obtain Res by back substitution using mat_upper_triangular_backsub() with R upper triangular.

◆ a4l_math_stddev()

void a4l_math_stddev ( double *  pstddev,
double  mean,
double *  val,
unsigned  nr 
)

Calculate the standard deviation of an array of values.

Parameters
[out]pstddevPointer to the resulting value
[in]meanMean value
[in]valArray of input values
[in]nrNumber of array elements

Referenced by a4l_math_stddev_of_mean().

◆ a4l_math_stddev_of_mean()

void a4l_math_stddev_of_mean ( double *  pstddevm,
double  mean,
double *  val,
unsigned  nr 
)

Calculate the standard deviation of the mean.

Parameters
[out]pstddevmPointer to the resulting value
[in]meanMean value
[in]valArray of input values
[in]nrNumber of array elements

References a4l_math_stddev().