Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74004 - in sandbox/big_number: boost/math boost/math/big_number boost/math/concepts libs/math/test
From: john_at_[hidden]
Date: 2011-08-22 08:03:51


Author: johnmaddock
Date: 2011-08-22 08:03:49 EDT (Mon, 22 Aug 2011)
New Revision: 74004
URL: http://svn.boost.org/trac/boost/changeset/74004

Log:
Added new backend adapter type, plus tentative e_float support.
Added numeric_limits support, plus embryonic test program.
Added:
   sandbox/big_number/boost/math/big_number/arithmetic_backend.hpp (contents, props changed)
   sandbox/big_number/boost/math/big_number/e_float.hpp (contents, props changed)
   sandbox/big_number/libs/math/test/test_numeric_limits.cpp (contents, props changed)
Text files modified:
   sandbox/big_number/boost/math/big_number.hpp | 8 +
   sandbox/big_number/boost/math/big_number/gmp.hpp | 212 ++++++++++++++++++++++++++++++++++++++++
   sandbox/big_number/boost/math/big_number/mpfr.hpp | 188 +++++++++++++++++++++++++++++++++++
   sandbox/big_number/boost/math/concepts/big_number_architypes.hpp | 38 +++++++
   sandbox/big_number/libs/math/test/linpack-benchmark.cpp | 35 ++---
   sandbox/big_number/libs/math/test/test_arithmetic.cpp | 14 --
   6 files changed, 464 insertions(+), 31 deletions(-)

Modified: sandbox/big_number/boost/math/big_number.hpp
==============================================================================
--- sandbox/big_number/boost/math/big_number.hpp (original)
+++ sandbox/big_number/boost/math/big_number.hpp 2011-08-22 08:03:49 EDT (Mon, 22 Aug 2011)
@@ -58,6 +58,14 @@
       m_backend = canonical_value(v);
    }
 
