Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73840 - in sandbox/big_number: boost/math/big_number libs/math/test
From: john_at_[hidden]
Date: 2011-08-17 04:38:18


Author: johnmaddock
Date: 2011-08-17 04:38:17 EDT (Wed, 17 Aug 2011)
New Revision: 73840
URL: http://svn.boost.org/trac/boost/changeset/73840

Log:
Add some more modulus tests, fix regressions and add abs function for gmp_int backend.
Text files modified:
   sandbox/big_number/boost/math/big_number/default_ops.hpp | 2 +-
   sandbox/big_number/boost/math/big_number/gmp.hpp | 5 +++++
   sandbox/big_number/libs/math/test/test_arithmetic.cpp | 25 +++++++++++++++++++++++++
   3 files changed, 31 insertions(+), 1 deletions(-)

Modified: sandbox/big_number/boost/math/big_number/default_ops.hpp
==============================================================================
--- sandbox/big_number/boost/math/big_number/default_ops.hpp (original)
+++ sandbox/big_number/boost/math/big_number/default_ops.hpp 2011-08-17 04:38:17 EDT (Wed, 17 Aug 2011)
@@ -52,7 +52,7 @@
 {
    T t;
    t = v;
- mudulus(result, t);
+ modulus(result, t);
 }
 
 template <class T>

Modified: sandbox/big_number/boost/math/big_number/gmp.hpp
==============================================================================
--- sandbox/big_number/boost/math/big_number/gmp.hpp (original)
+++ sandbox/big_number/boost/math/big_number/gmp.hpp 2011-08-17 04:38:17 EDT (Wed, 17 Aug 2011)
@@ -957,6 +957,11 @@
       mpz_neg(t.data(), t.data());
 }
    
+inline void abs(gmp_int* result, const gmp_int& val)
+{
+ mpz_abs(result->data(), val.data());
+}
+
 template<>
 struct is_extended_integer<gmp_int> : public mpl::true_ {};
 

Modified: sandbox/big_number/libs/math/test/test_arithmetic.cpp
==============================================================================
--- sandbox/big_number/libs/math/test/test_arithmetic.cpp (original)
+++ sandbox/big_number/libs/math/test/test_arithmetic.cpp 2011-08-17 04:38:17 EDT (Wed, 17 Aug 2011)
@@ -85,6 +85,31 @@
    a = -20;
    a %= -7;
    BOOST_TEST(a == -20 % -7);
+#ifndef BOOST_NO_LONG_LONG
+ a = 20;
+ a %= 7uLL;
+ BOOST_TEST(a == 20 % 7);
+ a = -20;
+ a %= 7uLL;
+ BOOST_TEST(a == -20 % 7);
+ a = 20;
+ a %= -7LL;
+ BOOST_TEST(a == 20 % -7);
+ a = -20;
+ a %= -7LL;
+ BOOST_TEST(a == -20 % -7);
+#endif
+ //
+ // Non-member functions:
+ //
+ a = -20;
+ BOOST_TEST(abs(a) == 20);
+ BOOST_TEST(abs(-a) == 20);
+ BOOST_TEST(abs(+a) == 20);
+ a = 20;
+ BOOST_TEST(abs(a) == 20);
+ BOOST_TEST(abs(-a) == 20);
+ BOOST_TEST(abs(+a) == 20);
 }
 
 template <class Real>


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