From c3cdecd19aa0439046d8bbac7a985cdfca2b73af Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Fri, 21 Sep 2012 21:56:51 +0000 Subject: [PATCH] * libs/numeric/ublas/test/utils.hpp: switch to boost::math::isnan, see #7296 [SVN r80624] --- test/utils.hpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/test/utils.hpp b/test/utils.hpp index 6efdf1f0..4cd9087e 100644 --- a/test/utils.hpp +++ b/test/utils.hpp @@ -54,6 +54,9 @@ #include #include + +#include // isnan, isinf + #include #include #include @@ -63,14 +66,17 @@ namespace boost { namespace numeric { namespace ublas { namespace test { namespace detail { namespace /**/ { + using ::std::abs; + using ::std::max; + /// Check if the given complex number is a NaN. +// read the comments in fpclassify as well template BOOST_UBLAS_INLINE -bool complex_isnan(::std::complex const& z) +bool (isnan)(::std::complex const& z) { - using namespace ::std; // According to IEEE, NaN is different even by itself - return (z != z) || isnan(z.real()) || isnan(z.imag()); + return (z != z) || (boost::math::isnan)(z.real()) || (boost::math::isnan)(z.imag()); } /// Check if two (real) numbers are close each other (wrt a given tolerance). @@ -81,8 +87,7 @@ bool close_to(T1 x, T2 y, T3 tol) typedef typename promote_traits::promote_type, T3>::promote_type real_type; - using namespace ::std; - if (isnan(x) || isnan(y)) + if ((boost::math::isnan)(x) || (boost::math::isnan)(y)) { // According to IEEE, NaN is different even by itself return false; @@ -98,7 +103,7 @@ bool close_to(::std::complex const& x, ::std::complex const& y, T3 tol) typedef typename promote_traits::promote_type, T3>::promote_type real_type; - if (complex_isnan(x) || complex_isnan(y)) + if ((isnan)(x) || (isnan)(y)) { // According to IEEE, NaN is different even by itself return false; @@ -106,7 +111,6 @@ bool close_to(::std::complex const& x, ::std::complex const& y, T3 tol) ::std::complex xx(x); ::std::complex yy(y); - using namespace ::std; return abs(xx-yy) <= (max(abs(xx), abs(yy))*tol); } @@ -118,8 +122,7 @@ bool rel_close_to(T1 x, T2 y, T3 tol) typedef typename promote_traits::promote_type, T3>::promote_type real_type; - using namespace ::std; - if (isnan(x) || isnan(y)) + if ((boost::math::isnan)(x) || (boost::math::isnan)(y)) { // According to IEEE, NaN is different even by itself return false; @@ -135,7 +138,7 @@ bool rel_close_to(::std::complex const& x, ::std::complex const& y, T3 t typedef typename promote_traits::promote_type, T3>::promote_type real_type; - if (complex_isnan(x) || complex_isnan(y)) + if ((isnan)(x) || (isnan)(y)) { // According to IEEE, NaN is different even by itself return false; @@ -143,7 +146,6 @@ bool rel_close_to(::std::complex const& x, ::std::complex const& y, T3 t ::std::complex xx(x); ::std::complex yy(y); - using namespace ::std; return abs(xx-yy)/abs(yy) <= tol; }