This function evaluates a piecewise polynomial.
PPVAL — Value of the piecewise polynomial at X. (Output)
X — Point at which the polynomial is to be evaluated. (Input)
BREAK — Array of
length NINTV + 1
containing the breakpoints of the piecewise polynomial
representation. (Input)
BREAK must be strictly
increasing.
PPCOEF — Array of
size KORDER
* NINTV containing the
local coefficients of the piecewise polynomial pieces. (Input)
PPCOEF is
treated internally as a matrix of size KORDER by NINTV.
KORDER — Order of
the polynomial. (Input)
Default: KORDER = size (PPCOEF,1).
NINTV — Number of
polynomial pieces. (Input)
Default: NINTV = size
(PPCOEF,2).
Generic: PPVAL (X, BREAK, PPCOEF [,…])
Specific: The specific interface names are S_PPVAL and D_PPVAL.
Single: PPVAL (X, KORDER, NINTV, BREAK, PPCOEF)
Double: The double precision function name is DPPVAL.
The routine PPVAL evaluates a piecewise polynomial at a given point. This routine is a special case of the routine PPDER, which evaluates the derivative of a piecewise polynomial. (The value of a piecewise polynomial is its zero-th derivative.)
The routine PPDER is based on the routine PPVALU in de Boor (1978, page 89).
In this example, a spline interpolant to a function f is computed using the IMSL routine BSINT. This routine represents the interpolant as a linear combination of B-splines. This representation is then converted to piecewise polynomial representation by calling the IMSL routine BSCPP. The piecewise polynomial is evaluated using PPVAL. These values are compared to the corresponding values of f.
USE PPVAL_INT
USE BSNAK_INT
USE BSCPP_INT
USE BSINT_INT
USE UMACH_INT
IMPLICIT NONE
INTEGER KORDER, NCOEF, NDATA, NKNOT
PARAMETER (KORDER=4, NCOEF=20, NDATA=20, NKNOT=NDATA+KORDER)
!
INTEGER I, NOUT, NPPCF
REAL BREAK(NCOEF), BSCOEF(NCOEF), EXP, F, FDATA(NDATA),&
FLOAT, PPCOEF(KORDER,NCOEF), S, X, XDATA(NDATA),&
XKNOT(NKNOT)
INTRINSIC EXP, FLOAT
! Define function
F(X) = X*EXP(X)
! Set up interpolation points
DO 30 I=1, NDATA
XDATA(I) = FLOAT(I-1)/FLOAT(NDATA-1)
FDATA(I) = F(XDATA(I))
30 CONTINUE
! Generate knot sequence
CALL BSNAK (NDATA, XDATA, KORDER, XKNOT)
! Compute the B-spline interpolant
CALL BSINT (NCOEF, XDATA, FDATA, KORDER, XKNOT, BSCOEF)
! Convert to piecewise polynomial
CALL BSCPP (KORDER, XKNOT, NCOEF, BSCOEF, NPPCF, BREAK, PPCOEF)
! Get output unit number
CALL UMACH (2, NOUT)
! Write heading
WRITE (NOUT,99999)
! Print the interpolant on a uniform
! grid
DO 40 I=1, NDATA
X = FLOAT(I-1)/FLOAT(NDATA-1)
! Compute value of the piecewise
! polynomial
S = PPVAL(X,BREAK,PPCOEF)
WRITE (NOUT,'(2F12.3, E14.3)') X, S, F(X) - S
40 CONTINUE
99999 FORMAT (11X, 'X', 8X, 'S(X)', 7X, 'Error')
END
X
S(X)
Error
0.000 0.000
0.000E+00
0.053 0.055
-0.745E-08
0.105
0.117
0.000E+00
0.158
0.185
0.000E+00
0.211 0.260
-0.298E-07
0.263
0.342
0.298E-07
0.316
0.433
0.000E+00
0.368
0.533
0.000E+00
0.421
0.642
0.000E+00
0.474
0.761
0.596E-07
0.526
0.891
0.000E+00
0.579
1.033
0.000E+00
0.632
1.188
0.000E+00
0.684
1.356
0.000E+00
0.737 1.540
-0.119E-06
0.789
1.739
0.000E+00
0.842
1.955
0.000E+00
0.895
2.189
0.238E-06
0.947
2.443
0.238E-06
1.000
2.718 0.238E-06
Visual Numerics, Inc. PHONE: 713.784.3131 FAX:713.781.9260 |