gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
chfev.f
Go to the documentation of this file.
1 C $Author: ulammers $
2 C $Date: 1997/02/14 14:09:43 $
3 C $Id: chfev.f,v 1.1 1997/02/14 14:09:43 ulammers Exp $
4 C $Source: /usr4/users/aparmar/SAXDAS/pipeline/LE_lemat/RCS/chfev.f,v $
5 *DECK CHFEV
6  SUBROUTINE chfev (X1, X2, F1, F2, D1, D2, NE, XE, FE, NEXT, IERR)
7 C***BEGIN PROLOGUE CHFEV
8 C***PURPOSE Evaluate a cubic polynomial given in Hermite form at an
9 C array of points. While designed for use by PCHFE, it may
10 C be useful directly as an evaluator for a piecewise cubic
11 C Hermite function in applications, such as graphing, where
12 C the interval is known in advance.
13 C***LIBRARY SLATEC (PCHIP)
14 C***CATEGORY E3
15 C***TYPE SINGLE PRECISION (CHFEV-S, DCHFEV-D)
16 C***KEYWORDS CUBIC HERMITE EVALUATION, CUBIC POLYNOMIAL EVALUATION,
17 C PCHIP
18 C***AUTHOR Fritsch, F. N., (LLNL)
19 C Lawrence Livermore National Laboratory
20 C P.O. Box 808 (L-316)
21 C Livermore, CA 94550
22 C FTS 532-4275, (510) 422-4275
23 C***DESCRIPTION
24 C
25 C CHFEV: Cubic Hermite Function EValuator
26 C
27 C Evaluates the cubic polynomial determined by function values
28 C F1,F2 and derivatives D1,D2 on interval (X1,X2) at the points
29 C XE(J), J=1(1)NE.
30 C
31 C ----------------------------------------------------------------------
32 C
33 C Calling sequence:
34 C
35 C INTEGER NE, NEXT(2), IERR
36 C REAL X1, X2, F1, F2, D1, D2, XE(NE), FE(NE)
37 C
38 C CALL CHFEV (X1,X2, F1,F2, D1,D2, NE, XE, FE, NEXT, IERR)
39 C
40 C Parameters:
41 C
42 C X1,X2 -- (input) endpoints of interval of definition of cubic.
43 C (Error RETURN if X1.EQ.X2 .)
44 C
45 C F1,F2 -- (input) values of function at X1 and X2, respectively.
46 C
47 C D1,D2 -- (input) values of derivative at X1 and X2, respectively.
48 C
49 C NE -- (input) number of evaluation points. (Error RETURN if
50 C NE.LT.1 .)
51 C
52 C XE -- (input) real array of points at which the function is to be
53 C evaluated. If any of the XE are outside the interval
54 C [X1,X2], a warning error is RETURNed in NEXT.
55 C
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.
58 C
59 C NEXT -- (output) integer array indicating number of extrapolation
60 C points:
61 C NEXT(1) = number of evaluation points to left of interval.
62 C NEXT(2) = number of evaluation points to right of interval.
63 C
64 C IERR -- (output) error flag.
65 C Normal RETURN:
66 C IERR = 0 (no errors).
67 C "Recoverable" errors:
68 C IERR = -1 if NE.LT.1 .
69 C IERR = -2 if X1.EQ.X2 .
70 C (The FE-array has not been changed in either case.)
71 C
72 C***REFERENCES (NONE)
73 C***ROUTINES CALLED XERMSG
74 C***REVISION HISTORY (YYMMDD)
75 C 811019 DATE WRITTEN
76 C 820803 Minor cosmetic changes for release 1.
77 C 890411 Added SAVE statements (Vers. 3.2).
78 C 890531 Changed all specific intrinsics to generic. (WRB)
79 C 890703 Corrected category record. (WRB)
80 C 890703 REVISION DATE from Version 3.2
81 C 891214 Prologue converted to Version 4.0 format. (BAB)
82 C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
83 C***END PROLOGUE CHFEV
84 C Programming notes:
85 C
86 C To produce a double precision version, simply:
87 C a. Change CHFEV to DCHFEV wherever it occurs,
88 C b. Change the real declaration to double precision, and
89 C c. Change the constant ZERO to double precision.
90 C
91 C DECLARE ARGUMENTS.
92 C
93  INTEGER NE, NEXT(2), IERR
94  REAL X1, X2, F1, F2, D1, D2, XE(*), FE(*)
95 C
96 C DECLARE LOCAL VARIABLES.
97 C
98  INTEGER I
99  REAL C2, C3, DEL1, DEL2, DELTA, H, X, XMI, XMA, ZERO
100  SAVE zero
101  DATA zero /0./
102 C
103 C VALIDITY-CHECK ARGUMENTS.
104 C
105 C***FIRST EXECUTABLE STATEMENT CHFEV
106  IF (ne .LT. 1) GO TO 5001
107  h = x2 - x1
108  IF (h .EQ. zero) GO TO 5002
109 C
110 C INITIALIZE.
111 C
112  ierr = 0
113  next(1) = 0
114  next(2) = 0
115  xmi = min(zero, h)
116  xma = max(zero, h)
117 C
118 C COMPUTE CUBIC COEFFICIENTS (EXPANDED ABOUT X1).
119 C
120  delta = (f2 - f1)/h
121  del1 = (d1 - delta)/h
122  del2 = (d2 - delta)/h
123 C (DELTA IS NO LONGER NEEDED.)
124  c2 = -(del1+del1 + del2)
125  c3 = (del1 + del2)/h
126 C (H, DEL1 AND DEL2 ARE NO LONGER NEEDED.)
127 C
128 C EVALUATION LOOP.
129 C
130  DO 500 i = 1, ne
131  x = xe(i) - x1
132  fe(i) = f1 + x*(d1 + x*(c2 + x*c3))
133 C COUNT EXTRAPOLATION POINTS.
134  IF ( x .LT. xmi ) next(1) = next(1) + 1
135  IF ( x .GT. xma ) next(2) = next(2) + 1
136 C (NOTE REDUNDANCY--IF EITHER CONDITION IS TRUE, OTHER IS FALSE.)
137  500 CONTINUE
138 C
139 C NORMAL RETURN.
140 C
141  RETURN
142 C
143 C ERROR returns.
144 C
145  5001 CONTINUE
146 C NE.LT.1 RETURN.
147  ierr = -1
148  CALL xermsg ('SLATEC', 'CHFEV',
149  + 'NUMBER OF EVALUATION POINTS LESS THAN ONE', ierr, 1)
150  RETURN
151 C
152  5002 CONTINUE
153 C X1.EQ.X2 RETURN.
154  ierr = -2
155  CALL xermsg ('SLATEC', 'CHFEV', 'INTERVAL ENDPOINTS EQUAL', ierr,
156  + 1)
157  RETURN
158 C------------- LAST LINE OF CHFEV FOLLOWS ------------------------------
159  END
subroutine xermsg(LIBNAME, SUBNAME, ERRMSG, ERRCODE, RETCODE)
Definition: xermsg.f:2
subroutine chfev(X1, X2, F1, F2, D1, D2, NE, XE, FE, NEXT, IERR)
Definition: chfev.f:7
gtkIOStream: /tmp/gtkiostream/futureInclusions/cubicInterp/chfev.f Source File
GTK+ IOStream  Beta