|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r75134 - in sandbox/big_number: boost/multiprecision libs/multiprecision/test
From: john_at_[hidden]
Date: 2011-10-27 12:46:47
Author: johnmaddock
Date: 2011-10-27 12:46:46 EDT (Thu, 27 Oct 2011)
New Revision: 75134
URL: http://svn.boost.org/trac/boost/changeset/75134
Log:
Add numeric_limits support for mp_float.
Text files modified:
sandbox/big_number/boost/multiprecision/mp_float.hpp | 65 ++++++++++++++++++++++++++++++++++++++++
sandbox/big_number/libs/multiprecision/test/Jamfile.v2 | 8 ++++
sandbox/big_number/libs/multiprecision/test/test_numeric_limits.cpp | 13 ++++---
3 files changed, 80 insertions(+), 6 deletions(-)
Modified: sandbox/big_number/boost/multiprecision/mp_float.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/mp_float.hpp (original)
+++ sandbox/big_number/boost/multiprecision/mp_float.hpp 2011-10-27 12:46:46 EDT (Thu, 27 Oct 2011)
@@ -95,6 +95,7 @@
mp_float<Digits10>::long_long_max();
mp_float<Digits10>::long_long_min();
mp_float<Digits10>::ulong_long_max();
+ mp_float<Digits10>::eps();
mp_float<Digits10>::pow2(0);
}
void do_nothing(){}
@@ -269,6 +270,12 @@
static mp_float val((std::numeric_limits<unsigned long long>::max)());
return val;
}
+ static const mp_float& eps()
+ {
+ init.do_nothing();
+ static mp_float val(1.0, 1 - Digits10);
+ return val;
+ }
// Basic operations.
mp_float& operator= (const mp_float& v)
@@ -2451,11 +2458,69 @@
*result = val.extract_long_double();
}
+//
+// Non member function support:
+//
+template <unsigned Digits10>
+int eval_fpclassify(const mp_float<Digits10>& x)
+{
+ if(x.isinf())
+ return FP_INFINITE;
+ if(x.isnan())
+ return FP_NAN;
+ if(x.iszero())
+ return FP_ZERO;
+ return FP_NORMAL;
+}
+
typedef mp_number<mp_float<50> > mp_float_50;
typedef mp_number<mp_float<100> > mp_float_100;
}}
+namespace std
+{
+ template <unsigned Digits10>
+ class numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::mp_float<Digits10> > >
+ {
+ public:
+ static const bool is_specialized = true;
+ static const bool is_signed = true;
+ static const bool is_integer = false;
+ static const bool is_exact = false;
+ static const bool is_bounded = true;
+ static const bool is_modulo = false;
+ static const bool is_iec559 = false;
+ static const int digits = boost::multiprecision::mp_float<Digits10>::mp_float_digits;
+ static const int digits10 = boost::multiprecision::mp_float<Digits10>::mp_float_digits10;
+ static const int max_digits10 = boost::multiprecision::mp_float<Digits10>::mp_float_max_digits10;
+ static const boost::int64_t min_exponent = boost::multiprecision::mp_float<Digits10>::mp_float_min_exp; // Type differs from int.
+ static const boost::int64_t min_exponent10 = boost::multiprecision::mp_float<Digits10>::mp_float_min_exp10; // Type differs from int.
+ static const boost::int64_t max_exponent = boost::multiprecision::mp_float<Digits10>::mp_float_max_exp; // Type differs from int.
+ static const boost::int64_t max_exponent10 = boost::multiprecision::mp_float<Digits10>::mp_float_max_exp10; // Type differs from int.
+ static const int radix = boost::multiprecision::mp_float<Digits10>::mp_radix;
+ static const std::float_round_style round_style = std::round_to_nearest;
+ static const bool has_infinity = true;
+ static const bool has_quiet_NaN = true;
+ static const bool has_signaling_NaN = false;
+ static const std::float_denorm_style has_denorm = std::denorm_absent;
+ static const bool has_denorm_loss = false;
+ static const bool traps = false;
+ static const bool tinyness_before = false;
+
+ static const boost::multiprecision::mp_number<boost::multiprecision::mp_float<Digits10> > (min) (void) throw() { return (boost::multiprecision::mp_float<Digits10>::min)(); }
+ static const boost::multiprecision::mp_number<boost::multiprecision::mp_float<Digits10> > (max) (void) throw() { return (boost::multiprecision::mp_float<Digits10>::max)(); }
+ static const boost::multiprecision::mp_number<boost::multiprecision::mp_float<Digits10> > lowest (void) throw() { return boost::multiprecision::mp_float<Digits10>::zero(); }
+ static const boost::multiprecision::mp_number<boost::multiprecision::mp_float<Digits10> > epsilon (void) throw() { return boost::multiprecision::mp_float<Digits10>::eps(); }
+ static const boost::multiprecision::mp_number<boost::multiprecision::mp_float<Digits10> > round_error (void) throw() { return 0.5L; }
+ static const boost::multiprecision::mp_number<boost::multiprecision::mp_float<Digits10> > infinity (void) throw() { return boost::multiprecision::mp_float<Digits10>::inf(); }
+ static const boost::multiprecision::mp_number<boost::multiprecision::mp_float<Digits10> > quiet_NaN (void) throw() { return boost::multiprecision::mp_float<Digits10>::nan(); }
+ static const boost::multiprecision::mp_number<boost::multiprecision::mp_float<Digits10> > signaling_NaN(void) throw() { return boost::multiprecision::mp_float<Digits10>::zero(); }
+ static const boost::multiprecision::mp_number<boost::multiprecision::mp_float<Digits10> > denorm_min (void) throw() { return boost::multiprecision::mp_float<Digits10>::zero(); }
+ };
+}
+
+
#endif
Modified: sandbox/big_number/libs/multiprecision/test/Jamfile.v2
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/Jamfile.v2 (original)
+++ sandbox/big_number/libs/multiprecision/test/Jamfile.v2 2011-10-27 12:46:46 EDT (Thu, 27 Oct 2011)
@@ -142,6 +142,14 @@
[ check-target-builds ../config//has_mpfr : : <build>no ]
: test_numeric_limits_mpfr_50 ;
+run test_numeric_limits.cpp
+ : # command line
+ : # input files
+ : # requirements
+ <define>TEST_MP_FLOAT
+ [ check-target-builds ../config//has_mpfr : : <build>no ]
+ : test_numeric_limits_mp_float ;
+
run mp_number_concept_check.cpp mpfr
: # command line
: # input files
Modified: sandbox/big_number/libs/multiprecision/test/test_numeric_limits.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/test_numeric_limits.cpp (original)
+++ sandbox/big_number/libs/multiprecision/test/test_numeric_limits.cpp 2011-10-27 12:46:46 EDT (Thu, 27 Oct 2011)
@@ -5,14 +5,14 @@
#include <boost/detail/lightweight_test.hpp>
-#if !defined(TEST_MPF_50) && !defined(TEST_MPF) && !defined(TEST_BACKEND) && !defined(TEST_MPZ) && !defined(TEST_E_FLOAT) && !defined(TEST_MPFR) && !defined(TEST_MPFR_50) && !defined(TEST_MPQ)
+#if !defined(TEST_MPF_50) && !defined(TEST_MPF) && !defined(TEST_BACKEND) && !defined(TEST_MPZ) && !defined(TEST_MP_FLOAT) && !defined(TEST_MPFR) && !defined(TEST_MPFR_50) && !defined(TEST_MPQ)
# define TEST_MPF_50
# define TEST_MPF
# define TEST_BACKEND
# define TEST_MPZ
# define TEST_MPFR
# define TEST_MPFR_50
-# define TEST_E_FLOAT
+# define TEST_MP_FLOAT
# define TEST_MPQ
#ifdef _MSC_VER
@@ -30,8 +30,8 @@
#ifdef TEST_BACKEND
#include <boost/multiprecision/concepts/mp_number_architypes.hpp>
#endif
-#ifdef TEST_E_FLOAT
-#include <boost/multiprecision/e_float.hpp>
+#ifdef TEST_MP_FLOAT
+#include <boost/multiprecision/mp_float.hpp>
#endif
#if defined(TEST_MPFR) || defined(TEST_MPFR_50)
#include <boost/multiprecision/mpfr.hpp>
@@ -159,8 +159,9 @@
#ifdef TEST_MPQ
test<boost::multiprecision::mpq_rational>();
#endif
-#ifdef TEST_E_FLOAT
- test<boost::multiprecision::e_float>();
+#ifdef TEST_MP_FLOAT
+ test<boost::multiprecision::mp_float_50>();
+ test<boost::multiprecision::mp_float_100>();
#endif
#ifdef TEST_MPFR
test<boost::multiprecision::mpfr_float>();
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