Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81464 - in trunk: boost/multiprecision libs/multiprecision/test
From: john_at_[hidden]
Date: 2012-11-21 12:54:52


Author: johnmaddock
Date: 2012-11-21 12:54:50 EST (Wed, 21 Nov 2012)
New Revision: 81464
URL: http://svn.boost.org/trac/boost/changeset/81464

Log:
Fix clang failures
Text files modified:
   trunk/boost/multiprecision/gmp.hpp | 8
   trunk/boost/multiprecision/mpfr.hpp | 16 +-
   trunk/libs/multiprecision/test/test_cpp_int.cpp | 174 +++++++++++++++++++++++++--------------
   3 files changed, 121 insertions(+), 77 deletions(-)

Modified: trunk/boost/multiprecision/gmp.hpp
==============================================================================
--- trunk/boost/multiprecision/gmp.hpp (original)
+++ trunk/boost/multiprecision/gmp.hpp 2012-11-21 12:54:50 EST (Wed, 21 Nov 2012)
@@ -2209,7 +2209,7 @@
    // mpf_get_str on 64-bit Linux builds. Possibly we could use larger
    // exponent values elsewhere.
    //
- BOOST_STATIC_CONSTEXPR number_type (min)() BOOST_NOEXCEPT
+ static number_type (min)() BOOST_NOEXCEPT
    {
       initializer.do_nothing();
       static std::pair<bool, number_type> value;
@@ -2221,7 +2221,7 @@
       }
       return value.second;
    }
