1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1996 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
6 |
|
|
7 |
|
/* |
8 |
|
* data.c - routines dealing with interpolated data. |
9 |
– |
* |
10 |
– |
* 6/4/86 |
9 |
|
*/ |
10 |
|
|
11 |
|
#include "standard.h" |
12 |
|
|
13 |
|
#include "color.h" |
14 |
|
|
15 |
+ |
#include "resolu.h" |
16 |
+ |
|
17 |
|
#include "data.h" |
18 |
|
|
19 |
+ |
/* picture memory usage before warning */ |
20 |
+ |
#ifndef PSIZWARN |
21 |
+ |
#ifdef BIGMEM |
22 |
+ |
#define PSIZWARN 3000000 |
23 |
+ |
#else |
24 |
+ |
#define PSIZWARN 1000000 |
25 |
+ |
#endif |
26 |
+ |
#endif |
27 |
|
|
28 |
< |
extern char *libpath; /* library search path */ |
28 |
> |
#ifndef TABSIZ |
29 |
> |
#define TABSIZ 97 /* table size (prime) */ |
30 |
> |
#endif |
31 |
|
|
32 |
< |
static DATARRAY *dlist = NULL; /* data array list */ |
32 |
> |
#define hash(s) (shash(s)%TABSIZ) |
33 |
|
|
24 |
– |
static DATARRAY *plist = NULL; /* picture list */ |
34 |
|
|
35 |
+ |
extern char *getlibpath(); /* library search path */ |
36 |
|
|
37 |
+ |
static DATARRAY *dtab[TABSIZ]; /* data array list */ |
38 |
+ |
|
39 |
+ |
|
40 |
|
DATARRAY * |
41 |
|
getdata(dname) /* get data array dname */ |
42 |
|
char *dname; |
44 |
|
char *dfname; |
45 |
|
FILE *fp; |
46 |
|
int asize; |
47 |
< |
register int i; |
47 |
> |
register int i, j; |
48 |
|
register DATARRAY *dp; |
49 |
|
/* look for array in list */ |
50 |
< |
for (dp = dlist; dp != NULL; dp = dp->next) |
50 |
> |
for (dp = dtab[hash(dname)]; dp != NULL; dp = dp->next) |
51 |
|
if (!strcmp(dname, dp->name)) |
52 |
|
return(dp); /* found! */ |
53 |
|
|
54 |
|
/* |
55 |
|
* If we haven't loaded the data already, we will look |
56 |
< |
* for it in the directorys specified by the library path. |
56 |
> |
* for it in the directories specified by the library path. |
57 |
|
* |
58 |
|
* The file has the following format: |
59 |
|
* |
60 |
< |
* #dimensions |
60 |
> |
* N |
61 |
|
* beg0 end0 n0 |
62 |
|
* beg1 end1 n1 |
63 |
|
* . . . |
64 |
+ |
* begN endN nN |
65 |
|
* data, later dimensions changing faster |
66 |
|
* . . . |
67 |
|
* |
68 |
+ |
* For irregularly spaced points, the following can be |
69 |
+ |
* substituted for begi endi ni: |
70 |
+ |
* |
71 |
+ |
* 0 0 ni p0i p1i .. pni |
72 |
|
*/ |
73 |
|
|
74 |
< |
if ((dfname = getpath(dname, libpath, R_OK)) == NULL) { |
74 |
> |
if ((dfname = getpath(dname, getlibpath(), R_OK)) == NULL) { |
75 |
|
sprintf(errmsg, "cannot find data file \"%s\"", dname); |
76 |
|
error(USER, errmsg); |
77 |
|
} |
60 |
– |
if ((dp = (DATARRAY *)malloc(sizeof(DATARRAY))) == NULL) |
61 |
– |
goto memerr; |
62 |
– |
|
63 |
– |
dp->name = savestr(dname); |
64 |
– |
|
78 |
|
if ((fp = fopen(dfname, "r")) == NULL) { |
79 |
|
sprintf(errmsg, "cannot open data file \"%s\"", dfname); |
80 |
|
error(SYSTEM, errmsg); |
81 |
|
} |
82 |
|
/* get dimensions */ |
83 |
< |
if (fscanf(fp, "%d", &dp->nd) != 1) |
83 |
> |
if (fgetval(fp, 'i', &asize) <= 0) |
84 |
|
goto scanerr; |
85 |
< |
if (dp->nd <= 0 || dp->nd > MAXDIM) { |
85 |
> |
if (asize <= 0 | asize > MAXDDIM) { |
86 |
|
sprintf(errmsg, "bad number of dimensions for \"%s\"", dname); |
87 |
|
error(USER, errmsg); |
88 |
|
} |
89 |
+ |
if ((dp = (DATARRAY *)malloc(sizeof(DATARRAY))) == NULL) |
90 |
+ |
goto memerr; |
91 |
+ |
dp->name = savestr(dname); |
92 |
+ |
dp->type = DATATY; |
93 |
+ |
dp->nd = asize; |
94 |
|
asize = 1; |
95 |
|
for (i = 0; i < dp->nd; i++) { |
96 |
< |
if (fscanf(fp, "%lf %lf %d", |
79 |
< |
&dp->dim[i].org, &dp->dim[i].siz, |
80 |
< |
&dp->dim[i].ne) != 3) |
96 |
> |
if (fgetval(fp, DATATY, &dp->dim[i].org) <= 0) |
97 |
|
goto scanerr; |
98 |
< |
dp->dim[i].siz -= dp->dim[i].org; |
98 |
> |
if (fgetval(fp, DATATY, &dp->dim[i].siz) <= 0) |
99 |
> |
goto scanerr; |
100 |
> |
if (fgetval(fp, 'i', &dp->dim[i].ne) <= 0) |
101 |
> |
goto scanerr; |
102 |
> |
if (dp->dim[i].ne < 2) |
103 |
> |
goto scanerr; |
104 |
|
asize *= dp->dim[i].ne; |
105 |
+ |
if ((dp->dim[i].siz -= dp->dim[i].org) == 0) { |
106 |
+ |
dp->dim[i].p = (DATATYPE *) |
107 |
+ |
malloc(dp->dim[i].ne*sizeof(DATATYPE)); |
108 |
+ |
if (dp->dim[i].p == NULL) |
109 |
+ |
goto memerr; |
110 |
+ |
for (j = 0; j < dp->dim[i].ne; j++) |
111 |
+ |
if (fgetval(fp, DATATY, &dp->dim[i].p[j]) <= 0) |
112 |
+ |
goto scanerr; |
113 |
+ |
for (j = 1; j < dp->dim[i].ne-1; j++) |
114 |
+ |
if ((dp->dim[i].p[j-1] < dp->dim[i].p[j]) != |
115 |
+ |
(dp->dim[i].p[j] < dp->dim[i].p[j+1])) |
116 |
+ |
goto scanerr; |
117 |
+ |
dp->dim[i].org = dp->dim[i].p[0]; |
118 |
+ |
dp->dim[i].siz = dp->dim[i].p[dp->dim[i].ne-1] |
119 |
+ |
- dp->dim[i].p[0]; |
120 |
+ |
} else |
121 |
+ |
dp->dim[i].p = NULL; |
122 |
|
} |
123 |
< |
if ((dp->arr = (DATATYPE *)malloc(asize*sizeof(DATATYPE))) == NULL) |
123 |
> |
if ((dp->arr.d = (DATATYPE *)malloc(asize*sizeof(DATATYPE))) == NULL) |
124 |
|
goto memerr; |
125 |
|
|
126 |
|
for (i = 0; i < asize; i++) |
127 |
< |
if (fscanf(fp, DSCANF, &dp->arr[i]) != 1) |
127 |
> |
if (fgetval(fp, DATATY, &dp->arr.d[i]) <= 0) |
128 |
|
goto scanerr; |
91 |
– |
|
129 |
|
fclose(fp); |
130 |
< |
dp->next = dlist; |
131 |
< |
return(dlist = dp); |
130 |
> |
i = hash(dname); |
131 |
> |
dp->next = dtab[i]; |
132 |
> |
return(dtab[i] = dp); |
133 |
|
|
134 |
|
memerr: |
135 |
|
error(SYSTEM, "out of memory in getdata"); |
140 |
|
} |
141 |
|
|
142 |
|
|
143 |
+ |
static |
144 |
+ |
headaspect(s, iap) /* check string for aspect ratio */ |
145 |
+ |
char *s; |
146 |
+ |
double *iap; |
147 |
+ |
{ |
148 |
+ |
if (isaspect(s)) |
149 |
+ |
*iap *= aspectval(s); |
150 |
+ |
} |
151 |
+ |
|
152 |
+ |
|
153 |
|
DATARRAY * |
154 |
|
getpict(pname) /* get picture pname */ |
155 |
|
char *pname; |
156 |
|
{ |
157 |
< |
extern char *libpath; |
157 |
> |
double inpaspect; |
158 |
|
char *pfname; |
159 |
|
FILE *fp; |
160 |
< |
COLOR *scanin; |
161 |
< |
int width, height; |
162 |
< |
int x, y; |
163 |
< |
register int i; |
160 |
> |
COLR *scanin; |
161 |
> |
int sl, ns; |
162 |
> |
RESOLU inpres; |
163 |
> |
FLOAT loc[2]; |
164 |
> |
int y; |
165 |
> |
register int x, i; |
166 |
|
register DATARRAY *pp; |
167 |
|
/* look for array in list */ |
168 |
< |
for (pp = plist; pp != NULL; pp = pp->next) |
168 |
> |
for (pp = dtab[hash(pname)]; pp != NULL; pp = pp->next) |
169 |
|
if (!strcmp(pname, pp->name)) |
170 |
|
return(pp); /* found! */ |
171 |
|
|
172 |
< |
if ((pfname = getpath(pname, libpath, R_OK)) == NULL) { |
172 |
> |
if ((pfname = getpath(pname, getlibpath(), R_OK)) == NULL) { |
173 |
|
sprintf(errmsg, "cannot find picture file \"%s\"", pname); |
174 |
|
error(USER, errmsg); |
175 |
|
} |
176 |
< |
if ((pp = (DATARRAY *)calloc(3, sizeof(DATARRAY))) == NULL) |
176 |
> |
if ((pp = (DATARRAY *)malloc(3*sizeof(DATARRAY))) == NULL) |
177 |
|
goto memerr; |
178 |
|
|
179 |
< |
pp[0].name = |
130 |
< |
pp[1].name = |
131 |
< |
pp[2].name = savestr(pname); |
179 |
> |
pp[0].name = savestr(pname); |
180 |
|
|
181 |
|
if ((fp = fopen(pfname, "r")) == NULL) { |
182 |
|
sprintf(errmsg, "cannot open picture file \"%s\"", pfname); |
183 |
|
error(SYSTEM, errmsg); |
184 |
|
} |
185 |
+ |
#ifdef MSDOS |
186 |
+ |
setmode(fileno(fp), O_BINARY); |
187 |
+ |
#endif |
188 |
|
/* get dimensions */ |
189 |
< |
getheader(fp, NULL); |
190 |
< |
if (fgetresolu(&width, &height, fp) != (YMAJOR|YDECR)) |
189 |
> |
inpaspect = 1.0; |
190 |
> |
getheader(fp, headaspect, &inpaspect); |
191 |
> |
if (!fgetsresolu(&inpres, fp)) |
192 |
|
goto readerr; |
193 |
< |
for (i = 0; i < 3; i++) { |
194 |
< |
pp[i].nd = 2; |
195 |
< |
pp[i].dim[0].ne = width; |
196 |
< |
pp[i].dim[1].ne = height; |
197 |
< |
pp[i].dim[0].org = |
198 |
< |
pp[i].dim[1].org = 0.0; |
199 |
< |
if (width <= height) { |
200 |
< |
pp[i].dim[0].siz = 1.0; |
201 |
< |
pp[i].dim[1].siz = (double)height/width; |
202 |
< |
} else { |
203 |
< |
pp[i].dim[0].siz = (double)width/height; |
204 |
< |
pp[i].dim[1].siz = 1.0; |
205 |
< |
} |
154 |
< |
pp[i].arr = (DATATYPE *)malloc(width*height*sizeof(DATATYPE)); |
155 |
< |
if (pp[i].arr == NULL) |
156 |
< |
goto memerr; |
193 |
> |
pp[0].nd = 2; |
194 |
> |
pp[0].dim[0].ne = inpres.yr; |
195 |
> |
pp[0].dim[1].ne = inpres.xr; |
196 |
> |
pp[0].dim[0].org = |
197 |
> |
pp[0].dim[1].org = 0.0; |
198 |
> |
if (inpres.xr <= inpres.yr*inpaspect) { |
199 |
> |
pp[0].dim[0].siz = inpaspect * |
200 |
> |
(double)inpres.yr/inpres.xr; |
201 |
> |
pp[0].dim[1].siz = 1.0; |
202 |
> |
} else { |
203 |
> |
pp[0].dim[0].siz = 1.0; |
204 |
> |
pp[0].dim[1].siz = (double)inpres.xr/inpres.yr / |
205 |
> |
inpaspect; |
206 |
|
} |
207 |
+ |
pp[0].dim[0].p = pp[0].dim[1].p = NULL; |
208 |
+ |
sl = scanlen(&inpres); /* allocate array */ |
209 |
+ |
ns = numscans(&inpres); |
210 |
+ |
i = ns*sl*sizeof(COLR); |
211 |
+ |
#if PSIZWARN |
212 |
+ |
if (i > PSIZWARN) { /* memory warning */ |
213 |
+ |
sprintf(errmsg, "picture file \"%s\" using %d bytes of memory", |
214 |
+ |
pname, i); |
215 |
+ |
error(WARNING, errmsg); |
216 |
+ |
} |
217 |
+ |
#endif |
218 |
+ |
if ((pp[0].arr.c = (COLR *)malloc(i)) == NULL) |
219 |
+ |
goto memerr; |
220 |
|
/* load picture */ |
221 |
< |
if ((scanin = (COLOR *)malloc(width*sizeof(COLOR))) == NULL) |
221 |
> |
if ((scanin = (COLR *)malloc(sl*sizeof(COLR))) == NULL) |
222 |
|
goto memerr; |
223 |
< |
for (y = height-1; y >= 0; y--) { |
224 |
< |
if (freadscan(scanin, width, fp) < 0) |
223 |
> |
for (y = 0; y < ns; y++) { |
224 |
> |
if (freadcolrs(scanin, sl, fp) < 0) |
225 |
|
goto readerr; |
226 |
< |
for (x = 0; x < width; x++) |
227 |
< |
for (i = 0; i < 3; i++) |
228 |
< |
pp[i].arr[x*height+y] = colval(scanin[x],i); |
226 |
> |
for (x = 0; x < sl; x++) { |
227 |
> |
pix2loc(loc, &inpres, x, y); |
228 |
> |
i = (int)(loc[1]*inpres.yr)*inpres.xr + |
229 |
> |
(int)(loc[0]*inpres.xr); |
230 |
> |
copycolr(pp[0].arr.c[i], scanin[x]); |
231 |
> |
} |
232 |
|
} |
233 |
|
free((char *)scanin); |
234 |
|
fclose(fp); |
235 |
< |
pp[0].next = |
236 |
< |
pp[1].next = |
237 |
< |
pp[2].next = plist; |
238 |
< |
return(plist = pp); |
235 |
> |
i = hash(pname); |
236 |
> |
pp[0].next = dtab[i]; /* link into picture list */ |
237 |
> |
copystruct(&pp[1], &pp[0]); |
238 |
> |
copystruct(&pp[2], &pp[0]); |
239 |
> |
pp[0].type = RED; /* differentiate RGB records */ |
240 |
> |
pp[1].type = GRN; |
241 |
> |
pp[2].type = BLU; |
242 |
> |
return(dtab[i] = pp); |
243 |
|
|
244 |
|
memerr: |
245 |
|
error(SYSTEM, "out of memory in getpict"); |
252 |
|
freedata(dname) /* free memory associated with dname */ |
253 |
|
char *dname; |
254 |
|
{ |
255 |
+ |
DATARRAY head; |
256 |
+ |
int hval, nents; |
257 |
|
register DATARRAY *dp, *dpl; |
258 |
+ |
register int i; |
259 |
|
|
260 |
< |
for (dpl = NULL, dp = dlist; dp != NULL; dpl = dp, dp = dp->next) |
261 |
< |
if (!strcmp(dname, dp->name)) { |
262 |
< |
if (dpl == NULL) |
263 |
< |
dlist = dp->next; |
264 |
< |
else |
260 |
> |
if (dname == NULL) { /* free all if NULL */ |
261 |
> |
hval = 0; nents = TABSIZ; |
262 |
> |
} else { |
263 |
> |
hval = hash(dname); nents = 1; |
264 |
> |
} |
265 |
> |
while (nents--) { |
266 |
> |
head.next = dtab[hval]; |
267 |
> |
dpl = &head; |
268 |
> |
while ((dp = dpl->next) != NULL) |
269 |
> |
if (dname == NULL || !strcmp(dname, dp->name)) { |
270 |
|
dpl->next = dp->next; |
271 |
< |
free((char *)dp->arr); |
272 |
< |
freestr(dp->name); |
273 |
< |
free((char *)dp); |
274 |
< |
return; |
275 |
< |
} |
271 |
> |
if (dp->type == DATATY) |
272 |
> |
free((char *)dp->arr.d); |
273 |
> |
else |
274 |
> |
free((char *)dp->arr.c); |
275 |
> |
for (i = 0; i < dp->nd; i++) |
276 |
> |
if (dp->dim[i].p != NULL) |
277 |
> |
free((char *)dp->dim[i].p); |
278 |
> |
freestr(dp->name); |
279 |
> |
free((char *)dp); |
280 |
> |
} else |
281 |
> |
dpl = dp; |
282 |
> |
dtab[hval++] = head.next; |
283 |
> |
} |
284 |
|
} |
285 |
|
|
286 |
|
|
202 |
– |
freepict(pname) /* free memory associated with pname */ |
203 |
– |
char *pname; |
204 |
– |
{ |
205 |
– |
register DATARRAY *pp, *ppl; |
206 |
– |
|
207 |
– |
for (ppl = NULL, pp = plist; pp != NULL; ppl = pp, pp = pp->next) |
208 |
– |
if (!strcmp(pname, pp->name)) { |
209 |
– |
if (ppl == NULL) |
210 |
– |
plist = pp->next; |
211 |
– |
else |
212 |
– |
ppl->next = pp->next; |
213 |
– |
free((char *)pp[0].arr); |
214 |
– |
free((char *)pp[1].arr); |
215 |
– |
free((char *)pp[2].arr); |
216 |
– |
freestr(pp[0].name); |
217 |
– |
free((char *)pp); |
218 |
– |
return; |
219 |
– |
} |
220 |
– |
} |
221 |
– |
|
222 |
– |
|
287 |
|
double |
288 |
|
datavalue(dp, pt) /* interpolate data value at a point */ |
289 |
|
register DATARRAY *dp; |
290 |
< |
double *pt; |
290 |
> |
double *pt; |
291 |
|
{ |
292 |
|
DATARRAY sd; |
293 |
|
int asize; |
294 |
+ |
int lower, upper; |
295 |
|
register int i; |
296 |
< |
double x, y, y0, y1; |
297 |
< |
|
298 |
< |
sd.nd = dp->nd - 1; |
299 |
< |
asize = 1; |
300 |
< |
for (i = 0; i < sd.nd; i++) { |
301 |
< |
sd.dim[i].org = dp->dim[i+1].org; |
302 |
< |
sd.dim[i].siz = dp->dim[i+1].siz; |
303 |
< |
asize *= sd.dim[i].ne = dp->dim[i+1].ne; |
296 |
> |
double x, y0, y1; |
297 |
> |
/* set up dimensions for recursion */ |
298 |
> |
if (dp->nd > 1) { |
299 |
> |
sd.name = dp->name; |
300 |
> |
sd.type = dp->type; |
301 |
> |
sd.nd = dp->nd - 1; |
302 |
> |
asize = 1; |
303 |
> |
for (i = 0; i < sd.nd; i++) { |
304 |
> |
sd.dim[i].org = dp->dim[i+1].org; |
305 |
> |
sd.dim[i].siz = dp->dim[i+1].siz; |
306 |
> |
sd.dim[i].p = dp->dim[i+1].p; |
307 |
> |
asize *= sd.dim[i].ne = dp->dim[i+1].ne; |
308 |
> |
} |
309 |
|
} |
310 |
< |
|
311 |
< |
x = (pt[0] - dp->dim[0].org)/dp->dim[0].siz; |
312 |
< |
|
313 |
< |
x *= dp->dim[0].ne - 1; |
314 |
< |
|
315 |
< |
i = x; |
316 |
< |
if (i < 0) |
317 |
< |
i = 0; |
318 |
< |
else if (i > dp->dim[0].ne - 2) |
319 |
< |
i = dp->dim[0].ne - 2; |
320 |
< |
|
321 |
< |
if (dp->nd == 1) { |
322 |
< |
y0 = dp->arr[i]; |
323 |
< |
y1 = dp->arr[i+1]; |
310 |
> |
/* get independent variable */ |
311 |
> |
if (dp->dim[0].p == NULL) { /* evenly spaced points */ |
312 |
> |
x = (pt[0] - dp->dim[0].org)/dp->dim[0].siz; |
313 |
> |
x *= (double)(dp->dim[0].ne - 1); |
314 |
> |
i = x; |
315 |
> |
if (i < 0) |
316 |
> |
i = 0; |
317 |
> |
else if (i > dp->dim[0].ne - 2) |
318 |
> |
i = dp->dim[0].ne - 2; |
319 |
> |
} else { /* unevenly spaced points */ |
320 |
> |
if (dp->dim[0].siz > 0.0) { |
321 |
> |
lower = 0; |
322 |
> |
upper = dp->dim[0].ne; |
323 |
> |
} else { |
324 |
> |
lower = dp->dim[0].ne; |
325 |
> |
upper = 0; |
326 |
> |
} |
327 |
> |
do { |
328 |
> |
i = (lower + upper) >> 1; |
329 |
> |
if (pt[0] >= dp->dim[0].p[i]) |
330 |
> |
lower = i; |
331 |
> |
else |
332 |
> |
upper = i; |
333 |
> |
} while (i != (lower + upper) >> 1); |
334 |
> |
if (i > dp->dim[0].ne - 2) |
335 |
> |
i = dp->dim[0].ne - 2; |
336 |
> |
x = i + (pt[0] - dp->dim[0].p[i]) / |
337 |
> |
(dp->dim[0].p[i+1] - dp->dim[0].p[i]); |
338 |
> |
} |
339 |
> |
/* get dependent variable */ |
340 |
> |
if (dp->nd > 1) { |
341 |
> |
if (dp->type == DATATY) { |
342 |
> |
sd.arr.d = dp->arr.d + i*asize; |
343 |
> |
y0 = datavalue(&sd, pt+1); |
344 |
> |
sd.arr.d = dp->arr.d + (i+1)*asize; |
345 |
> |
y1 = datavalue(&sd, pt+1); |
346 |
> |
} else { |
347 |
> |
sd.arr.c = dp->arr.c + i*asize; |
348 |
> |
y0 = datavalue(&sd, pt+1); |
349 |
> |
sd.arr.c = dp->arr.c + (i+1)*asize; |
350 |
> |
y1 = datavalue(&sd, pt+1); |
351 |
> |
} |
352 |
|
} else { |
353 |
< |
sd.arr = &dp->arr[i*asize]; |
354 |
< |
y0 = datavalue(&sd, pt+1); |
355 |
< |
sd.arr = &dp->arr[(i+1)*asize]; |
356 |
< |
y1 = datavalue(&sd, pt+1); |
353 |
> |
if (dp->type == DATATY) { |
354 |
> |
y0 = dp->arr.d[i]; |
355 |
> |
y1 = dp->arr.d[i+1]; |
356 |
> |
} else { |
357 |
> |
y0 = colrval(dp->arr.c[i],dp->type); |
358 |
> |
y1 = colrval(dp->arr.c[i+1],dp->type); |
359 |
> |
} |
360 |
|
} |
260 |
– |
|
361 |
|
/* |
362 |
|
* Extrapolate as far as one division, then |
363 |
|
* taper off harmonically to zero. |
364 |
|
*/ |
365 |
|
if (x > i+2) |
366 |
< |
y = (2*y1-y0)/(x-i-1); |
267 |
< |
else if (x < i-1) |
268 |
< |
y = (2*y0-y1)/(i-x); |
269 |
< |
else |
270 |
< |
y = y0*((i+1)-x) + y1*(x-i); |
366 |
> |
return( (2*y1-y0)/(x-(i-1)) ); |
367 |
|
|
368 |
< |
return(y); |
368 |
> |
if (x < i-1) |
369 |
> |
return( (2*y0-y1)/(i-x) ); |
370 |
> |
|
371 |
> |
return( y0*((i+1)-x) + y1*(x-i) ); |
372 |
|
} |