BEGIN PROLOGUE PCHFE PURPOSE Evaluate a piecewise cubic Hermite function at an array of points. May be used by itself for Hermite interpolation, or as an evaluator for PCHIM or PCHIC. LIBRARY SLATEC (PCHIP) CATEGORY E3 TYPE SINGLE PRECISION (PCHFE-S, DPCHFE-D) KEYWORDS CUBIC HERMITE EVALUATION, HERMITE INTERPOLATION, PCHIP, PIECEWISE CUBIC EVALUATION AUTHOR Fritsch, F. N., (LLNL) Lawrence Livermore National Laboratory P.O. Box 808 (L-316) Livermore, CA 94550 FTS 532-4275, (510) 422-4275 DESCRIPTION
PCHFE: Piecewise Cubic Hermite Function Evaluator
Evaluates the cubic Hermite function defined by N, X, F, D at the points XE(J), J=1(1)NE.
To provide compatibility with PCHIM and PCHIC, includes an increment between successive values of the F- and D-arrays.
Calling sequence:
PARAMETER (INCFD = ...)
INTEGER N, NE, IERR
REAL X(N), F(INCFD,N), D(INCFD,N), XE(NE), FE(NE)
LOGICAL SKIP
CALL PCHFE (N, X, F, D, INCFD, SKIP, NE, XE, FE, IERR)
Parameters:
N -- (input) number of data points. (Error return if N.LT.2 .)
X -- (input) real array of independent variable values. The elements of X must be strictly increasing: X(I-1) .LT. X(I), I = 2(1)N. (Error return if not.)
F -- (input) real array of function values. F(1+(I-1)*INCFD) is the value corresponding to X(I).
D -- (input) real array of derivative values. D(1+(I-1)*INCFD) is the value corresponding to X(I).
INCFD -- (input) increment between successive values in F and D. (Error return if INCFD.LT.1 .)
SKIP -- (input/output) logical variable which should be set to .TRUE. if the user wishes to skip checks for validity of preceding parameters, or to .FALSE. otherwise. This will save time in case these checks have already been performed (say, in PCHIM or PCHIC). SKIP will be set to .TRUE. on normal return.
NE -- (input) number of evaluation points. (Error return if NE.LT.1 .)
XE -- (input) real array of points at which the function is to be evaluated.
NOTES:
1. The evaluation will be most efficient if the elements
of XE are increasing relative to X;
that is, XE(J) .GE. X(I)
implies XE(K) .GE. X(I), all K.GE.J .
2. If any of the XE are outside the interval [X(1),X(N)],
values are extrapolated from the nearest extreme cubic,
and a warning error is returned.
FE -- (output) real array of values of the cubic Hermite function defined by N, X, F, D at the points XE.
IERR -- (output) error flag. Normal return: IERR = 0 (no errors). Warning error: IERR.GT.0 means that extrapolation was performed at IERR points. "Recoverable" errors: IERR = -1 if N.LT.2 . IERR = -2 if INCFD.LT.1 . IERR = -3 if the X-array is not strictly increasing. IERR = -4 if NE.LT.1 . (The FE-array has not been changed in any of these cases.) NOTE: The above errors are checked in the order listed, and following arguments have NOT been validated.
REFERENCES (NONE) ROUTINES CALLED CHFEV, XERMSG REVISION HISTORY (YYMMDD) 811020 DATE WRITTEN 820803 Minor cosmetic changes for release 1. 870707 Minor cosmetic changes to prologue. 890531 Changed all specific intrinsics to generic. (WRB) 890831 Modified array declarations. (WRB) 890831 REVISION DATE from Version 3.2 891214 Prologue converted to Version 4.0 format. (BAB) 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ) END PROLOGUE PCHFE Programming notes:
To produce a double precision version, simply: a. Change PCHFE to DPCHFE, and CHFEV to DCHFEV, wherever they occur, b. Change the real declaration to double precision,
Most of the coding between the call to CHFEV and the end of the IR-loop could be eliminated if it were permissible to assume that XE is ordered relative to X.
CHFEV does not assume that X1 is less than X2. thus, it would be possible to write a version of PCHFE that assumes a strict- ly decreasing X-array by simply running the IR-loop backwards (and reversing the order of appropriate tests).
The present code has a minor bug, which I have decided is not worth the effort that would be required to fix it. If XE contains points in [X(N-1),X(N)], followed by points .LT. X(N-1), followed by points .GT.X(N), the extrapolation points will be counted (at least) twice in the total returned in IERR.
DECLARE ARGUMENTS.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer | :: | N | ||||
| real | :: | X(*) | ||||
| real | :: | F(INCFD,*) | ||||
| real | :: | D(INCFD,*) | ||||
| integer | :: | INCFD | ||||
| logical | :: | SKIP | ||||
| integer | :: | NE | ||||
| real | :: | XE(*) | ||||
| real | :: | FE(*) | ||||
| integer | :: | IERR |