1      FUNCTION PPVAL(LDC,C,XI,LXI,K,IDERIV,X,INPPV)
2C***BEGIN PROLOGUE  PPVAL
3C***DATE WRITTEN   800901   (YYMMDD)
4C***REVISION DATE  820801   (YYMMDD)
5C***CATEGORY NO.  E3,K6
6C***KEYWORDS  B-SPLINE,DATA FITTING,INTERPOLATION,SPLINE
7C***AUTHOR  AMOS, D. E., (SNLA)
8C***PURPOSE  Calculates (at X) the value of the IDERIV-th derivative
9C            of the B-spline from the PP-representation.
10C***DESCRIPTION
11C
12C     Written by Carl de Boor and modified by D. E. Amos
13C
14C     Reference
15C         SIAM J. Numerical Analysis, 14, No. 3, June, 1977, pp.441-472.
16C
17C     Abstract
18C         PPVAL is the PPVALU function of the reference.
19C
20C         PPVAL calculates (at X) the value of the IDERIV-th
21C         derivative of the B-spline from the PP-representation
22C         (C,XI,LXI,K).  The Taylor expansion about XI(J) for X in
23C         the interval XI(J) .LE. X .LT. XI(J+1) is evaluated, J=1,LXI.
24C         Right limiting values at X=XI(J) are obtained.  PPVAL will
25C         extrapolate beyond XI(1) and XI(LXI+1).
26C
27C         To obtain left limiting values (left derivatives) at XI(J),
28C         replace LXI by J-1 and set X=XI(J),J=2,LXI+1.
29C
30C         PPVAL calls INTRV
31C
32C     Description of Arguments
33C         Input
34C          LDC     - leading dimension of C matrix, LDC .GE. K
35C          C       - matrix of dimension at least (K,LXI) containing
36C                    right derivatives at break points XI(*).
37C          XI      - break point vector of length LXI+1
38C          LXI     - number of polynomial pieces
39C          K       - order of B-spline, K .GE. 1
40C          IDERIV  - order of the derivative, 0 .LE. IDERIV .LE. K-1
41C                    IDERIV=0 gives the B-spline value
42C          X       - argument, XI(1) .LE. X .LE. XI(LXI+1)
43C          INPPV   - an initialization parameter which must be set
44C                    to 1 the first time PPVAL is called.
45C
46C         Output
47C          INPPV   - INPPV contains information for efficient process-
48C                    ing after the initial call and INPPV must not
49C                    be changed by the user.  Distinct splines require
50C                    distinct INPPV parameters.
51C          PPVAL   - value of the IDERIV-th derivative at X
52C
53C     Error Conditions
54C         Improper input is a fatal error
55C***REFERENCES  C. DE BOOR, *PACKAGE FOR CALCULATING WITH B-SPLINES*,
56C                 SIAM JOURNAL ON NUMERICAL ANALYSIS, VOLUME 14, NO. 3,
57C                 JUNE 1977, PP. 441-472.
58C***ROUTINES CALLED  INTRV,XERROR
59C***END PROLOGUE  PPVAL
60C
61C
62      INTEGER I, IDERIV, INPPV, J, K, LDC, LXI, NDUMMY
63      REAL C, DX, FLTK, X, XI
64      DIMENSION XI(1), C(LDC,LXI)
65C***FIRST EXECUTABLE STATEMENT  PPVAL
66      PPVAL = 0.0E0
67      IF(K.LT.1) GO TO 90
68      IF(LDC.LT.K) GO TO 80
69      IF(LXI.LT.1) GO TO 85
70      IF(IDERIV.LT.0 .OR. IDERIV.GE.K) GO TO 95
71      I = K - IDERIV
72      FLTK = FLOAT(I)
73      CALL INTRV(XI, LXI, X, INPPV, I, NDUMMY)
74      DX = X - XI(I)
75      J = K
76   10 PPVAL = (PPVAL/FLTK)*DX + C(J,I)
77      J = J - 1
78      FLTK = FLTK - 1.0E0
79      IF (FLTK.GT.0.0E0) GO TO 10
80      RETURN
81C
82C
83   80 CONTINUE
84      CALL XERROR( ' PPVAL,  LDC DOES NOT SATISFY LDC.GE.K', 38, 2, 1)
85      RETURN
86   85 CONTINUE
87      CALL XERROR( ' PPVAL,  LXI DOES NOT SATISFY LXI.GE.1', 38, 2, 1)
88      RETURN
89   90 CONTINUE
90      CALL XERROR( ' PPVAL,  K DOES NOT SATISFY K.GE.1', 34, 2, 1)
91      RETURN
92   95 CONTINUE
93      CALL XERROR( ' PPVAL,  IDERIV DOES NOT SATISFY 0.LE.IDERIV.LT.K',
94     1 49, 2, 1)
95      RETURN
96      END
97