VCLib Documentation  6.12.2

1D->1D Polynomial

1D->1D Polynomial

Data Structures

struct  VCPolynom1D1D
 1D->1D Polynomial Representation More...
 

Functions

I32 vc_poly1d1d_allocate (VCPolynom1D1D *poly, I32 order)
 Allocates memory for a VCPolynom1D1D structure. More...
 
void vc_poly1d1d_free (VCPolynom1D1D *poly)
 Frees a previously allocated VCPolynom1D1D structure. More...
 
I32 vc_poly1d1d_map (F64 xIn, F64 *yOut, VCPolynom1D1D *poly)
 Calculates a result using a VCPolynom1D1D structure. More...
 
I32 vc_poly1d1d_copy (VCPolynom1D1D *polyFrom, VCPolynom1D1D *polyTo)
 Copies a VCPolynom1D1D structure. More...
 
void vc_poly1d1d_print (VCPolynom1D1D *poly, I32 indentation)
 Prints out a VCPolynom1D1D struct. More...
 
I32 vc_poly1d1d_derive_and_allocate (VCPolynom1D1D *polyDerivative, VCPolynom1D1D *polyFrom)
 Derives and allocates from a given polynomial. More...
 
I32 vc_poly1d1d_zero_crossing (VCPolynom1D1D *poly, F64 *xZero, F64 xStart, F64 maxDev, I32 maxSteps)
 Get a Zero of a Polynomial by Newton's Method. More...
 
I32 vc_poly1d1d_line_intersection (point *pt, F64 xStart, VCPolynom1D1D *poly, vcline *l, F64 maxDev, I32 maxSteps)
 Get an Intersection Point of Polynomial with a Line by Newton's Method. More...
 
I32 vc_poly1d1d_load_and_allocate_from_ini (VCPolynom1D1D *poly, char *filename, I8 tiCompatibleIff1)
 Reads and allocates a VCPolynom1D1D struct from an INI file. More...
 
I32 vc_poly1d1d_store_as_ini (char *filename, VCPolynom1D1D *poly, I8 tiCompatibleIff1)
 Stores VCPolynom1D1D struct values as INI file. More...
 

Detailed Description


Data Structure Documentation

◆ VCPolynom1D1D

struct VCPolynom1D1D

This struct represents a polynomial of order N defined as follows:

\begin{eqnarray*}\begin{array}{rccccccc} Y(x) = & a_{0} x^{0} &+& a_{1} x^{1} &+& \dots &+& a_{N} x^{N} \end{array} \end{eqnarray*}

Due to numerical stability at the polynomial estimation, there may be transforms which are additionally done instead of inherently at the polynomial itself:

If the value of transformInIff1 is 1, the polynomials input value x is calculated from given xInput as pre-transform by the following formula:

\begin{eqnarray*}\begin{array}{rl} x &= (xInput - offsIn) / scaleIn \\ \end{array}\end{eqnarray*}

Likewise if the value of transformOutIff1 is 1, the polynomials output value Y is post-transformed to the result YOutput by the following formula:

\begin{eqnarray*}\begin{array}{rl} YOutput &= (Y * scaleOut) + offsOut \\ \end{array}\end{eqnarray*}

Data Fields
I32 order

Maximum order in polynomial for calculating Y(x).

F64 * coeff

Coefficients of polynomial for calculating Y(x).

I32 transformInIff1

If 1, prior to application of the input value to the polynomial it is transformed: in = (in - offsIn) / scaleIn.

F64 offsIn

Offset for Input Value.

F64 scaleIn

Scale Factor for Input Value.

I32 transformOutIff1

If 1, after mapping through the polynomial the output value is transformed: out = (out * scaleOut) + offsOut.

F64 offsOut

Offset for Output Value.

F64 scaleOut

Scale Factor for Output Value.

Function Documentation

◆ vc_poly1d1d_allocate()

I32 vc_poly1d1d_allocate ( VCPolynom1D1D poly,
I32  order 
)

The function allocates memory for a VCPolynom1D1D structure.

Parameters
polyThe polynom struct with internals to be allocated.
orderThe maximum order of the polynom $Y(x)$.
Return values
ERR_NONEon Success.
ERR_PARAMif order is malformed.
ERR_MEMORYif memory allocation fails.
See also
vc_poly1d1d_free().

◆ vc_poly1d1d_free()

void vc_poly1d1d_free ( VCPolynom1D1D poly)

The function frees a previously allocated VCPolynom1D1D structure.

Parameters
polyThe polynom struct to be freed.
See also
vc_poly1d1d_allocate().

◆ vc_poly1d1d_map()

