aboutsummaryrefslogtreecommitdiff
path: root/sys/vops/ak/abavl.x
diff options
context:
space:
mode:
Diffstat (limited to 'sys/vops/ak/abavl.x')
-rw-r--r--sys/vops/ak/abavl.x36
1 files changed, 36 insertions, 0 deletions
diff --git a/sys/vops/ak/abavl.x b/sys/vops/ak/abavl.x
new file mode 100644
index 00000000..29332022
--- /dev/null
+++ b/sys/vops/ak/abavl.x
@@ -0,0 +1,36 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+# ABAV -- Vector block average. Each pixel in the output vector is the
+# average of the input vector over a block of pixels. The input vector must
+# be at least (nblocks * npix_per_block) pixels in length.
+
+procedure abavl (a, b, nblocks, npix_per_block)
+
+long a[ARB] # input vector
+long b[nblocks] # output vector
+int nblocks # number of blocks (pixels in output vector)
+int npix_per_block # number of input pixels per block
+
+real sum, width
+
+int i, j
+int block_offset, next_block, block_length
+
+begin
+ block_offset = 1
+ block_length = npix_per_block
+ width = block_length
+
+ if (block_length <= 1)
+ call amovl (a[block_offset], b, nblocks)
+ else {
+ do j = 1, nblocks {
+ next_block = block_offset + block_length
+ sum = 0
+ do i = block_offset, next_block - 1
+ sum = sum + a[i]
+ b[j] = sum / width
+ block_offset = next_block
+ }
+ }
+end