gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
chfev.c
Go to the documentation of this file.
1 /* chfev.f -- translated by f2c (version 20061008).
2  You must link the resulting object file with libf2c:
3  on Microsoft Windows system, link with libf2c.lib;
4  on Linux or Unix systems, link with .../path/to/libf2c.a -lm
5  or, if you install libf2c.a in a standard place, with -lf2c -lm
6  -- in that order, at the end of the command line, as in
7  cc *.o -lf2c -lm
8  Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
9 
10  http://www.netlib.org/f2c/libf2c.zip
11 */
12 
13 #include "f2c.h"
14 
15 /* Table of constant values */
16 
17 static integer c__1 = 1;
18 
19 /* $Author: ulammers $ */
20 /* $Date: 1997/02/14 14:09:43 $ */
21 /* $Id: chfev.f,v 1.1 1997/02/14 14:09:43 ulammers Exp $ */
22 /* $Source: /usr4/users/aparmar/SAXDAS/pipeline/LE_lemat/RCS/chfev.f,v $ */
23 /* DECK CHFEV */
24 /* Subroutine */ int chfev_(real *x1, real *x2, real *f1, real *f2, real *d1,
25  real *d2, integer *ne, real *xe, real *fe, integer *next, integer *
26  ierr)
27 {
28  /* Initialized data */
29 
30  static real zero = 0.f;
31 
32  /* System generated locals */
33  integer i__1;
34 
35  /* Local variables */
36  static real h__;
37  static integer i__;
38  static real x, c2, c3, xma, xmi, del1, del2, delta;
39  extern /* Subroutine */ int xermsg_(char *, char *, char *, integer *,
40  integer *, ftnlen, ftnlen, ftnlen);
41 
42 /* ***BEGIN PROLOGUE CHFEV */
43 /* ***PURPOSE Evaluate a cubic polynomial given in Hermite form at an */
44 /* array of points. While designed for use by PCHFE, it may */
45 /* be useful directly as an evaluator for a piecewise cubic */
46 /* Hermite function in applications, such as graphing, where */
47 /* the interval is known in advance. */
48 /* ***LIBRARY SLATEC (PCHIP) */
49 /* ***CATEGORY E3 */
50 /* ***TYPE SINGLE PRECISION (CHFEV-S, DCHFEV-D) */
51 /* ***KEYWORDS CUBIC HERMITE EVALUATION, CUBIC POLYNOMIAL EVALUATION, */
52 /* PCHIP */
53 /* ***AUTHOR Fritsch, F. N., (LLNL) */
54 /* Lawrence Livermore National Laboratory */
55 /* P.O. Box 808 (L-316) */
56 /* Livermore, CA 94550 */
57 /* FTS 532-4275, (510) 422-4275 */
58 /* ***DESCRIPTION */
59 
60 /* CHFEV: Cubic Hermite Function EValuator */
61 
62 /* Evaluates the cubic polynomial determined by function values */
63 /* F1,F2 and derivatives D1,D2 on interval (X1,X2) at the points */
64 /* XE(J), J=1(1)NE. */
65 
66 /* ---------------------------------------------------------------------- */
67 
68 /* Calling sequence: */
69 
70 /* INTEGER NE, NEXT(2), IERR */
71 /* REAL X1, X2, F1, F2, D1, D2, XE(NE), FE(NE) */
72 
73 /* CALL CHFEV (X1,X2, F1,F2, D1,D2, NE, XE, FE, NEXT, IERR) */
74 
75 /* Parameters: */
76 
77 /* X1,X2 -- (input) endpoints of interval of definition of cubic. */
78 /* (Error RETURN if X1.EQ.X2 .) */
79 
80 /* F1,F2 -- (input) values of function at X1 and X2, respectively. */
81 
82 /* D1,D2 -- (input) values of derivative at X1 and X2, respectively. */
83 
84 /* NE -- (input) number of evaluation points. (Error RETURN if */
85 /* NE.LT.1 .) */
86 
87 /* XE -- (input) real array of points at which the function is to be */
88 /* evaluated. If any of the XE are outside the interval */
89 /* [X1,X2], a warning error is RETURNed in NEXT. */
90 
91 /* FE -- (output) real array of values of the cubic function defined */
92 /* by X1,X2, F1,F2, D1,D2 at the points XE. */
93 
94 /* NEXT -- (output) integer array indicating number of extrapolation */
95 /* points: */
96 /* NEXT(1) = number of evaluation points to left of interval. */
97 /* NEXT(2) = number of evaluation points to right of interval. */
98 
99 /* IERR -- (output) error flag. */
100 /* Normal RETURN: */
101 /* IERR = 0 (no errors). */
102 /* "Recoverable" errors: */
103 /* IERR = -1 if NE.LT.1 . */
104 /* IERR = -2 if X1.EQ.X2 . */
105 /* (The FE-array has not been changed in either case.) */
106 
107 /* ***REFERENCES (NONE) */
108 /* ***ROUTINES CALLED XERMSG */
109 /* ***REVISION HISTORY (YYMMDD) */
110 /* 811019 DATE WRITTEN */
111 /* 820803 Minor cosmetic changes for release 1. */
112 /* 890411 Added SAVE statements (Vers. 3.2). */
113 /* 890531 Changed all specific intrinsics to generic. (WRB) */
114 /* 890703 Corrected category record. (WRB) */
115 /* 890703 REVISION DATE from Version 3.2 */
116 /* 891214 Prologue converted to Version 4.0 format. (BAB) */
117 /* 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ) */
118 /* ***END PROLOGUE CHFEV */
119 /* Programming notes: */
120 
121 /* To produce a double precision version, simply: */
122 /* a. Change CHFEV to DCHFEV wherever it occurs, */
123 /* b. Change the real declaration to double precision, and */
124 /* c. Change the constant ZERO to double precision. */
125 
126 /* DECLARE ARGUMENTS. */
127 
128 
129 /* DECLARE LOCAL VARIABLES. */
130 
131  /* Parameter adjustments */
132  --next;
133  --fe;
134  --xe;
135 
136  /* Function Body */
137 
138 /* VALIDITY-CHECK ARGUMENTS. */
139 
140 /* ***FIRST EXECUTABLE STATEMENT CHFEV */
141  if (*ne < 1) {
142  goto L5001;
143  }
144  h__ = *x2 - *x1;
145  if (h__ == zero) {
146  goto L5002;
147  }
148 
149 /* INITIALIZE. */
150 
151  *ierr = 0;
152  next[1] = 0;
153  next[2] = 0;
154  xmi = dmin(zero,h__);
155  xma = dmax(zero,h__);
156 
157 /* COMPUTE CUBIC COEFFICIENTS (EXPANDED ABOUT X1). */
158 
159  delta = (*f2 - *f1) / h__;
160  del1 = (*d1 - delta) / h__;
161  del2 = (*d2 - delta) / h__;
162 /* (DELTA IS NO LONGER NEEDED.) */
163  c2 = -(del1 + del1 + del2);
164  c3 = (del1 + del2) / h__;
165 /* (H, DEL1 AND DEL2 ARE NO LONGER NEEDED.) */
166 
167 /* EVALUATION LOOP. */
168 
169  i__1 = *ne;
170  for (i__ = 1; i__ <= i__1; ++i__) {
171  x = xe[i__] - *x1;
172  fe[i__] = *f1 + x * (*d1 + x * (c2 + x * c3));
173 /* COUNT EXTRAPOLATION POINTS. */
174  if (x < xmi) {
175  ++next[1];
176  }
177  if (x > xma) {
178  ++next[2];
179  }
180 /* (NOTE REDUNDANCY--IF EITHER CONDITION IS TRUE, OTHER IS FALSE.) */
181 /* L500: */
182  }
183 
184 /* NORMAL RETURN. */
185 
186  return 0;
187 
188 /* ERROR returns. */
189 
190 L5001:
191 /* NE.LT.1 RETURN. */
192  *ierr = -1;
193  xermsg_("SLATEC", "CHFEV", "NUMBER OF EVALUATION POINTS LESS THAN ONE",
194  ierr, &c__1, (ftnlen)6, (ftnlen)5, (ftnlen)41);
195  return 0;
196 
197 L5002:
198 /* X1.EQ.X2 RETURN. */
199  *ierr = -2;
200  xermsg_("SLATEC", "CHFEV", "INTERVAL ENDPOINTS EQUAL", ierr, &c__1, (
201  ftnlen)6, (ftnlen)5, (ftnlen)24);
202  return 0;
203 /* ------------- LAST LINE OF CHFEV FOLLOWS ------------------------------ */
204 } /* chfev_ */
205 
float * x
int xermsg_(char *libname, char *subname, char *errmsg, integer *errcode, integer *retcode, ftnlen libname_len, ftnlen subname_len, ftnlen errmsg_len)
Definition: xermsg.c:19
static integer c__1
Definition: chfev.c:17
int chfev_(real *x1, real *x2, real *f1, real *f2, real *d1, real *d2, integer *ne, real *xe, real *fe, integer *next, integer *ierr)
Definition: chfev.c:24
gtkIOStream: /tmp/gtkiostream/futureInclusions/cubicInterp/chfev.c Source File
GTK+ IOStream  Beta