VF_polyVD_polyVE_poly
VF_poly_dVF_poly_eVD_poly_e
VFx_polyVDx_polyVEx_poly
VFx_poly_dVFx_poly_eVDx_poly_e
VF_polyOddVD_polyOddVE_polyOdd
VF_polyOdd_dVF_polyOdd_eVD_polyOdd_e
VFx_polyOddVDx_polyOddVEx_polyOdd
VFx_polyOdd_dVFx_polyOdd_eVDx_polyOdd_e
VF_polyEvenVD_polyEvenVE_polyEven
VF_polyEven_dVF_polyEven_eVD_polyEven_e
VFx_polyEvenVDx_polyEvenVEx_polyEven
VFx_polyEven_dVFx_polyEven_eVDx_polyEven_e
FunctionPolynomial
Syntax C/C++#include <VFmath.h>
int VF_poly( fVector Y, fVector X, ui size, fVector Coeff, unsigned deg );
int VFx_poly( fVector Y, fVector X, ui size, fVector Coeff, unsigned deg, float A, float B );
int VFu_poly( fVector Y, fVector X, ui size, fVector Coeff, unsigned deg );
int VFux_poly( fVector Y, fVector X, ui size, fVector Coeff, unsigned deg, float A, float B );
C++ VecObj#include <OptiVec.h>
int vector<T>::poly( const vector<T>& X, const vector<T>& Coeff, unsigned deg );
int vector<T>::x_poly( const vector<T>& X, const vector<T>& Coeff, unsigned deg, const T& A, const T& B );
Pascal/Delphiuses VFmath;
function VF_poly( Y, X:fVector; size:UIntSize; Coeff:fVector; deg:UInt ): IntBool;
function VFx_poly( Y, X:fVector; size:UIntSize; Coeff:fVector; deg:UInt; A, B:Single ): IntBool;
function VFu_poly( Y, X:fVector; size:UIntSize; Coeff:fVector; deg:UInt ): IntBool;
function VFux_poly( Y, X:fVector; size:UIntSize; Coeff:fVector; deg:UInt; A, B:Single ): IntBool;
CUDA function C/C++#include <cudaVFmath.h>
int cudaVF_poly( fVector d_Y, fVector d_X, ui size, fVector h_Coeff, unsigned deg );
int cusdVF_poly( fVector d_Y, fVector d_X, ui size, fVector d_Coeff, unsigned deg );
int cudaVFx_poly( fVector d_Y, fVector d_X, ui size, fVector h_Coeff, unsigned deg, float A, float B );
int cusdVFx_poly( fVector d_Y, fVector d_X, ui size, fVector d_Coeff, unsigned deg, float *d_A, float *d_B );
int cudaVFu_poly( fVector d_Y, fVector d_X, ui size, fVector h_Coeff, unsigned deg );
int cusdVFu_poly( fVector d_Y, fVector d_X, ui size, fVector d_Coeff, unsigned deg );
int cudaVFux_poly( fVector d_Y, fVector d_X, ui size, fVector h_Coeff, unsigned deg, float A, float B );
int cusdVFux_poly( fVector d_Y, fVector d_X, ui size, fVector d_Coeff, unsigned deg, float *d_A, float *d_B );
int VFcu_poly( fVector h_Y, fVector h_X, ui size, fVector h_Coeff, unsigned deg );
int VFxcu_poly( fVector h_Y, fVector h_X, ui size, fVector h_Coeff, unsigned deg, float A, float B );
int VFucu_poly( fVector h_Y, fVector h_X, ui size, fVector h_Coeff, unsigned deg );
int VFuxcu_poly( fVector h_Y, fVector h_X, ui size, fVector h_Coeff, unsigned deg, float A, float B );
CUDA function Pascal/Delphiuses VFmath;
function cudaVF_poly( d_Y, d_X:fVector; size:UIntSize; h_Coeff:fVector; deg:UInt ): IntBool;
function cusdVF_poly( d_Y, d_X:fVector; size:UIntSize; d_Coeff:fVector; deg:UInt ): IntBool;
function cudaVFx_poly( d_Y, d_X:fVector; size:UIntSize; h_Coeff:fVector; deg:UInt; A, B:Single ): IntBool;
function cusdVFx_poly( d_Y, d_X:fVector; size:UIntSize; d_Coeff:fVector; deg:UInt; d_A, d_B:PSingle ): IntBool;
function cudaVFu_poly( d_Y, d_X:fVector; size:UIntSize; h_Coeff:fVector; deg:UInt ): IntBool;
function cusdVFu_poly( d_Y, d_X:fVector; size:UIntSize; d_Coeff:fVector; deg:UInt ): IntBool;
function cudaVFux_poly( d_Y, d_X:fVector; size:UIntSize; h_Coeff:fVector; deg:UInt; A, B:Single ): IntBool;
function cusdVFux_poly( d_Y, d_X:fVector; size:UIntSize; d_Coeff:fVector; deg:UInt; d_A, d_B:PSingle ): IntBool;
function VFcu_poly( h_Y, h_X:fVector; size:UIntSize; h_Coeff:fVector; deg:UInt ): IntBool;
function VFxcu_poly( h_Y, h_X:fVector; size:UIntSize; h_Coeff:fVector; deg:UInt; A, B:Single ): IntBool;
function VFucu_poly( h_Y, h_X:fVector; size:UIntSize; h_Coeff:fVector; deg:UInt ): IntBool;
function VFuxcu_poly( h_Y, h_X:fVector; size:UIntSize; h_Coeff:fVector; deg:UInt; A, B:Single ): IntBool;
Descriptionsimple versions VF_poly, VD_poly, VE_poly:
Yi = c0 + c1 * Xi + c2 * Xi2 + ... + cn * Xin
expanded versions VFx_poly, VDx_poly, VEx_poly:
xi = (A*Xi + B),
Yi = c0 + c1 * xi + c2 * xi2 + ... + cn * xin

