CbmRoot
Loading...
Searching...
No Matches
cbm::algo::kf::math Namespace Reference

Functions

constexpr size_t NofPolCoefficients (size_t N, size_t M)
 Number of coefficients in a polynomial.
 
template<size_t N, typename T >
constexpr T Horner (const T *c, const T &x)
 Horner's scheme for a 1D-polynomial estimation.
 
template<size_t N, typename T , typename... Args>
constexpr T Horner (const T *c, const T &x1, Args... xI)
 Horner's scheme for a multidvariable polynomial estimation.
 

Function Documentation

◆ Horner() [1/2]

template<size_t N, typename T >
T cbm::algo::kf::math::Horner ( const T * c,
const T & x )
constexpr

Horner's scheme for a 1D-polynomial estimation.

Template Parameters
TUnderlying data type
NDegree of the polynomial
Parameters
cPointer to the first element of the polynomial coefficients
xVariable, for which the polynomial is to be estimated

The polynomial coefficients are indexed as follows:

P<N>(x) = x * (... * (x * (x * c[0] + c[1]) + c[2]) + ...) + c[N] = c[0] * x^N + c[1] * x^(N-1) + ... + c[N - 1] * x + c[N]

Definition at line 35 of file KfMath.h.

References Horner(), and x.

Referenced by Horner(), and Horner().

◆ Horner() [2/2]

template<size_t N, typename T , typename... Args>
T cbm::algo::kf::math::Horner ( const T * c,
const T & x1,
Args... xI )
constexpr

Horner's scheme for a multidvariable polynomial estimation.

Template Parameters
TUnderlying data type
NDegree of the polynomial
Parameters
cPointer to the first element of the polynomial coefficients
x1First variable of the polynomial
xIOther variables: x2, ..., xM

Example of the polynomial coefficient indexing for N = 4, M = 3:

P(x,y,z) = c[0] * x4 +

c[1] * x3y + c[2] * x3z + c[3] * x3 +

c[4] * x2y2 + c[5] * x2yz + c[6] * x2y + c[7] * x2z2 + c[8] * x2z + c[9] * x2 +

c[10] * xy3 + c[11] * xy2z + c[12] * xy2 + c[13] * xyz2 + c[14] * xyz + c[15] * xy + c[16] * xz3 + c[17] * xz2 + c[18] * xz + c[19] * x +

c[20] * y4 + c[21] * y3z + c[22] * y3 + c[23] * y2z2 + c[24] * y2z + c[25] * y2 + c[26] * yz3 + c[27] * yz2 + c[28] * yz + c[29] * y + c[30] * z4 + c[31] * z3 + c[32] * z2 + c[33] * z + c[34];

Definition at line 75 of file KfMath.h.

References Horner(), and NofPolCoefficients().

◆ NofPolCoefficients()

size_t cbm::algo::kf::math::NofPolCoefficients ( size_t N,
size_t M )
constexpr

Number of coefficients in a polynomial.

Parameters
NDegree of the polynomial
MNumber of dimensions

Definition at line 19 of file KfMath.h.

References NofPolCoefficients().

Referenced by Horner(), and NofPolCoefficients().