+ template <class V>
+ big_number(V v, typename enable_if<mpl::and_<is_convertible<V, Backend>, mpl::not_<boost::is_arithmetic<V> > > >::type* dummy1 = 0)
+ : m_backend(v)
+ {
+ proto::value(*this) = this;
+ BOOST_ASSERT(proto::value(*this) == this);
+ }
+
    template <class Exp>
    big_number& operator=(const detail::big_number_exp<Exp>& e)
    {

Added: sandbox/big_number/boost/math/big_number/arithmetic_backend.hpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/boost/math/big_number/arithmetic_backend.hpp 2011-08-22 08:03:49 EDT (Mon, 22 Aug 2011)
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////
+// Copyright 2011 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_
+
+#ifndef BOOST_MATH_ARITH_BACKEND_HPP
+#define BOOST_MATH_ARITH_BACKEND_HPP
+
+#include <iostream>
+#include <iomanip>
+#include <boost/cstdint.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/math/big_number.hpp>
+
+namespace boost{
+namespace math{
+
+template <class Arithmetic>
+struct arithmetic_backend
+{
+ typedef mpl::list<long long> signed_types;
+ typedef mpl::list<unsigned long long> unsigned_types;
+ typedef mpl::list<long double> real_types;
+
+ arithmetic_backend(){}
+ arithmetic_backend(const arithmetic_backend& o)
+ {
+ m_value = o.m_value;
+ }
+ arithmetic_backend(const Arithmetic& o) : m_value(o) {}
+#ifndef BOOST_NO_RVALUE_REFERENCES
+ arithmetic_backend(arithmetic_backend&& o) : m_value(o.m_value) {}
+ arithmetic_backend(Arithmetic&& o) : m_value(o) {}
+#endif
+ arithmetic_backend& operator = (const arithmetic_backend& o)
+ {
+ m_value = o.m_value;
+ return *this;
+ }
+ arithmetic_backend& operator = (boost::uintmax_t i)
+ {
+ m_value = i;
+ return *this;
+ }
+ arithmetic_backend& operator = (boost::intmax_t i)
+ {
+ m_value = i;
+ return *this;
+ }
+ arithmetic_backend& operator = (long double d)
+ {
+ m_value = d;
+ return *this;
+ }
+ arithmetic_backend& operator = (const char* s)
+ {
+ m_value = boost::lexical_cast<double>(s);
+ return *this;
+ }
+ void swap(arithmetic_backend& o)
+ {
+ std::swap(m_value, o.m_value);
+ }
+ std::string str(unsigned digits, bool scientific)const
+ {
+ return boost::lexical_cast<std::string>(m_value);
+ }
+ void negate()
+ {
+ m_value = -m_value;
+ }
+ int compare(const arithmetic_backend& o)const
+ {
+ return m_value > o.m_value ? 1 : (m_value < o.m_value ? -1 : 0);
+ }
+ int compare(boost::intmax_t i)const
+ {
+ return m_value > i ? 1 : (m_value < i ? -1 : 0);
+ }
+ int compare(boost::uintmax_t i)const
+ {
+ return m_value > i ? 1 : (m_value < i ? -1 : 0);
+ }
+ int compare(long double d)const
+ {
+ return m_value > d ? 1 : (m_value < d ? -1 : 0);
+ }
+ Arithmetic& data() { return m_value; }
+ const Arithmetic& data()const { return m_value; }
+private:
+ Arithmetic m_value;
+};
+
+template <class Arithmetic>
+inline void add(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o)
+{
+ result.data() += o.data();
+}
+template <class Arithmetic>
+inline void subtract(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o)
+{
+ result.data() -= o.data();
+}
+template <class Arithmetic>
+inline void multiply(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o)
+{
+ result.data() *= o.data();
+}
+template <class Arithmetic>
+inline void divide(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o)
+{
+ result.data() /= o.data();
+}
+
+}} // namespaces
+
+
+namespace std{
+
+#ifdef BOOST_NO_NOEXCEPT
+# define noexcept
+#endif
+
+template <class Arithmetic>
+class numeric_limits<boost::math::big_number<boost::math::arithmetic_backend<Arithmetic> > > : public std::numeric_limits<Arithmetic>
+{
+ typedef std::numeric_limits<Arithmetic> base_type;
+ typedef boost::math::big_number<boost::math::arithmetic_backend<Arithmetic> > number_type;
+public:
+ BOOST_STATIC_CONSTEXPR number_type (min)() noexcept { return (base_type::min)(); }
+ BOOST_STATIC_CONSTEXPR number_type (max)() noexcept { return (base_type::max)(); }
+ BOOST_STATIC_CONSTEXPR number_type lowest() noexcept { return -(max)(); }
+ BOOST_STATIC_CONSTEXPR number_type epsilon() noexcept { return base_type::epsilon(); }
+ BOOST_STATIC_CONSTEXPR number_type round_error() noexcept { return epsilon() / 2; }
+ BOOST_STATIC_CONSTEXPR number_type infinity() noexcept { return base_type::infinity(); }
+ BOOST_STATIC_CONSTEXPR number_type quiet_NaN() noexcept { return base_type::quiet_NaN(); }
+ BOOST_STATIC_CONSTEXPR number_type signaling_NaN() noexcept { return base_type::signaling_NaN(); }
+ BOOST_STATIC_CONSTEXPR number_type denorm_min() noexcept { return base_type::denorm_min(); }
+};
+
+#ifdef BOOST_NO_NOEXCEPT
+# undef noexcept
+#endif
+
+}
+
+#endif

Added: sandbox/big_number/boost/math/big_number/e_float.hpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/boost/math/big_number/e_float.hpp 2011-08-22 08:03:49 EDT (Mon, 22 Aug 2011)
@@ -0,0 +1,33 @@
+///////////////////////////////////////////////////////////////
+// Copyright 2011 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_
+
+#ifndef BOOST_MATH_EFX_BACKEND_HPP
+#define BOOST_MATH_EFX_BACKEND_HPP
+
+#include <boost/math/big_number/arithmetic_backend.hpp>
+#include <boost/e_float/e_float.hpp>
+#include <boost/e_float/e_float_complex.hpp>
+#include <boost/e_float/e_float_elementary_math.hpp>
+
+namespace boost{
+namespace math{
+
+typedef big_number<arithmetic_backend<efx::e_float> > e_float;
+
+template<>
+inline void arithmetic_backend<efx::e_float>::negate()
+{
+ m_value.negate();
+}
+
+inline void abs(arithmetic_backend<efx::e_float>* result, const arithmetic_backend<efx::e_float>& arg)
+{
+ result->data() = ef::fabs(arg.data());
+}
+
+
+}} // namespaces
+
+#endif

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-22 08:03:49 EDT (Mon, 22 Aug 2011)
@@ -12,6 +12,8 @@
 #include <boost/lexical_cast.hpp>
 #include <gmp.h>
 #include <cmath>
+#include <limits>
+#include <climits>
 
 namespace boost{ namespace math{
 
@@ -981,4 +983,214 @@
 
 }} // namespaces
 
+namespace std{
+
+#ifdef BOOST_NO_NOEXCEPT
+# define noexcept
+#endif
+
+//
+// numeric_limits [partial] specializations for the types declared in this header:
+//
+template<unsigned Digits10>
+class numeric_limits<boost::math::big_number<boost::math::gmp_real<Digits10> > >
+{
+ typedef boost::math::big_number<boost::math::gmp_real<Digits10> > number_type;
+public:
+ BOOST_STATIC_CONSTEXPR bool is_specialized = true;
+ BOOST_STATIC_CONSTEXPR number_type (min)() noexcept
+ {
+ initializer.do_nothing();
+ static std::pair<bool, number_type> value;
+ if(!value.first)
+ {
+ value.first = true;
+ value.second = 1;
+ mpf_div_2exp(value.second.backend().data(), value.second.backend().data(), LONG_MAX);
+ }
+ return value.second;
+ }
+ BOOST_STATIC_CONSTEXPR number_type (max)() noexcept
+ {
+ initializer.do_nothing();
+ static std::pair<bool, number_type> value;
+ if(!value.first)
+ {
+ value.first = true;
+ value.second = 1;
+ mpf_mul_2exp(value.second.backend().data(), value.second.backend().data(), LONG_MAX - 1);
+ }
+ return value.second;
+ }
+ BOOST_STATIC_CONSTEXPR number_type lowest() noexcept
+ {
+ return -(max)();
+ }
+ BOOST_STATIC_CONSTEXPR int digits = static_cast<int>(((Digits10 + 1) * 1000L) / 301L);
+ BOOST_STATIC_CONSTEXPR int digits10 = Digits10;
+ // Is this really correct???
+ BOOST_STATIC_CONSTEXPR int max_digits10 = Digits10 + 1;
+ BOOST_STATIC_CONSTEXPR bool is_signed = true;
+ 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() noexcept
+ {
+ initializer.do_nothing();
+ static std::pair<bool, number_type> value;
+ if(!value.first)
+ {
+ value.first = true;
+ value.second = 1;
+ mpf_div_2exp(value.second.backend().data(), value.second.backend().data(), std::numeric_limits<number_type>::digits - 1);
+ }
+ return value.second;
+ }
+ // What value should this be????
+ BOOST_STATIC_CONSTEXPR number_type round_error() noexcept
+ {
+ // returns epsilon/2
+ initializer.do_nothing();
+ static std::pair<bool, number_type> value;
+ if(!value.first)
+ {
+ value.first = true;
+ value.second = 1;
+ mpf_div_2exp(value.second.backend().data(), value.second.backend().data(), digits);
+ }
+ return value.second;
+ }
+ BOOST_STATIC_CONSTEXPR long min_exponent = LONG_MIN;
+ BOOST_STATIC_CONSTEXPR long min_exponent10 = (LONG_MIN / 1000) * 301L;
+ BOOST_STATIC_CONSTEXPR long max_exponent = LONG_MAX;
+ BOOST_STATIC_CONSTEXPR long max_exponent10 = (LONG_MAX / 1000) * 301L;
+ BOOST_STATIC_CONSTEXPR bool has_infinity = false;
+ BOOST_STATIC_CONSTEXPR bool has_quiet_NaN = false;
+ 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() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR number_type quiet_NaN() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR number_type signaling_NaN() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR number_type denorm_min() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR bool is_iec559 = false;
+ BOOST_STATIC_CONSTEXPR bool is_bounded = true;
+ BOOST_STATIC_CONSTEXPR bool is_modulo = false;
+ BOOST_STATIC_CONSTEXPR bool traps = true;
+ BOOST_STATIC_CONSTEXPR bool tinyness_before = false;
+ BOOST_STATIC_CONSTEXPR float_round_style round_style = round_to_nearest;
+
+private:
+ struct data_initializer
+ {
+ data_initializer()
+ {
+ std::numeric_limits<boost::math::big_number<boost::math::gmp_real<digits10> > >::epsilon();
+ std::numeric_limits<boost::math::big_number<boost::math::gmp_real<digits10> > >::round_error();
+ std::numeric_limits<boost::math::big_number<boost::math::gmp_real<digits10> > >::min();
+ std::numeric_limits<boost::math::big_number<boost::math::gmp_real<digits10> > >::max();
+ }
+ void do_nothing()const{}
+ };
+ static const data_initializer initializer;
+};
+
+template<unsigned Digits10>
+const typename numeric_limits<boost::math::big_number<boost::math::gmp_real<Digits10> > >::data_initializer numeric_limits<boost::math::big_number<boost::math::gmp_real<Digits10> > >::initializer;
+
+template<>
+class numeric_limits<boost::math::big_number<boost::math::gmp_real<0> > >
+{
+ typedef boost::math::big_number<boost::math::gmp_real<0> > number_type;
+public:
+ BOOST_STATIC_CONSTEXPR bool is_specialized = false;
+ BOOST_STATIC_CONSTEXPR number_type (min)() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR number_type (max)() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR number_type lowest() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR int digits = 0;
+ BOOST_STATIC_CONSTEXPR int digits10 = 0;
+ BOOST_STATIC_CONSTEXPR int max_digits10 = 0;
+ BOOST_STATIC_CONSTEXPR bool is_signed = false;
+ BOOST_STATIC_CONSTEXPR bool is_integer = false;
+ BOOST_STATIC_CONSTEXPR bool is_exact = false;
+ BOOST_STATIC_CONSTEXPR int radix = 0;
+ BOOST_STATIC_CONSTEXPR number_type epsilon() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR number_type round_error() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR int min_exponent = 0;
+ BOOST_STATIC_CONSTEXPR int min_exponent10 = 0;
+ BOOST_STATIC_CONSTEXPR int max_exponent = 0;
+ BOOST_STATIC_CONSTEXPR int max_exponent10 = 0;
+ BOOST_STATIC_CONSTEXPR bool has_infinity = false;
+ BOOST_STATIC_CONSTEXPR bool has_quiet_NaN = false;
+ 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() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR number_type quiet_NaN() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR number_type signaling_NaN() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR number_type denorm_min() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR bool is_iec559 = false;
+ BOOST_STATIC_CONSTEXPR bool is_bounded = false;
+ BOOST_STATIC_CONSTEXPR bool is_modulo = false;
+ BOOST_STATIC_CONSTEXPR bool traps = false;
+ BOOST_STATIC_CONSTEXPR bool tinyness_before = false;
+ BOOST_STATIC_CONSTEXPR float_round_style round_style = round_toward_zero;
+};
+
+template<>
+class numeric_limits<boost::math::mpz_int >
+{
+ typedef boost::math::mpz_int number_type;
+public:
+ BOOST_STATIC_CONSTEXPR bool is_specialized = true;
+ //
+ // Largest and smallest numbers are bounded only by available memory, set
+ // to zero:
+ //
+ BOOST_STATIC_CONSTEXPR number_type (min)() noexcept
+ {
+ return number_type();
+ }
+ BOOST_STATIC_CONSTEXPR number_type (max)() noexcept
+ {
+ return number_type();
+ }
+ BOOST_STATIC_CONSTEXPR number_type lowest() noexcept { return (min)(); }
+ // Digits are unbounded, use zero for now:
+ BOOST_STATIC_CONSTEXPR int digits = 0;
+ BOOST_STATIC_CONSTEXPR int digits10 = 0;
+ BOOST_STATIC_CONSTEXPR int max_digits10 = 0;
+ BOOST_STATIC_CONSTEXPR bool is_signed = true;
+ BOOST_STATIC_CONSTEXPR bool is_integer = true;
+ BOOST_STATIC_CONSTEXPR bool is_exact = true;
+ BOOST_STATIC_CONSTEXPR int radix = 2;
+ BOOST_STATIC_CONSTEXPR number_type epsilon() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR number_type round_error() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR int min_exponent = 0;
+ BOOST_STATIC_CONSTEXPR int min_exponent10 = 0;
+ BOOST_STATIC_CONSTEXPR int max_exponent = 0;
+ BOOST_STATIC_CONSTEXPR int max_exponent10 = 0;
+ BOOST_STATIC_CONSTEXPR bool has_infinity = false;
+ BOOST_STATIC_CONSTEXPR bool has_quiet_NaN = false;
+ 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() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR number_type quiet_NaN() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR number_type signaling_NaN() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR number_type denorm_min() noexcept { return number_type(); }
+ BOOST_STATIC_CONSTEXPR bool is_iec559 = false;
+ BOOST_STATIC_CONSTEXPR bool is_bounded = false;
+ BOOST_STATIC_CONSTEXPR bool is_modulo = false;
+ BOOST_STATIC_CONSTEXPR bool traps = false;
+ BOOST_STATIC_CONSTEXPR bool tinyness_before = false;
+ BOOST_STATIC_CONSTEXPR float_round_style round_style = round_toward_zero;
+};
+
+#ifdef BOOST_NO_NOEXCEPT
+# undef noexcept
+#endif
+
+} // namespace std
+
 #endif

Modified: sandbox/big_number/boost/math/big_number/mpfr.hpp
==============================================================================
--- sandbox/big_number/boost/math/big_number/mpfr.hpp (original)
+++ sandbox/big_number/boost/math/big_number/mpfr.hpp 2011-08-22 08:03:49 EDT (Mon, 22 Aug 2011)
@@ -610,4 +610,192 @@
 
 }} // namespaces
 
