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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <math/iminterp.h>
include "im1interpdef.h"
# ASIGRL -- Procedure to find the integral of the interpolant from a to
# b be assuming that both a and b land in the array.
real procedure asigrl (asi, a, b)
pointer asi # interpolant descriptor
real a # lower limit for integral
real b # upper limit for integral
int neara, nearb, i, j, nterms, index
real deltaxa, deltaxb, accum, xa, xb, pcoeff[MAX_NDERIVS]
pointer c0ptr, n0ptr
begin
# Flip order and sign at end.
xa = a
xb = b
if (a > b) {
xa = b
xb = a
}
# Initialize.
c0ptr = ASI_COEFF(asi) - 1 + ASI_OFFSET(asi)
neara = xa
nearb = xb
accum = 0.
switch (ASI_TYPE(asi)) {
case II_NEAREST, II_SINC, II_LSINC, II_DRIZZLE:
nterms = 0
case II_LINEAR:
nterms = 1
case II_POLY3:
nterms = 4
case II_POLY5:
nterms = 6
case II_SPLINE3:
nterms = 4
}
# NEAREST_NEIGHBOR, LINEAR, SINC and LSINC are handled differently
# because of storage. Also probably good for speed in the case of
# LINEAR and NEAREST_NEIGHBOUR.
# NEAREST_NEIGHBOR
switch (ASI_TYPE(asi)) {
case II_NEAREST:
# Reset segment to center values.
neara = xa + 0.5
nearb = xb + 0.5
# Set up for first segment.
deltaxa = xa - neara
# For clarity one segment case is handled separately.
# Only one segment involved.
if (nearb == neara) {
deltaxb = xb - nearb
n0ptr = c0ptr + neara
accum = accum + (deltaxb - deltaxa) * COEFF(n0ptr)
# More than one segment.
} else {
# First segment.
n0ptr = c0ptr + neara
accum = accum + (0.5 - deltaxa) * COEFF(n0ptr)
# Middle segment.
do j = neara + 1, nearb - 1 {
n0ptr = c0ptr + j
accum = accum + COEFF(n0ptr)
}
# Last segment.
n0ptr = c0ptr + nearb
deltaxb = xb - nearb
accum = accum + (deltaxb + 0.5) * COEFF(n0ptr)
}
# LINEAR
case II_LINEAR:
# Set up for first segment.
deltaxa = xa - neara
# For clarity one segment case is handled separately.
# Only one segment is involved.
if (nearb == neara) {
deltaxb = xb - nearb
n0ptr = c0ptr + neara
accum = accum + (deltaxb - deltaxa) * COEFF(n0ptr) +
0.5 * (COEFF(n0ptr+1) - COEFF(n0ptr)) *
(deltaxb * deltaxb - deltaxa * deltaxa)
# More than one segment.
} else {
# First segment.
n0ptr = c0ptr + neara
accum = accum + (1. - deltaxa) * COEFF(n0ptr) +
0.5 * (COEFF(n0ptr+1) - COEFF(n0ptr)) *
(1. - deltaxa * deltaxa)
# Middle segment.
do j = neara + 1, nearb - 1 {
n0ptr = c0ptr + j
accum = accum + 0.5 * (COEFF(n0ptr+1) + COEFF(n0ptr))
}
# Last segment.
n0ptr = c0ptr + nearb
deltaxb = xb - nearb
accum = accum + COEFF(n0ptr) * deltaxb + 0.5 *
(COEFF(n0ptr+1) - COEFF(n0ptr)) * deltaxb * deltaxb
}
# SINC
case II_SINC, II_LSINC:
call ii_sincigrl (xa, xb, accum, COEFF(ASI_COEFF(asi) +
ASI_OFFSET(asi)), ASI_NCOEFF(asi), ASI_NSINC(asi), DX)
# DRIZZLE
case II_DRIZZLE:
if (ASI_PIXFRAC(asi) >= 1.0)
call ii_dzigrl1 (xa, xb, accum, COEFF(ASI_COEFF(asi) +
ASI_OFFSET(asi)))
else
call ii_dzigrl (xa, xb, accum, COEFF(ASI_COEFF(asi) +
ASI_OFFSET(asi)), ASI_PIXFRAC(asi))
# A higher order interpolant.
default:
# Set up for first segment.
deltaxa = xa - neara
# For clarity one segment case is handled separately.
# Only one segment involved.
if (nearb == neara) {
deltaxb = xb - nearb
n0ptr = c0ptr + neara
index = ASI_OFFSET(asi) + neara
call ii_getpcoeff (COEFF(ASI_COEFF(asi)), index, pcoeff,
ASI_TYPE(asi))
do i = 1, nterms
accum = accum + (1./i) * pcoeff[i] *
(deltaxb ** i - deltaxa ** i)
# More than one segment.
} else {
# First segment.
index = ASI_OFFSET(asi) + neara
call ii_getpcoeff (COEFF(ASI_COEFF(asi)), index, pcoeff,
ASI_TYPE(asi))
do i = 1, nterms
accum = accum + (1./i) * pcoeff[i] * (1. - deltaxa ** i)
# Middle segment.
do j = neara + 1, nearb - 1 {
index = ASI_OFFSET(asi) + j
call ii_getpcoeff (COEFF(ASI_COEFF(asi)),
index, pcoeff, ASI_TYPE(asi))
do i = 1, nterms
accum = accum + (1./i) * pcoeff[i]
}
# Last segment.
index = ASI_OFFSET(asi) + nearb
deltaxb = xb - nearb
call ii_getpcoeff (COEFF(ASI_COEFF(asi)), index, pcoeff,
ASI_TYPE(asi))
do i = 1, nterms
accum = accum + (1./i) * pcoeff[i] * deltaxb ** i
}
}
if (a < b)
return (accum)
else
return (-accum)
end
|