Mercurial > hg > octave-nkf
diff liboctave/util/oct-cmplx.h @ 20132:31e3799b9e27
Map -pi to pi for principal argument in complex operators with float values (bug #43313)
* Array-fC.cc (nan_ascending_compare, nan_descending_compare): Use static_cast
to float on M_PI so that comparisons work.
* oct-cmplx.h (DEF_COMPLEXR_COMP): Use static_cast to type <T> on M_PI so that
comparisons work.
* complex.tst: Add tests for single values on top of those for double.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 10 Mar 2015 09:42:19 -0700 |
parents | 4197fc428c7d |
children |
line wrap: on
line diff
--- a/liboctave/util/oct-cmplx.h +++ b/liboctave/util/oct-cmplx.h @@ -50,14 +50,14 @@ { \ FLOAT_TRUNCATE const T ay = std::arg (a); \ FLOAT_TRUNCATE const T by = std::arg (b); \ - if (ay == -M_PI) \ + if (ay == static_cast<T> (-M_PI)) \ { \ - if (by != -M_PI) \ - return M_PI OP by; \ + if (by != static_cast<T> (-M_PI)) \ + return static_cast<T> (M_PI) OP by; \ } \ - else if (by == -M_PI) \ + else if (by == static_cast<T> (-M_PI)) \ { \ - return ay OP M_PI; \ + return ay OP static_cast<T> (M_PI); \ } \ return ay OP by; \ } \ @@ -72,8 +72,8 @@ if (ax == bx) \ { \ FLOAT_TRUNCATE const T ay = std::arg (a); \ - if (ay == -M_PI) \ - return M_PI OP 0; \ + if (ay == static_cast<T> (-M_PI)) \ + return static_cast<T> (M_PI) OP 0; \ return ay OP 0; \ } \ else \ @@ -87,8 +87,8 @@ if (ax == bx) \ { \ FLOAT_TRUNCATE const T by = std::arg (b); \ - if (by == -M_PI) \ - return 0 OP M_PI; \ + if (by == static_cast<T> (-M_PI)) \ + return 0 OP static_cast<T> (M_PI); \ return 0 OP by; \ } \ else \