1
2      REAL FUNCTION PCHDF(K,X,S,IERR)
3C***BEGIN PROLOGUE  PCHDF
4C***REFER TO  PCHCE,PCHSP
5C***ROUTINES CALLED  XERROR
6C***REVISION DATE  870707   (YYMMDD)
7C***DESCRIPTION
8C
9C          PCHDF:   PCHIP Finite Difference Formula
10C
11C     Uses a divided difference formulation to compute a K-point approx-
12C     imation to the derivative at X(K) based on the data in X and S.
13C
14C     Called by  PCHCE  and  PCHSP  to compute 3- and 4-point boundary
15C     derivative approximations.
16C
17C ----------------------------------------------------------------------
18C
19C     On input:
20C        K      is the order of the desired derivative approximation.
21C               K must be at least 3 (error return if not).
22C        X      contains the K values of the independent variable.
23C               X need not be ordered, but the values **MUST** be
24C               distinct.  (Not checked here.)
25C        S      contains the associated slope values:
26C                  S(I) = (F(I+1)-F(I))/(X(I+1)-X(I)), I=1(1)K-1.
27C               (Note that S need only be of length K-1.)
28C
29C     On return:
30C        S      will be destroyed.
31C        IERR   will be set to -1 if K.LT.2 .
32C        PCHDF  will be set to the desired derivative approximation if
33C               IERR=0 or to zero if IERR=-1.
34C
35C ----------------------------------------------------------------------
36C
37C  Reference:  Carl de Boor, A Practical Guide to Splines, Springer-
38C              Verlag (New York, 1978), pp. 10-16.
39C
40C ----------------------------------------------------------------------
41C
42C  Programmed by:  Fred N. Fritsch,  FTS 532-4275, (415) 422-4275,
43C                  Mathematics and Statistics Division,
44C                  Lawrence Livermore National Laboratory.
45C
46C  Change record:
47C     82-08-05   Converted to SLATEC library version.
48C
49C ----------------------------------------------------------------------
50C
51C  Programming notes:
52C
53C     To produce a double precision version, simply:
54C        a. Change PCHDF to DPCHDF wherever it occurs,
55C        b. Change the real declarations to double precision, and
56C        c. Change the constant ZERO to double precision.
57C***END PROLOGUE  PCHDF
58
59
60