blob: 12b16b0fde1a01a08989d534db934f98626dbf79 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
.help
asifit -- fit interpolator to data
This version uses the "basis-spline" representation for the spline.
It stores the data array itself for the polynomial interpolants.
.endhelp
procedure asifit(datain,n,coeff)
include "interpdef.h"
include "asidef.h"
real datain[ARB] # data array
int n # no. of data points
real coeff[ARB]
int i
begin
NPTS = n
# error trap - check data array for size
switch (ITYPEI) {
case IT_SPLINE3:
if(n < 4)
call error(ASIFITERR,"too few points for spline")
case IT_POLY5:
if(n < 6)
call error(ASIFITERR,"too few points for poly5")
case IT_POLY3:
if(n < 4)
call error(ASIFITERR,"too few points for poly3")
case IT_LINEAR:
if(n < 2)
call error(ASIFITERR,"too few points for linear")
default:
if(n < 1)
call error(ASIFITERR,"too few points for interpolation")
}
do i = 1,n
coeff[COFF + i] = datain[i]
if (ITYPEI == IT_SPLINE3) {
# specify natural end conditions - second deriv. zero
coeff[COFF] = 0.
coeff[COFF+n+1] = 0.
# fit spline - generate b-spline coefficients.
call iif_spline(coeff[COFF],coeff[COFF + n + 2],n)
} else { # not the spline
# We extend array to take care of values near edge.
# Assign arbitrary values in case there are only a few points.
for(i = n + 1; i < 5; i = i + 1)
coeff[COFF + i] = coeff[COFF + n]
# Extend for worst case - poly 5 may need 3 extra points.
do i = 1,3 { # same recipe as project
coeff[COFF+1 - i] = 2. * coeff[COFF + 1] -
coeff[COFF + 1 + i]
coeff[COFF+n + i] = 2. * coeff[COFF + n] -
coeff[COFF + n - i]
}
}
return
end
|