# HG changeset patch # User jwe # Date 1106100713 0 # Node ID ea96466f98eafff0bffcb03d8c45641f15b5f91b # Parent 1e36493572a0eaa432c0314d7670f91d9343f483 [project @ 2005-01-19 02:11:53 by jwe] diff --git a/liboctave/CNDArray.cc b/liboctave/CNDArray.cc --- a/liboctave/CNDArray.cc +++ b/liboctave/CNDArray.cc @@ -613,7 +613,10 @@ ComplexNDArray::any (int dim) const { MX_ND_ANY_ALL_REDUCTION - (MX_ND_ANY_EVAL (elem (iter_idx) != Complex (0, 0)), false); + (MX_ND_ANY_EVAL (elem (iter_idx) != Complex (0, 0) + && ! (lo_ieee_isnan (::real (elem (iter_idx))) + || lo_ieee_isnan (::imag (elem (iter_idx))))), + false); } ComplexNDArray diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,11 @@ +2005-01-18 John W. Eaton + + * mx-inlines.cc (MX_ND_REDUCTION): Delete RET_ELT_TYPE arg. + Change all uses. Use VAL instead of RET_ELT_TYPE when resizing. + + * dNDArray.cc (NDArray::any): NaN does not count as a nonzero value. + * CNDArray.cc (ComplexNDArray::any): Likewise. + 2005-01-18 David Bateman * Array.cc (Array::insert (const Array&, const Array&)): diff --git a/liboctave/dNDArray.cc b/liboctave/dNDArray.cc --- a/liboctave/dNDArray.cc +++ b/liboctave/dNDArray.cc @@ -605,7 +605,9 @@ boolNDArray NDArray::any (int dim) const { - MX_ND_ANY_ALL_REDUCTION (MX_ND_ANY_EVAL (MX_ND_ANY_EXPR), false); + MX_ND_ANY_ALL_REDUCTION + (MX_ND_ANY_EVAL (elem (iter_idx) != 0 + && ! lo_ieee_isnan (elem (iter_idx))), false); } NDArray diff --git a/liboctave/mx-inlines.cc b/liboctave/mx-inlines.cc --- a/liboctave/mx-inlines.cc +++ b/liboctave/mx-inlines.cc @@ -379,7 +379,7 @@ } #define MX_ND_REDUCTION(EVAL_EXPR, END_EXPR, VAL, ACC_DECL, \ - RET_TYPE, RET_ELT_TYPE) \ + RET_TYPE) \ \ RET_TYPE retval; \ \ @@ -457,7 +457,7 @@ int num_iter = (this->numel () / dim_length); \ \ /* Make sure retval has correct dimensions */ \ - retval.resize (dv, RET_ELT_TYPE ()); \ + retval.resize (dv, VAL); \ \ Array iter_idx (dv.length (), 0); \ \ @@ -489,14 +489,14 @@ #define MX_ND_REAL_OP_REDUCTION(ASN_EXPR, INIT_VAL) \ MX_ND_REDUCTION (acc ASN_EXPR, retval.elem (iter_idx) = acc, \ - INIT_VAL, double acc = INIT_VAL, NDArray, double) + INIT_VAL, double acc = INIT_VAL, NDArray) #define MX_ND_COMPLEX_OP_REDUCTION(ASN_EXPR, INIT_VAL) \ MX_ND_REDUCTION (acc ASN_EXPR, retval.elem (iter_idx) = acc, \ - INIT_VAL, Complex acc = INIT_VAL, ComplexNDArray, Complex) + INIT_VAL, Complex acc = INIT_VAL, ComplexNDArray) #define MX_ND_ANY_ALL_REDUCTION(EVAL_EXPR, VAL) \ - MX_ND_REDUCTION (EVAL_EXPR, , VAL, , boolNDArray, bool) + MX_ND_REDUCTION (EVAL_EXPR, , VAL, , boolNDArray) #define MX_ND_CUMULATIVE_OP(RET_TYPE, ACC_TYPE, VAL, OP) \ RET_TYPE retval; \ diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2005-01-18 John W. Eaton + * ov-complex.h (octave_complex::any): New function. + * ov-scalar.h (octave_scalar::any): New function. + * file-io.cc (Fmkstemp): Fix doc string. Error message belongs in third output value. From Mats Jansson . diff --git a/src/ov-complex.h b/src/ov-complex.h --- a/src/ov-complex.h +++ b/src/ov-complex.h @@ -28,6 +28,7 @@ #include #include +#include "lo-ieee.h" #include "mx-base.h" #include "oct-alloc.h" #include "str-vec.h" @@ -74,6 +75,13 @@ octave_value do_index_op (const octave_value_list& idx, int resize_ok); + octave_value any (int = 0) const + { + return (scalar != Complex (0, 0) + && ! (lo_ieee_isnan (::real (scalar)) + || lo_ieee_isnan (::imag (scalar)))); + } + bool is_complex_scalar (void) const { return true; } bool is_complex_type (void) const { return true; } diff --git a/src/ov-scalar.h b/src/ov-scalar.h --- a/src/ov-scalar.h +++ b/src/ov-scalar.h @@ -28,6 +28,7 @@ #include #include +#include "lo-ieee.h" #include "lo-mappers.h" #include "lo-utils.h" #include "mx-base.h" @@ -73,6 +74,9 @@ idx_vector index_vector (void) const { return idx_vector (scalar); } + octave_value any (int = 0) const + { return (scalar != 0 && ! lo_ieee_isnan (scalar)); } + bool is_real_scalar (void) const { return true; } bool is_real_type (void) const { return true; }