Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55005 - in sandbox/numeric_adaptor: boost/numeric_adaptor libs/numeric_adaptor/test
From: bruno.lalande_at_[hidden]
Date: 2009-07-17 17:36:31


Author: bruno.lalande
Date: 2009-07-17 17:36:30 EDT (Fri, 17 Jul 2009)
New Revision: 55005
URL: http://svn.boost.org/trac/boost/changeset/55005

Log:
Refactoring continued.
Text files modified:
   sandbox/numeric_adaptor/boost/numeric_adaptor/cln_value_type.hpp | 24 ++++++++++++++++++++++++
   sandbox/numeric_adaptor/boost/numeric_adaptor/gmp_value_type.hpp | 24 ++++++++++++++++++++++++
   sandbox/numeric_adaptor/libs/numeric_adaptor/test/Jamroot | 2 +-
   sandbox/numeric_adaptor/libs/numeric_adaptor/test/test_arithmetic.cpp | 31 ++++++++++++++-----------------
   4 files changed, 63 insertions(+), 18 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-17 17:36:30 EDT (Fri, 17 Jul 2009)
@@ -53,6 +53,12 @@
         return cln_value_type(a.m_value + b.m_value);
     }
 
+ cln_value_type& operator+=(cln_value_type const& other)
+ {
+ m_value += other.m_value;
+ return *this;
+ }
+
     friend inline cln_value_type operator-(
         cln_value_type const& a,
         cln_value_type const& b)
@@ -60,6 +66,12 @@
         return cln_value_type(a.m_value - b.m_value);
     }
 
+ cln_value_type& operator-=(cln_value_type const& other)
+ {
+ m_value -= other.m_value;
+ return *this;
+ }
+
     friend inline cln_value_type operator*(
         cln_value_type const& a,
         cln_value_type const& b)
@@ -67,6 +79,12 @@
         return cln_value_type(a.m_value * b.m_value);
     }
 
+ cln_value_type& operator*=(cln_value_type const& other)
+ {
+ m_value *= other.m_value;
+ return *this;
+ }
+
     friend inline cln_value_type operator/(
         cln_value_type const& a,
         cln_value_type const& b)
@@ -74,6 +92,12 @@
         return cln_value_type(a.m_value / b.m_value);
     }
 
+ cln_value_type& operator/=(cln_value_type const& other)
+ {
+ m_value /= other.m_value;
+ return *this;
+ }
+
     cln::cl_F 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-17 17:36:30 EDT (Fri, 17 Jul 2009)
@@ -49,6 +49,12 @@
         return r;
     }
 
+ gmp_value_type& operator+=(gmp_value_type const& other)
+ {
+ mpf_add(m_value, m_value, other.m_value);
+ return *this;
+ }
+
     friend inline gmp_value_type operator-(
         gmp_value_type const& a,
         gmp_value_type const& b)
@@ -58,6 +64,12 @@
         return r;
     }
 
+ gmp_value_type& operator-=(gmp_value_type const& other)
+ {
+ mpf_sub(m_value, m_value, other.m_value);
+ return *this;
+ }
+
     friend inline gmp_value_type operator*(
         gmp_value_type const& a,
         gmp_value_type const& b)
@@ -67,6 +79,12 @@
         return r;
     }
 
+ gmp_value_type& operator*=(gmp_value_type const& other)
+ {
+ mpf_mul(m_value, m_value, other.m_value);
+ return *this;
+ }
+
     friend inline gmp_value_type operator/(
         gmp_value_type const& a,
         gmp_value_type const& b)
@@ -76,6 +94,12 @@
         return r;
     }
 
+ gmp_value_type& operator/=(gmp_value_type const& other)
+ {
+ mpf_div(m_value, m_value, other.m_value);
+ return *this;
+ }
+
     mpf_t m_value;
 };
 

Modified: sandbox/numeric_adaptor/libs/numeric_adaptor/test/Jamroot
==============================================================================
--- sandbox/numeric_adaptor/libs/numeric_adaptor/test/Jamroot (original)
+++ sandbox/numeric_adaptor/libs/numeric_adaptor/test/Jamroot 2009-07-17 17:36:30 EDT (Fri, 17 Jul 2009)
@@ -19,6 +19,6 @@
 import testing ;
 
 run test_heron.cpp ;
-#run test_arithmetic.cpp ;
+run test_arithmetic.cpp ;
 #run test_trig.cpp ;
 #run test_conversions.cpp ;

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-17 17:36:30 EDT (Fri, 17 Jul 2009)
@@ -9,41 +9,38 @@
 
 #include <boost/test/included/test_exec_monitor.hpp>
 #include <boost/numeric_adaptor/numeric_adaptor.hpp>
-#include <boost/numeric_adaptor/ieee_policy.hpp>
 
 #if defined(HAVE_GMP)
-# include <boost/numeric_adaptor/gmp_policy.hpp>
+# include <boost/numeric_adaptor/gmp_value_type.hpp>
 #endif
 
 #if defined(HAVE_CLN)
-# include <boost/numeric_adaptor/cln_policy.hpp>
+# include <boost/numeric_adaptor/cln_value_type.hpp>
 #endif
 
 
-template <typename Policy>
+template <typename ValueType>
 void test_all()
 {
- typedef boost::numeric_adaptor::numeric_adaptor<Policy> num;
+ ValueType n1 = 1.0;
+ ValueType n2 = 2.0;
 
- num n1 = 1.0;
- num n2 = 2.0;
-
- num n3 = n1 + n2;
+ ValueType n3 = n1 + n2;
     BOOST_CHECK_EQUAL((double)n3, 3.0);
     n3 += 4.0;
     BOOST_CHECK_EQUAL((double)n3, 7.0);
 
- num n4 = n3 - n1;
+ ValueType n4 = n3 - n1;
     BOOST_CHECK_EQUAL((double)n4, 6.0);
     n4 -= 2.0;
     BOOST_CHECK_EQUAL((double)n4, 4.0);
 
- num n5 = n4*n3;
+ ValueType n5 = n4*n3;
     BOOST_CHECK_EQUAL((double)n5, 28.0);
     n5 *= n2;
     BOOST_CHECK_EQUAL((double)n5, 56.0);
 
- num n6 = n5/n4;
+ ValueType n6 = n5/n4;
     BOOST_CHECK_EQUAL((double)n6, 14.0);
     n6 /= n3;
     BOOST_CHECK_EQUAL((double)n6, 2.0);
@@ -61,16 +58,16 @@
 
 int test_main(int, char*[])
 {
- test_all<boost::numeric_adaptor::ieee_policy<float> >();
- test_all<boost::numeric_adaptor::ieee_policy<double> >();
- test_all<boost::numeric_adaptor::ieee_policy<long double> >();
+ test_all<float>();
+ test_all<double>();
+ test_all<long double>();
 
 #if defined(HAVE_GMP)
- test_all<boost::numeric_adaptor::gmp_policy>();
+ test_all<boost::numeric_adaptor::gmp_value_type>();
 #endif
 
 #if defined(HAVE_CLN)
- test_all<boost::numeric_adaptor::cln_policy>();
+ test_all<boost::numeric_adaptor::cln_value_type>();
 #endif
 
     return 0;


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