These subroutines evaluate a polynomial of degree k, using coefficient vector u, input vector x, and output vector y:
where uk, xi, and
yi are elements of u, x,
and y, respectively.
u, x, y | Subroutine |
---|---|
Short-precision real | SPOLY |
Long-precision real | DPOLY |
Fortran | CALL SPOLY | DPOLY (u, incu, k, x, incx, y, incy, n) |
C and C++ | spoly | dpoly (u, incu, k, x, incx, y, incy, n); |
PL/I | CALL SPOLY | DPOLY (u, incu, k, x, incx, y, incy, n); |
Vectors u, x, and y must have no common elements; otherwise, results are unpredictable. See Concepts.
The evaluation of the polynomial:
is expressed as follows:
See reference [81] for Horner's Rule. If n is 0, no computation is performed. For SPOLY, intermediate results are accumulated in long precision.
SPOLY provides the same function as the IBM 3838 function POLY, with restrictions removed. DPOLY provides a long-precision computation that is not included in the IBM 3838 functions. See the IBM 3838 Array Processor Functional Characteristics manual.
None
This example shows a polynomial evaluation with the degree, K, equal to 0.
U INCU K X INCX Y INCY N | | | | | | | | CALL SPOLY( U , INCU , 0 , X , INCX , Y , 1 , 3 )
Y = (4.0, 4.0, 4.0)
This example shows a polynomial evaluation, using a negative stride INCU for vector u. For u, processing begins at element U(4) which is 1.0.
U INCU K X INCX Y INCY N | | | | | | | | CALL SPOLY( U , -1 , 3 , X , 1 , Y , 1 , 3 ) U = (4.0, 3.0, 2.0, 1.0) X = (2.0, 1.0, -3.0)
Y = (49.0, 10.0, -86.0)
This example shows a polynomial evaluation, using a stride INCX of 0 for input vector x.
U INCU K X INCX Y INCY N | | | | | | | | CALL SPOLY( U , 1 , 3 , X , 0 , Y , 1 , 3 ) U = (4.0, 3.0, 2.0, 1.0) X = (2.0, . , . )
Y = (26.0, 26.0, 26.0)
This example shows a polynomial evaluation, using a stride INCX greater than 1 for input vector x, and a negative stride INCY for output vector y. For y, results are stored beginning at element Y(5).
U INCU K X INCX Y INCY N | | | | | | | | CALL SPOLY( U , 1 , 3 , X , 2 , Y , -2 , 3 ) U = (4.0, 3.0, 2.0, 1.0) X = (2.0, . , -3.0, . , 1.0)
Y = (10.0, . , -14.0, . , 26.0)