VF_ratio_d | VF_ratio_e | VD_ratio_e |
VFx_ratio | VDx_ratio | VEx_ratio |
VFx_ratio_d | VFx_ratio_e | VDx_ratio_e |
VF_ratioOddEven | VD_ratioOddEven | VE_ratioOddEven |
VF_ratioOddEven_d | VF_ratioOddEven_e | VD_ratioOddEven_e |
VFx_ratioOddEven | VDx_ratioOddEven | VEx_ratioOddEven |
VFx_ratioOddEven_d | VFx_ratioOddEven_e | VDx_ratioOddEven_e |
VF_ratioEvenOdd | VD_ratioEvenOdd | VE_ratioEvenOdd |
VF_ratioEvenOdd_d | VF_ratioEvenOdd_e | VD_ratioEvenOdd_e |
VFx_ratioEvenOdd | VDx_ratioEvenOdd | VEx_ratioEvenOdd |
VFx_ratioEvenOdd_d | VFx_ratioEvenOdd_e | VDx_ratioEvenOdd_e |
VFu_ratio | VDu_ratio | VEu_ratio |
VFu_ratio_d | VFu_ratio_e | VDu_ratio_e |
VFux_ratio | VDux_ratio | VEux_ratio |
VFux_ratio_d | VFux_ratio_e | VDux_ratio_e |
VFu_ratioOddEven | VDu_ratioOddEven | VEu_ratioOddEven |
VFu_ratioOddEven_d | VFu_ratioOddEven_e | VDu_ratioOddEven_e |
VFux_ratioOddEven | VDux_ratioOddEven | VEux_ratioOddEven |
VFux_ratioOddEven_d | VFux_ratioOddEven_e | VDux_ratioOddEven_e |
VFu_ratioEvenOdd | VDu_ratioEvenOdd | VEu_ratioEvenOdd |
VFu_ratioEvenOdd_d | VFu_ratioEvenOdd_e | VDu_ratioEvenOdd_e |
VFux_ratioEvenOdd | VDux_ratioEvenOdd | VEux_ratioEvenOdd |
VFux_ratioEvenOdd_d | VFux_ratioEvenOdd_e | VDux_ratioEvenOdd_e |
|
Function | Rational expression: ratio of two polynomials |
|
Syntax C/C++ | #include <VFmath.h>
int VF_ratio( fVector Y, fVector X, ui size, fVector Coeff, unsigned degP, unsigned degQ );
int VFx_ratio( fVector Y, fVector X, ui size, fVector Coeff, unsigned degP, unsigned degQ, float A, float B );
int VFu_ratio( fVector Y, fVector X, ui size, fVector Coeff, unsigned degP, unsigned degQ );
int VFux_ratio( fVector Y, fVector X, ui size, fVector Coeff, unsigned degP, unsigned degQ, float A, float B ); |
C++ VecObj | #include <OptiVec.h>
int vector<T>::ratio( const vector<T>& X, const vector<T>& Coeff, unsigned degP, unsigned degQ );
int vector<T>::x_ratio( const vector<T>& X, const vector<T>& Coeff, unsigned degP, unsigned degQ, const T& A, const T& B ); |
Pascal/Delphi | uses VFmath;
function VF_ratio( Y, X:fVector; size:UIntSize; Coeff:fVector; degP, degQ:UInt ): IntBool;
function VFx_ratio( Y, X:fVector; size:UIntSize; Coeff:fVector; degP, degQ:UInt; A, B:Single ): IntBool;
function VFu_ratio( Y, X:fVector; size:UIntSize; Coeff:fVector; degP, degQ:UInt ): IntBool;
function VFux_ratio( Y, X:fVector; size:UIntSize; Coeff:fVector; degP, degQ:UInt; A, B:Single ): IntBool; |
|
CUDA function C/C++ | #include <cudaVFmath.h>
int cudaVF_ratio( fVector d_Y, fVector d_X, ui size, fVector h_Coeff, unsigned degP, unsigned degQ );
int cusdVF_ratio( fVector d_Y, fVector d_X, ui size, fVector d_Coeff, unsigned degP, unsigned degQ );
int cudaVFx_ratio( fVector d_Y, fVector d_X, ui size, fVector h_Coeff, unsigned degP, unsigned degQ, float A, float B );
int cusdVFx_ratio( fVector d_Y, fVector d_X, ui size, fVector d_Coeff, unsigned degP, unsigned degQ, float *d_A, float *d_B );
int cudaVFu_ratio( fVector d_Y, fVector d_X, ui size, fVector h_Coeff, unsigned degP, unsigned degQ );
int cusdVFu_ratio( fVector d_Y, fVector d_X, ui size, fVector d_Coeff, unsigned degP, unsigned degQ );
int cudaVFux_ratio( fVector d_Y, fVector d_X, ui size, fVector h_Coeff, unsigned degP, unsigned degQ, float A, float B );
int cusdVFux_ratio( fVector d_Y, fVector d_X, ui size, fVector d_Coeff, unsigned degP, unsigned degQ, float *d_A, float *d_B );
int VFcu_ratio( fVector h_Y, fVector h_X, ui size, fVector h_Coeff, unsigned degP, unsigned degQ );
int VFxcu_ratio( fVector h_Y, fVector h_X, ui size, fVector h_Coeff, unsigned degP, unsigned degQ, float A, float B );
int VFucu_ratio( fVector h_Y, fVector h_X, ui size, fVector h_Coeff, unsigned degP, unsigned degQ );
int VFuxcu_ratio( fVector h_Y, fVector h_X, ui size, fVector h_Coeff, unsigned degP, unsigned degQ, float A, float B );
|
CUDA function Pascal/Delphi | uses VFmath;
function cudaVF_ratio( d_Y, d_X:fVector; size:UIntSize; h_Coeff:fVector; degP, degQ:UInt ): IntBool;
function cusdVF_ratio( d_Y, d_X:fVector; size:UIntSize; d_Coeff:fVector; degP, degQ:UInt ): IntBool;
function cudaVFx_ratio( d_Y, d_X:fVector; size:UIntSize; h_Coeff:fVector; degP, degQ:UInt; A, B:Single ): IntBool;
function cusdVFx_ratio( d_Y, d_X:fVector; size:UIntSize; d_Coeff:fVector; degP, degQ:UInt; d_A, d_B:PSingle ): IntBool;
function cudaVFu_ratio( d_Y, d_X:fVector; size:UIntSize; h_Coeff:fVector; degP, degQ:UInt ): IntBool;
function cusdVFu_ratio( d_Y, d_X:fVector; size:UIntSize; d_Coeff:fVector; degP, degQ:UInt ): IntBool;
function cudaVFux_ratio( d_Y, d_X:fVector; size:UIntSize; h_Coeff:fVector; degP, degQ:UInt; A, B:Single ): IntBool;
function cusdVFux_ratio( d_Y, d_X:fVector; size:UIntSize; d_Coeff:fVector; degP, degQ:UInt; d_A, d_B:PSingle ): IntBool;
function VFcu_ratio( h_Y, h_X:fVector; size:UIntSize; h_Coeff:fVector; degP, degQ:UInt ): IntBool;
function VFxcu_ratio( h_Y, h_X:fVector; size:UIntSize; h_Coeff:fVector; degP, degQ:UInt; A, B:Single ): IntBool;
function VFucu_ratio( h_Y, h_X:fVector; size:UIntSize; h_Coeff:fVector; degP, degQ:UInt ): IntBool;
function VFuxcu_ratio( h_Y, h_X:fVector; size:UIntSize; h_Coeff:fVector; degP, degQ:UInt; A, B:Single ): IntBool;
|
|
Description | simple versions VF_ratio, VD_ratio, VE_ratio:
Yi = P/Q, with
P = p0 + p1 * Xi + p2 * Xi2 + ... + pdegP * XidegP,
Q = q0 + q1 * Xi + q2 * Xi2 + ... + qdegQ * XidegQ
expanded versions VFx_ratio, VDx_ratio, VEx_ratio:
xi = (A*Xi + B),
Yi = P/Q as above with xi instead of Xi
A polynomial P of degree degP is divided by a polynomial Q of degree degQ. The coefficients pk and qk are taken from the vector Coeff. Coeff must contain the constant term p0 as element no. 0, the linear coefficient p1 as element no. 1, and so one until pdegP as element no. degP immediately followed by q0 as element no. (degP+1), q1 as element no. (degP+2) etc., until qdegQ as element no. (degP+degQ+1). This means that Coeff contains a total of (degP+degQ+2) elements.
"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. They do, however, indicate in their return value, if an error occurred.
Even in the case that the individual polynomials P and Q might overflow, their ratio still might yield a perfectly legal result. Therefore, OptiVec offers additional versions which internally employ higher accuracy (and range): VF_ratio_d and VF_ratio_e work in double or extended precision, resp., before converting the result back to single precision. Likewise, VD_ratio_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.
When rational models are used for the approximation of mathematical functions, sometimes one of the polynomials only consists of odd terms, while the other polynomial has only even terms. Examples are the rational representation of the tangent function (P has only odd terms, Q has only even terms) or of the cotangent function (P has only even terms, Q has only odd terms). These cases are covered by the following OptiVec functions:
VF_ratioOddEven: P has only odd terms, Q has only even terms:
Pi = p1 * Xi + p1 * Xi3 + ... + pdegP * XidegP, with degP = 2n+1
Qi = q0 + q2 * Xi2 + ... + qdegQ * XidegQ, with degQ = 2n
Coeff here contains (degP+1)/2 + (degQ/2)+1 coefficients.
VF_ratioEvenOdd: P has only even, Q has only odd terms:
Pi = p0 + p2 * Xi2 + ... + pdegP * XidegP, with degP = 2n
Qi = q1 * Xi + q1 * Xi3 + ... + qdegQ * XidegQ, with degQ = 2n+1
Coeff here contains (degP/2)+1 + (degQ+1)/2 coefficients.
While mathematically legal, round-off error makes polynomials and, by extension, rations of high degrees practically useless. In the present implementation, VF_ratio, VF_ratio_d, and VD_ratio allow degP+degQ ± 32. Above that, an error message "Invalid Parameter(s)" is emitted and program execution halted. Only the VE_ versions along with VF_ratio_e and VD_ratio_e allow to evaluate ratios of higher degrees.
|
|
Error handling | OVERFLOW or ZERODIVIDE errors lead to the result ±HUGE_VAL. 0/0 situations are solved only in the VE_ and ratio_e versions, where 0/0 is replaced by the first derivative of P divided by the first derivative of Q. In all other versions, 0/0 leads to the result ±HUGE_VAL. |
|
Return value | FALSE (0), if no error occured; otherwise a bit combination of the error codes, 0x4 (division by 0), 0x8 (OVERFLOW), and 0x1 (0/0).
Although the "unprotected" variants (prefixes VFu_, VFux_, etc.) do not actually hande errors, they return the same error codes as the normal variant. |
|
|