Mercurial > hg > octave-nkf
changeset 9667:641a788c82a4
fix complex-real comparisons
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sun, 27 Sep 2009 12:11:33 +0200 |
parents | a531dec450c4 |
children | 6291b69cf2d2 |
files | liboctave/ChangeLog liboctave/oct-cmplx.h |
diffstat | 2 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,7 @@ +2009-09-27 Jaroslav Hajek <highegg@gmail.com> + + * oct-cmplx.h: Fix complex-real orderings. + 2009-09-27 Jaroslav Hajek <highegg@gmail.com> * dim-vector.h (dim_vector::redim): Rewrite.
--- a/liboctave/oct-cmplx.h +++ b/liboctave/oct-cmplx.h @@ -53,26 +53,26 @@ template <class T> \ inline bool operator OP (const std::complex<T>& a, T b) \ { \ - FLOAT_TRUNCATE const T ax = std::abs (a); \ - if (ax == b) \ + FLOAT_TRUNCATE const T ax = std::abs (a), bx = std::abs (b); \ + if (ax == bx) \ { \ FLOAT_TRUNCATE const T ay = std::arg (a); \ return ay OP 0; \ } \ else \ - return ax OPS b; \ + return ax OPS bx; \ } \ template <class T> \ inline bool operator OP (T a, const std::complex<T>& b) \ { \ - FLOAT_TRUNCATE const T bx = std::abs (b); \ - if (a == bx) \ + FLOAT_TRUNCATE const T ax = std::abs (a), bx = std::abs (b); \ + if (ax == bx) \ { \ FLOAT_TRUNCATE const T by = std::arg (b); \ return 0 OP by; \ } \ else \ - return a OPS bx; \ + return ax OPS bx; \ } DEF_COMPLEXR_COMP (>, >)