Xenomai  3.0.8
Math API
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...

## ◆ a4l_math_mean()

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

Calculate the aritmetic mean of an array of values.

Parameters
 [out] pmean Pointer to the resulting value [in] val Array of input values [in] nr Number 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_dim Number of elements of the resulting polynomial [out] r Polynomial [in] orig [in] dim Number of elements in the polynomials [in] x Polynomial [in] y Polynomial

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] pstddev Pointer to the resulting value [in] mean Mean value [in] val Array of input values [in] nr Number 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] pstddevm Pointer to the resulting value [in] mean Mean value [in] val Array of input values [in] nr Number of array elements

References a4l_math_stddev().