From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/vops/lz/amed4l.x | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 sys/vops/lz/amed4l.x (limited to 'sys/vops/lz/amed4l.x') diff --git a/sys/vops/lz/amed4l.x b/sys/vops/lz/amed4l.x new file mode 100644 index 00000000..367124ef --- /dev/null +++ b/sys/vops/lz/amed4l.x @@ -0,0 +1,41 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +# AMED4 -- Median of four vectors. Each output point M[i] is the median of the +# four input points A[i],B[i],C[i],D[i]. The vector min and max are also +# computed and returned in the A and D vectors. The input vectors are modifed +# in place. + +procedure amed4l (a, b, c, d, m, npix) + +long a[ARB], b[ARB] # input vectors +long c[ARB], d[ARB] # input vectors +long m[ARB] # output vector (median) +int npix + +int i +long temp +define swap {temp=$1;$1=$2;$2=temp} + +begin + do i = 1, npix { + # Move the minimum value to A[i]. + if (b[i] < a[i]) + swap (b[i], a[i]) + if (c[i] < a[i]) + swap (c[i], a[i]) + if (d[i] < a[i]) + swap (d[i], a[i]) + + # Move the maximum value to D[i]. + if (b[i] > d[i]) + swap (b[i], d[i]) + if (c[i] > d[i]) + swap (c[i], d[i]) + + # Return the median value. + if (b[i] < c[i]) + m[i] = b[i] + else + m[i] = c[i] + } +end -- cgit