|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r74669 - in sandbox/big_number: boost/multiprecision boost/multiprecision/concepts boost/multiprecision/detail boost/multiprecision/detail/functions libs/multiprecision/test
From: john_at_[hidden]
Date: 2011-10-03 12:56:40
Author: johnmaddock
Date: 2011-10-03 12:56:24 EDT (Mon, 03 Oct 2011)
New Revision: 74669
URL: http://svn.boost.org/trac/boost/changeset/74669
Log:
Changed namespace to "multiprecision".
Added some numberic constant calculations.
Added exp function support and test case.
Added:
sandbox/big_number/boost/multiprecision/detail/functions/constants.hpp (contents, props changed)
sandbox/big_number/libs/multiprecision/test/test_exp.cpp (contents, props changed)
Text files modified:
sandbox/big_number/boost/multiprecision/arithmetic_backend.hpp | 6
sandbox/big_number/boost/multiprecision/concepts/big_number_architypes.hpp | 23 +++-
sandbox/big_number/boost/multiprecision/detail/big_number_base.hpp | 10 +-
sandbox/big_number/boost/multiprecision/detail/default_ops.hpp | 189 +++++++++++++++++++++++++++------------
sandbox/big_number/boost/multiprecision/detail/functions/pow.hpp | 146 ++++++++++++++++++++++++++++++
sandbox/big_number/boost/multiprecision/e_float.hpp | 2
sandbox/big_number/boost/multiprecision/gmp.hpp | 90 ++++++++++++++++--
sandbox/big_number/boost/multiprecision/mp_number.hpp | 29 -----
sandbox/big_number/boost/multiprecision/mpfr.hpp | 30 +++--
sandbox/big_number/libs/multiprecision/test/Jamfile.v2 | 8 +
sandbox/big_number/libs/multiprecision/test/big_number_concept_check.cpp | 22 ++--
sandbox/big_number/libs/multiprecision/test/linpack-benchmark.cpp | 10 +-
sandbox/big_number/libs/multiprecision/test/test_arithmetic.cpp | 30 +++---
sandbox/big_number/libs/multiprecision/test/test_numeric_limits.cpp | 22 ++--
14 files changed, 446 insertions(+), 171 deletions(-)
Modified: sandbox/big_number/boost/multiprecision/arithmetic_backend.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/arithmetic_backend.hpp (original)
+++ sandbox/big_number/boost/multiprecision/arithmetic_backend.hpp 2011-10-03 12:56:24 EDT (Mon, 03 Oct 2011)
@@ -13,7 +13,7 @@
#include <boost/multiprecision/mp_number.hpp>
namespace boost{
-namespace math{
+namespace multiprecision{
template <class Arithmetic>
struct arithmetic_backend
@@ -122,10 +122,10 @@
#endif
template <class Arithmetic>
-class numeric_limits<boost::math::mp_number<boost::math::arithmetic_backend<Arithmetic> > > : public std::numeric_limits<Arithmetic>
+class numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::arithmetic_backend<Arithmetic> > > : public std::numeric_limits<Arithmetic>
{
typedef std::numeric_limits<Arithmetic> base_type;
- typedef boost::math::mp_number<boost::math::arithmetic_backend<Arithmetic> > number_type;
+ typedef boost::multiprecision::mp_number<boost::multiprecision::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)(); }
Modified: sandbox/big_number/boost/multiprecision/concepts/big_number_architypes.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/concepts/big_number_architypes.hpp (original)
+++ sandbox/big_number/boost/multiprecision/concepts/big_number_architypes.hpp 2011-10-03 12:56:24 EDT (Mon, 03 Oct 2011)
@@ -15,7 +15,7 @@
#include <boost/math/special_functions/trunc.hpp>
namespace boost{
-namespace math{
+namespace multiprecision{
namespace concepts{
#ifdef BOOST_MSVC
@@ -64,7 +64,7 @@
}
big_number_backend_real_architype& operator = (const char* s)
{
- m_value = boost::lexical_cast<double>(s);
+ m_value = boost::lexical_cast<long double>(s);
std::cout << "const char* Assignment (" << s << ")" << std::endl;
return *this;
}
@@ -143,6 +143,19 @@
result.m_value /= o.m_value;
}
+inline void convert_to(boost::uintmax_t* result, const big_number_backend_real_architype& val)
+{
+ *result = static_cast<boost::uintmax_t>(val.m_value);
+}
+inline void convert_to(boost::intmax_t* result, const big_number_backend_real_architype& val)
+{
+ *result = static_cast<boost::intmax_t>(val.m_value);
+}
+inline void convert_to(long double* result, big_number_backend_real_architype& val)
+{
+ *result = val.m_value;
+}
+
inline void eval_frexp(big_number_backend_real_architype& result, const big_number_backend_real_architype& arg, int* exp)
{
result = std::frexp(arg.m_value, exp);
@@ -253,7 +266,7 @@
result = std::tanh(arg.m_value);
}
-typedef boost::math::mp_number<big_number_backend_real_architype> big_number_real_architype;
+typedef boost::multiprecision::mp_number<big_number_backend_real_architype> big_number_real_architype;
}}} // namespaces
@@ -264,10 +277,10 @@
#endif
template <>
-class numeric_limits<boost::math::concepts::big_number_real_architype> : public std::numeric_limits<long double>
+class numeric_limits<boost::multiprecision::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;
+ typedef boost::multiprecision::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)(); }
Modified: sandbox/big_number/boost/multiprecision/detail/big_number_base.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/detail/big_number_base.hpp (original)
+++ sandbox/big_number/boost/multiprecision/detail/big_number_base.hpp 2011-10-03 12:56:24 EDT (Mon, 03 Oct 2011)
@@ -10,7 +10,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_convertible.hpp>
-namespace boost{ namespace math{
+namespace boost{ namespace multiprecision{
template <class Backend>
class mp_number;
@@ -139,11 +139,11 @@
template <class T>
struct is_big_number : public mpl::false_{};
template <class T>
-struct is_big_number<boost::math::mp_number<T> > : public mpl::true_{};
+struct is_big_number<boost::multiprecision::mp_number<T> > : public mpl::true_{};
template <class T>
struct is_big_number_exp : public mpl::false_{};
template <class Tag, class Arg1, class Arg2, class Arg3>
-struct is_big_number_exp<boost::math::detail::mp_exp<Tag, Arg1, Arg2, Arg3> > : public mpl::true_{};
+struct is_big_number_exp<boost::multiprecision::detail::mp_exp<Tag, Arg1, Arg2, Arg3> > : public mpl::true_{};
template <class T1, class T2>
struct combine_expression;
@@ -971,9 +971,9 @@
struct promote_arg;
template <class tag, class A1, class A2, class A3>
-struct promote_arg<boost::math::detail::mp_exp<tag, A1, A2, A3> >
+struct promote_arg<boost::multiprecision::detail::mp_exp<tag, A1, A2, A3> >
{
- typedef typename boost::math::detail::mp_exp<tag, A1, A2, A3>::result_type type;
+ typedef typename boost::multiprecision::detail::mp_exp<tag, A1, A2, A3>::result_type type;
};
}}}
Modified: sandbox/big_number/boost/multiprecision/detail/default_ops.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/detail/default_ops.hpp (original)
+++ sandbox/big_number/boost/multiprecision/detail/default_ops.hpp 2011-10-03 12:56:24 EDT (Mon, 03 Oct 2011)
@@ -12,8 +12,9 @@
#include <boost/lexical_cast.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/mpl/front.hpp>
+#include <boost/cstdint.hpp>
-namespace boost{ namespace math{ namespace big_num_default_ops{
+namespace boost{ namespace multiprecision{ namespace big_num_default_ops{
//
// Default versions of mixed arithmetic, these just construct a temporary
@@ -372,6 +373,29 @@
multiply(n, b);
subtract(result, a, n);
}
+template <class T>
+inline void eval_trunc(T& result, const T& a)
+{
+ if(get_sign(a) < 0)
+ eval_ceil(result, a);
+ else
+ eval_floor(result, a);
+}
+
+template <class T>
+inline void eval_round(T& result, const T& a)
+{
+ if(get_sign(a) < 0)
+ {
+ subtract(result, a, 0.5f);
+ eval_ceil(result, result);
+ }
+ else
+ {
+ add(result, a, 0.5f);
+ eval_floor(result, result);
+ }
+}
//
// These have to implemented by the backend, declared here so that our macro generated code compiles OK.
@@ -414,8 +438,10 @@
template <class T>
typename enable_if_c<sizeof(T) == 0>::type eval_tanh();
//
-// These functions are implemented in separate files, but expanded inline here:
+// These functions are implemented in separate files, but expanded inline here,
+// DO NOT CHANGE THE ORDER OF THESE INCLUDES:
//
+#include <boost/multiprecision/detail/functions/constants.hpp>
#include <boost/multiprecision/detail/functions/pow.hpp>
}
@@ -423,74 +449,95 @@
template <class Backend>
class mp_number;
+} // namespace multiprecision
+namespace math{
//
// Default versions of floating point classification routines:
//
template <class Backend>
-inline int fpclassify BOOST_PREVENT_MACRO_SUBSTITUTION(const mp_number<Backend>& arg)
+inline int fpclassify BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::mp_number<Backend>& arg)
{
- using big_num_default_ops::eval_fpclassify;
+ using multiprecision::big_num_default_ops::eval_fpclassify;
return eval_fpclassify(arg.backend());
}
template <class tag, class A1, class A2, class A3>
-inline int fpclassify BOOST_PREVENT_MACRO_SUBSTITUTION(const detail::mp_exp<tag, A1, A2, A3>& arg)
+inline int fpclassify BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::detail::mp_exp<tag, A1, A2, A3>& arg)
{
- typedef typename detail::mp_exp<tag, A1, A2, A3>::result_type value_type;
+ typedef typename multiprecision::detail::mp_exp<tag, A1, A2, A3>::result_type value_type;
return fpclassify(value_type(arg));
}
template <class Backend>
-inline bool isfinite BOOST_PREVENT_MACRO_SUBSTITUTION(const mp_number<Backend>& arg)
+inline bool isfinite BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::mp_number<Backend>& arg)
{
int v = fpclassify(arg);
return (v != FP_INFINITE) && (v != FP_NAN);
}
template <class tag, class A1, class A2, class A3>
-inline bool isfinite BOOST_PREVENT_MACRO_SUBSTITUTION(const detail::mp_exp<tag, A1, A2, A3>& arg)
+inline bool isfinite BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::detail::mp_exp<tag, A1, A2, A3>& arg)
{
- typedef typename detail::mp_exp<tag, A1, A2, A3>::result_type value_type;
+ typedef typename multiprecision::detail::mp_exp<tag, A1, A2, A3>::result_type value_type;
return isfinite(value_type(arg));
}
template <class Backend>
-inline bool isnan BOOST_PREVENT_MACRO_SUBSTITUTION(const mp_number<Backend>& arg)
+inline bool isnan BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::mp_number<Backend>& arg)
{
return fpclassify(arg) == FP_NAN;
}
template <class tag, class A1, class A2, class A3>
-inline bool isnan BOOST_PREVENT_MACRO_SUBSTITUTION(const detail::mp_exp<tag, A1, A2, A3>& arg)
+inline bool isnan BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::detail::mp_exp<tag, A1, A2, A3>& arg)
{
- typedef typename detail::mp_exp<tag, A1, A2, A3>::result_type value_type;
+ typedef typename multiprecision::detail::mp_exp<tag, A1, A2, A3>::result_type value_type;
return isnan(value_type(arg));
}
template <class Backend>
-inline bool isinf BOOST_PREVENT_MACRO_SUBSTITUTION(const mp_number<Backend>& arg)
+inline bool isinf BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::mp_number<Backend>& arg)
{
return fpclassify(arg) == FP_INFINITE;
}
template <class tag, class A1, class A2, class A3>
-inline bool isinf BOOST_PREVENT_MACRO_SUBSTITUTION(const detail::mp_exp<tag, A1, A2, A3>& arg)
+inline bool isinf BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::detail::mp_exp<tag, A1, A2, A3>& arg)
{
- typedef typename detail::mp_exp<tag, A1, A2, A3>::result_type value_type;
+ typedef typename multiprecision::detail::mp_exp<tag, A1, A2, A3>::result_type value_type;
return isinf(value_type(arg));
}
template <class Backend>
-inline bool isnormal BOOST_PREVENT_MACRO_SUBSTITUTION(const mp_number<Backend>& arg)
+inline bool isnormal BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::mp_number<Backend>& arg)
{
return fpclassify(arg) == FP_NORMAL;
}
template <class tag, class A1, class A2, class A3>
-inline bool isnormal BOOST_PREVENT_MACRO_SUBSTITUTION(const detail::mp_exp<tag, A1, A2, A3>& arg)
+inline bool isnormal BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::detail::mp_exp<tag, A1, A2, A3>& arg)
{
- typedef typename detail::mp_exp<tag, A1, A2, A3>::result_type value_type;
+ typedef typename multiprecision::detail::mp_exp<tag, A1, A2, A3>::result_type value_type;
return isnormal(value_type(arg));
}
+} // namespace math
+namespace multiprecision{
+
+template <class tag, class A1, class A2, class A3, class Policy>
+inline typename detail::mp_exp<tag, A1, A2, A3>::result_type trunc(const detail::mp_exp<tag, A1, A2, A3>& v, const Policy& pol)
+{
+ typedef typename detail::mp_exp<tag, A1, A2, A3>::result_type number_type;
+ return trunc(v, pol);
+}
+
+template <class Backend, class Policy>
+inline mp_number<Backend> trunc(const mp_number<Backend>& v, const Policy& pol)
+{
+ using big_num_default_ops::eval_trunc;
+ mp_number<Backend> result;
+ eval_trunc(result.backend(), v.backend());
+ return result;
+}
+
template <class tag, class A1, class A2, class A3, class Policy>
inline int itrunc(const detail::mp_exp<tag, A1, A2, A3>& v, const Policy& pol)
{
typedef typename detail::mp_exp<tag, A1, A2, A3>::result_type number_type;
number_type r = trunc(v, pol);
if(fabs(r) > (std::numeric_limits<int>::max)())
- return policies::raise_rounding_error("boost::math::itrunc<%1%>(%1%)", 0, v, 0, pol).template convert_to<int>();
+ return boost::math::policies::raise_rounding_error("boost::multiprecision::itrunc<%1%>(%1%)", 0, v, 0, pol).template convert_to<int>();
return r.template convert_to<int>();
}
template <class Backend, class Policy>
@@ -498,7 +545,7 @@
{
mp_number<Backend> r = trunc(v, pol);
if(fabs(r) > (std::numeric_limits<int>::max)())
- return policies::raise_rounding_error("boost::math::itrunc<%1%>(%1%)", 0, v, 0, pol).template convert_to<int>();
+ return boost::math::policies::raise_rounding_error("boost::multiprecision::itrunc<%1%>(%1%)", 0, v, 0, pol).template convert_to<int>();
return r.template convert_to<int>();
}
template <class tag, class A1, class A2, class A3, class Policy>
@@ -507,7 +554,7 @@
typedef typename detail::mp_exp<tag, A1, A2, A3>::result_result number_type;
number_type r = trunc(v, pol);
if(fabs(r) > (std::numeric_limits<long>::max)())
- return policies::raise_rounding_error("boost::math::ltrunc<%1%>(%1%)", 0, v, 0L, pol).template convert_to<long>();
+ return boost::math::policies::raise_rounding_error("boost::multiprecision::ltrunc<%1%>(%1%)", 0, v, 0L, pol).template convert_to<long>();
return r.template convert_to<long>();
}
template <class T, class Policy>
@@ -515,7 +562,7 @@
{
mp_number<T> r = trunc(v, pol);
if(fabs(r) > (std::numeric_limits<long>::max)())
- return policies::raise_rounding_error("boost::math::ltrunc<%1%>(%1%)", 0, v, 0L, pol).template convert_to<long>();
+ return boost::math::policies::raise_rounding_error("boost::multiprecision::ltrunc<%1%>(%1%)", 0, v, 0L, pol).template convert_to<long>();
return r.template convert_to<long>();
}
#ifndef BOOST_NO_LONG_LONG
@@ -525,7 +572,7 @@
typedef typename detail::mp_exp<tag, A1, A2, A3>::result_result number_type;
number_type r = trunc(v, pol);
if(fabs(r) > (std::numeric_limits<long long>::max)())
- return policies::raise_rounding_error("boost::math::lltrunc<%1%>(%1%)", 0, v, 0LL, pol).template convert_to<long long>();
+ return boost::math::policies::raise_rounding_error("boost::multiprecision::lltrunc<%1%>(%1%)", 0, v, 0LL, pol).template convert_to<long long>();
return r.template convert_to<long long>();
}
template <class T, class Policy>
@@ -533,17 +580,32 @@
{
mp_number<T> r = trunc(v, pol);
if(fabs(r) > (std::numeric_limits<long long>::max)())
- return policies::raise_rounding_error("boost::math::lltrunc<%1%>(%1%)", 0, v, 0LL, pol).template convert_to<long long>();
+ return boost::math::policies::raise_rounding_error("boost::multiprecision::lltrunc<%1%>(%1%)", 0, v, 0LL, pol).template convert_to<long long>();
return r.template convert_to<long long>();
}
#endif
template <class tag, class A1, class A2, class A3, class Policy>
+inline typename detail::mp_exp<tag, A1, A2, A3>::result_result round(const detail::mp_exp<tag, A1, A2, A3>& v, const Policy& pol)
+{
+ typedef typename detail::mp_exp<tag, A1, A2, A3>::result_result number_type;
+ return round(static_cast<number_type>(v), pol);
+}
+template <class T, class Policy>
+inline mp_number<T> round(const mp_number<T>& v, const Policy& pol)
+{
+ using big_num_default_ops::eval_round;
+ mp_number<T> result;
+ eval_round(result.backend(), v.backend());
+ return result;
+}
+
+template <class tag, class A1, class A2, class A3, class Policy>
inline int iround(const detail::mp_exp<tag, A1, A2, A3>& v, const Policy& pol)
{
typedef typename detail::mp_exp<tag, A1, A2, A3>::result_result number_type;
number_type r = round(v, pol);
if(fabs(r) > (std::numeric_limits<int>::max)())
- return policies::raise_rounding_error("boost::math::iround<%1%>(%1%)", 0, v, 0, pol).template convert_to<int>();
+ return boost::math::policies::raise_rounding_error("boost::multiprecision::iround<%1%>(%1%)", 0, v, 0, pol).template convert_to<int>();
return r.template convert_to<int>();
}
template <class T, class Policy>
@@ -551,7 +613,7 @@
{
mp_number<T> r = round(v, pol);
if(fabs(r) > (std::numeric_limits<int>::max)())
- return policies::raise_rounding_error("boost::math::iround<%1%>(%1%)", 0, v, 0, pol).template convert_to<int>();
+ return boost::math::policies::raise_rounding_error("boost::multiprecision::iround<%1%>(%1%)", 0, v, 0, pol).template convert_to<int>();
return r.template convert_to<int>();
}
template <class tag, class A1, class A2, class A3, class Policy>
@@ -560,7 +622,7 @@
typedef typename detail::mp_exp<tag, A1, A2, A3>::result_result number_type;
number_type r = round(v, pol);
if(fabs(r) > (std::numeric_limits<long>::max)())
- return policies::raise_rounding_error("boost::math::lround<%1%>(%1%)", 0, v, 0L, pol).template convert_to<long>();
+ return boost::math::policies::raise_rounding_error("boost::multiprecision::lround<%1%>(%1%)", 0, v, 0L, pol).template convert_to<long>();
return r.template convert_to<long>();
}
template <class T, class Policy>
@@ -568,7 +630,7 @@
{
mp_number<T> r = round(v, pol);
if(fabs(r) > (std::numeric_limits<long>::max)())
- return policies::raise_rounding_error("boost::math::lround<%1%>(%1%)", 0, v, 0L, pol).template convert_to<long>();
+ return boost::math::policies::raise_rounding_error("boost::multiprecision::lround<%1%>(%1%)", 0, v, 0L, pol).template convert_to<long>();
return r.template convert_to<long>();
}
#ifndef BOOST_NO_LONG_LONG
@@ -578,7 +640,7 @@
typedef typename detail::mp_exp<tag, A1, A2, A3>::result_result number_type;
number_type r = round(v, pol);
if(fabs(r) > (std::numeric_limits<long long>::max)())
- return policies::raise_rounding_error("boost::math::iround<%1%>(%1%)", 0, v, 0LL, pol).template convert_to<long long>();
+ return boost::math::policies::raise_rounding_error("boost::multiprecision::iround<%1%>(%1%)", 0, v, 0LL, pol).template convert_to<long long>();
return r.template convert_to<long long>();
}
template <class T, class Policy>
@@ -586,40 +648,10 @@
{
mp_number<T> r = round(v, pol);
if(fabs(r) > (std::numeric_limits<long long>::max)())
- return policies::raise_rounding_error("boost::math::iround<%1%>(%1%)", 0, v, 0LL, pol).template convert_to<long long>();
+ return boost::math::policies::raise_rounding_error("boost::multiprecision::iround<%1%>(%1%)", 0, v, 0LL, pol).template convert_to<long long>();
return r.template convert_to<long long>();
}
#endif
-//
-// Overload of Boost.Math functions that find the wrong overload when used with mp_number:
-//
-namespace detail{
- template <class T> T sinc_pi_imp(T);
- template <class T> T sinhc_pi_imp(T);
-}
-template <class Backend>
-inline mp_number<Backend> sinc_pi(const mp_number<Backend>& x)
-{
- return detail::sinc_pi_imp(x);
-}
-
-template <class Backend, class Policy>
-inline mp_number<Backend> sinc_pi(const mp_number<Backend>& x, const Policy&)
-{
- return detail::sinc_pi_imp(x);
-}
-
-template <class Backend>
-inline mp_number<Backend> sinhc_pi(const mp_number<Backend>& x)
-{
- return detail::sinhc_pi_imp(x);
-}
-
-template <class Backend, class Policy>
-inline mp_number<Backend> sinhc_pi(const mp_number<Backend>& x, const Policy&)
-{
- return boost::math::sinhc_pi(x);
-}
#define UNARY_OP_FUNCTOR(func)\
namespace detail{\
@@ -897,7 +929,42 @@
#undef BINARY_OP_FUNCTOR
#undef UNARY_OP_FUNCTOR
-}} // namespaces
+} //namespace multiprecision
+
+namespace math{
+//
+// Overload of Boost.Math functions that find the wrong overload when used with mp_number:
+//
+namespace detail{
+ template <class T> T sinc_pi_imp(T);
+ template <class T> T sinhc_pi_imp(T);
+}
+template <class Backend>
+inline multiprecision::mp_number<Backend> sinc_pi(const multiprecision::mp_number<Backend>& x)
+{
+ return detail::sinc_pi_imp(x);
+}
+
+template <class Backend, class Policy>
+inline multiprecision::mp_number<Backend> sinc_pi(const multiprecision::mp_number<Backend>& x, const Policy&)
+{
+ return detail::sinc_pi_imp(x);
+}
+
+template <class Backend>
+inline multiprecision::mp_number<Backend> sinhc_pi(const multiprecision::mp_number<Backend>& x)
+{
+ return detail::sinhc_pi_imp(x);
+}
+
+template <class Backend, class Policy>
+inline multiprecision::mp_number<Backend> sinhc_pi(const multiprecision::mp_number<Backend>& x, const Policy&)
+{
+ return boost::multiprecision::sinhc_pi(x);
+}
+
+} // namespace math
+} // namespace boost
#endif
Added: sandbox/big_number/boost/multiprecision/detail/functions/constants.hpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/boost/multiprecision/detail/functions/constants.hpp 2011-10-03 12:56:24 EDT (Mon, 03 Oct 2011)
@@ -0,0 +1,116 @@
+// Copyright 2011 John Maddock. Distributed under the Boost
+// 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_0.txt)
+//
+// This file has no include guards or namespaces - it's expanded inline inside default_ops.hpp
+//
+
+template <class T>
+void calc_log2(T& num, unsigned digits)
+{
+ typedef typename has_enough_bits<unsigned, std::numeric_limits<unsigned>::digits>::template type<mpl::_> pred_type;
+ typedef typename mpl::find_if<
+ typename T::unsigned_types,
+ pred_type
+ >::type iter_type;
+ typedef typename mpl::deref<iter_type>::type ui_type;
+ typedef typename mpl::front<typename T::signed_types>::type si_type;
+
+ num = static_cast<ui_type>(1180509120u);
+ T denom, next_term, temp;
+ denom = static_cast<ui_type>(1277337600u);
+ next_term = static_cast<ui_type>(120u);
+ si_type sign = -1;
+
+ ui_type limit = digits / 3 + 1;
+
+ for(ui_type n = 6; n < limit; ++n)
+ {
+ temp = static_cast<ui_type>(2);
+ multiply(temp, ui_type(2 * n));
+ multiply(temp, ui_type(2 * n + 1));
+ multiply(num, temp);
+ multiply(denom, temp);
+ sign = -sign;
+ multiply(next_term, n);
+ multiply(temp, next_term, next_term);
+ multiply(temp, sign);
+ add(num, temp);
+ }
+ multiply(denom, ui_type(4));
+ multiply(num, ui_type(3));
+ divide(num, denom);
+}
+
+template <class T>
+void calc_e(T& result, unsigned digits)
+{
+ typedef typename mpl::front<typename T::unsigned_types>::type ui_type;
+ typedef typename mpl::front<typename T::real_types>::type real_type;
+ T lim;
+ lim = ui_type(1);
+ eval_ldexp(lim, lim, digits);
+
+ result = ui_type(2);
+ T denom;
+ denom = ui_type(1);
+ ui_type i = 2;
+ do{
+ multiply(denom, i);
+ multiply(result, i);
+ add(result, ui_type(1));
+ ++i;
+ }while(denom.compare(lim) <= 0);
+ divide(result, denom);
+}
+
+
+template <class T, const T& (*F)(void)>
+struct constant_initializer
+{
+ static void do_nothing()
+ {
+ init.do_nothing();
+ }
+private:
+ struct initializer
+ {
+ initializer()
+ {
+ F();
+ }
+ void do_nothing()const{}
+ };
+ static const initializer init;
+};
+
+template <class T, const T& (*F)(void)>
+typename constant_initializer<T, F>::initializer const constant_initializer<T, F>::init;
+
+template <class T>
+const T& get_constant_ln2()
+{
+ static T result;
+ static bool b = false;
+ if(!b)
+ calc_log2(result, std::numeric_limits<mp_number<T> >::digits);
+
+ constant_initializer<T, &get_constant_ln2<T> >::do_nothing();
+
+ return result;
+}
+
+template <class T>
+const T& get_constant_e()
+{
+ static T result;
+ static bool b = false;
+ if(!b)
+ calc_e(result, std::numeric_limits<mp_number<T> >::digits);
+
+ constant_initializer<T, &get_constant_e<T> >::do_nothing();
+
+ return result;
+}
+
Modified: sandbox/big_number/boost/multiprecision/detail/functions/pow.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/detail/functions/pow.hpp (original)
+++ sandbox/big_number/boost/multiprecision/detail/functions/pow.hpp 2011-10-03 12:56:24 EDT (Mon, 03 Oct 2011)
@@ -94,4 +94,150 @@
detail::pow_imp(result, t, p, tag_type());
}
+template <class T>
+void hyp0F0(T& H0F0, const T& x)
+{
+ // Compute the series representation of Hypergeometric0F0 taken from
+ // http://functions.wolfram.com/HypergeometricFunctions/Hypergeometric0F0/06/01/
+ // There are no checks on input range or parameter boundaries.
+
+ typedef typename mpl::front<typename T::unsigned_types>::type ui_type;
+
+ long tol = std::numeric_limits<mp_number<T> >::digits;
+ T t;
+
+ T x_pow_n_div_n_fact(x);
+
+ add(H0F0, x_pow_n_div_n_fact, ui_type(1));
+
+ ui_type n;
+
+ // Series expansion of hyperg_0f0(; ; x).
+ for(n = 2; n < 300; ++n)
+ {
+ multiply(x_pow_n_div_n_fact, x);
+ divide(x_pow_n_div_n_fact, n);
+
+ if(n > 20)
+ {
+ eval_ldexp(t, H0F0, -tol);
+ if(t.compare(x_pow_n_div_n_fact) >= 0)
+ {
+ break;
+ }
+ }
+
+ add(H0F0, x_pow_n_div_n_fact);
+ }
+ if(n >= 300)
+ throw std::runtime_error("H0F0 failed to converge");
+}
+
+
+template <class T>
+void eval_exp(T& result, const T& x)
+{
+ if(&x == &result)
+ {
+ T temp;
+ eval_exp(temp, x);
+ result = temp;
+ }
+ typedef typename mpl::front<T::unsigned_types>::type ui_type;
+ // Handle special arguments.
+ int type = eval_fpclassify(x);
+ bool isneg = get_sign(x) < 0;
+ if(type == FP_NAN)
+ {
+ result = std::numeric_limits<mp_number<T> >::quiet_NaN().backend();
+ return;
+ }
+ else if(type == FP_INFINITE)
+ {
+ result = x;
+ if(isneg)
+ result = ui_type(0u);
+ else
+ result = x;
+ return;
+ }
+ else if(type == FP_ZERO)
+ {
+ result = ui_type(1);
+ return;
+ }
+
+ // Get local copy of argument and force it to be positive.
+ T xx = x;
+ T exp_series;
+ if(isneg)
+ xx.negate();
+
+ // Check the range of the argument.
+ static const boost::intmax_t maximum_arg_for_exp = std::numeric_limits<mp_number<T> >::max_exponent == 0 ? std::numeric_limits<long>::max() : std::numeric_limits<mp_number<T> >::max_exponent;
+
+ if(xx.compare(maximum_arg_for_exp) >= 0)
+ {
+ // Overflow / underflow
+ if(isneg)
+ result = ui_type(0);
+ else
+ result = std::numeric_limits<mp_number<T> >::has_infinity ? std::numeric_limits<mp_number<T> >::infinity().backend() : (std::numeric_limits<mp_number<T> >::max)().backend();
+ return;
+ }
+
+ // Check for pure-integer arguments which can be either signed or unsigned.
+ boost::intmax_t ll;
+ eval_trunc(exp_series, x);
+ convert_to(&ll, exp_series);
+ if(x.compare(ll) == 0)
+ {
+ detail::pow_imp(result, get_constant_e<T>(), ll, mpl::true_());
+ return;
+ }
+
+ // The algorithm for exp has been taken from MPFUN.
+ // exp(t) = [ (1 + r + r^2/2! + r^3/3! + r^4/4! ...)^p2 ] * 2^n
+ // where p2 is a power of 2 such as 2048, r = t_prime / p2, and
+ // t_prime = t - n*ln2, with n chosen to minimize the absolute
+ // value of t_prime. In the resulting Taylor series, which is
+ // implemented as a hypergeometric function, |r| is bounded by
+ // ln2 / p2. For small arguments, no scaling is done.
+
+ typedef typename mpl::front<typename T::real_types>::type float_type;
+
+ const bool b_scale = (xx.compare(float_type(1e-4)) > 0);
+
+ // Compute the exponential series of the (possibly) scaled argument.
+
+ if(b_scale)
+ {
+ divide(result, xx, get_constant_ln2<T>());
+ boost::intmax_t n;
+ convert_to(&n, result);
+
+ // The scaling is 2^11 = 2048.
+ static const long long p2 = static_cast<boost::uint32_t>(boost::uint32_t(1u) << 11);
+
+ multiply(exp_series, get_constant_ln2<T>(), n);
+ subtract(exp_series, xx);
+ divide(exp_series, p2);
+ exp_series.negate();
+ hyp0F0(result, exp_series);
+
+ detail::pow_imp(exp_series, result, p2, mpl::true_());
+ result = ui_type(1);
+ eval_ldexp(result, result, n);
+ multiply(exp_series, result);
+ }
+ else
+ {
+ hyp0F0(exp_series, xx);
+ }
+
+ if(isneg)
+ divide(result, ui_type(1), exp_series);
+ else
+ result = exp_series;
+}
Modified: sandbox/big_number/boost/multiprecision/e_float.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/e_float.hpp (original)
+++ sandbox/big_number/boost/multiprecision/e_float.hpp 2011-10-03 12:56:24 EDT (Mon, 03 Oct 2011)
@@ -13,7 +13,7 @@
#include <fstream>
namespace boost{
-namespace math{
+namespace multiprecision{
typedef mp_number<arithmetic_backend<efx::e_float> > e_float;
Modified: sandbox/big_number/boost/multiprecision/gmp.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/gmp.hpp (original)
+++ sandbox/big_number/boost/multiprecision/gmp.hpp 2011-10-03 12:56:24 EDT (Mon, 03 Oct 2011)
@@ -15,7 +15,7 @@
#include <limits>
#include <climits>
-namespace boost{ namespace math{
+namespace boost{ namespace multiprecision{
template <unsigned digits10>
struct gmp_real;
@@ -567,6 +567,68 @@
{
*result = mpf_get_d(val.data());
}
+#ifdef BOOST_HAS_LONG_LONG
+template <unsigned digits10>
+inline void convert_to(long long* result, const gmp_real<digits10>& val)
+{
+ gmp_real<digits10> t(val);
+ if(get_sign(t) < 0)
+ t.negate();
+
+ long digits = std::numeric_limits<long long>::digits - std::numeric_limits<long>::digits;
+
+ if(digits > 0)
+ mpf_div_2exp(t.data(), t.data(), digits);
+
+ if(!mpf_fits_slong_p(t.data()))
+ {
+ *result = (std::numeric_limits<long long>::max)();
+ return;
+ };
+
+ *result = mpf_get_si(t.data());
+ while(digits > 0)
+ {
+ *result <<= digits;
+ digits -= std::numeric_limits<unsigned long>::digits;
+ mpf_mul_2exp(t.data(), t.data(), digits >= 0 ? std::numeric_limits<unsigned long>::digits : std::numeric_limits<unsigned long>::digits + digits);
+ unsigned long l = mpf_get_ui(t.data());
+ if(digits < 0)
+ l >>= -digits;
+ *result |= l;
+ }
+ if(get_sign(val) < 0)
+ *result = -*result;
+}
+template <unsigned digits10>
+inline void convert_to(unsigned long long* result, const gmp_real<digits10>& val)
+{
+ gmp_real<digits10> t(val);
+
+ long digits = std::numeric_limits<long long>::digits - std::numeric_limits<long>::digits;
+
+ if(digits > 0)
+ mpf_div_2exp(t.data(), t.data(), digits);
+
+ if(!mpf_fits_ulong_p(t.data()))
+ {
+ *result = (std::numeric_limits<long long>::max)();
+ return;
+ }
+
+ *result = mpf_get_ui(t.data());
+ while(digits > 0)
+ {
+ *result <<= digits;
+ digits -= std::numeric_limits<unsigned long>::digits;
+ mpf_mul_2exp(t.data(), t.data(), digits >= 0 ? std::numeric_limits<unsigned long>::digits : std::numeric_limits<unsigned long>::digits + digits);
+ unsigned long l = mpf_get_ui(t.data());
+ if(digits < 0)
+ l >>= -digits;
+ *result |= l;
+ }
+}
+#endif
//
// Native non-member operations:
@@ -1289,14 +1351,14 @@
{
double r;
convert_to(&r, val);
- *result = r;
+ *result = static_cast<long>(r);
}
inline void convert_to(unsigned long* result, const gmp_rational& val)
{
double r;
convert_to(&r, val);
- *result = r;
+ *result = static_cast<long>(r);
}
inline void eval_abs(gmp_rational& result, const gmp_rational& val)
@@ -1329,9 +1391,9 @@
// numeric_limits [partial] specializations for the types declared in this header:
//
template<unsigned Digits10>
-class numeric_limits<boost::math::mp_number<boost::math::gmp_real<Digits10> > >
+class numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::gmp_real<Digits10> > >
{
- typedef boost::math::mp_number<boost::math::gmp_real<Digits10> > number_type;
+ typedef boost::multiprecision::mp_number<boost::multiprecision::gmp_real<Digits10> > number_type;
public:
BOOST_STATIC_CONSTEXPR bool is_specialized = true;
BOOST_STATIC_CONSTEXPR number_type (min)() noexcept
@@ -1421,10 +1483,10 @@
{
data_initializer()
{
- std::numeric_limits<boost::math::mp_number<boost::math::gmp_real<digits10> > >::epsilon();
- std::numeric_limits<boost::math::mp_number<boost::math::gmp_real<digits10> > >::round_error();
- (std::numeric_limits<boost::math::mp_number<boost::math::gmp_real<digits10> > >::min)();
- (std::numeric_limits<boost::math::mp_number<boost::math::gmp_real<digits10> > >::max)();
+ std::numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::gmp_real<digits10> > >::epsilon();
+ std::numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::gmp_real<digits10> > >::round_error();
+ (std::numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::gmp_real<digits10> > >::min)();
+ (std::numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::gmp_real<digits10> > >::max)();
}
void do_nothing()const{}
};
@@ -1432,12 +1494,12 @@
};
template<unsigned Digits10>
-const typename numeric_limits<boost::math::mp_number<boost::math::gmp_real<Digits10> > >::data_initializer numeric_limits<boost::math::mp_number<boost::math::gmp_real<Digits10> > >::initializer;
+const typename numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::gmp_real<Digits10> > >::data_initializer numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::gmp_real<Digits10> > >::initializer;
template<>
-class numeric_limits<boost::math::mp_number<boost::math::gmp_real<0> > >
+class numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::gmp_real<0> > >
{
- typedef boost::math::mp_number<boost::math::gmp_real<0> > number_type;
+ typedef boost::multiprecision::mp_number<boost::multiprecision::gmp_real<0> > number_type;
public:
BOOST_STATIC_CONSTEXPR bool is_specialized = false;
BOOST_STATIC_CONSTEXPR number_type (min)() noexcept { return number_type(); }
@@ -1474,9 +1536,9 @@
};
template<>
-class numeric_limits<boost::math::mpz_int >
+class numeric_limits<boost::multiprecision::mpz_int >
{
- typedef boost::math::mpz_int number_type;
+ typedef boost::multiprecision::mpz_int number_type;
public:
BOOST_STATIC_CONSTEXPR bool is_specialized = true;
//
Modified: sandbox/big_number/boost/multiprecision/mp_number.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/mp_number.hpp (original)
+++ sandbox/big_number/boost/multiprecision/mp_number.hpp 2011-10-03 12:56:24 EDT (Mon, 03 Oct 2011)
@@ -21,7 +21,7 @@
#include <boost/throw_exception.hpp>
#include <boost/multiprecision/detail/default_ops.hpp>
-namespace boost{ namespace math{
+namespace boost{ namespace multiprecision{
template <class Backend>
class mp_number
@@ -546,31 +546,6 @@
divide(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
}
-#if 0
- template <class Exp>
- void do_assign(const Exp& e, const detail::multiply_and_negate_immediates&)
- {
- using big_num_default_ops::multiply;
- multiply(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
- m_backend.negate();
- }
-
- template <class Exp>
- void do_assign(const Exp& e, const detail::divide_and_negate_immediates&)
- {
- using big_num_default_ops::divide;
- divide(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
- m_backend.negate();
- }
-
- template <class Exp>
- void do_assign(const Exp& e, const detail::unary_plus&)
- {
- typedef typename Exp::left_type left_type;
- do_assign(e.left(), typename left_type::tag_type());
- }
-
-#endif
template <class Exp>
void do_assign(const Exp& e, const detail::negate&)
{
@@ -1491,7 +1466,7 @@
};
template <class Exp1, class Exp2>
-struct is_valid_comparison : public boost::math::detail::is_valid_comparison_imp<Exp1, Exp2>::type {};
+struct is_valid_comparison : public boost::multiprecision::detail::is_valid_comparison_imp<Exp1, Exp2>::type {};
}
Modified: sandbox/big_number/boost/multiprecision/mpfr.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/mpfr.hpp (original)
+++ sandbox/big_number/boost/multiprecision/mpfr.hpp 2011-10-03 12:56:24 EDT (Mon, 03 Oct 2011)
@@ -15,7 +15,7 @@
#include <cmath>
#include <algorithm>
-namespace boost{ namespace math{
+namespace boost{ namespace multiprecision{
template <unsigned digits10>
struct mpfr_real_backend;
@@ -736,10 +736,14 @@
typedef mp_number<mpfr_real_backend<1000> > mpfr_real_1000;
typedef mp_number<mpfr_real_backend<0> > mpfr_real;
+} // namespace boost
+
+namespace math{
+
namespace lanczos{
template<unsigned Digits10, class Policy>
-struct lanczos<mp_number<mpfr_real_backend<Digits10> >, Policy>
+struct lanczos<multiprecision::mp_number<multiprecision::mpfr_real_backend<Digits10> >, Policy>
{
typedef typename mpl::if_c<
Digits10 <= 36,
@@ -771,9 +775,9 @@
// numeric_limits [partial] specializations for the types declared in this header:
//
template<unsigned Digits10>
-class numeric_limits<boost::math::mp_number<boost::math::mpfr_real_backend<Digits10> > >
+class numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::mpfr_real_backend<Digits10> > >
{
- typedef boost::math::mp_number<boost::math::mpfr_real_backend<Digits10> > number_type;
+ typedef boost::multiprecision::mp_number<boost::multiprecision::mpfr_real_backend<Digits10> > number_type;
public:
BOOST_STATIC_CONSTEXPR bool is_specialized = true;
BOOST_STATIC_CONSTEXPR number_type (min)() noexcept
@@ -890,12 +894,12 @@
{
data_initializer()
{
- std::numeric_limits<boost::math::mp_number<boost::math::mpfr_real_backend<digits10> > >::epsilon();
- std::numeric_limits<boost::math::mp_number<boost::math::mpfr_real_backend<digits10> > >::round_error();
- (std::numeric_limits<boost::math::mp_number<boost::math::mpfr_real_backend<digits10> > >::min)();
- (std::numeric_limits<boost::math::mp_number<boost::math::mpfr_real_backend<digits10> > >::max)();
- std::numeric_limits<boost::math::mp_number<boost::math::mpfr_real_backend<digits10> > >::infinity();
- std::numeric_limits<boost::math::mp_number<boost::math::mpfr_real_backend<digits10> > >::quiet_NaN();
+ std::numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::mpfr_real_backend<digits10> > >::epsilon();
+ std::numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::mpfr_real_backend<digits10> > >::round_error();
+ (std::numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::mpfr_real_backend<digits10> > >::min)();
+ (std::numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::mpfr_real_backend<digits10> > >::max)();
+ std::numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::mpfr_real_backend<digits10> > >::infinity();
+ std::numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::mpfr_real_backend<digits10> > >::quiet_NaN();
}
void do_nothing()const{}
};
@@ -903,12 +907,12 @@
};
template<unsigned Digits10>
-const typename numeric_limits<boost::math::mp_number<boost::math::mpfr_real_backend<Digits10> > >::data_initializer numeric_limits<boost::math::mp_number<boost::math::mpfr_real_backend<Digits10> > >::initializer;
+const typename numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::mpfr_real_backend<Digits10> > >::data_initializer numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::mpfr_real_backend<Digits10> > >::initializer;
template<>
-class numeric_limits<boost::math::mp_number<boost::math::mpfr_real_backend<0> > >
+class numeric_limits<boost::multiprecision::mp_number<boost::multiprecision::mpfr_real_backend<0> > >
{
- typedef boost::math::mp_number<boost::math::mpfr_real_backend<0> > number_type;
+ typedef boost::multiprecision::mp_number<boost::multiprecision::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); }
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-03 12:56:24 EDT (Mon, 03 Oct 2011)
@@ -187,3 +187,11 @@
[ check-target-builds ../config//has_mpfr : : <build>no ]
: big_number_concept_check_mpfr_50 ;
+run test_exp.cpp gmp
+ : # command line
+ : # input files
+ : # requirements
+ <define>TEST_MPF50
+ [ check-target-builds ../config//has_gmp : : <build>no ]
+ : test_exp_mpf50 ;
+
Modified: sandbox/big_number/libs/multiprecision/test/big_number_concept_check.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/big_number_concept_check.cpp (original)
+++ sandbox/big_number/libs/multiprecision/test/big_number_concept_check.cpp 2011-10-03 12:56:24 EDT (Mon, 03 Oct 2011)
@@ -57,22 +57,22 @@
void foo()
{
#ifdef TEST_BACKEND
- instantiate(boost::math::big_number_real_architype());
+ instantiate(boost::multiprecision::big_number_real_architype());
#endif
#ifdef TEST_MPF_50
- instantiate(boost::math::mpf_real_50());
+ instantiate(boost::multiprecision::mpf_real_50());
#endif
#ifdef TEST_MPF
- instantiate(boost::math::mpf_real());
+ instantiate(boost::multiprecision::mpf_real());
#endif
#ifdef TEST_MPFR_50
- instantiate(boost::math::mpfr_real_50());
+ instantiate(boost::multiprecision::mpfr_real_50());
#endif
#ifdef TEST_MPFR
- instantiate(boost::math::mpfr_real());
+ instantiate(boost::multiprecision::mpfr_real());
#endif
#ifdef TEST_E_FLOAT
- instantiate(boost::math::e_float());
+ instantiate(boost::multiprecision::e_float());
#endif
}
@@ -82,19 +82,19 @@
BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::math::concepts::big_number_real_architype>));
#endif
#ifdef TEST_MPF_50
- BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::math::mpf_real_50>));
+ BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::multiprecision::mpf_real_50>));
#endif
#ifdef TEST_MPF
- BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::math::mpf_real>));
+ BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::multiprecision::mpf_real>));
#endif
#ifdef TEST_MPFR_50
- BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::math::mpfr_real_50>));
+ BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::multiprecision::mpfr_real_50>));
#endif
#ifdef TEST_MPFR
- BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::math::mpfr_real>));
+ BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::multiprecision::mpfr_real>));
#endif
#ifdef TEST_E_FLOAT
- BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::math::e_float>));
+ BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::multiprecision::e_float>));
#endif
}
Modified: sandbox/big_number/libs/multiprecision/test/linpack-benchmark.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/linpack-benchmark.cpp (original)
+++ sandbox/big_number/libs/multiprecision/test/linpack-benchmark.cpp 2011-10-03 12:56:24 EDT (Mon, 03 Oct 2011)
@@ -21,10 +21,10 @@
#ifdef TEST_MPF_100
#include <boost/multiprecision/gmp.hpp>
-typedef boost::math::mpf_real_100 real_type;
+typedef boost::multiprecision::mpf_real_100 real_type;
#elif defined(TEST_MPFR_100)
#include <boost/multiprecision/mpfr.hpp>
-typedef boost::math::mpfr_real_100 real_type;
+typedef boost::multiprecision::mpfr_real_100 real_type;
#elif defined(TEST_GMPXX)
#include <gmpxx.h>
typedef mpf_class real_type;
@@ -39,7 +39,7 @@
using ef::abs;
#elif defined(TEST_E_FLOAT_BN)
#include <boost/multiprecision/e_float.hpp>
-typedef boost::math::e_float real_type;
+typedef boost::multiprecision::e_float real_type;
#else
typedef double real_type;
#endif
@@ -111,7 +111,7 @@
#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;
+ std::cout << "Testing boost::multiprecision::e_float" << std::endl;
#else
std::cout << "Testing double" << std::endl;
#endif
@@ -1242,7 +1242,7 @@
times for array with leading dimension of1001
279.96 0.84 280.8 2.3813 0.83988 5014.3
-boost::math::ef::e_float:
+boost::multiprecision::ef::e_float:
~~~~~~~~~~~~~~~~~~~~~~~~~
norm. resid resid machep x(1) x(n)
Modified: sandbox/big_number/libs/multiprecision/test/test_arithmetic.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/test_arithmetic.cpp (original)
+++ sandbox/big_number/libs/multiprecision/test/test_arithmetic.cpp 2011-10-03 12:56:24 EDT (Mon, 03 Oct 2011)
@@ -74,7 +74,7 @@
void test_integer_ops(const T&){}
template <class Real>
-void test_integer_ops(const boost::mpl::int_<boost::math::number_kind_integer>&)
+void test_integer_ops(const boost::mpl::int_<boost::multiprecision::number_kind_integer>&)
{
Real a(20);
Real b(7);
@@ -270,7 +270,7 @@
void test_real_ops(const T&){}
template <class Real>
-void test_real_ops(const boost::mpl::int_<boost::math::number_kind_floating_point>&)
+void test_real_ops(const boost::mpl::int_<boost::multiprecision::number_kind_floating_point>&)
{
#if defined(TEST_MPF) || defined(TEST_MPF_50) || defined(TEST_BACKEND) || defined(TEST_MPFR)
BOOST_TEST(abs(Real(2)) == 2);
@@ -566,11 +566,11 @@
//
// Integer only functions:
//
- test_integer_ops<Real>(typename boost::math::number_category<Real>::type());
+ test_integer_ops<Real>(typename boost::multiprecision::number_category<Real>::type());
//
// Real number only functions:
//
- test_real_ops<Real>(typename boost::math::number_category<Real>::type());
+ test_real_ops<Real>(typename boost::multiprecision::number_category<Real>::type());
//
// Test basic arithmetic:
//
@@ -859,35 +859,35 @@
int main()
{
#ifdef TEST_BACKEND
- test<boost::math::mp_number<boost::math::concepts::big_number_backend_real_architype> >();
+ test<boost::multiprecision::mp_number<boost::multiprecision::concepts::big_number_backend_real_architype> >();
#endif
#ifdef TEST_MPF50
- test<boost::math::mpf_real_50>();
+ test<boost::multiprecision::mpf_real_50>();
#endif
#ifdef TEST_MPF
- boost::math::mpf_real::default_precision(1000);
+ boost::multiprecision::mpf_real::default_precision(1000);
/*
- boost::math::mpf_real r;
+ boost::multiprecision::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>();
+ BOOST_TEST(boost::multiprecision::mpf_real::default_precision() == 1000);
+ test<boost::multiprecision::mpf_real>();
#endif
#ifdef TEST_MPZ
- test<boost::math::mpz_int>();
+ test<boost::multiprecision::mpz_int>();
#endif
#ifdef TEST_MPQ
- test<boost::math::mpq_rational>();
+ test<boost::multiprecision::mpq_rational>();
#endif
#ifdef TEST_E_FLOAT
- test<boost::math::e_float>();
+ test<boost::multiprecision::e_float>();
#endif
#ifdef TEST_MPFR
- test<boost::math::mpfr_real>();
+ test<boost::multiprecision::mpfr_real>();
#endif
#ifdef TEST_MPFR_50
- test<boost::math::mpfr_real_50>();
+ test<boost::multiprecision::mpfr_real_50>();
#endif
return boost::report_errors();
}
Added: sandbox/big_number/libs/multiprecision/test/test_exp.cpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/libs/multiprecision/test/test_exp.cpp 2011-10-03 12:56:24 EDT (Mon, 03 Oct 2011)
@@ -0,0 +1,129 @@
+///////////////////////////////////////////////////////////////
+// Copyright Christopher Kormanyos 2002 - 2011.
+// 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_
+//
+// This work is based on an earlier work:
+// "Algorithm 910: A Portable C++ Multiple-Precision System for Special-Function Calculations",
+// in ACM TOMS, {VOL 37, ISSUE 4, (February 2011)} (C) ACM, 2011. http://doi.acm.org/10.1145/1916461.1916469
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/array.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) && !defined(TEST_MPQ)
+# define TEST_MPF50
+//# define TEST_MPF
+# define TEST_BACKEND
+# 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)
+#include <boost/multiprecision/gmp.hpp>
+#endif
+#ifdef TEST_BACKEND
+#include <boost/multiprecision/concepts/big_number_architypes.hpp>
+#endif
+#ifdef TEST_E_FLOAT
+#include <boost/multiprecision/e_float.hpp>
+#endif
+
+template <class T>
+void test()
+{
+ static const boost::array<T, 51u> data =
+ {{
+ T("1."),
+ T("9.4774758759621877024211675170518456366884502921505415491512637467314221915954853431757689726613032841249599156149038435317513116309445221664968991934479367736962368912070497862135887440758964938422498610719192114666493107120133053433933470080716434904854804591983841381870449665144170011709399012693158566138960223723364102555657731121349862591746773752353141675856300389702807704522952296232409058995e76"),
+ T("8.9822548979445237099762393639075561506833309483454509238768979587574644012197081949903511127689329087920328909235374785049128571553031890973238724279779592658729244759890277209350767466719784199679796679076195510817453034019585841414276969807276603422838152196159579020392165208404938697706742432405072185394955217454998873094186010667116964062108348411120353180844989880619261736047981860732797930644e153"),
+ T("8.5129104107012425752479825179539835555229492815662784863307311391672159207488925610548399363157976134510028424514441050609545913878842822386467301206413201029623476769026205205033685817764924800488232855250724008684495915251712280130842326233108250199883461186105839257510617980635806077595457588382413118792469142952313318664506759914894358735407111388609445312410411768354469087810933243701518863094e230"),
+ T("8.068090305164838604842549259891290171124821324687615632762765947633748868268417454336601924388552143324691924117594027902831510205350887969459808981202607973311868683121411298688279975061789109893607155133896078457388071886309741456291076644788440713510519219662121306330169119711707661687366546188062768141595534496102806873207221787877336040297603480708540379623897605936160066148763011880191621869e307"),
+ T("7.6465131232284163049316971133689488893295181895713899732751818669118734787914222264428338943260471340902326391726435840091710708695473968075461348860956049684669812738873320847453110965340325334947107583391780473997991426818290712114444252407495208024999404559898062464415917818325137468413597347923471238518514205589873079135934550659222795036544923795379322078022614498712288611880678752777952015152e384"),
+ T("7.2469643660625598538019258566517379445511821515071121090548187005319333633673122846436747032786828698818049511140660969044546275219845755939273078671198074959632409619498154244698031034440156360197935648334627868546857888857494388700626844388689389822377033582839158752694909185487984346545185318857120307481828458998400770240716997943805543726689069264680883497414036698656007667489582007899001829547e461"),
+ T("6.8682929953315519748061086577140456531398698780106027012062193513974157724673145902422782875956445003426789107235281687028397040131570497762100824722937078427155330107861397918035390454699657109557435638021678699307825502445861009401889929556587580492784546438388738373098175168819944606997023434060917962050793068854615280653706806955349426233710968944941108524201897185239272184650924550094159165184e538"),
+ T("6.5094081172294858524266967236074125271501239931616451822606100184551967070123942960365792762875516947968906251960679962384234952003522496976521459488146737312705400397630193900773373659538930712803305054506593414261773420168174852358519629345494258520616169148118576343286498482213483702930624725613384454163670114665649516148482263466492457979074135245336808430956247276655511233636218374141666023272e615"),
+ T("6.1692758397834896445466565257129421525132737513712327204187797947854551109008575685822530235797715953977744784785550340516715598557366923302859690730271083925820960776432604991610505575079802877181530212126674968757212631217826462154883556827312493006938669407561453082743084716913350560632423093917610154998589982600001382392313694022445670347030705319164552170150291848012351937100953890036300105871e692"),
+ T("5.8469162943704389675386957200432422884983339114040809517125791843529698266123366406953460141383587627250027572569096847362363831549584856898467181999391413025165420386358087621054569033111477610047027055333381725754117391518041977019653549862107958916803866421362184761931585219445620128589637254918343555371393128431807715170682738452071618887807426604132681626154765999537959315476068213542621180322e769"),
+ T("5.5414008128666064583537076240692868933072418197965454555020420111392626928160330156411498052861994284073777041588578343924444729815070056061660603933966757946018263861283152733720240516173400789600385493382166372543010812180148374708916504088803663809915284719654025586373106511403877362732360653577732630088912763232117614936657631128626622480330571961457177097015572841013819523862056676302123590835e846"),
+ T("5.251849252298052001849336634596605624932615050587242126709230836437099642948552827155317681622985673796485738044339684860221300378963566030058095552267153924938244515158005499605803770525751057401451830019036344558051163875818942505974131107483204115256933385945743955379487500587051829522367096042702717218823641765552373631712919055254215952997997242218608413439149796128454371169305737207513128807e923"),
+ T("4.9774274592844840922553532523399895707687997944019016434779659339099599495175571066749191102647610895707050400315564576144486939330191822264020831239376081750240177080224855259905972322795436336044718080591030837173922087243357258882189147341298494439853073189728114774501846930002388008365636203966891211742478022416179489779372415512232819505675629656011956781715868427072593283654666589611808073581e1000"),
+ T("4.7173448669720462237188351865970295455238511572394280863649015756105641752582788447957398889951756658763666977964561080316844537247511176975067430907677318411628894592131659609314519705065696036773840172243882880973707032036317239517638220758446197062685014773982890420289865519060688689357420655259758455221621133987780001331686741987234669397265361446155200793231408284664030082289902730362397848561e1077"),
+ T("4.4708522175321623603760234543012160551233097542464376709898701080016161641305114803775155211008103406608130900779618211357983931505100150872036597773168012401952663951774811462178950982356754934520420952750636967336804589186617110996219414674248378823188434472686833719446877071963169624353004701806734777657062069056499506562750389037932975870328903604743080312421901044848764763554120280608069622747e1154"),
+ T("4.2372394036653119830098671356758800877704381245840070556972166015743494177406662087025674510726553612407773483679793826805395046830522912774907458645315666657109679555711516123219895337097780310478450990346378570451984628571968728862717021688464671183102216087482134582783233462788612276436433844843113340117661068800967697425945952185565756591509948286825746552902121339188076398953061591657510445066e1231"),
+ T("4.0158334228914400539745590178164794975437536606699818222034254004811114067672490994749378759633661049912208598371211928081486311385567301424145253923797915452955822482631387668888916584389521441919397036718125302432512547147127924813280974253855801042782701987819292329831163944563371019697555352578545825707188652122309957602602328073674784142564935616256457537057261596233390671696504290741500824325e1308"),
+ T("3.8059964387336281390030628447736918731950638905889859981670562575013579651080893378643261418615597248563793905721216409752849171768325689975193281668646707475626612103018049529414972031338274254587787676115938524624210494070325582923806604462125023016462957768718261849099968552115528194693187665051765401859680442459296615169707213689087378346661673375123735787731940984618937841286808679717684045601e1385"),
+ T("3.6071239432095959207430930181651037268769528665018877695729199475196601891740487861223796136712863819929038760151135883635004445484745979300525669576636222972289788167180919942439736319800034914890005316195880400774555618160525047519091232763877112549157224779431406160698065686340819410841933246641650269061746492965033484737240772388735312991521074123198706383278511433856343165625103198269467277045e1462"),
+ T("3.4186430153374545706606299190728926303831987493039531531525792716113836020659611610272471306951869724846396516471297290706571995664799809535296646907832639466194597092728987006624017784246439039721439649240230770188576832674257817653601012003365792748252816491311084472983584896236685446078049796997495088275235014482876422624572733765422511563417424717976734285541485840205576333292292629705898026712e1539"),
+ T("3.2400106706387356945670320428646200776993383104555861757828941469924476740373605793183477572742076241032829759659681490962141240145141581865097423924646660398220529435794134651336421615115538294144878610322957162996489151882559706577258950380659727211777291935939480320782190247511227788798308670601955093205987496538797636913777784465756466432434857195432171054628069149765836567108796606518876161411e1616"),
+ T("3.0707122968838686808762365976116630656317083977116234783051460697759202764413714416029446981398815846396774097846142086219585484898425128945637835965609311626781498745013601665202311991073858493014761614369526954113562966924343632898676526247434944353812116870344357416617678601015459053297989079589299509864871767253387806087559388044642587983434307487581273247444950986227978405821984630380335522999e1693"),
+ T("2.9102601715737304709407721855237845605215030467786367061140857045899101530013173126178764480141553804302726818509771061464761826116800985901969508353958187973711321043157119127861178260598364278447637770099918746816176840436194047559028684276346030463240065993810821297209992114976352565659256401456824943396501998104720348581392556524094012469848383344186510494751840542956622168648051127134605419049e1770"),
+ T("2.7581920568863607870027917438011158114732314795167030242749419621017647849448607372158405505948973604056597946655107017870542301435918693041804847351891423642078041222831042196395295270728440674479791111077414832394734353235316069842707878669474381815671796103458710433178002392178092638286037259141627485462419803958568427330260813821541600701534519737633707025577914995456788692103051108422425375408e1847"),
+ T("2.6140698680411010453416773970464335103997599275990557963505882402750774237538007727638017837647068698785550358186768104621786728298395959017968646659450681758854495815775051287976515457472752962763600118692278131638936053170621574407487878235430394106909122081064770622396768825200987517033934258510550698555707917420074884651382528854596786633229647900291304513978131386770725311082555006911467864447e1924"),
+ T("2.4774784112439194545961900234630392526964078574399033336208722389562768176981620423625796094049751937688183037372271145640392552111592856112971332411543527668988982189213357069766999642690629174087636518790443153236463649626796203655474042490645756106046469120382604539074502111722789325269571247140534108791736500356851939956197404652273603941323630209215720013693452205022518765760329070842616941046e2001"),
+ T("2.3480241875781374631691380066790792771892564869650825534762414159728147468382334513664061092463982019282596608230957530311211307328143974085747420399537158037724095218243991423228023444859379580883072434670530040478491744472651118485401814194033214517221050352934587398275852096346826910101105240186236412184656659382535831384647508927079089332738325920621748164698159861195345140124576533260099531818e2078"),
+ T("2.2253342593947512482894343051033346460553514685284868064761586762995307539088982139722858486639592417618934607300618026000707839555068686077050219383701773511012374743383996188227317471958686041947524249098686209176989223885354176417280209218097978029585985115430634192732411379059159347252165834440501107479076728537702323035968171445551276815488702844227415317075032577967598705531043548190902240163e2155"),
+ T("2.1090551759365936315455394763107180892546255311406814474807735913225599344136347904154067215849740466098616361782897296314219278981058583564722586146448606213894635847184726562609032113220295749441955633109205157660265084141265451792574855174504712050982199997333601700242161381263233947649564996752502282300661121812212460958677667464307539559824119716390823776389116062024328503582458296404661030724e2232"),
+ T("1.9988519551012253626665391606414160629542055458014061990042537070247177860439177457869686789999953426516957430680890680964654190474258046504015466343786427551666546734635351226235742257396796694133189981279578839780058454761985247524191011603418127443226153000194710273722264940047399226885184129896957721196752811974521300721776877014427959949663663916026486491804231252409445050163051004298903230857e2309"),
+ T("1.8944071184091717327769157288694214491666404740796335627119828665408788464610207014827128441011823347031833774554689560285831180446909490973719926278454999562091766786964617295311248054209296251829365565657637585794799613184943543642149302253502921625588487967178044987717063245419475512579228948005151251220172269440562559442067650076109382783512605616677262078725150593936302571039602645533145833688e2386"),
+ T("1.795419776397396870883759116489769402541419469341753006054859662887039319928613872577712647027984056309170986725948997439220662114370977055801553872855064859465160778064610757538797519726695741862251510315436821959386698539808251950372887792620010350735505164024826909107013909479283953771859666151170337965452357673457347076929518296009792647791360547551255623795595827532506478122285622521680723198e2463"),
+ T("1.7016047618031754086134654579111810617120348758710143771069305417445489516040399750813776000705885685499141312138983442910516360247333185628492894202543743484367527766696250509432364995620305699351629185845681107616307847503246334638085810705895758535310625200703209004562084637734409371699916561240290054446464424202718339701400783109986719573562903857763873129540597357986671423745013710023231651329e2540"),
+ T("1.6126918080411979609715701452747988352165611850041775296367567768434358897691585163763723200113910842065988232661477200356230494761269971912897846125539659247231849257562594838887825972384334125491030803473533770400171029646043156961751894914511918427584075989532586054167207076781379343029365612771751032986978351517889027305091647604463730801257161289620542661422918279902166096709193161081148394122e2617"),
+ T("1.5284247706072296906699846404669034984154826955667742337840818347648901587881658504557814138346370867446936528153779291440974222875392035177334798180491517730019043230270100162475021422595011732593995371616778833697035670363475607783524853038032682034425785665657694174408203262209215616997795015596310706005669556487099297258112136814894205842056567712320200105413268352722573109566950626278687930372e2694"),
+ T("1.4485608891653060012262662362934733670202669964729350005811103752638169264554793857733858200215714810347904907192143845165275567906538821978702789157309454852049290295796799965552485868312721404394594588565776908022341972957647259592625133676589615774282958675900831935353271514314162851566868342929429856058517618472279436082944777949290121160320329701032110206134281440294897812652040954276090507017e2771"),
+ T("1.3728700881926523987377787943233319240491435703774938014541289523016635231812897840380838214278403055812374826352836064462692100642008102237346834361992329341687329019897351648991658099511836287726680508579879561481258870568846143059698287552784017902374151003189575311983375350280503953688511659632273800604956059446835976326153862663879531247057664632472283459374059559730646129713043045914280036191e2848"),
+ T("1.3011343141675944177179012805391104090720749087989014559756238032895645009279901485614947480934542467295834329661576448972096487118616044389963400689819864304760083535444189376011062378910379399366999838002995455575533727570818112349042088887223540611741471886797668792340331999553880029276216552340520965077802458183989229739403020238639120027067012696404307310649637683517662985846874429681252694077e2925"),
+ T("1.233146907390998223699634116604196321303527338063194018635704429203476960154098702362306563055636743760637784824497167438582308977860508068061535923688719183483752799354995864650650838160287374006896203951016533958052684442079538436867039485265319300786722392487965089753674979550869797200905652353584841188368624722200329909417714522575076225901000950862809939580119622301038231535752640718531560503e3002"),
+ T("1.1687120066315563646851448403936869404385185807787910322183199726441909641701499694514314549503826524393274595370652625335780618101237045988306992211747149512692179708353068119406926898226236555424247858876734064642321276408994327805695378682350680381138120637976561992552983027128491109399057399204806734536960608717759169335403208815710861794231703278779715979117164411304050798514670593787652928186e3079"),
+ T("1.1076439848797935780459011708913459693873418501614440121893411516856155264044888921508915048116297777621412439748701311029558308262037962091076982761455032906089728939898793892875302522325111709336468475276025046431105649997619822361542676063571655376547693673809133715806114929084161165591159275087382589295164718676930405790416367425834825705001722880024431488182592089567213871253363437453881724614e3156"),
+ T("1.0497669145852869831822072985740561681644437400018209440593094671016875295492661221847443008152631201881081765740915849038613188076178075126640018128968505236614758225634907922757204588825919348747289334952559508285340900441213069663101271469490908846474748126491486153897933707558113462272399019590825684419149149971088390644736001969102418531930304048460671867178170486969430030044866749941411652221e3233"),
+ T("9.9491406083653158286834756917422021600764727853686312719802358420566982531788421914469238540915616504216223401740335370367923898274605089490332650511788075886198714135795808528419557141582217964579360685402741569208063074313253490838482414281367060197950065504143914001338572155467333984661503453898847902871372714795379743025547542723839248318892138759596907306100969830936341255021634987471789706941e3309"),
+ T("9.42927401023380446961314339401657458785389811652244742482194123119943160577946366372207045050095290781679375214307398843926493195734487944624333413228893399732976728321980799677091653454804065271499274601941255651159823827574140068157063214410760869314717732028275496245648005191215048930881016330693755275282258597115402181603925122663256538590166426964332556533036059527784227962722441198371434037e3386"),
+ T("8.9365716959828116465632229827533775010309573979010794366666818430433566556286774474031057786888009871925254918684981245088107384317036889752292156920146379694165987770273470926340201197874812456173862271880689137375502421735431888891334269040972307308842443051934967463204037988999112477683156448819368015441070611711599827182978835927951062291039453298334013800388495719125476482150507255562932471987e3463"),
+ T("8.4696142662483591182651710363149061965529671414187214114508986504580419620532836415592194561692587545892671733647852519586965260182156246891106882514113059675737245160959965677478337885852837584798963994305283509311992268344932659689149044725278268851178262071743625689593833327527427790889142934871390124497847187559769333723286181059355730422352609633594972880679988434632727829633392971196615348162e3540"),
+ T("8.0270564887074008992929481581600294386090831745459505539216873340458312207422342705431057237884163498424349206319209533661302797554406960728685696384646157216820308811030692783501496335637205341645641865876987704911724172887422201095488046489024482854111274279939733922390803256997868575641148291588995771500671739181954270612789001072297006035844811068998273723866529350060897658557177391069889428138e3617"),
+ T("7.6076234226710136997076519198854581037482480050087592375273646746765716709802670790534160394910843369630438334623933329715061433126854176918572680591852491900095968421410826840041652944667732505393218836407650478812322026068521739096553158504199794298343738853325452463396386800405102937609865179610358195390467842398985491405704400439203254032406556044023342935195219037071893174834506422022272020608e3694"),
+ T("7.2101067461769422102719046864935900042020946053983858930538783546380741670622477730299778929732944630854151363803543748221329578582604770541719603126349873057195532110292846743563791049380608460124840094825775295226949060515234109528775156283010154878061758953690404860422160965162770534213586973008276804840802176466270909812402590547626695704877606695620372290113893333718784454195491413120278571381e3771"),
+ T("6.833361275000419432343650592319686694062674227594429857464606108305032877344799885305123090652406787997867592503236607009836687444829395552541403634550659710745653974928907350064693400553697943529341780925791186120102910163514753761188563821153759960369188532092163964559115206212975793696371318151500479047238166891574507004736959512033943570963451048752039151427991562182278434585245918970979972925e3848"),
+ }};
+
+ T pi = "3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609";
+
+ unsigned max_err = 0;
+ for(unsigned k = 0; k < data.size(); k++)
+ {
+ T val = boost::multiprecision::exp(boost::multiprecision::sqrt((pi * (100 * k)) * (100 * k)));
+ T e = ceil(fabs((val - data[k]) / data[k]) / std::numeric_limits<T>::epsilon());
+ unsigned err = e.template convert_to<unsigned>();
+ if(err > max_err)
+ max_err = err;
+ }
+ std::cout << "Max error was: " << max_err << std::endl;
+ BOOST_TEST(max_err < 1200);
+}
+
+
+int main()
+{
+#ifdef TEST_BACKEND
+ test<boost::multiprecision::mp_number<boost::multiprecision::concepts::big_number_backend_real_architype> >();
+#endif
+#ifdef TEST_MPF50
+ test<boost::multiprecision::mpf_real_50>();
+ test<boost::multiprecision::mpf_real_100>();
+#endif
+#ifdef TEST_E_FLOAT
+ test<boost::multiprecision::e_float>();
+#endif
+ return boost::report_errors();
+}
+
+
+
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-03 12:56:24 EDT (Mon, 03 Oct 2011)
@@ -138,35 +138,35 @@
int main()
{
#ifdef TEST_BACKEND
- test<boost::math::mp_number<boost::math::concepts::big_number_backend_real_architype> >();
+ test<boost::multiprecision::mp_number<boost::multiprecision::concepts::big_number_backend_real_architype> >();
#endif
#ifdef TEST_MPF50
- test<boost::math::mpf_real_50>();
+ test<boost::multiprecision::mpf_real_50>();
#endif
#ifdef TEST_MPF
- boost::math::mpf_real::default_precision(1000);
+ boost::multiprecision::mpf_real::default_precision(1000);
/*
- boost::math::mpf_real r;
+ boost::multiprecision::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>();
+ BOOST_TEST(boost::multiprecision::mpf_real::default_precision() == 1000);
+ test<boost::multiprecision::mpf_real>();
#endif
#ifdef TEST_MPZ
- test<boost::math::mpz_int>();
+ test<boost::multiprecision::mpz_int>();
#endif
#ifdef TEST_MPQ
- test<boost::math::mpq_rational>();
+ test<boost::multiprecision::mpq_rational>();
#endif
#ifdef TEST_E_FLOAT
- test<boost::math::e_float>();
+ test<boost::multiprecision::e_float>();
#endif
#ifdef TEST_MPFR
- test<boost::math::mpfr_real>();
+ test<boost::multiprecision::mpfr_real>();
#endif
#ifdef TEST_MPFR_50
- test<boost::math::mpfr_real_50>();
+ test<boost::multiprecision::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