+namespace std{
+
+#ifdef BOOST_NO_NOEXCEPT
+# define noexcept
+#endif
+
+//
+// numeric_limits [partial] specializations for the types declared in this header:
+//
+template<unsigned Digits10>
+class numeric_limits<boost::math::big_number<boost::math::mpfr_real_backend<Digits10> > >
+{
+ typedef boost::math::big_number<boost::math::mpfr_real_backend<Digits10> > number_type;
+public:
+ BOOST_STATIC_CONSTEXPR bool is_specialized = true;
+ BOOST_STATIC_CONSTEXPR number_type (min)() noexcept
+ {
+ initializer.do_nothing();
+ static std::pair<bool, number_type> value;
+ if(!value.first)
+ {
+ value.first = true;
+ value.second = 0.5;
+ mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), -mpfr_get_emin(), MPFR_RNDN);
+ }
+ return value.second;
+ }
+ BOOST_STATIC_CONSTEXPR number_type (max)() noexcept
+ {
+ initializer.do_nothing();
+ static std::pair<bool, number_type> value;
+ if(!value.first)
+ {
+ value.first = true;
+ value.second = 0.5;
+ mpfr_mul_2exp(value.second.backend().data(), value.second.backend().data(), mpfr_get_emax(), MPFR_RNDN);
+ }
+ return value.second;
+ }
+ BOOST_STATIC_CONSTEXPR number_type lowest() noexcept
+ {
+ return -(max)();
+ }
+ BOOST_STATIC_CONSTEXPR int digits = static_cast<int>(((Digits10 + 1) * 1000L) / 301L);
+ BOOST_STATIC_CONSTEXPR int digits10 = Digits10;
+ // Is this really correct???
+ BOOST_STATIC_CONSTEXPR int max_digits10 = Digits10 + 1;
+ BOOST_STATIC_CONSTEXPR bool is_signed = true;
+ 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() noexcept
+ {
+ initializer.do_nothing();
+ static std::pair<bool, number_type> value;
+ if(!value.first)
+ {
+ value.first = true;
+ value.second = 1;
+ mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), std::numeric_limits<number_type>::digits - 1, MPFR_RNDN);
+ }
+ return value.second;
+ }
+ // What value should this be????
+ BOOST_STATIC_CONSTEXPR number_type round_error() noexcept
+ {
+ // returns epsilon/2
+ initializer.do_nothing();
+ static std::pair<bool, number_type> value;
+ if(!value.first)
+ {
+ value.first = true;
+ value.second = 1;
+ mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), digits, MPFR_RNDN);
+ }
+ return value.second;
+ }
+ BOOST_STATIC_CONSTEXPR long min_exponent = MPFR_EMIN_DEFAULT;
+ BOOST_STATIC_CONSTEXPR long min_exponent10 = (MPFR_EMIN_DEFAULT / 1000) * 301L;
+ BOOST_STATIC_CONSTEXPR long max_exponent = MPFR_EMAX_DEFAULT;
+ BOOST_STATIC_CONSTEXPR long max_exponent10 = (MPFR_EMAX_DEFAULT / 1000) * 301L;
+ BOOST_STATIC_CONSTEXPR bool has_infinity = true;
+ BOOST_STATIC_CONSTEXPR bool has_quiet_NaN = true;
+ 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() noexcept
+ {
+ // returns epsilon/2
+ initializer.do_nothing();
+ static std::pair<bool, number_type> value;
+ if(!value.first)
+ {
+ value.first = true;
+ value.second = 1;
+ mpfr_set_inf(value.second.backend().data(), 1);
+ }
+ return value.second;
+ }
+ BOOST_STATIC_CONSTEXPR number_type quiet_NaN() noexcept
+ {
+ // returns epsilon/2
+ initializer.do_nothing();
+ static std::pair<bool, number_type> value;
+ if(!value.first)
+ {
+ value.first = true;
+ value.second = 1;
+ mpfr_set_nan(value.second.backend().data());
+ }
+ return value.second;
+ }
+ BOOST_STATIC_CONSTEXPR number_type signaling_NaN() noexcept
+ {
+ return number_type(0);
+ }
+ BOOST_STATIC_CONSTEXPR number_type denorm_min() noexcept { return number_type(0); }
+ BOOST_STATIC_CONSTEXPR bool is_iec559 = false;
+ BOOST_STATIC_CONSTEXPR bool is_bounded = true;
+ BOOST_STATIC_CONSTEXPR bool is_modulo = false;
+ BOOST_STATIC_CONSTEXPR bool traps = true;
+ BOOST_STATIC_CONSTEXPR bool tinyness_before = false;
+ BOOST_STATIC_CONSTEXPR float_round_style round_style = round_to_nearest;
+
+private:
+ struct data_initializer
+ {
+ data_initializer()
+ {
+ std::numeric_limits<boost::math::big_number<boost::math::mpfr_real_backend<digits10> > >::epsilon();
+ std::numeric_limits<boost::math::big_number<boost::math::mpfr_real_backend<digits10> > >::round_error();
+ std::numeric_limits<boost::math::big_number<boost::math::mpfr_real_backend<digits10> > >::min();
+ std::numeric_limits<boost::math::big_number<boost::math::mpfr_real_backend<digits10> > >::max();
+ std::numeric_limits<boost::math::big_number<boost::math::mpfr_real_backend<digits10> > >::infinity();
+ std::numeric_limits<boost::math::big_number<boost::math::mpfr_real_backend<digits10> > >::quiet_NaN();
+ }
+ void do_nothing()const{}
+ };
+ static const data_initializer initializer;
+};
+
+template<unsigned Digits10>
+const typename numeric_limits<boost::math::big_number<boost::math::mpfr_real_backend<Digits10> > >::data_initializer numeric_limits<boost::math::big_number<boost::math::mpfr_real_backend<Digits10> > >::initializer;
+
+template<>
+class numeric_limits<boost::math::big_number<boost::math::mpfr_real_backend<0> > >
+{
+ typedef boost::math::big_number<boost::math::mpfr_real_backend<0> > number_type;
+public:
+ BOOST_STATIC_CONSTEXPR bool is_specialized = false;
+ BOOST_STATIC_CONSTEXPR number_type (min)() noexcept { return number_type(0); }
+ BOOST_STATIC_CONSTEXPR number_type (max)() noexcept { return number_type(0); }
+ BOOST_STATIC_CONSTEXPR number_type lowest() noexcept { return number_type(0); }
+ BOOST_STATIC_CONSTEXPR int digits = 0;
+ BOOST_STATIC_CONSTEXPR int digits10 = 0;
+ BOOST_STATIC_CONSTEXPR int max_digits10 = 0;
+ BOOST_STATIC_CONSTEXPR bool is_signed = false;
+ BOOST_STATIC_CONSTEXPR bool is_integer = false;
+ BOOST_STATIC_CONSTEXPR bool is_exact = false;
+ BOOST_STATIC_CONSTEXPR int radix = 0;
+ BOOST_STATIC_CONSTEXPR number_type epsilon() noexcept { return number_type(0); }
+ BOOST_STATIC_CONSTEXPR number_type round_error() noexcept { return number_type(0); }
+ BOOST_STATIC_CONSTEXPR int min_exponent = 0;
+ BOOST_STATIC_CONSTEXPR int min_exponent10 = 0;
+ BOOST_STATIC_CONSTEXPR int max_exponent = 0;
+ BOOST_STATIC_CONSTEXPR int max_exponent10 = 0;
+ BOOST_STATIC_CONSTEXPR bool has_infinity = false;
+ BOOST_STATIC_CONSTEXPR bool has_quiet_NaN = false;
+ 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() noexcept { return number_type(0); }
+ BOOST_STATIC_CONSTEXPR number_type quiet_NaN() noexcept { return number_type(0); }
+ BOOST_STATIC_CONSTEXPR number_type signaling_NaN() noexcept { return number_type(0); }
+ BOOST_STATIC_CONSTEXPR number_type denorm_min() noexcept { return number_type(0); }
+ BOOST_STATIC_CONSTEXPR bool is_iec559 = false;
+ BOOST_STATIC_CONSTEXPR bool is_bounded = false;
+ BOOST_STATIC_CONSTEXPR bool is_modulo = false;
+ BOOST_STATIC_CONSTEXPR bool traps = false;
+ BOOST_STATIC_CONSTEXPR bool tinyness_before = false;
+ BOOST_STATIC_CONSTEXPR float_round_style round_style = round_toward_zero;
+};
+
+#ifdef noexcept
+#undef noexcept
+#endif
+
+} // namespace std
 #endif

