aboutsummaryrefslogtreecommitdiff
path: root/sys/vops/asum.gx
blob: 716d2b537b9b44a44ec45239999a766c77ccda2b (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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

# ASUM -- Vector sum.  Take care to prevent integer overflow by returning
# a floating point sum.

$if (datatype == csir)
real procedure asum$t (a, npix)
$else $if (datatype == ld)
double procedure asum$t (a, npix)
$else
PIXEL procedure asum$t (a, npix)
$endif $endif

PIXEL	a[ARB]
int	npix
int	i

$if (datatype == csir)
real	sum
$else $if (datatype == ld)
double	sum
$else
PIXEL	sum
$endif $endif

begin
	sum = 0$f
	do i = 1, npix
	    sum = sum + a[i]
	
	return (sum)
end