I32 vc_poly1d1d_map ( F64  xIn,
F64 yOut,
VCPolynom1D1D poly 
)

The function calculates a result using a VCPolynom1D1D structure.

Parameters
polyThe polynom struct.
xInInput Value $x$ for the polynom poly.
yOutOutput Value $Y(x)$ of the polynom poly.
Return values
ERR_NONEon Success.
ERR_SINGULARif transformInIff1 is 1 and scaleX/YIn is 0.

◆ vc_poly1d1d_copy()

I32 vc_poly1d1d_copy ( VCPolynom1D1D polyFrom,
VCPolynom1D1D polyTo 
)

The function copies a VCPolynom1D1D structure to another.

Parameters
polyFromThe polynom struct with internals to be copied from.
polyToThe polynom struct with internals to be copied to.
Return values
ERR_NONEon Success.
ERR_INCONSif order differs.
ERR_MEMORYif any polynomial is not allocated.
See also
vc_poly1d1d_allocate().

◆ vc_poly1d1d_print()

void vc_poly1d1d_print ( VCPolynom1D1D poly,
I32  indentation 
)

This function prints out a VCPolynom1D1D struct.

Parameters
polyThe polynom struct.

◆ vc_poly1d1d_derive_and_allocate()

I32 vc_poly1d1d_derive_and_allocate ( VCPolynom1D1D polyDerivative,
VCPolynom1D1D polyFrom 
)

The function allocates memory for a VCPolynom1D1D structure which represents the derivative of a given polynomial. Pre- and post transformation information is applied accordingly.

Parameters
polyDerivativeThe internally allocated derivate polynom.
polyThe polynom struct to be derived from.
Returns
Error code of function vc_poly1d1d_allocate().
See also
vc_poly1d1d_free().

◆ vc_poly1d1d_zero_crossing()

I32 vc_poly1d1d_zero_crossing ( VCPolynom1D1D poly,
F64 xZero,
F64  xStart,
F64  maxDev,
I32  maxSteps 
)
Parameters
polyThe polynom struct to be derived from.
xZeroThe zero x-position result.
xStartBeginning of the walk, should be near the zero crossing, if there are more than one zero, the value of this parameter determines the xZero candidate.
maxDevZero is found, if the function value falls below this.
maxStepsLimits the search duration.
Return values
ERR_PARAMif deriving or mapping fails.
ERR_SINGULARif derivate is zero.
ERR_OVERRUNif maxSteps is exceeded.

◆ vc_poly1d1d_line_intersection()

I32 vc_poly1d1d_line_intersection ( point pt,
F64  xStart,
VCPolynom1D1D poly,
vcline l,
F64  maxDev,
I32  maxSteps 
)
Parameters
ptThe intersection result.
xStartBeginning of the walk, if there are more than one intersection, the value of this parameter determines the pt candidate.
polyThe polynom struct to be intersected.
lThe line to be intersected.
maxDevThe intersection is found, if the function value falls below this.
maxStepsLimits the search duration.
Return values
ERR_PARAMif deriving or mapping fails.
ERR_SINGULARif derivate is zero.
ERR_OVERRUNif maxSteps is exceeded.

◆ vc_poly1d1d_load_and_allocate_from_ini()

I32 vc_poly1d1d_load_and_allocate_from_ini ( VCPolynom1D1D poly,
char *  filename,
I8  tiCompatibleIff1 
)

This function reads and allocates a VCPolynom1D1D struct from an INI file.

Parameters
filenameThe input INI file.
polyThe unallocated output polynom struct, on success it is allocated, free with vc_poly1d1d_free().
tiCompatibleIff1Use the same value at writing: If set to 1, the ini file can be interchanged between ARM and TI. On TI based platforms, this value has to be 1.
Return values
ERR_NONEon Success.
<0on Error, especially ERR_FIO if file reading fails, either by missing entries, or by opening.
See also
vc_poly1d1d_store_as_ini().

◆ vc_poly1d1d_store_as_ini()

I32 vc_poly1d1d_store_as_ini ( char *  filename,
VCPolynom1D1D poly,
I8  tiCompatibleIff1 
)

This function stores VCPolynom1D1D struct values as INI file.

Parameters
filenameThe output INI file.
polyThe polynom struct.
tiCompatibleIff1Use the same value at reading: If set to 1, the ini file can be interchanged between ARM and TI. On TI based platforms, this value has to be 1.
Return values
ERR_NONEon Success.
<0on Error, especially (-10 + 100 * vcmenu_store_values_in_file()).
See also
vc_poly1d1d_load_and_allocate_from_ini().