Modified: sandbox/big_number/boost/math/concepts/big_number_architypes.hpp
==============================================================================
--- sandbox/big_number/boost/math/concepts/big_number_architypes.hpp (original)
+++ sandbox/big_number/boost/math/concepts/big_number_architypes.hpp 2011-08-22 08:03:49 EDT (Mon, 22 Aug 2011)
@@ -16,6 +16,11 @@
 namespace math{
 namespace concepts{
 
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4244)
+#endif
+
 struct big_number_backend_real_architype
 {
    typedef mpl::list<long long> signed_types;
@@ -140,4 +145,37 @@
 
 }}} // namespaces
 
+namespace std{
+
+#ifdef BOOST_NO_NOEXCEPT
+# define noexcept
+#endif
+
+template <>
+class numeric_limits<boost::math::concepts::big_number_real_architype> : public std::numeric_limits<long double>
+{
+ typedef std::numeric_limits<long double> base_type;
+ typedef boost::math::concepts::big_number_real_architype number_type;
+public:
+ BOOST_STATIC_CONSTEXPR number_type (min)() noexcept { return (base_type::min)(); }
+ BOOST_STATIC_CONSTEXPR number_type (max)() noexcept { return (base_type::max)(); }
+ BOOST_STATIC_CONSTEXPR number_type lowest() noexcept { return -(max)(); }
+ BOOST_STATIC_CONSTEXPR number_type epsilon() noexcept { return base_type::epsilon(); }
+ BOOST_STATIC_CONSTEXPR number_type round_error() noexcept { return epsilon() / 2; }
+ BOOST_STATIC_CONSTEXPR number_type infinity() noexcept { return base_type::infinity(); }
+ BOOST_STATIC_CONSTEXPR number_type quiet_NaN() noexcept { return base_type::quiet_NaN(); }
+ BOOST_STATIC_CONSTEXPR number_type signaling_NaN() noexcept { return base_type::signaling_NaN(); }
+ BOOST_STATIC_CONSTEXPR number_type denorm_min() noexcept { return base_type::denorm_min(); }
+};
+
+#ifdef BOOST_NO_NOEXCEPT
+# undef noexcept
+#endif
+
+}
+
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
 #endif

