# HG changeset patch # User Jaroslav Hajek # Date 1254046293 -7200 # Node ID 641a788c82a4abd65f6c2ca03c3e45d2a1718736 # Parent a531dec450c47863167e2856c7002aeb211e3d7c fix complex-real comparisons diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,7 @@ +2009-09-27 Jaroslav Hajek + + * oct-cmplx.h: Fix complex-real orderings. + 2009-09-27 Jaroslav Hajek * dim-vector.h (dim_vector::redim): Rewrite. diff --git a/liboctave/oct-cmplx.h b/liboctave/oct-cmplx.h --- a/liboctave/oct-cmplx.h +++ b/liboctave/oct-cmplx.h @@ -53,26 +53,26 @@ template \ inline bool operator OP (const std::complex& 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 \ inline bool operator OP (T a, const std::complex& 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 (>, >)