aboutsummaryrefslogtreecommitdiff
path: root/noao/nproto/ir/irmedr.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /noao/nproto/ir/irmedr.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'noao/nproto/ir/irmedr.x')
-rw-r--r--noao/nproto/ir/irmedr.x35
1 files changed, 35 insertions, 0 deletions
diff --git a/noao/nproto/ir/irmedr.x b/noao/nproto/ir/irmedr.x
new file mode 100644
index 00000000..436a3673
--- /dev/null
+++ b/noao/nproto/ir/irmedr.x
@@ -0,0 +1,35 @@
+# IRMEDR -- Procedure to compute the median of an array in which some
+# elements are undefined.
+
+real procedure irmedr (a, aindex, npts)
+
+real a[ARB] # input array
+int aindex[ARB] # definition array
+int npts # number of points
+
+int i, n
+pointer sp, b
+real med
+real asokr()
+
+begin
+ call smark (sp)
+ call salloc (b, npts, TY_REAL)
+
+ n = 0
+ do i = 1, npts {
+ if (aindex[i] > 0) {
+ Memr[b+n] = a[i]
+ n = n + 1
+ }
+ }
+
+ if (n == 0)
+ med = INDEFR
+ else
+ med = asokr (Memr[b], n, (n + 1) / 2)
+
+ call sfree (sp)
+
+ return (med)
+end