Modified: sandbox/big_number/libs/math/test/linpack-benchmark.cpp
==============================================================================
--- sandbox/big_number/libs/math/test/linpack-benchmark.cpp (original)
+++ sandbox/big_number/libs/math/test/linpack-benchmark.cpp 2011-08-22 08:03:49 EDT (Mon, 22 Aug 2011)
@@ -31,16 +31,15 @@
 #elif defined(TEST_MPFRXX)
 #include <gmpfrxx.h>
 typedef mpfr_class real_type;
-#elif defined(TEST_EF_GMP)
-#define E_FLOAT_TYPE_GMP
-#include <e_float/e_float.h>
-typedef e_float real_type;
-#define CAST_TO_RT(x) real_type(x)
-#elif defined(TEST_MATH_EF)
-#define E_FLOAT_TYPE_GMP
-#include <boost/math/bindings/e_float.hpp>
-typedef boost::math::ef::e_float real_type;
-//#define CAST_TO_RT(x) real_type(x)
+#elif defined(TEST_E_FLOAT)
+#include <boost/e_float/e_float.hpp>
+#include <boost/e_float/e_float_complex.hpp>
+#include <boost/e_float/e_float_elementary_math.hpp>
+typedef ::efx::e_float real_type;
+using ef::abs;
+#elif defined(TEST_E_FLOAT_BN)
+#include <boost/math/big_number/e_float.hpp>
+typedef boost::math::e_float real_type;
 #else
 typedef double real_type;
 #endif
