Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80483 - in trunk: boost/numeric/ublas libs/numeric/ublas/test
From: guwi17_at_[hidden]
Date: 2012-09-10 16:50:10


Author: guwi17
Date: 2012-09-10 16:50:10 EDT (Mon, 10 Sep 2012)
New Revision: 80483
URL: http://svn.boost.org/trac/boost/changeset/80483

Log:

boost/numeric/ublas/traits.hpp, libs/numeric/ublas/test/test_assignment.cpp, libs/numeric/ublas/test/begin_end.cpp: see #7296, fix test issues with unsigned integer types
 

Text files modified:
   trunk/boost/numeric/ublas/traits.hpp | 8 ++++++++
   trunk/libs/numeric/ublas/test/begin_end.cpp | 8 ++++----
   trunk/libs/numeric/ublas/test/test_assignment.cpp | 4 ++--
   3 files changed, 14 insertions(+), 6 deletions(-)

Modified: trunk/boost/numeric/ublas/traits.hpp
==============================================================================
--- trunk/boost/numeric/ublas/traits.hpp (original)
+++ trunk/boost/numeric/ublas/traits.hpp 2012-09-10 16:50:10 EDT (Mon, 10 Sep 2012)
@@ -41,6 +41,14 @@
     // we'll find either std::abs or else another version via ADL:
     return abs (t);
   }
+ // unsigned types are always non-negative
+ template<> unsigned int boost_numeric_ublas_abs (const unsigned int& t) {
+ return t;
+ }
+ // unsigned types are always non-negative
+ template<> unsigned long boost_numeric_ublas_abs (const unsigned long& t) {
+ return t;
+ }
 }
 
 namespace boost { namespace numeric { namespace ublas {

Modified: trunk/libs/numeric/ublas/test/begin_end.cpp
==============================================================================
--- trunk/libs/numeric/ublas/test/begin_end.cpp (original)
+++ trunk/libs/numeric/ublas/test/begin_end.cpp 2012-09-10 16:50:10 EDT (Mon, 10 Sep 2012)
@@ -49,7 +49,7 @@
             ++it
     ) {
         BOOST_UBLAS_DEBUG_TRACE( "*it = " << *it << " ==> " << v(ix) );
- BOOST_UBLAS_TEST_CHECK( std::fabs(*it - v(ix)) <= TOL );
+ BOOST_UBLAS_TEST_CHECK( std::abs(*it - v(ix)) <= TOL );
         ++ix;
     }
 }
@@ -78,7 +78,7 @@
             ++it
     ) {
         BOOST_UBLAS_DEBUG_TRACE( "*it = " << *it << " ==> " << v(ix) );
- BOOST_UBLAS_TEST_CHECK( std::fabs(*it - v(ix)) <= TOL );
+ BOOST_UBLAS_TEST_CHECK( std::abs(*it - v(ix)) <= TOL );
         ++ix;
     }
 }
@@ -116,7 +116,7 @@
                 ++inner_it
         ) {
             BOOST_UBLAS_DEBUG_TRACE( "*it = " << *inner_it << " ==> " << A(row,col) );
- BOOST_UBLAS_TEST_CHECK( std::fabs(*inner_it - A(row,col)) <= TOL );
+ BOOST_UBLAS_TEST_CHECK( std::abs(*inner_it - A(row,col)) <= TOL );
 
             ++col;
         }
@@ -158,7 +158,7 @@
                 ++inner_it
         ) {
             BOOST_UBLAS_DEBUG_TRACE( "*it = " << *inner_it << " ==> " << A(row,col) );
- BOOST_UBLAS_TEST_CHECK( std::fabs(*inner_it - A(row,col)) <= TOL );
+ BOOST_UBLAS_TEST_CHECK( std::abs(*inner_it - A(row,col)) <= TOL );
 
             ++row;
         }

Modified: trunk/libs/numeric/ublas/test/test_assignment.cpp
==============================================================================
--- trunk/libs/numeric/ublas/test/test_assignment.cpp (original)
+++ trunk/libs/numeric/ublas/test/test_assignment.cpp 2012-09-10 16:50:10 EDT (Mon, 10 Sep 2012)
@@ -26,7 +26,7 @@
     typename AE::size_type i, j;
     for (i=0; i!= me().size1(); i++) {
         for (j=0; j!= me().size2(); j++) {
- s+=std::fabs(me()(i,j));
+ s+= scalar_traits<typename AE::value_type>::type_abs(me()(i,j));
         }
     }
     return s/me().size1()*me().size2();
@@ -39,7 +39,7 @@
     typename AE::value_type s(0);
     typename AE::size_type i;
     for (i=0; i!= ve().size(); i++) {
- s+=std::fabs(ve()(i));
+ s+=scalar_traits<typename AE::value_type>::type_abs(ve()(i));
         }
     return s/ve().size();
 }


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