aboutsummaryrefslogtreecommitdiff
path: root/sys/vops/ak/ahgmc.x
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/ak/ahgmc.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/vops/ak/ahgmc.x')
-rw-r--r--sys/vops/ak/ahgmc.x39
1 files changed, 39 insertions, 0 deletions
diff --git a/sys/vops/ak/ahgmc.x b/sys/vops/ak/ahgmc.x
new file mode 100644
index 00000000..b0917e8f
--- /dev/null
+++ b/sys/vops/ak/ahgmc.x
@@ -0,0 +1,39 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+
+# AHGM -- Accumulate the histogram of the input vector. The output vector
+# HGM (the histogram) should be cleared prior to the first call.
+
+procedure ahgmc (data, npix, hgm, nbins, z1, z2)
+
+char data[ARB] # data vector
+int npix # number of pixels
+int hgm[ARB] # output histogram
+int nbins # number of bins in histogram
+char z1, z2 # greyscale values of first and last bins
+
+char z
+real dz
+int bin, i
+
+begin
+ dz = real (nbins - 1) / real (z2 - z1)
+ if (abs (dz - 1.0) < (EPSILONR * 2.0)) {
+ do i = 1, npix {
+ z = data[i]
+ if (z >= z1 && z <= z2) {
+ bin = int (z - z1) + 1
+ hgm[bin] = hgm[bin] + 1
+ }
+ }
+ } else {
+ do i = 1, npix {
+ z = data[i]
+ if (z >= z1 && z <= z2) {
+ bin = int ((z - z1) * dz) + 1
+ hgm[bin] = hgm[bin] + 1
+ }
+ }
+ }
+end