@@ -69,12 +68,6 @@
 }
 #include <time.h>
 
-
-#if defined(TEST_EF_GMP)
-#include <functions/functions.h>
-using namespace ef;
-#endif
-
 using std::min;
 using std::max;
 
@@ -115,10 +108,10 @@
 #elif defined(TEST_MPFRXX)
    std::cout << "Testing mpfr_class at 100 decimal degits" << std::endl;
    mpfr_set_default_prec(((100 + 1) * 1000L) / 301L);
-#elif defined(TEST_EF_GMP)
- std::cout << "Testing gmp::e_float" << std::endl;
-#elif defined(TEST_MATH_EF)
- std::cout << "Testing boost::math::ef::e_float" << std::endl;
+#elif defined(TEST_E_FLOAT)
+ std::cout << "Testing boost::ef::e_float" << std::endl;
+#elif defined(TEST_E_FLOAT_BN)
+ std::cout << "Testing boost::math::e_float" << std::endl;
 #else
    std::cout << "Testing double" << std::endl;
 #endif
@@ -926,6 +919,8 @@
 {
 #if defined(TEST_MPF_100) || defined(TEST_MPFR_100) || defined(TEST_GMPXX) || defined(TEST_MPFRXX)
    return std::ldexp(1.0, 1 - ((100 + 1) * 1000L) / 301L);
+#elif defined(TEST_E_FLOAT_BN)
+ return std::pow(10.0, 1-std::numeric_limits<efx::e_float>::digits10);
 #else
    return CAST_TO_RT(std::numeric_limits<real_type>::epsilon());
 #endif

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-22 08:03:49 EDT (Mon, 22 Aug 2011)
@@ -12,6 +12,7 @@
 # define TEST_MPZ
 # define TEST_MPFR
 # define TEST_MPFR_50
+# define TEST_E_FLOAT
 
 #ifdef _MSC_VER
 #pragma message("CAUTION!!: No backend type specified so testing everything.... this will take some time!!")
@@ -29,8 +30,7 @@
 #include <boost/math/concepts/big_number_architypes.hpp>
 #endif
 #ifdef TEST_E_FLOAT
-#include <boost/math/big_number.hpp>
-#include <boost/math/bindings/e_float.hpp>
+#include <boost/math/big_number/e_float.hpp>
 #endif
 #if defined(TEST_MPFR) || defined(TEST_MPFR_50)
 #include <boost/math/big_number/mpfr.hpp>
@@ -616,7 +616,7 @@
    test<boost::math::mpz_int>();
 #endif
 #ifdef TEST_E_FLOAT
- test<boost::math::ef::e_float>();
+ test<boost::math::e_float>();
 #endif
 #ifdef TEST_MPFR
    test<boost::math::mpfr_real>();
@@ -627,11 +627,3 @@
    return boost::report_errors();
 }
 
