diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
commit | fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch) | |
tree | bdda434976bc09c864f2e4fa6f16ba1952b1e555 /pkg/utilities/nttools/trebin/tutrim.x | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
Diffstat (limited to 'pkg/utilities/nttools/trebin/tutrim.x')
-rw-r--r-- | pkg/utilities/nttools/trebin/tutrim.x | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/pkg/utilities/nttools/trebin/tutrim.x b/pkg/utilities/nttools/trebin/tutrim.x new file mode 100644 index 00000000..e792c37a --- /dev/null +++ b/pkg/utilities/nttools/trebin/tutrim.x @@ -0,0 +1,43 @@ +# This routine trims elements from the end of the xout array by +# decrementing nelem. Values are trimmed if they are INDEF or +# equal to padvalue (and padvalue itself is not INDEF). Trimming +# starts at the end and stops with the first value that is not +# INDEF and not equal to padvalue. +# +# Phil Hodge, 26-Apr-2000 + +procedure tu_trim (xout, nelem, padvalue) + +double xout[ARB] # i: independent variable values +int nelem # io: size of xout array +double padvalue # i: trim these values at end of xout array +#-- +int curr_nelem # current value of nelem +int i + +begin + curr_nelem = nelem + + if (!IS_INDEFD(padvalue)) { + + # Check for either INDEF or padvalue. + do i = curr_nelem, 1, -1 { + if (IS_INDEFD(xout[i])) + nelem = nelem - 1 + else if (xout[i] == padvalue) + nelem = nelem - 1 + else # neither INDEF nor a pad value + break + } + + } else { + + # Just check for INDEF. + do i = curr_nelem, 1, -1 { + if (IS_INDEFD(xout[i])) + nelem = nelem - 1 + else # not INDEF + break + } + } +end |