This is a re-do of the patch I sent previously, plus the modifications
to the min and max interpreter routines. It's the first of four:
1. Just modify the mappers.
2. Factor matrix reduction operations and add ignore_nan opt. arg.
3. Make the interpreter aware of the "ignore-nan" and "prefer-nan"
4. Add a few tests.
The intent is to allow NaNs to be ignored when taking a min or max
reduction. So min(NaN, 0) == min(NaN, 0, 'ignore-nan') == 0 by
default, while isnan(min([NaN, 0], 'prefer-nan')) is true. This
isn't fully exposed through Octave until the third patch, so these
don't make too much sense separately, but they're easier to read.
This patch is straight-forward.
BTW, the new BLAS standard officially has no position on the
behavior of NaNs w.r.t. min and max pseudo-operators. Blah.
So the future idamax (can't recall the new names) are undefined
in the face of NaNs. sigh...
* lo-mappers.h: Add xmin_nan, xmax_nan declarations.
* lo-mappers.cc (xmin_nan): Added double and Complex as copy of
(xmin): Replaced xisnan(x) with xisnan(y) to prefer returning
numbers rather than NaNs.
--- octave.orig/liboctave/lo-mappers.cc Thu Sep 9 22:17:01 1999
+++ octave.2/liboctave/lo-mappers.cc Sat Sep 2 20:06:29 2000
@@ -185,12 +185,24 @@
xmin (double x, double y)
- return x < y ? x : (xisnan (x) ? x : y);
+ return x < y ? x : (xisnan (y) ? x : y);
xmax (double x, double y)
+ return x > y ? x : (xisnan (y) ? x : y);
+xmin_nan (double x, double y)
+ return x < y ? x : (xisnan (x) ? x : y);
+xmax_nan (double x, double y)
return x > y ? x : (xisnan (x) ? x : y);