-namespace boost
-{
- void assertion_failed(char const * expr,
- char const * function, char const * file, long line)
- {
- std::cout << "Failed assertion in expression: " << expr << " in function: " << function << " in file: " << file << " at line: " << line <<std::endl;
- }
-}
\ No newline at end of file

Added: sandbox/big_number/libs/math/test/test_numeric_limits.cpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/libs/math/test/test_numeric_limits.cpp 2011-08-22 08:03:49 EDT (Mon, 22 Aug 2011)
@@ -0,0 +1,117 @@
+///////////////////////////////////////////////////////////////
+// Copyright 2011 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_
+
+#include <boost/detail/lightweight_test.hpp>
+
+#if !defined(TEST_MPF50) && !defined(TEST_MPF) && !defined(TEST_BACKEND) && !defined(TEST_MPZ) && !defined(TEST_E_FLOAT) && !defined(TEST_MPFR) && !defined(TEST_MPFR_50)
+# define TEST_MPF50
+# define TEST_MPF
+# define TEST_BACKEND
+# define TEST_MPZ
+# define TEST_MPFR
+# define TEST_MPFR_50
+# define TEST_E_FLOAT
+
+#ifdef _MSC_VER
+#pragma message("CAUTION!!: No backend type specified so testing everything.... this will take some time!!")
+#endif
+#ifdef __GNUC__
+#pragma warning "CAUTION!!: No backend type specified so testing everything.... this will take some time!!"
+#endif
+
+#endif
+
+#if defined(TEST_MPF50) || defined(TEST_MPF) || defined(TEST_MPZ)
+#include <boost/math/big_number/gmp.hpp>
+#endif
+#ifdef TEST_BACKEND
+#include <boost/math/concepts/big_number_architypes.hpp>
+#endif
+#ifdef TEST_E_FLOAT
+#include <boost/math/big_number/e_float.hpp>
+#endif
+#if defined(TEST_MPFR) || defined(TEST_MPFR_50)
+#include <boost/math/big_number/mpfr.hpp>
+#endif
+
+#define PRINT(x)\
+ std::cout << BOOST_STRINGIZE(x) << " = " << std::numeric_limits<Number>::x << std::endl;
+
+template <class Number>
+void test()
+{
+ //
+ // Note really a test just yet, but we can at least print out all the values:
+ //
+ std::cout << "numeric_limits values for type " << typeid(Number).name() << std::endl;
+
+ PRINT(is_specialized);
+ PRINT(min());
+ PRINT(max());
+ PRINT(lowest());
+ PRINT(digits);
+ PRINT(digits10);
+ PRINT(max_digits10);
+ PRINT(is_signed);
+ PRINT(is_integer);
+ PRINT(is_exact);
+ PRINT(radix);
+ PRINT(epsilon());
+ PRINT(round_error());
+ PRINT(min_exponent);
+ PRINT(min_exponent10);
+ PRINT(max_exponent);
+ PRINT(max_exponent10);
+ PRINT(has_infinity);
+ PRINT(has_quiet_NaN);
+ PRINT(has_signaling_NaN);
+ PRINT(has_denorm);
+ PRINT(has_denorm_loss);
+ PRINT(infinity());
+ PRINT(quiet_NaN());
+ PRINT(signaling_NaN());
+ PRINT(denorm_min());
+ PRINT(is_iec559);
+ PRINT(is_bounded);
+ PRINT(is_modulo);
+ PRINT(traps);
+ PRINT(tinyness_before);
+ PRINT(round_style);
+}
+
+
+int main()
+{
+#ifdef TEST_BACKEND
+ test<boost::math::big_number<boost::math::concepts::big_number_backend_real_architype> >();
+#endif
+#ifdef TEST_MPF50
+ test<boost::math::mpf_real_50>();
+#endif
+#ifdef TEST_MPF
+ boost::math::mpf_real::default_precision(1000);
+ /*
+ boost::math::mpf_real r;
+ r.precision(50);
+ BOOST_TEST(r.precision() >= 50);
+ */
+ BOOST_TEST(boost::math::mpf_real::default_precision() == 1000);
+ test<boost::math::mpf_real>();
+#endif
+#ifdef TEST_MPZ
+ test<boost::math::mpz_int>();
+#endif
+#ifdef TEST_E_FLOAT
+ test<boost::math::e_float>();
+#endif
+#ifdef TEST_MPFR
+ test<boost::math::mpfr_real>();
+#endif
+#ifdef TEST_MPFR_50
+ test<boost::math::mpfr_real_50>();
+#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