Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55017 - in sandbox/numeric_adaptor: boost/numeric_adaptor libs/numeric_adaptor/test
From: bruno.lalande_at_[hidden]
Date: 2009-07-18 13:50:42


Author: bruno.lalande
Date: 2009-07-18 13:50:41 EDT (Sat, 18 Jul 2009)
New Revision: 55017
URL: http://svn.boost.org/trac/boost/changeset/55017

Log:
Fixed a test and added abs().
Text files modified:
   sandbox/numeric_adaptor/boost/numeric_adaptor/cln_value_type.hpp | 5 +++++
   sandbox/numeric_adaptor/boost/numeric_adaptor/gmp_value_type.hpp | 7 +++++++
   sandbox/numeric_adaptor/boost/numeric_adaptor/numeric_adaptor.hpp | 4 ++++
   sandbox/numeric_adaptor/libs/numeric_adaptor/test/test_arithmetic.cpp | 4 ++--
   4 files changed, 18 insertions(+), 2 deletions(-)

Modified: sandbox/numeric_adaptor/boost/numeric_adaptor/cln_value_type.hpp
==============================================================================
--- sandbox/numeric_adaptor/boost/numeric_adaptor/cln_value_type.hpp (original)
+++ sandbox/numeric_adaptor/boost/numeric_adaptor/cln_value_type.hpp 2009-07-18 13:50:41 EDT (Sat, 18 Jul 2009)
@@ -105,6 +105,11 @@
 } // namespace numeric_adaptor
 
 
+numeric_adaptor::cln_value_type abs(numeric_adaptor::cln_value_type const& v)
+{
+ return numeric_adaptor::cln_value_type(cln::abs(v.m_value));
+}
+
 numeric_adaptor::cln_value_type sqrt(numeric_adaptor::cln_value_type const& v)
 {
     return numeric_adaptor::cln_value_type(cln::sqrt(v.m_value));

Modified: sandbox/numeric_adaptor/boost/numeric_adaptor/gmp_value_type.hpp
==============================================================================
--- sandbox/numeric_adaptor/boost/numeric_adaptor/gmp_value_type.hpp (original)
+++ sandbox/numeric_adaptor/boost/numeric_adaptor/gmp_value_type.hpp 2009-07-18 13:50:41 EDT (Sat, 18 Jul 2009)
@@ -119,6 +119,13 @@
 } // namespace numeric_adaptor
 
 
+numeric_adaptor::gmp_value_type abs(numeric_adaptor::gmp_value_type const& v)
+{
+ numeric_adaptor::gmp_value_type r;
+ mpf_abs(r.m_value, v.m_value);
+ return r;
+}
+
 numeric_adaptor::gmp_value_type sqrt(numeric_adaptor::gmp_value_type const& v)
 {
     numeric_adaptor::gmp_value_type r;

Modified: sandbox/numeric_adaptor/boost/numeric_adaptor/numeric_adaptor.hpp
==============================================================================
--- sandbox/numeric_adaptor/boost/numeric_adaptor/numeric_adaptor.hpp (original)
+++ sandbox/numeric_adaptor/boost/numeric_adaptor/numeric_adaptor.hpp 2009-07-18 13:50:41 EDT (Sat, 18 Jul 2009)
@@ -20,6 +20,10 @@
 
 
 template <class T>
+T abs(T value)
+{ return std::abs(value); }
+
+template <class T>
 T sqrt(T value)
 { return std::sqrt(value); }
 

Modified: sandbox/numeric_adaptor/libs/numeric_adaptor/test/test_arithmetic.cpp
==============================================================================
--- sandbox/numeric_adaptor/libs/numeric_adaptor/test/test_arithmetic.cpp (original)
+++ sandbox/numeric_adaptor/libs/numeric_adaptor/test/test_arithmetic.cpp 2009-07-18 13:50:41 EDT (Sat, 18 Jul 2009)
@@ -52,8 +52,8 @@
     BOOST_CHECK_EQUAL((double)-n5, -56.0);
     BOOST_CHECK_EQUAL((double)-n6, -2.0);
 
- BOOST_CHECK_EQUAL((double)abs(-n5), 56.0);
- BOOST_CHECK_EQUAL((double)sqrt(n4), 2.0);
+ BOOST_CHECK_EQUAL((double)boost::abs(-n5), 56.0);
+ BOOST_CHECK_EQUAL((double)boost::sqrt(n4), 2.0);
 }
 
 int test_main(int, char*[])


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