blob: 6601daaeb0dda6ec85071b78a37e6dd9d31bf0b5 (
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
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
# ABSU -- Vector block sum. Each pixel in the output vector is the
# sum of the input vector over a block of pixels. The input vector must
# be at least (nblocks * npix_per_block) pixels in length.
procedure absu$t (a, b, nblocks, npix_per_block)
PIXEL a[ARB] # input vector
PIXEL b[nblocks] # output vector
int nblocks # number of blocks (pixels in output vector)
int npix_per_block # number of input pixels per block
$if (datatype == cs)
long sum
$else $if (datatype == il)
real sum
$else
PIXEL sum
$endif $endif
int i, j
int block_offset, next_block, block_length
begin
block_offset = 1
block_length = npix_per_block
if (block_length <= 1)
call amov$t (a[block_offset], b, nblocks)
else {
do j = 1, nblocks {
next_block = block_offset + block_length
sum = 0
do i = block_offset, next_block - 1
sum = sum + a[i]
b[j] = sum
block_offset = next_block
}
}
end
|