A polynomial of degree deg is generated for every element of X, using the coefficients contained in the vector Coeff. The coefficients in Coeff have to be ordered in such a way that the constant term is the zero'th element, the linear coefficient the first element etc., up to the deg'th element which is the coefficient for the highest power used in the polynomial. (Beware a frequent source of errors: for a polynomial of deg = 4, there are 5 (!) coefficients; do not forget the constant term).

"unprotected" versions (prefix VFu_,   VFux_, etc.):
These functions do not perform any error handling, which makes them much faster (up to 50%) than the standard versions.

As polynomials are prone to overflow, sometimes also intermediate overflow, while the end result could still be legal, additional versions offer the internal calculation to be made in higher precision: VF_poly_d and VF_poly_e work in double or extended precision, resp., before converting the result back to single precision. Likewise, VD_poly_e works in extended precision (even if the compiler does not support extended precision!), before converting the result back to double. These versions exist only on the CPU, not in CUDA.

For polynomials consisting of odd terms only (like the polynomial representation of the sine function) or of even terms only (like the polynomial representation of the cosine function), special versions are provided:
VF_polyOdd:
Yi = c1 * Xi + c1 * Xi3 + ... + c(2n+1) * Xi2n+1
Coeff here contains (deg+1)/2 coefficients: c1, c3, c5 etc.

VF_polyEven:
Yi = c0 + c2 * Xi2 + ... + c2n * Xi2n
Coeff here contains (deg/2)+1 coefficients: c0, c2, c4 etc.

Error handlingOVERFLOW errors lead to ±HUGE_VAL as the default result. In contrast to the ANSI C function poly (where deg is declared as int), the declaration of deg as unsigned precludes DOMAIN errors (which would occur for negative deg).
Return valueFALSE (0), if no error occurred, otherwise TRUE (non-zero)
See alsoVF_ratio,   VF_ipow,   VF_pow,   poly

VectorLib Table of Contents  OptiVec home