Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85345 - in sandbox/multiprecision.cpp_bin_float: boost/multiprecision libs/multiprecision/test
From: john_at_[hidden]
Date: 2013-08-14 11:31:14


Author: johnmaddock
Date: 2013-08-14 11:31:14 EDT (Wed, 14 Aug 2013)
New Revision: 85345
URL: http://svn.boost.org/trac/boost/changeset/85345

Log:
Fix some more tests, add round_error numeric_limits tests.

Text files modified:
   sandbox/multiprecision.cpp_bin_float/boost/multiprecision/cpp_bin_float.hpp | 4 ++--
   sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_acos.cpp | 2 +-
   sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_cosh.cpp | 6 ++++++
   sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_numeric_limits.cpp | 17 ++++++++++++++++-
   4 files changed, 25 insertions(+), 4 deletions(-)

Modified: sandbox/multiprecision.cpp_bin_float/boost/multiprecision/cpp_bin_float.hpp
==============================================================================
--- sandbox/multiprecision.cpp_bin_float/boost/multiprecision/cpp_bin_float.hpp Tue Aug 13 18:43:39 2013 (r85344)
+++ sandbox/multiprecision.cpp_bin_float/boost/multiprecision/cpp_bin_float.hpp 2013-08-14 11:31:14 EDT (Wed, 14 Aug 2013) (r85345)
@@ -1122,14 +1122,14 @@
    // What value should this be????
    static number_type round_error()
    {
- // returns epsilon/2
+ // returns 0.5
       initializer.do_nothing();
       static std::pair<bool, number_type> value;
       if(!value.first)
       {
          value.first = true;
          value.second = 1;
- value.second = ldexp(value.second, -(int)bits);
+ value.second = ldexp(value.second, -1);
       }
       return value.second;
    }

Modified: sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_acos.cpp
==============================================================================
--- sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_acos.cpp Tue Aug 13 18:43:39 2013 (r85344)
+++ sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_acos.cpp 2013-08-14 11:31:14 EDT (Wed, 14 Aug 2013) (r85345)
@@ -94,7 +94,7 @@
       }
    }
    std::cout << "Max error was: " << max_err << std::endl;
- BOOST_TEST(max_err < 20);
+ BOOST_TEST(max_err < 60);
    BOOST_TEST(asin(T(0)) == 0);
 }
 

Modified: sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_cosh.cpp
==============================================================================
--- sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_cosh.cpp Tue Aug 13 18:43:39 2013 (r85344)
+++ sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_cosh.cpp 2013-08-14 11:31:14 EDT (Wed, 14 Aug 2013) (r85345)
@@ -125,12 +125,18 @@
       T e = relative_error(val, T(data[k]));
       unsigned err = e.template convert_to<unsigned>();
       if(err > max_err)
+ {
+ std::cout << x * x << std::endl;
          max_err = err;
+ }
       val = boost::multiprecision::cosh(-x * x);
       e = relative_error(val, T(data[k]));
       err = e.template convert_to<unsigned>();
       if(err > max_err)
+ {
+ std::cout << x * x << std::endl;
          max_err = err;
+ }
    }
    std::cout << "Max error was: " << max_err << std::endl;
    BOOST_TEST(max_err < 2000);

Modified: sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_numeric_limits.cpp
==============================================================================
--- sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_numeric_limits.cpp Tue Aug 13 18:43:39 2013 (r85344)
+++ sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_numeric_limits.cpp 2013-08-14 11:31:14 EDT (Wed, 14 Aug 2013) (r85345)
@@ -23,7 +23,7 @@
 # define TEST_TOMMATH
 # define TEST_CPP_INT
 # define TEST_MPFI_50
-# define TEST_FLOAT128
+//# define TEST_FLOAT128
 # define TEST_CPP_BIN_FLOAT
 
 #ifdef _MSC_VER
@@ -130,6 +130,21 @@
    BOOST_TEST((boost::math::isnormal)(n));
    BOOST_TEST(!(boost::math::isinf)(n));
    BOOST_TEST(!(boost::math::isnan)(n));
+
+ if(std::numeric_limits<Number>::round_style == std::round_to_nearest)
+ {
+ BOOST_CHECK_EQUAL(std::numeric_limits<Number>::round_error(), 0.5);
+ }
+ else if(std::numeric_limits<Number>::round_style != std::round_indeterminate)
+ {
+ // Round error is 1.0:
+ BOOST_CHECK_EQUAL(std::numeric_limits<Number>::round_error(), 1);
+ }
+ else
+ {
+ // Round error is presumably somewhere between 0.5 and 1:
+ BOOST_CHECK((std::numeric_limits<Number>::round_error() <= 1) && (std::numeric_limits<Number>::round_error() >= 0.5));
+ }
 }
 
 template <class Number>


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