aboutsummaryrefslogtreecommitdiff
path: root/pkg/xtools/ranges/rgunion.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 /pkg/xtools/ranges/rgunion.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'pkg/xtools/ranges/rgunion.x')
-rw-r--r--pkg/xtools/ranges/rgunion.x48
1 files changed, 48 insertions, 0 deletions
diff --git a/pkg/xtools/ranges/rgunion.x b/pkg/xtools/ranges/rgunion.x
new file mode 100644
index 00000000..5b9dfa6f
--- /dev/null
+++ b/pkg/xtools/ranges/rgunion.x
@@ -0,0 +1,48 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <pkg/rg.h>
+
+# RG_UNION -- Find the union of two sets of ranges.
+
+pointer procedure rg_union (rg1, rg2)
+
+pointer rg1 # First set of ranges
+pointer rg2 # Second set of ranges
+
+pointer rg3 # Pointer to union
+
+int i, j
+
+begin
+ # Error check the range pointers.
+
+ if ((rg1 == NULL) || (rg2 == NULL))
+ call error (0, "Range descriptor(s) undefined")
+
+ # Allocate the range points array.
+
+ i = RG_NRGS(rg1) + RG_NRGS(rg2)
+ call malloc (rg3, LEN_RG + 2 * max (1, i), TY_STRUCT)
+
+ # Set the ranges.
+
+ RG_NRGS(rg3) = i
+ RG_NPTS(rg3) = RG_NPTS(rg1) + RG_NPTS(rg2)
+
+ j = 1
+ do i = 1, RG_NRGS(rg1) {
+ RG_X1(rg3, j) = RG_X1(rg1, i)
+ RG_X2(rg3, j) = RG_X2(rg1, i)
+ j = j + 1
+ }
+ do i = 1, RG_NRGS(rg2) {
+ RG_X1(rg3, j) = RG_X1(rg2, i)
+ RG_X2(rg3, j) = RG_X2(rg2, i)
+ j = j + 1
+ }
+
+ call rgorder (rg3)
+ call rgmerge (rg3)
+
+ return (rg3)
+end