Mercurial > hg > octave-nkf
changeset 5110:ea96466f98ea
[project @ 2005-01-19 02:11:53 by jwe]
author | jwe |
---|---|
date | Wed, 19 Jan 2005 02:11:53 +0000 |
parents | 1e36493572a0 |
children | aa9bc151d2fa |
files | liboctave/CNDArray.cc liboctave/ChangeLog liboctave/dNDArray.cc liboctave/mx-inlines.cc src/ChangeLog src/ov-complex.h src/ov-scalar.h |
diffstat | 7 files changed, 35 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,11 @@ +2005-01-18 John W. Eaton <jwe@octave.org> + + * 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 <dbateman@free.fr> * Array.cc (Array<T>::insert (const Array<T>&, const Array<int>&)):
--- 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
--- 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<int> 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; \
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2005-01-18 John W. Eaton <jwe@octave.org> + * 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 <mats.e.jansson@home.se>.
--- a/src/ov-complex.h +++ b/src/ov-complex.h @@ -28,6 +28,7 @@ #include <iostream> #include <string> +#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; }
--- a/src/ov-scalar.h +++ b/src/ov-scalar.h @@ -28,6 +28,7 @@ #include <iostream> #include <string> +#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; }