|
|
|
| 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 ); |
| 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/Delphi | uses VFmath;
function VF_poly( Y, X:fVector; size:UInt; Coeff:fVector; deg:UInt ): IntBool;
function VFx_poly( Y, X:fVector; size:UInt; Coeff:fVector; deg:UInt; A, B:Single ): IntBool; |
|
| Description | normal versions:
Yi = c0 + c1 * Xi + c2 * Xi2 + ... + cn * Xin
expanded versions:
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). |
|
| Error handling | OVERFLOW 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 value | FALSE (0), if no error occurred, otherwise TRUE (non-zero) |
|
|