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

# ABLEK -- Vector boolean less than or equals constant.  C[i], type INT,
# is set to 1 if A[i] is less than or equal to B, else C[i] is set to zero.

procedure ablek$t (a, b, c, npix)

PIXEL	a[ARB]
PIXEL	b
int	c[ARB]
int	npix
int	i
$if (datatype == x)
real	abs_b
$endif

begin
	# The case b==0 is perhaps worth optimizing.  On many machines this
	# will save a memory fetch.

	if (b == 0$f) {
	    do i = 1, npix
		$if (datatype == x)
		if (abs (a[i]) == 0)
		$else
		if (a[i] <= 0)
		$endif
		    c[i] = 1
		else
		    c[i] = 0
	} else {
	    $if (datatype == x)
	    abs_b = abs (b)
	    $endif
	    do i = 1, npix
		$if (datatype == x)
		if (abs (a[i]) <= abs_b)
		$else
		if (a[i] <= b)
		$endif
		    c[i] = 1
		else
		    c[i] = 0
	}
end