Mercurial > hg > octave-avbm
changeset 8776:d23c33ec6bd3
fix min/max behaviour with NaNs
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Tue, 17 Feb 2009 09:45:34 +0100 |
parents | a2a9dc5e8565 |
children | 724c0f46d9d4 |
files | liboctave/ChangeLog liboctave/mx-inlines.cc |
diffstat | 2 files changed, 16 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,7 @@ +2009-02-17 Jaroslav Hajek <highegg@gmail.com> + + * mx-inlines.cc (OP_MINMAX_FCN): Correct behaviour with NaNs. + 2009-02-17 Jaroslav Hajek <highegg@gmail.com> * MArray-defs.h: Move declarative part to MArray-decl.h
--- a/liboctave/mx-inlines.cc +++ b/liboctave/mx-inlines.cc @@ -498,8 +498,12 @@ if (! n) return; \ T tmp = v[0]; \ octave_idx_type i = 1; \ - while (xisnan (tmp) && i < n) tmp = v[i++]; \ - for (i = 1; i < n; i++) \ + if (xisnan (tmp)) \ + { \ + for (; i < n && xisnan (v[i]); i++) ; \ + if (i < n) tmp = v[i]; \ + } \ + for (; i < n; i++) \ if (v[i] OP tmp) tmp = v[i]; \ *r = tmp; \ } \ @@ -510,8 +514,12 @@ T tmp = v[0]; \ octave_idx_type tmpi = 0; \ octave_idx_type i = 1; \ - while (xisnan (tmp) && i < n) tmp = v[i++]; \ - for (i = 1; i < n; i++) \ + if (xisnan (tmp)) \ + { \ + for (; i < n && xisnan (v[i]); i++) ; \ + if (i < n) { tmp = v[i]; tmpi = i; } \ + } \ + for (; i < n; i++) \ if (v[i] OP tmp) { tmp = v[i]; tmpi = i; }\ *r = tmp; \ *ri = tmpi; \