aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/lib/invert.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/utilities/nttools/lib/invert.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/utilities/nttools/lib/invert.x')
-rw-r--r--pkg/utilities/nttools/lib/invert.x55
1 files changed, 55 insertions, 0 deletions
diff --git a/pkg/utilities/nttools/lib/invert.x b/pkg/utilities/nttools/lib/invert.x
new file mode 100644
index 00000000..f8a36675
--- /dev/null
+++ b/pkg/utilities/nttools/lib/invert.x
@@ -0,0 +1,55 @@
+
+include <tbset.h>
+
+# INVERT -- Create the complement (inverse) of an array of column pointers
+#
+# B.Simon 20-Oct-87 First Code
+
+procedure invert (tp, numptr, colptr)
+
+pointer tp # i: Table descriptor
+int numptr # io: Number of column pointers
+pointer colptr[ARB] # io: Array of column pointers
+
+bool match
+int numcol, icol, iptr, jptr
+pointer newptr, cp
+
+int tbpsta(), tbcnum()
+
+begin
+ # Create a temporary array to hold the pointers
+
+ numcol = tbpsta (tp, TBL_NCOLS)
+ call malloc (newptr, numcol, TY_INT)
+
+ jptr = 0
+ do icol = 1, numcol {
+
+ # Get each pointer in the table and
+ # see if it is in the original array
+
+ cp = tbcnum (tp, icol)
+ match = false
+ do iptr = 1, numptr {
+ if (cp == colptr[iptr]) {
+ match = true
+ break
+ }
+ }
+
+ # If not, add it to the temporary array
+
+ if (! match) {
+ Memi[newptr+jptr] = cp
+ jptr = jptr + 1
+ }
+ }
+
+# Copy the temporary array to the output array
+
+ numptr = jptr
+ call amovi (Memi[newptr], colptr, numptr)
+ call mfree (newptr, TY_INT)
+
+end