2
SUBROUTINE CHFDV (X1, X2, F1, F2, D1, D2, NE, XE, FE, DE, NEXT,
4
C***BEGIN PROLOGUE CHFDV
5
C***PURPOSE Evaluate a cubic polynomial given in Hermite form and its
6
C first derivative at an array of points. While designed for
7
C use by PCHFD, it may be useful directly as an evaluator
8
C for a piecewise cubic Hermite function in applications,
9
C such as graphing, where the interval is known in advance.
10
C If only function values are required, use CHFEV instead.
11
C***LIBRARY SLATEC (PCHIP)
13
C***TYPE SINGLE PRECISION (CHFDV-S, DCHFDV-D)
14
C***KEYWORDS CUBIC HERMITE DIFFERENTIATION, CUBIC HERMITE EVALUATION,
15
C CUBIC POLYNOMIAL EVALUATION, PCHIP
16
C***AUTHOR Fritsch, F. N., (LLNL)
17
C Lawrence Livermore National Laboratory
18
C P.O. Box 808 (L-316)
20
C FTS 532-4275, (510) 422-4275
23
C CHFDV: Cubic Hermite Function and Derivative Evaluator
25
C Evaluates the cubic polynomial determined by function values
26
C F1,F2 and derivatives D1,D2 on interval (X1,X2), together with
27
C its first derivative, at the points XE(J), J=1(1)NE.
29
C If only function values are required, use CHFEV, instead.
31
C ----------------------------------------------------------------------
35
C INTEGER NE, NEXT(2), IERR
36
C REAL X1, X2, F1, F2, D1, D2, XE(NE), FE(NE), DE(NE)
38
C CALL CHFDV (X1,X2, F1,F2, D1,D2, NE, XE, FE, DE, NEXT, IERR)
42
C X1,X2 -- (input) endpoints of interval of definition of cubic.
43
C (Error return if X1.EQ.X2 .)
45
C F1,F2 -- (input) values of function at X1 and X2, respectively.
47
C D1,D2 -- (input) values of derivative at X1 and X2, respectively.
49
C NE -- (input) number of evaluation points. (Error return if
52
C XE -- (input) real array of points at which the functions are to
53
C be evaluated. If any of the XE are outside the interval
54
C [X1,X2], a warning error is returned in NEXT.
56
C FE -- (output) real array of values of the cubic function defined
57
C by X1,X2, F1,F2, D1,D2 at the points XE.
59
C DE -- (output) real array of values of the first derivative of
60
C the same function at the points XE.
62
C NEXT -- (output) integer array indicating number of extrapolation
64
C NEXT(1) = number of evaluation points to left of interval.
65
C NEXT(2) = number of evaluation points to right of interval.
67
C IERR -- (output) error flag.
69
C IERR = 0 (no errors).
70
C "Recoverable" errors:
71
C IERR = -1 if NE.LT.1 .
72
C IERR = -2 if X1.EQ.X2 .
73
C (Output arrays have not been changed in either case.)
76
C***ROUTINES CALLED XERMSG
77
C***REVISION HISTORY (YYMMDD)
79
C 820803 Minor cosmetic changes for release 1.
80
C 890411 Added SAVE statements (Vers. 3.2).
81
C 890531 Changed all specific intrinsics to generic. (WRB)
82
C 890831 Modified array declarations. (WRB)
83
C 890831 REVISION DATE from Version 3.2
84
C 891214 Prologue converted to Version 4.0 format. (BAB)
85
C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
86
C***END PROLOGUE CHFDV
89
C To produce a double precision version, simply:
90
C a. Change CHFDV to DCHFDV wherever it occurs,
91
C b. Change the real declaration to double precision, and
92
C c. Change the constant ZERO to double precision.
96
INTEGER NE, NEXT(2), IERR
97
REAL X1, X2, F1, F2, D1, D2, XE(*), FE(*), DE(*)
99
C DECLARE LOCAL VARIABLES.
102
REAL C2, C2T2, C3, C3T3, DEL1, DEL2, DELTA, H, X, XMI, XMA, ZERO
106
C VALIDITY-CHECK ARGUMENTS.
108
C***FIRST EXECUTABLE STATEMENT CHFDV
109
IF (NE .LT. 1) GO TO 5001
111
IF (H .EQ. ZERO) GO TO 5002
121
C COMPUTE CUBIC COEFFICIENTS (EXPANDED ABOUT X1).
124
DEL1 = (D1 - DELTA)/H
125
DEL2 = (D2 - DELTA)/H
126
C (DELTA IS NO LONGER NEEDED.)
127
C2 = -(DEL1+DEL1 + DEL2)
130
C (H, DEL1 AND DEL2 ARE NO LONGER NEEDED.)
137
FE(I) = F1 + X*(D1 + X*(C2 + X*C3))
138
DE(I) = D1 + X*(C2T2 + X*C3T3)
139
C COUNT EXTRAPOLATION POINTS.
140
IF ( X.LT.XMI ) NEXT(1) = NEXT(1) + 1
141
IF ( X.GT.XMA ) NEXT(2) = NEXT(2) + 1
142
C (NOTE REDUNDANCY--IF EITHER CONDITION IS TRUE, OTHER IS FALSE.)
154
CALL XERMSG ('SLATEC', 'CHFDV',
155
+ 'NUMBER OF EVALUATION POINTS LESS THAN ONE', IERR, 1)
161
CALL XERMSG ('SLATEC', 'CHFDV', 'INTERVAL ENDPOINTS EQUAL', IERR,
164
C------------- LAST LINE OF CHFDV FOLLOWS ------------------------------