- BOOST_STATIC_CONSTEXPR number_type (max)() BOOST_NOEXCEPT
+ static number_type (max)() BOOST_NOEXCEPT
    {
       initializer.do_nothing();
       static std::pair<bool, number_type> value;
@@ -2245,7 +2245,7 @@
    BOOST_STATIC_CONSTEXPR bool is_integer = false;
    BOOST_STATIC_CONSTEXPR bool is_exact = false;
    BOOST_STATIC_CONSTEXPR int radix = 2;
- BOOST_STATIC_CONSTEXPR number_type epsilon() BOOST_NOEXCEPT
+ static number_type epsilon() BOOST_NOEXCEPT
    {
       initializer.do_nothing();
       static std::pair<bool, number_type> value;
@@ -2258,7 +2258,7 @@
       return value.second;
    }
    // What value should this be????
- BOOST_STATIC_CONSTEXPR number_type round_error() BOOST_NOEXCEPT
+ static number_type round_error() BOOST_NOEXCEPT
    {
       // returns epsilon/2
       initializer.do_nothing();

Modified: trunk/boost/multiprecision/mpfr.hpp
==============================================================================
--- trunk/boost/multiprecision/mpfr.hpp (original)
+++ trunk/boost/multiprecision/mpfr.hpp 2012-11-21 12:54:50 EST (Wed, 21 Nov 2012)
@@ -1371,12 +1371,12 @@
 namespace tools{
 
 template <>
-inline int digits<boost::multiprecision::mpfr_float>() BOOST_NOEXCEPT
+inline int digits<boost::multiprecision::mpfr_float>()
 {
    return boost::multiprecision::backends::detail::get_default_precision();
 }
 template <>
-inline int digits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> >() BOOST_NOEXCEPT
+inline int digits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> >()
 {
    return boost::multiprecision::backends::detail::get_default_precision();
 }
@@ -1396,7 +1396,7 @@
    typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> number_type;
 public:
    BOOST_STATIC_CONSTEXPR bool is_specialized = true;
- BOOST_STATIC_CONSTEXPR number_type (min)() BOOST_NOEXCEPT
+ static number_type (min)() BOOST_NOEXCEPT
    {
       initializer.do_nothing();
       static std::pair<bool, number_type> value;
@@ -1408,7 +1408,7 @@
       }
       return value.second;
    }
- BOOST_STATIC_CONSTEXPR number_type (max)() BOOST_NOEXCEPT
+ static number_type (max)() BOOST_NOEXCEPT
    {
       initializer.do_nothing();
       static std::pair<bool, number_type> value;
@@ -1432,7 +1432,7 @@
    BOOST_STATIC_CONSTEXPR bool is_integer = false;
    BOOST_STATIC_CONSTEXPR bool is_exact = false;
    BOOST_STATIC_CONSTEXPR int radix = 2;
- BOOST_STATIC_CONSTEXPR number_type epsilon() BOOST_NOEXCEPT
+ static number_type epsilon() BOOST_NOEXCEPT
    {
       initializer.do_nothing();
       static std::pair<bool, number_type> value;
@@ -1445,7 +1445,7 @@
       return value.second;
    }
    // What value should this be????
- BOOST_STATIC_CONSTEXPR number_type round_error() BOOST_NOEXCEPT
+ static number_type round_error() BOOST_NOEXCEPT
    {
       // returns epsilon/2
       initializer.do_nothing();
@@ -1467,7 +1467,7 @@
    BOOST_STATIC_CONSTEXPR bool has_signaling_NaN = false;
    BOOST_STATIC_CONSTEXPR float_denorm_style has_denorm = denorm_absent;
    BOOST_STATIC_CONSTEXPR bool has_denorm_loss = false;
- BOOST_STATIC_CONSTEXPR number_type infinity() BOOST_NOEXCEPT
+ static number_type infinity() BOOST_NOEXCEPT
    {
       // returns epsilon/2
       initializer.do_nothing();
@@ -1480,7 +1480,7 @@
       }
       return value.second;
    }
- BOOST_STATIC_CONSTEXPR number_type quiet_NaN() BOOST_NOEXCEPT
+ static number_type quiet_NaN() BOOST_NOEXCEPT
    {
       // returns epsilon/2
       initializer.do_nothing();

Modified: trunk/libs/multiprecision/test/test_cpp_int.cpp
==============================================================================
--- trunk/libs/multiprecision/test/test_cpp_int.cpp (original)
+++ trunk/libs/multiprecision/test/test_cpp_int.cpp 2012-11-21 12:54:50 EST (Wed, 21 Nov 2012)
@@ -58,32 +58,23 @@
 struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public boost::mpl::true_ {};
 
 template <class Number>
-void test()
+struct tester
 {
- using namespace boost::multiprecision;
    typedef Number test_type;
    typedef typename test_type::backend_type::checked_type checked;
 
- unsigned last_error_count = 0;
+ unsigned last_error_count;
    boost::timer tim;
 
- BOOST_CHECK_EQUAL(Number(), 0);
+ boost::multiprecision::mpz_int a, b, c, d;
+ int si;
+ unsigned ui;
+ test_type a1, b1, c1, d1;
 
- for(int i = 0; i < 10000; ++i)
- {
- mpz_int a = generate_random<mpz_int>(1000);
- mpz_int b = generate_random<mpz_int>(512);
- mpz_int c = generate_random<mpz_int>(256);
- mpz_int d = generate_random<mpz_int>(32);
-
- int si = d.convert_to<int>();
- unsigned ui = si;
-
- test_type a1 = static_cast<test_type>(a.str());
- test_type b1 = static_cast<test_type>(b.str());
- test_type c1 = static_cast<test_type>(c.str());
- test_type d1 = static_cast<test_type>(d.str());
 
+ void t1()
+ {
+ using namespace boost::multiprecision;
       BOOST_CHECK_EQUAL(a.str(), a1.str());
       BOOST_CHECK_EQUAL(b.str(), b1.str());
       BOOST_CHECK_EQUAL(c.str(), c1.str());
@@ -117,6 +108,11 @@
       BOOST_CHECK_EQUAL((mpz_int(-a)%=b).str(), (test_type(-a1) %= b1).str());
       BOOST_CHECK_EQUAL(mpz_int(a % d).str(), test_type(a1 % d1).str());
       BOOST_CHECK_EQUAL((mpz_int(a)%=d).str(), (test_type(a1) %= d1).str());
+ }
+
+ void t2()
+ {
+ using namespace boost::multiprecision;
       // bitwise ops:
       BOOST_CHECK_EQUAL(mpz_int(a|b).str(), test_type(a1 | b1).str());
       BOOST_CHECK_EQUAL((mpz_int(a)|=b).str(), (test_type(a1) |= b1).str());
@@ -160,6 +156,11 @@
          }
          BOOST_CHECK_EQUAL(mpz_int(a >> i).str(), test_type(a1 >> i).str());
       }
+ }
+
+ void t3()
+ {
+ using namespace boost::multiprecision;
       // Now check operations involving signed integers:
       BOOST_CHECK_EQUAL(mpz_int(a + si).str(), test_type(a1 + si).str());
       BOOST_CHECK_EQUAL(mpz_int(a + -si).str(), test_type(a1 + -si).str());
@@ -219,6 +220,11 @@
       BOOST_CHECK_EQUAL(mpz_int(lcm(-c, -d)).str(), test_type(lcm(-c1, -d1)).str());
       BOOST_CHECK_EQUAL(mpz_int(gcd(a, -b)).str(), test_type(gcd(a1, -b1)).str());
       BOOST_CHECK_EQUAL(mpz_int(lcm(c, -d)).str(), test_type(lcm(c1, -d1)).str());
+ }
+
+ void t4()
+ {
+ using namespace boost::multiprecision;
       // Now check operations involving unsigned integers:
       BOOST_CHECK_EQUAL(mpz_int(a + ui).str(), test_type(a1 + ui).str());
       BOOST_CHECK_EQUAL(mpz_int(-a + ui).str(), test_type(-a1 + ui).str());
@@ -277,7 +283,11 @@
          }
          BOOST_CHECK_EQUAL(t.str(), t1.str());
       }
+ }
 
+ void t5()
+ {
+ using namespace boost::multiprecision;
       //
       // Now integer functions:
       //
@@ -304,56 +314,87 @@
          BOOST_CHECK_EQUAL(mpz_int(powm(a, b, ui)).str(), test_type(powm(a1, b1, ui)).str());
          BOOST_CHECK_EQUAL(mpz_int(powm(a, ui, c)).str(), test_type(powm(a1, ui, c1)).str());
       }
+ }
 
- if(last_error_count != (unsigned)boost::detail::test_errors())
- {
- last_error_count = boost::detail::test_errors();
- std::cout << std::hex << std::showbase;
+ void test()
+ {
+ using namespace boost::multiprecision;
 
- std::cout << "a = " << a << std::endl;
- std::cout << "a1 = " << a1 << std::endl;
- std::cout << "b = " << b << std::endl;
- std::cout << "b1 = " << b1 << std::endl;
- std::cout << "c = " << c << std::endl;
- std::cout << "c1 = " << c1 << std::endl;
- std::cout << "d = " << d << std::endl;
- std::cout << "d1 = " << d1 << std::endl;
- std::cout << "a + b = " << a+b << std::endl;
- std::cout << "a1 + b1 = " << a1+b1 << std::endl;
- std::cout << std::dec;
- std::cout << "a - b = " << a-b << std::endl;
- std::cout << "a1 - b1 = " << a1-b1 << std::endl;
- std::cout << "-a + b = " << mpz_int(-a)+b << std::endl;
- std::cout << "-a1 + b1 = " << test_type(-a1)+b1 << std::endl;
- std::cout << "-a - b = " << mpz_int(-a)-b << std::endl;
- std::cout << "-a1 - b1 = " << test_type(-a1)-b1 << std::endl;
- std::cout << "c*d = " << c*d << std::endl;
- std::cout << "c1*d1 = " << c1*d1 << std::endl;
- std::cout << "b*c = " << b*c << std::endl;
- std::cout << "b1*c1 = " << b1*c1 << std::endl;
- std::cout << "a/b = " << a/b << std::endl;
- std::cout << "a1/b1 = " << a1/b1 << std::endl;
- std::cout << "a/d = " << a/d << std::endl;
- std::cout << "a1/d1 = " << a1/d1 << std::endl;
- std::cout << "a%b = " << a%b << std::endl;
- std::cout << "a1%b1 = " << a1%b1 << std::endl;
- std::cout << "a%d = " << a%d << std::endl;
- std::cout << "a1%d1 = " << a1%d1 << std::endl;
- }
+ last_error_count = 0;
 
- //
- // Check to see if test is taking too long.
- // Tests run on the compiler farm time out after 300 seconds,
- // so don't get too close to that:
- //
- if(tim.elapsed() > 200)
+ BOOST_CHECK_EQUAL(Number(), 0);
+
+ for(int i = 0; i < 10000; ++i)
       {
- std::cout << "Timeout reached, aborting tests now....\n";
- break;
- }
+ a = generate_random<mpz_int>(1000);
+ b = generate_random<mpz_int>(512);
+ c = generate_random<mpz_int>(256);
+ d = generate_random<mpz_int>(32);
+
+ si = d.convert_to<int>();
+ ui = si;
+
+ a1 = static_cast<test_type>(a.str());
+ b1 = static_cast<test_type>(b.str());
+ c1 = static_cast<test_type>(c.str());
+ d1 = static_cast<test_type>(d.str());
+
+ t1();
+ t2();
+ t3();
+ t4();
+ t5();
+
+ if(last_error_count != (unsigned)boost::detail::test_errors())
+ {
+ last_error_count = boost::detail::test_errors();
+ std::cout << std::hex << std::showbase;
 
+ std::cout << "a = " << a << std::endl;
+ std::cout << "a1 = " << a1 << std::endl;
+ std::cout << "b = " << b << std::endl;
+ std::cout << "b1 = " << b1 << std::endl;
+ std::cout << "c = " << c << std::endl;
+ std::cout << "c1 = " << c1 << std::endl;
+ std::cout << "d = " << d << std::endl;
+ std::cout << "d1 = " << d1 << std::endl;
+ std::cout << "a + b = " << a+b << std::endl;
+ std::cout << "a1 + b1 = " << a1+b1 << std::endl;
+ std::cout << std::dec;
+ std::cout << "a - b = " << a-b << std::endl;
+ std::cout << "a1 - b1 = " << a1-b1 << std::endl;
+ std::cout << "-a + b = " << mpz_int(-a)+b << std::endl;
+ std::cout << "-a1 + b1 = " << test_type(-a1)+b1 << std::endl;
+ std::cout << "-a - b = " << mpz_int(-a)-b << std::endl;
+ std::cout << "-a1 - b1 = " << test_type(-a1)-b1 << std::endl;
+ std::cout << "c*d = " << c*d << std::endl;
+ std::cout << "c1*d1 = " << c1*d1 << std::endl;
+ std::cout << "b*c = " << b*c << std::endl;
+ std::cout << "b1*c1 = " << b1*c1 << std::endl;
+ std::cout << "a/b = " << a/b << std::endl;
+ std::cout << "a1/b1 = " << a1/b1 << std::endl;
+ std::cout << "a/d = " << a/d << std::endl;
+ std::cout << "a1/d1 = " << a1/d1 << std::endl;
+ std::cout << "a%b = " << a%b << std::endl;
+ std::cout << "a1%b1 = " << a1%b1 << std::endl;
+ std::cout << "a%d = " << a%d << std::endl;
+ std::cout << "a1%d1 = " << a1%d1 << std::endl;
+ }
+
+ //
+ // Check to see if test is taking too long.
+ // Tests run on the compiler farm time out after 300 seconds,
+ // so don't get too close to that:
+ //
+ if(tim.elapsed() > 200)
+ {
+ std::cout << "Timeout reached, aborting tests now....\n";
+ break;
+ }
+
+ }
    }
-}
+};
 
 #if !defined(TEST1) && !defined(TEST2) && !defined(TEST3)
 #define TEST1
@@ -365,14 +406,17 @@
 {
    using namespace boost::multiprecision;
 #ifdef TEST1
- test<cpp_int>();
+ tester<cpp_int> t1;
+ t1.test();
 #endif
 #ifdef TEST2
- test<number<cpp_int_backend<2048, 2048, signed_magnitude, checked, void> > >();
+ tester<number<cpp_int_backend<2048, 2048, signed_magnitude, checked, void> > > t2;
+ t2.test();
 #endif
 #ifdef TEST3
    // Unchecked test verifies modulo arithmetic:
- test<number<cpp_int_backend<2048, 2048, signed_magnitude, unchecked, void> > >();
+ tester<number<cpp_int_backend<2048, 2048, signed_magnitude, unchecked, void> > > t3;
+ t3.test();
 #endif
    return boost::report_errors();
 }


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