aboutsummaryrefslogtreecommitdiff
path: root/sys/vops/ak/advzx.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 /sys/vops/ak/advzx.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/vops/ak/advzx.x')
-rw-r--r--sys/vops/ak/advzx.x33
1 files changed, 33 insertions, 0 deletions
diff --git a/sys/vops/ak/advzx.x b/sys/vops/ak/advzx.x
new file mode 100644
index 00000000..e6089049
--- /dev/null
+++ b/sys/vops/ak/advzx.x
@@ -0,0 +1,33 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+# ADVZ -- Vector divide with checking for zero divisors. If the result of a
+# divide would be undefined a user supplied function is called to get the
+# output pixel value.
+#
+# NOTE: in the interests of simplicity a somewhat arbitrary tolerance is used
+# to check for an undefined divide, i.e., a divide by zero or a divide by a
+# number small enough to cause floating point overflow. A better way to do
+# this would be to provide a machine dependent version of this operator in
+# host$as which catches the hardware exception rather than using a comparison.
+
+procedure advzx (a, b, c, npix, errfcn)
+
+complex a[ARB], b[ARB], c[ARB] # numerator, divisor, and output arrays
+int npix # number of pixels
+complex errfcn() # user function, called on divide by zero
+
+int i
+complex divisor
+extern errfcn()
+errchk errfcn
+
+begin
+
+ do i = 1, npix {
+ divisor = b[i]
+ if (divisor == (0.0,0.0))
+ c[i] = errfcn (a[i])
+ else
+ c[i] = a[i] / divisor
+ }
+end