aboutsummaryrefslogtreecommitdiff
path: root/sys/imio/imsamp.x
diff options
context:
space:
mode:
Diffstat (limited to 'sys/imio/imsamp.x')
-rw-r--r--sys/imio/imsamp.x61
1 files changed, 61 insertions, 0 deletions
diff --git a/sys/imio/imsamp.x b/sys/imio/imsamp.x
new file mode 100644
index 00000000..43e144c9
--- /dev/null
+++ b/sys/imio/imsamp.x
@@ -0,0 +1,61 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+# IMSAMP -- Subsample a vector.
+
+procedure imsamp (a, b, npix, sz_pixel, step)
+
+char a[ARB], b[ARB]
+int npix, sz_pixel, step, i, j, in, out, delta_in
+
+begin
+ switch (sz_pixel) {
+ case SZ_SHORT:
+ call imsmps (a, b, npix, step)
+ case SZ_LONG:
+ call imsmpl (a, b, npix, step)
+
+ default: # flip odd sized elements
+ in = 0
+ out = 0
+ delta_in = sz_pixel * step
+
+ do j = 1, npix {
+ do i = 1, sz_pixel
+ b[out+i] = a[in+i]
+ in = in + delta_in
+ out = out + sz_pixel
+ }
+ }
+end
+
+
+# IMSMPS -- Sample an array of SHORT sized elements.
+
+procedure imsmps (a, b, npix, step)
+
+short a[ARB], b[npix]
+int npix, step, ip, op
+
+begin
+ ip = 1
+ do op = 1, npix {
+ b[op] = a[ip]
+ ip = ip + step
+ }
+end
+
+
+# IMSMPL -- Sample an array of LONG sized elements.
+
+procedure imsmpl (a, b, npix, step)
+
+long a[ARB], b[npix]
+int npix, step, ip, op
+
+begin
+ ip = 1
+ do op = 1, npix {
+ b[op] = a[ip]
+ ip = ip + step
+ }
+end