aboutsummaryrefslogtreecommitdiff
path: root/pkg/xtools/ranges/rgindices.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 /pkg/xtools/ranges/rgindices.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/xtools/ranges/rgindices.x')
-rw-r--r--pkg/xtools/ranges/rgindices.x81
1 files changed, 81 insertions, 0 deletions
diff --git a/pkg/xtools/ranges/rgindices.x b/pkg/xtools/ranges/rgindices.x
new file mode 100644
index 00000000..48f1ec8f
--- /dev/null
+++ b/pkg/xtools/ranges/rgindices.x
@@ -0,0 +1,81 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <pkg/rg.h>
+
+# RG_INDICES -- Return the indices in the ranges.
+
+procedure rg_indices (rg, indices, npts, type)
+
+pointer rg # Ranges
+pointer indices # Indices
+int npts # Number of indices
+int type # Data type of points
+
+int i, j, k, step
+
+begin
+ # Error check the range pointer.
+
+ if (rg == NULL)
+ call error (0, "Range descriptor undefined")
+
+ # Determine the number of range points.
+
+ indices = NULL
+ npts = 0
+ if (RG_NRGS (rg) == 0)
+ return
+
+ do i = 1, RG_NRGS(rg) {
+ if (RG_X1(rg, i) > RG_X2(rg, i))
+ npts = npts + RG_X1(rg, i) - RG_X2(rg, i) + 1
+ else
+ npts = npts + RG_X2(rg, i) - RG_X1(rg, i) + 1
+ }
+
+ # Allocate the range points array.
+
+ call malloc (indices, npts, type)
+
+ # Set the range points.
+
+ k = indices
+ do i = 1, RG_NRGS(rg) {
+ if (RG_X1(rg, i) > RG_X2(rg, i))
+ step = -1
+ else
+ step = 1
+
+ switch (type) {
+ case TY_SHORT:
+ do j = RG_X1(rg, i), RG_X2(rg, i), step {
+ Mems[k] = j
+ k = k + 1
+ }
+ case TY_INT:
+ do j = RG_X1(rg, i), RG_X2(rg, i), step {
+ Memi[k] = j
+ k = k + 1
+ }
+ case TY_LONG:
+ do j = RG_X1(rg, i), RG_X2(rg, i), step {
+ Meml[k] = j
+ k = k + 1
+ }
+ case TY_REAL:
+ do j = RG_X1(rg, i), RG_X2(rg, i), step {
+ Memr[k] = j
+ k = k + 1
+ }
+ case TY_DOUBLE:
+ do j = RG_X1(rg, i), RG_X2(rg, i), step {
+ Memd[k] = j
+ k = k + 1
+ }
+ default:
+ call error (0, "rg_indices: Datatype not available")
+ }
+ }
+
+ return
+end