2
DOUBLE PRECISION FUNCTION DPCHDF (K, X, S, IERR)
3
C***BEGIN PROLOGUE DPCHDF
5
C***PURPOSE Computes divided differences for DPCHCE and DPCHSP
6
C***LIBRARY SLATEC (PCHIP)
7
C***TYPE DOUBLE PRECISION (PCHDF-S, DPCHDF-D)
8
C***AUTHOR Fritsch, F. N., (LLNL)
11
C DPCHDF: DPCHIP Finite Difference Formula
13
C Uses a divided difference formulation to compute a K-point approx-
14
C imation to the derivative at X(K) based on the data in X and S.
16
C Called by DPCHCE and DPCHSP to compute 3- and 4-point boundary
17
C derivative approximations.
19
C ----------------------------------------------------------------------
22
C K is the order of the desired derivative approximation.
23
C K must be at least 3 (error return if not).
24
C X contains the K values of the independent variable.
25
C X need not be ordered, but the values **MUST** be
26
C distinct. (Not checked here.)
27
C S contains the associated slope values:
28
C S(I) = (F(I+1)-F(I))/(X(I+1)-X(I)), I=1(1)K-1.
29
C (Note that S need only be of length K-1.)
32
C S will be destroyed.
33
C IERR will be set to -1 if K.LT.2 .
34
C DPCHDF will be set to the desired derivative approximation if
35
C IERR=0 or to zero if IERR=-1.
37
C ----------------------------------------------------------------------
39
C***SEE ALSO DPCHCE, DPCHSP
40
C***REFERENCES Carl de Boor, A Practical Guide to Splines, Springer-
41
C Verlag, New York, 1978, pp. 10-16.
42
C***ROUTINES CALLED XERMSG
43
C***REVISION HISTORY (YYMMDD)
45
C 820805 Converted to SLATEC library version.
46
C 870707 Corrected XERROR calls for d.p. name(s).
47
C 870813 Minor cosmetic changes.
48
C 890206 Corrected XERROR calls.
49
C 890411 Added SAVE statements (Vers. 3.2).
50
C 890411 REVISION DATE from Version 3.2
51
C 891214 Prologue converted to Version 4.0 format. (BAB)
52
C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
53
C 900328 Added TYPE section. (WRB)
54
C 910408 Updated AUTHOR and DATE WRITTEN sections in prologue. (WRB)
55
C 920429 Revised format and order of references. (WRB,FNF)
56
C 930503 Improved purpose. (FNF)
57
C***END PROLOGUE DPCHDF
64
DOUBLE PRECISION X(K), S(K)
66
C DECLARE LOCAL VARIABLES.
69
DOUBLE PRECISION VALUE, ZERO
73
C CHECK FOR LEGAL VALUE OF K.
75
C***FIRST EXECUTABLE STATEMENT DPCHDF
76
IF (K .LT. 3) GO TO 5001
78
C COMPUTE COEFFICIENTS OF INTERPOLATING POLYNOMIAL.
82
S(I) = (S(I+1)-S(I))/(X(I+J)-X(I))
86
C EVALUATE DERIVATIVE AT X(K).
90
VALUE = S(I) + VALUE*(X(K)-X(I))
104
CALL XERMSG ('SLATEC', 'DPCHDF', 'K LESS THAN THREE', IERR, 1)
107
C------------- LAST LINE OF DPCHDF FOLLOWS -----------------------------