diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /sys/vops/lz/amed5d.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/vops/lz/amed5d.x')
-rw-r--r-- | sys/vops/lz/amed5d.x | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/sys/vops/lz/amed5d.x b/sys/vops/lz/amed5d.x new file mode 100644 index 00000000..a813f82f --- /dev/null +++ b/sys/vops/lz/amed5d.x @@ -0,0 +1,55 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +# AMED5 -- Median of five vectors. Each output point M[i] is the median of the +# five input points A[i],B[i],C[i],D[i],E[i]. The vector min and max are also +# computed and returned in the A and E vectors. The input vectors are modifed. + +procedure amed5d (a, b, c, d, e, m, npix) + +double a[ARB], b[ARB] # input vectors +double c[ARB], d[ARB], e[ARB] # input vectors +double m[ARB] # output vector (median) +int npix + +int i +double 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]) + if (e[i] < a[i]) + swap (e[i], a[i]) + + # Move the maximum value to E[i]. + if (b[i] > e[i]) + swap (b[i], e[i]) + if (c[i] > e[i]) + swap (c[i], e[i]) + if (d[i] > e[i]) + swap (d[i], e[i]) + + # Return the median value of the central three points. + if (b[i] < c[i]) { + if (c[i] < d[i]) # bcd + m[i] = c[i] + else if (b[i] < d[i]) # bdc + m[i] = d[i] + else # dbc + m[i] = b[i] + } else { + if (c[i] > d[i]) # dcb + m[i] = c[i] + else if (b[i] > d[i]) # cdb + m[i] = d[i] + else # cbd + m[i] = b[i] + } + } +end |