aboutsummaryrefslogtreecommitdiff
path: root/sys/vops/amed4.gx
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /sys/vops/amed4.gx
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/vops/amed4.gx')
-rw-r--r--sys/vops/amed4.gx41
1 files changed, 41 insertions, 0 deletions
diff --git a/sys/vops/amed4.gx b/sys/vops/amed4.gx
new file mode 100644
index 00000000..fb5fab5e
--- /dev/null
+++ b/sys/vops/amed4.gx
@@ -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 amed4$t (a, b, c, d, m, npix)
+
+PIXEL a[ARB], b[ARB] # input vectors
+PIXEL c[ARB], d[ARB] # input vectors
+PIXEL m[ARB] # output vector (median)
+int npix
+
+int i
+PIXEL 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