Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80624 - trunk/libs/numeric/ublas/test
From: guwi17_at_[hidden]
Date: 2012-09-21 17:56:52


Author: guwi17
Date: 2012-09-21 17:56:51 EDT (Fri, 21 Sep 2012)
New Revision: 80624
URL: http://svn.boost.org/trac/boost/changeset/80624

Log:

* libs/numeric/ublas/test/utils.hpp: switch to boost::math::isnan, see #7296

Text files modified:
   trunk/libs/numeric/ublas/test/utils.hpp | 24 +++++++++++++-----------
   1 files changed, 13 insertions(+), 11 deletions(-)

Modified: trunk/libs/numeric/ublas/test/utils.hpp
==============================================================================
--- trunk/libs/numeric/ublas/test/utils.hpp (original)
+++ trunk/libs/numeric/ublas/test/utils.hpp 2012-09-21 17:56:51 EDT (Fri, 21 Sep 2012)
@@ -54,6 +54,9 @@
 
 #include <boost/numeric/ublas/detail/config.hpp>
 #include <boost/numeric/ublas/traits.hpp>
+
+#include <boost/math/special_functions/fpclassify.hpp> // isnan, isinf
+
 #include <cmath>
 #include <complex>
 #include <cstddef>
@@ -63,14 +66,17 @@
 
 namespace boost { namespace numeric { namespace ublas { namespace test { namespace detail { namespace /*<unnamed>*/ {
 
+ using ::std::abs;
+ using ::std::max;
+
 /// Check if the given complex number is a NaN.
+// read the comments in fpclassify as well
 template <typename T>
 BOOST_UBLAS_INLINE
-bool complex_isnan(::std::complex<T> const& z)
+bool (isnan)(::std::complex<T> 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 @@
         typedef typename promote_traits<typename promote_traits<T1,T2>::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 @@
         typedef typename promote_traits<typename promote_traits<T1,T2>::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 @@
         ::std::complex<real_type> xx(x);
         ::std::complex<real_type> yy(y);
 
- using namespace ::std;
     return abs(xx-yy) <= (max(abs(xx), abs(yy))*tol);
 }
 
@@ -118,8 +122,7 @@
         typedef typename promote_traits<typename promote_traits<T1,T2>::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 @@
         typedef typename promote_traits<typename promote_traits<T1,T2>::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 @@
         ::std::complex<real_type> xx(x);
         ::std::complex<real_type> yy(y);
 
- using namespace ::std;
     return abs(xx-yy)/abs(yy) <= tol;
 }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk