aboutsummaryrefslogtreecommitdiff
path: root/sys/vops/lz/amed3i.x
blob: 2be5fb151f260fdcfb400c3eed32cb23987ed419 (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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

# AMED3 -- Median of three vectors.  Each output point M[i] is the median value
# of the three input points A[i],B[i],C[i].

procedure amed3i (a, b, c, m, npix)

int	a[ARB], b[ARB], c[ARB]	# input vectors
int	m[ARB]				# output vector (median)
int	npix
int	i

begin
	do i = 1, npix
	    if (a[i] < b[i]) {
		if (b[i] < c[i])		# abc
		    m[i] = b[i]
		else if (a[i] < c[i])		# acb
		    m[i] = c[i]
		else				# cab
		    m[i] = a[i]
	    } else {
		if (b[i] > c[i])		# cba
		    m[i] = b[i]
		else if (a[i] > c[i])		# bca
		    m[i] = c[i]
		else				# bac
		    m[i] = a[i]
	    }
end