Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74354 - in sandbox/big_number: boost/math boost/math/big_number libs/math/test
From: john_at_[hidden]
Date: 2011-09-12 04:35:46


Author: johnmaddock
Date: 2011-09-12 04:35:42 EDT (Mon, 12 Sep 2011)
New Revision: 74354
URL: http://svn.boost.org/trac/boost/changeset/74354

Log:
Bring mpfr backend into line with Boost.Math's requirements.
Fix input streaming.
Add MPQ support.
Mostly fix gcc compiler issues.
Text files modified:
   sandbox/big_number/boost/math/big_number.hpp | 68 ++++++-
   sandbox/big_number/boost/math/big_number/big_number_base.hpp | 26 ++
   sandbox/big_number/boost/math/big_number/default_ops.hpp | 347 ++++++++++++++++++++++++++++++++++++---
   sandbox/big_number/boost/math/big_number/gmp.hpp | 233 +++++++++++++++++++++++++-
   sandbox/big_number/boost/math/big_number/mpfr.hpp | 281 +++++++++++++++++++++-----------
   sandbox/big_number/libs/math/test/Jamfile.v2 | 16 +
   sandbox/big_number/libs/math/test/big_number_concept_check.cpp | 140 +++++++++++++++
   sandbox/big_number/libs/math/test/test_arithmetic.cpp | 10
   sandbox/big_number/libs/math/test/test_numeric_limits.cpp | 8
   9 files changed, 960 insertions(+), 169 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-09-12 04:35:42 EDT (Mon, 12 Sep 2011)
@@ -453,7 +453,7 @@
    template <class V>
    void check_shift_range(V val, const mpl::true_&, const mpl::true_&)
    {
- if(val > std::numeric_limits<std::size_t>::max())
+ if(val > (std::numeric_limits<std::size_t>::max)())
          BOOST_THROW_EXCEPTION(std::out_of_range("Can not shift by a value greater than std::numeric_limits<std::size_t>::max()."));
       if(val < 0)
          BOOST_THROW_EXCEPTION(std::out_of_range("Can not shift by a negative value."));
@@ -467,7 +467,7 @@
    template <class V>
    void check_shift_range(V val, const mpl::true_&, const mpl::false_&)
    {
- if(val > std::numeric_limits<std::size_t>::max())
+ if(val > (std::numeric_limits<std::size_t>::max)())
          BOOST_THROW_EXCEPTION(std::out_of_range("Can not shift by a value greater than std::numeric_limits<std::size_t>::max()."));
    }
    template <class V>
@@ -686,9 +686,6 @@
       typedef typename proto::result_of::left<Exp>::type left_type;
       typedef typename proto::result_of::right<Exp>::type right_type;
 
- static int const left_depth = boost::result_of<detail::CalcDepth(left_type)>::type::value;
- static int const right_depth = boost::result_of<detail::CalcDepth(right_type)>::type::value;
-
       bool bl = contains_self(proto::left(e));
       bool br = contains_self(proto::right(e));
 
@@ -719,9 +716,6 @@
       typedef typename proto::result_of::left<Exp>::type left_type;
       typedef typename proto::result_of::right<Exp>::type right_type;
 
- static int const left_depth = boost::result_of<detail::CalcDepth(left_type)>::type::value;
- static int const right_depth = boost::result_of<detail::CalcDepth(right_type)>::type::value;
-
       bool bl = contains_self(proto::left(e));
       bool br = contains_self(proto::right(e));
 
@@ -777,11 +771,16 @@
       {
          do_bitwise_and(proto::left(e), typename proto::tag_of<left_type>::type());
       }
- else
+ else if(left_depth >= right_depth)
       {
          do_assign(proto::left(e), typename detail::assign_and_eval<left_type>::type());
          do_bitwise_and(proto::right(e), typename proto::tag_of<right_type>::type());
       }
+ else
+ {
+ do_assign(proto::right(e), typename detail::assign_and_eval<right_type>::type());
+ do_bitwise_and(proto::left(e), typename proto::tag_of<left_type>::type());
+ }
    }
    template <class Exp>
    void do_assign(const Exp& e, const detail::bitwise_and_immediates&)
@@ -819,11 +818,16 @@
       {
          do_bitwise_or(proto::left(e), typename proto::tag_of<left_type>::type());
       }
- else
+ else if(left_depth >= right_depth)
       {
          do_assign(proto::left(e), typename detail::assign_and_eval<left_type>::type());
          do_bitwise_or(proto::right(e), typename proto::tag_of<right_type>::type());
       }
+ else
+ {
+ do_assign(proto::right(e), typename detail::assign_and_eval<right_type>::type());
+ do_bitwise_or(proto::left(e), typename proto::tag_of<left_type>::type());
+ }
    }
    template <class Exp>
    void do_assign(const Exp& e, const detail::bitwise_or_immediates&)
@@ -861,11 +865,16 @@
       {
          do_bitwise_xor(proto::left(e), typename proto::tag_of<left_type>::type());
       }
- else
+ else if(left_depth >= right_depth)
       {
          do_assign(proto::left(e), typename detail::assign_and_eval<left_type>::type());
          do_bitwise_xor(proto::right(e), typename proto::tag_of<right_type>::type());
       }
+ else
+ {
+ do_assign(proto::right(e), typename detail::assign_and_eval<right_type>::type());
+ do_bitwise_xor(proto::left(e), typename proto::tag_of<left_type>::type());
+ }
    }
    template <class Exp>
    void do_assign(const Exp& e, const detail::bitwise_xor_immediates&)
@@ -1001,6 +1010,25 @@
    {
       f(m_backend, canonical_value(proto::value(val1)), canonical_value(proto::value(val2)));
    }
+ template <class F, class Exp1, class Exp2, class Tag1>
+ void do_assign_function_2(const F& f, const Exp1& val1, const Exp2& val2, const Tag1&, const proto::tag::terminal&)
+ {
+ self_type temp1(val1);
+ f(m_backend, temp1.backend(), canonical_value(proto::value(val2)));
+ }
+ template <class F, class Exp1, class Exp2, class Tag2>
+ void do_assign_function_2(const F& f, const Exp1& val1, const Exp2& val2, const proto::tag::terminal&, const Tag2&)
+ {
+ self_type temp2(val2);
+ f(m_backend, canonical_value(proto::value(val1)), temp2.backend());
+ }
+ template <class F, class Exp1, class Exp2, class Tag1, class Tag2>
+ void do_assign_function_2(const F& f, const Exp1& val1, const Exp2& val2, const Tag1&, const Tag2&)
+ {
+ self_type temp1(val1);
+ self_type temp2(val2);
+ f(m_backend, temp1.backend(), temp2.backend());
+ }
 
    template <class Exp>
    void do_add(const Exp& e, const proto::tag::terminal&)
@@ -1297,6 +1325,16 @@
       typedef typename proto::result_of::child_c<Exp, 1>::type child1_type;
       return contains_self(proto::child_c<0>(e), mpl::int_<proto::arity_of<child0_type>::value>()) || contains_self(proto::child_c<1>(e), mpl::int_<proto::arity_of<child1_type>::value>());
    }
+ template <class Exp>
+ bool contains_self(const Exp& e, mpl::int_<3> const&)const
+ {
+ typedef typename proto::result_of::child_c<Exp, 0>::type child0_type;
+ typedef typename proto::result_of::child_c<Exp, 1>::type child1_type;
+ typedef typename proto::result_of::child_c<Exp, 2>::type child2_type;
+ return contains_self(proto::child_c<0>(e), mpl::int_<proto::arity_of<child0_type>::value>())
+ || contains_self(proto::child_c<1>(e), mpl::int_<proto::arity_of<child1_type>::value>())
+ || contains_self(proto::child_c<2>(e), mpl::int_<proto::arity_of<child2_type>::value>());
+ }
 
    // Test if the expression is a reference to *this:
    template <class Exp>
@@ -1326,13 +1364,13 @@
       return v == this;
    }
    template <class Exp>
- static typename detail::underlying_result<Exp>::type underlying_value(const big_number_exp<Exp>& e, const proto::tag::terminal&)
+ static typename detail::underlying_result<Exp>::type underlying_value(const detail::big_number_exp<Exp>& e, const proto::tag::terminal&)
    {
       return proto::value(e);
    }
    template <class Exp, class tag>
    static typename detail::underlying_result<Exp>::type
- underlying_value(const big_number_exp<Exp>& e, const tag&)
+ underlying_value(const detail::big_number_exp<Exp>& e, const tag&)
    {
       typedef typename proto::result_of::left<Exp>::type left_type;
       typedef typename proto::tag_of<left_type>::type tag_type;
@@ -1500,8 +1538,8 @@
 
 } // namespace detail
 
-template <class Stream, class Backend>
-inline typename enable_if<is_convertible<Stream*, std::ostream*>, std::istream&>::type operator >> (Stream& is, big_number<Backend>& r)
+template <class Backend>
+inline std::istream& operator >> (std::istream& is, big_number<Backend>& r)
 {
    std::string s;
    is >> s;

Modified: sandbox/big_number/boost/math/big_number/big_number_base.hpp
==============================================================================
--- sandbox/big_number/boost/math/big_number/big_number_base.hpp (original)
+++ sandbox/big_number/boost/math/big_number/big_number_base.hpp 2011-09-12 04:35:42 EDT (Mon, 12 Sep 2011)
@@ -6,6 +6,8 @@
 #ifndef BOOST_MATH_BIG_NUM_BASE_HPP
 #define BOOST_MATH_BIG_NUM_BASE_HPP
 
+#include <limits>
+
 namespace boost{ namespace math{
 
 template <class Backend>
@@ -122,6 +124,14 @@
   : proto::complement<big_number_grammar>
 {};
 
+template<>
+struct big_number_grammar_cases::case_<proto::tag::function>
+ : proto::or_<
+ proto::function< proto::_, big_number_grammar >,
+ proto::function< proto::_, big_number_grammar, proto::_ >
+ >
+{};
+
 struct big_number_grammar : proto::switch_<big_number_grammar_cases>{};
 
 // Define a calculator domain. Expression within
@@ -625,7 +635,7 @@
       : base_type(expr)
     {}
     template <class Other>
- big_number_exp(const Other& o)
+ big_number_exp(const Other& o, typename enable_if<is_convertible<Other, base_type> >::type const* = 0)
        : base_type(o)
     {}
 
@@ -645,9 +655,21 @@
 template <class Backend>
 struct is_extended_integer<big_number<Backend> > : public is_extended_integer<Backend>{};
 
-
 }} // namespaces
 
+namespace boost{ namespace math{ namespace tools{
+
+template <class T>
+struct promote_arg;
+
+template <class Exp>
+struct promote_arg<boost::math::detail::big_number_exp<Exp> >
+{
+ typedef typename boost::math::detail::expression_type<Exp>::type type;
+};
+
+}}}
+
 #endif // BOOST_MATH_BIG_NUM_BASE_HPP
 
 

Modified: sandbox/big_number/boost/math/big_number/default_ops.hpp
==============================================================================
--- sandbox/big_number/boost/math/big_number/default_ops.hpp (original)
+++ sandbox/big_number/boost/math/big_number/default_ops.hpp 2011-09-12 04:35:42 EDT (Mon, 12 Sep 2011)
@@ -6,8 +6,10 @@
 #ifndef BOOST_MATH_BIG_NUM_DEF_OPS
 #define BOOST_MATH_BIG_NUM_DEF_OPS
 
+#include <boost/math/policies/error_handling.hpp>
 #include <boost/math/big_number/big_number_base.hpp>
 #include <boost/math/special_functions/fpclassify.hpp>
+#include <boost/lexical_cast.hpp>
 
 namespace boost{ namespace math{ namespace big_num_default_ops{
 
@@ -306,7 +308,7 @@
 template <class R, class B>
 inline void convert_to(R* result, const B& backend)
 {
- typedef calculate_next_larger_type<R, B>::type next_type;
+ typedef typename calculate_next_larger_type<R, B>::type next_type;
    next_type n;
    convert_to(&n, backend);
    *result = static_cast<R>(n);
@@ -365,6 +367,31 @@
 template <class T>
 typename enable_if_c<sizeof(T) == 0>::type eval_frexp();
 //
+// TODO: implement default versions of these:
+//
+template <class T>
+typename enable_if_c<sizeof(T) == 0>::type eval_exp();
+template <class T>
+typename enable_if_c<sizeof(T) == 0>::type eval_log();
+template <class T>
+typename enable_if_c<sizeof(T) == 0>::type eval_sin();
+template <class T>
+typename enable_if_c<sizeof(T) == 0>::type eval_cos();
+template <class T>
+typename enable_if_c<sizeof(T) == 0>::type eval_tan();
+template <class T>
+typename enable_if_c<sizeof(T) == 0>::type eval_asin();
+template <class T>
+typename enable_if_c<sizeof(T) == 0>::type eval_acos();
+template <class T>
+typename enable_if_c<sizeof(T) == 0>::type eval_atan();
+template <class T>
+typename enable_if_c<sizeof(T) == 0>::type eval_sinh();
+template <class T>
+typename enable_if_c<sizeof(T) == 0>::type eval_cosh();
+template <class T>
+typename enable_if_c<sizeof(T) == 0>::type eval_tanh();
+//
 // These functions are implemented in separate files, but expanded inline here:
 //
 #include <boost/math/big_number/functions/pow.hpp>
@@ -394,7 +421,7 @@
 template <class Exp>
 inline int fpclassify BOOST_PREVENT_MACRO_SUBSTITUTION(const detail::big_number_exp<Exp>& arg)
 {
- typedef typename expression_type<Exp>::type value_type;
+ typedef typename detail::expression_type<Exp>::type value_type;
    return fpclassify(value_type(arg));
 }
 template <class Backend>
@@ -406,7 +433,7 @@
 template <class Exp>
 inline bool isfinite BOOST_PREVENT_MACRO_SUBSTITUTION(const detail::big_number_exp<Exp>& arg)
 {
- typedef typename expression_type<Exp>::type value_type;
+ typedef typename detail::expression_type<Exp>::type value_type;
    return isfinite(value_type(arg));
 }
 template <class Backend>
@@ -417,7 +444,7 @@
 template <class Exp>
 inline bool isnan BOOST_PREVENT_MACRO_SUBSTITUTION(const detail::big_number_exp<Exp>& arg)
 {
- typedef typename expression_type<Exp>::type value_type;
+ typedef typename detail::expression_type<Exp>::type value_type;
    return isnan(value_type(arg));
 }
 template <class Backend>
@@ -428,7 +455,7 @@
 template <class Exp>
 inline bool isinf BOOST_PREVENT_MACRO_SUBSTITUTION(const detail::big_number_exp<Exp>& arg)
 {
- typedef typename expression_type<Exp>::type value_type;
+ typedef typename detail::expression_type<Exp>::type value_type;
    return isinf(value_type(arg));
 }
 template <class Backend>
@@ -439,13 +466,150 @@
 template <class Exp>
 inline bool isnormal BOOST_PREVENT_MACRO_SUBSTITUTION(const detail::big_number_exp<Exp>& arg)
 {
- typedef typename expression_type<Exp>::type value_type;
+ typedef typename detail::expression_type<Exp>::type value_type;
    return isnormal(value_type(arg));
 }
 
+template <class Exp, class Policy>
+inline int itrunc(const detail::big_number_exp<Exp>& v, const Policy& pol)
+{
+ typedef typename detail::expression_type<Exp>::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 r.template convert_to<int>();
+}
+template <class Backend, class Policy>
+inline int itrunc(const big_number<Backend>& v, const Policy& pol)
+{
+ big_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 r.template convert_to<int>();
+}
+template <class T, class Policy>
+inline long ltrunc(const detail::big_number_exp<T>& v, const Policy& pol)
+{
+ typedef typename detail::expression_type<T>::type 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 r.template convert_to<long>();
+}
+template <class T, class Policy>
+inline long ltrunc(const big_number<T>& v, const Policy& pol)
+{
+ big_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 r.template convert_to<long>();
+}
+#ifndef BOOST_NO_LONG_LONG
+template <class T, class Policy>
+inline long long lltrunc(const detail::big_number_exp<T>& v, const Policy& pol)
+{
+ typedef typename detail::expression_type<T>::type 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 r.template convert_to<long long>();
+}
+template <class T, class Policy>
+inline long long lltrunc(const big_number<T>& v, const Policy& pol)
+{
+ big_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 r.template convert_to<long long>();
+}
+#endif
+template <class T, class Policy>
+inline int iround(const detail::big_number_exp<T>& v, const Policy& pol)
+{
+ typedef typename detail::expression_type<T>::type 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 r.template convert_to<int>();
+}
+template <class T, class Policy>
+inline int iround(const big_number<T>& v, const Policy& pol)
+{
+ big_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 r.template convert_to<int>();
+}
+template <class T, class Policy>
+inline long lround(const detail::big_number_exp<T>& v, const Policy& pol)
+{
+ typedef typename detail::expression_type<T>::type 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 r.template convert_to<long>();
+}
+template <class T, class Policy>
+inline long lround(const big_number<T>& v, const Policy& pol)
+{
+ big_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 r.template convert_to<long>();
+}
+#ifndef BOOST_NO_LONG_LONG
+template <class T, class Policy>
+inline long long llround(const detail::big_number_exp<T>& v, const Policy& pol)
+{
+ typedef typename detail::expression_type<T>::type 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 r.template convert_to<long long>();
+}
+template <class T, class Policy>
+inline long long llround(const big_number<T>& v, const Policy& pol)
+{
+ big_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 r.template convert_to<long long>();
+}
+#endif
+//
+// Overload of Boost.Math functions that find the wrong overload when used with big_number:
+//
+namespace detail{
+ template <class T> T sinc_pi_imp(T);
+ template <class T> T sinhc_pi_imp(T);
+}
+template <class Backend>
+inline big_number<Backend> sinc_pi(const big_number<Backend>& x)
+{
+ return detail::sinc_pi_imp(x);
+}
+
+template <class Backend, class Policy>
+inline big_number<Backend> sinc_pi(const big_number<Backend>& x, const Policy&)
+{
+ return detail::sinc_pi_imp(x);
+}
+
+template <class Backend>
+inline big_number<Backend> sinhc_pi(const big_number<Backend>& x)
+{
+ return detail::sinhc_pi_imp(x);
+}
+
+template <class Backend, class Policy>
+inline big_number<Backend> sinhc_pi(const big_number<Backend>& x, const Policy&)
+{
+ return boost::math::sinhc_pi(x);
+}
+
 #define UNARY_OP_FUNCTOR(func)\
 namespace detail{\
-template <class Backend>\
+template <class Backend> \
 struct BOOST_JOIN(func, _funct)\
 {\
    void operator()(Backend& result, const Backend& arg)const\
@@ -457,11 +621,11 @@
 \
 }\
 \
-template <class Exp>\
+template <class Exp> \
 typename proto::result_of::make_expr<\
     proto::tag::function\
- , detail::BOOST_JOIN(func, _funct)<typename detail::backend_type<Exp>::type>\
- , detail::big_number_exp<Exp>\
+ , detail::BOOST_JOIN(func, _funct)<typename detail::backend_type<Exp>::type> \
+ , detail::big_number_exp<Exp> \
>::type const \
 func(const detail::big_number_exp<Exp>& arg)\
 {\
@@ -470,11 +634,11 @@
       , arg \
     );\
 }\
-template <class Backend>\
+template <class Backend> \
 typename proto::result_of::make_expr<\
     proto::tag::function\
- , detail::BOOST_JOIN(func, _funct)<Backend>\
- , detail::big_number_exp<typename proto::terminal<big_number<Backend>*>::type>\
+ , detail::BOOST_JOIN(func, _funct)<Backend> \
+ , detail::big_number_exp<typename proto::terminal<big_number<Backend>*>::type> \
>::type const \
 func(const big_number<Backend>& arg)\
 {\
@@ -486,11 +650,125 @@
 
 #define BINARY_OP_FUNCTOR(func)\
 namespace detail{\
-template <class Backend>\
+template <class Backend> \
 struct BOOST_JOIN(func, _funct)\
 {\
- template <class A2>\
- void operator()(Backend& result, const Backend& arg, const A2& a)const\
+ void operator()(Backend& result, const Backend& arg, const Backend& a)const\
+ {\
+ using big_num_default_ops:: BOOST_JOIN(eval_,func);\
+ BOOST_JOIN(eval_,func)(result, arg, a);\
+ }\
+ template <class Arithmetic> \
+ void operator()(Backend& result, const Backend& arg, const Arithmetic& a)const\
+ {\
+ using big_num_default_ops:: BOOST_JOIN(eval_,func);\
+ BOOST_JOIN(eval_,func)(result, arg, a);\
+ }\
+};\
+\
+}\
+template <class Backend> \
+typename proto::result_of::make_expr<\
+ proto::tag::function\
+ , detail::BOOST_JOIN(func, _funct)<Backend> \
+ , detail::big_number_exp<typename proto::terminal<big_number<Backend>*>::type> \
+ , detail::big_number_exp<typename proto::terminal<big_number<Backend>*>::type> \
+>::type const \
+func(const big_number<Backend>& arg, const big_number<Backend>& a)\
+{\
+ return proto::make_expr<proto::tag::function>(\
+ detail::BOOST_JOIN(func, _funct)<Backend>() \
+ , static_cast<const detail::big_number_exp<typename proto::terminal<big_number<Backend>*>::type>&>(arg),\
+ static_cast<const detail::big_number_exp<typename proto::terminal<big_number<Backend>*>::type>&>(a)\
+ );\
+}\
+template <class Backend, class Exp> \
+typename proto::result_of::make_expr<\
+ proto::tag::function\
+ , detail::BOOST_JOIN(func, _funct)<Backend> \
+ , detail::big_number_exp<typename proto::terminal<big_number<Backend>*>::type> \
+ , detail::big_number_exp<Exp> \
+>::type const \
+func(const big_number<Backend>& arg, const detail::big_number_exp<Exp>& a)\
+{\
+ return proto::make_expr<proto::tag::function>(\
+ detail::BOOST_JOIN(func, _funct)<Backend>() \
+ , static_cast<const detail::big_number_exp<typename proto::terminal<big_number<Backend>*>::type>&>(arg),\
+ a\
+ );\
+}\
+template <class Exp, class Backend> \
+typename proto::result_of::make_expr<\
+ proto::tag::function\
+ , detail::BOOST_JOIN(func, _funct)<Backend> \
+ , detail::big_number_exp<Exp> \
+ , detail::big_number_exp<typename proto::terminal<big_number<Backend>*>::type > \
+>::type const \
+func(const detail::big_number_exp<Exp>& arg, const big_number<Backend>& a)\
+{\
+ return proto::make_expr<proto::tag::function>(\
+ detail::BOOST_JOIN(func, _funct)<Backend>() \
+ , arg,\
+ static_cast<const detail::big_number_exp<typename proto::terminal<big_number<Backend>*>::type>&>(a)\
+ );\
+}\
+template <class Exp1, class Exp2> \
+typename proto::result_of::make_expr<\
+ proto::tag::function\
+ , detail::BOOST_JOIN(func, _funct)<typename detail::backend_type<Exp1>::type> \
+ , detail::big_number_exp<Exp1> \
+ , detail::big_number_exp<Exp2> \
+>::type const \
+func(const detail::big_number_exp<Exp1>& arg, const detail::big_number_exp<Exp2>& a)\
+{\
+ return proto::make_expr<proto::tag::function>(\
+ detail::BOOST_JOIN(func, _funct)<typename detail::backend_type<Exp1>::type>() \
+ , arg,\
+ a\
+ );\
+}\
+template <class Backend, class Arithmetic> \
+typename enable_if<\
+ is_arithmetic<Arithmetic>,\
+ typename proto::result_of::make_expr<\
+ proto::tag::function\
+ , detail::BOOST_JOIN(func, _funct)<Backend> \
+ , detail::big_number_exp<typename proto::terminal<big_number<Backend>*>::type> \
+ , typename proto::result_of::as_child<const Arithmetic&>::type\
+>::type>::type const \
+func(const big_number<Backend>& arg, const Arithmetic& a)\
+{\
+ return proto::make_expr<proto::tag::function>(\
+ detail::BOOST_JOIN(func, _funct)<Backend>() \
+ , static_cast<const detail::big_number_exp<typename proto::terminal<big_number<Backend>*>::type>&>(arg),\
+ proto::as_child(a)\
+ );\
+}\
+template <class Exp, class Arithmetic> \
+typename enable_if<\
+ is_arithmetic<Arithmetic>,\
+ typename proto::result_of::make_expr<\
+ proto::tag::function\
+ , detail::BOOST_JOIN(func, _funct)<typename detail::backend_type<Exp>::type> \
+ , detail::big_number_exp<Exp> \
+ , typename proto::result_of::as_child<const Arithmetic&>::type\
+>::type>::type const \
+func(const detail::big_number_exp<Exp>& arg, const Arithmetic& a)\
+{\
+ return proto::make_expr<proto::tag::function>(\
+ detail::BOOST_JOIN(func, _funct)<typename detail::backend_type<Exp>::type>() \
+ , arg,\
+ proto::as_child(a)\
+ );\
+}\
+
+
+#define HETERO_BINARY_OP_FUNCTOR(func, Arg2)\
+namespace detail{\
+template <class Backend> \
+struct BOOST_JOIN(func, _funct)\
+{\
+ void operator()(Backend& result, Backend const& arg, Arg2 a)const\
    {\
       using big_num_default_ops:: BOOST_JOIN(eval_,func);\
       BOOST_JOIN(eval_,func)(result, arg, a);\
@@ -499,35 +777,35 @@
 \
 }\
 \
-template <class Exp, class A2>\
+template <class Exp> \
 typename proto::result_of::make_expr<\
     proto::tag::function\
- , detail::BOOST_JOIN(func, _funct)<typename detail::backend_type<Exp>::type>\
- , detail::big_number_exp<Exp>\
- , typename proto::result_of::as_child<const A2&>::type\
+ , detail::BOOST_JOIN(func, _funct)<typename detail::backend_type<Exp>::type> \
+ , detail::big_number_exp<Exp> \
+ , typename proto::result_of::as_child<Arg2>::type \
>::type const \
-func(const detail::big_number_exp<Exp>& arg, const A2& a)\
+func(const detail::big_number_exp<Exp>& arg, Arg2 const& a)\
 {\
     return proto::make_expr<proto::tag::function>(\
         detail::BOOST_JOIN(func, _funct)<typename detail::backend_type<Exp>::type>() \
       , arg, proto::as_child(a) \
     );\
 }\
-template <class Backend, class A2>\
+template <class Backend> \
 typename proto::result_of::make_expr<\
     proto::tag::function\
- , detail::BOOST_JOIN(func, _funct)<Backend>\
- , detail::big_number_exp<typename proto::terminal<big_number<Backend>*>::type>\
- , typename proto::result_of::as_child<const A2&>::type\
+ , detail::BOOST_JOIN(func, _funct)<Backend> \
+ , detail::big_number_exp<typename proto::terminal<big_number<Backend>*>::type> \
+ , typename proto::result_of::as_child<Arg2 const>::type \
>::type const \
-func(const big_number<Backend>& arg, const A2& a)\
+func(const big_number<Backend>& arg, Arg2 const& a)\
 {\
     return proto::make_expr<proto::tag::function>(\
         detail::BOOST_JOIN(func, _funct)<Backend>() \
       , static_cast<const detail::big_number_exp<typename proto::terminal<big_number<Backend>*>::type>&>(arg),\
       proto::as_child(a)\
     );\
-}
+}\
 
 UNARY_OP_FUNCTOR(abs)
 UNARY_OP_FUNCTOR(fabs)
@@ -535,9 +813,20 @@
 UNARY_OP_FUNCTOR(floor)
 UNARY_OP_FUNCTOR(ceil)
 UNARY_OP_FUNCTOR(trunc)
+UNARY_OP_FUNCTOR(exp)
+UNARY_OP_FUNCTOR(log)
+UNARY_OP_FUNCTOR(cos)
+UNARY_OP_FUNCTOR(sin)
+UNARY_OP_FUNCTOR(tan)
+UNARY_OP_FUNCTOR(asin)
+UNARY_OP_FUNCTOR(acos)
+UNARY_OP_FUNCTOR(atan)
+UNARY_OP_FUNCTOR(cosh)
+UNARY_OP_FUNCTOR(sinh)
+UNARY_OP_FUNCTOR(tanh)
 
-BINARY_OP_FUNCTOR(ldexp)
-BINARY_OP_FUNCTOR(frexp)
+HETERO_BINARY_OP_FUNCTOR(ldexp, int)
+HETERO_BINARY_OP_FUNCTOR(frexp, int*)
 BINARY_OP_FUNCTOR(pow)
 
 #undef BINARY_OP_FUNCTOR

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-09-12 04:35:42 EDT (Mon, 12 Sep 2011)
@@ -39,7 +39,7 @@
       // to get the right value, but if it's then used in further calculations
       // things go badly wrong!!
       //
- mpf_init2(m_data, (((digits10 ? digits10 : gmp_real<0>::default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
       mpf_set(m_data, o.m_data);
    }
 #ifndef BOOST_NO_RVALUE_REFERENCES
@@ -66,7 +66,7 @@
       boost::uintmax_t mask = ((1uLL << std::numeric_limits<unsigned>::digits) - 1);
       unsigned shift = 0;
       mpf_t t;
- mpf_init2(t, (((digits10 ? digits10 : gmp_real<0>::default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(t, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
       mpf_set_ui(m_data, 0);
       while(i)
       {
@@ -226,6 +226,11 @@
    const mpf_t& data()const { return m_data; }
 protected:
    mpf_t m_data;
+ static unsigned& get_default_precision()
+ {
+ static unsigned val = 50;
+ return val;
+ }
 };
 
 } // namespace detail
@@ -316,12 +321,6 @@
    {
       mpf_set_prec(this->m_data, (digits10 + 1) * 1000L / 301);
    }
-private:
- static unsigned& get_default_precision()
- {
- static unsigned val = 50;
- return val;
- }
 };
 
 template <unsigned digits10>
@@ -892,22 +891,22 @@
 template <class UI>
 inline void left_shift(gmp_int& t, UI i)
 {
- mpz_mul_2exp(t.data(), t.data(), static_cast<mp_bitcnt_t>(i));
+ mpz_mul_2exp(t.data(), t.data(), static_cast<unsigned long>(i));
 }
 template <class UI>
 inline void right_shift(gmp_int& t, UI i)
 {
- mpz_fdiv_q_2exp(t.data(), t.data(), static_cast<mp_bitcnt_t>(i));
+ mpz_fdiv_q_2exp(t.data(), t.data(), static_cast<unsigned long>(i));
 }
 template <class UI>
 inline void left_shift(gmp_int& t, const gmp_int& v, UI i)
 {
- mpz_mul_2exp(t.data(), v.data(), static_cast<mp_bitcnt_t>(i));
+ mpz_mul_2exp(t.data(), v.data(), static_cast<unsigned long>(i));
 }
 template <class UI>
 inline void right_shift(gmp_int& t, const gmp_int& v, UI i)
 {
- mpz_fdiv_q_2exp(t.data(), v.data(), static_cast<mp_bitcnt_t>(i));
+ mpz_fdiv_q_2exp(t.data(), v.data(), static_cast<unsigned long>(i));
 }
 
 inline void bitwise_and(gmp_int& result, const gmp_int& v)
@@ -1074,6 +1073,215 @@
    mpz_abs(result.data(), val.data());
 }
 
+struct gmp_rational;
+void add(gmp_rational& t, const gmp_rational& o);
+
+struct gmp_rational
+{
+ typedef mpl::list<long, long long> signed_types;
+ typedef mpl::list<unsigned long, unsigned long long> unsigned_types;
+ typedef mpl::list<double, long double> real_types;
+
+ gmp_rational()
+ {
+ mpq_init(this->m_data);
+ }
+ gmp_rational(const gmp_rational& o)
+ {
+ mpq_init(m_data);
+ mpq_set(m_data, o.m_data);
+ }
+ gmp_rational& operator = (const gmp_rational& o)
+ {
+ mpq_set(m_data, o.m_data);
+ return *this;
+ }
+ gmp_rational& operator = (boost::uintmax_t i)
+ {
+ boost::uintmax_t mask = ((1uLL << std::numeric_limits<unsigned>::digits) - 1);
+ unsigned shift = 0;
+ mpq_t t;
+ mpq_init(m_data);
+ mpq_init(t);
+ while(i)
+ {
+ mpq_set_ui(t, static_cast<unsigned>(i & mask), 1);
+ if(shift)
+ mpq_mul_2exp(t, t, shift);
+ mpq_add(m_data, m_data, t);
+ shift += std::numeric_limits<unsigned>::digits;
+ i >>= std::numeric_limits<unsigned>::digits;
+ }
+ mpq_clear(t);
+ return *this;
+ }
+ gmp_rational& operator = (boost::intmax_t i)
+ {
+ bool neg = i < 0;
+ *this = static_cast<boost::uintmax_t>(std::abs(i));
+ if(neg)
+ mpq_neg(m_data, m_data);
+ return *this;
+ }
+ gmp_rational& operator = (unsigned long i)
+ {
+ mpq_set_ui(m_data, i, 1);
+ return *this;
+ }
+ gmp_rational& operator = (long i)
+ {
+ mpq_set_si(m_data, i, 1);
+ return *this;
+ }
+ gmp_rational& operator = (double d)
+ {
+ mpq_set_d(m_data, d);
+ return *this;
+ }
+ gmp_rational& operator = (long double a)
+ {
+ using std::frexp;
+ using std::ldexp;
+ using std::floor;
+ using big_num_default_ops::add;
+ using big_num_default_ops::subtract;
+
+ if (a == 0) {
+ mpq_set_si(m_data, 0, 1);
+ return *this;
+ }
+
+ if (a == 1) {
+ mpq_set_si(m_data, 1, 1);
+ return *this;
+ }
+
+ BOOST_ASSERT(!(boost::math::isinf)(a));
+ BOOST_ASSERT(!(boost::math::isnan)(a));
+
+ int e;
+ long double f, term;
+ mpq_init(m_data);
+ mpq_set_ui(m_data, 0u, 1);
+ gmp_rational t;
+
+ f = frexp(a, &e);
+
+ static const int shift = std::numeric_limits<int>::digits - 1;
+
+ while(f)
+ {
+ // extract int sized bits from f:
+ f = ldexp(f, shift);
+ term = floor(f);
+ e -= shift;
+ mpq_mul_2exp(m_data, m_data, shift);
+ t = static_cast<long>(term);
+ add(*this, t);
+ f -= term;
+ }
+ if(e > 0)
+ mpq_mul_2exp(m_data, m_data, e);
+ else if(e < 0)
+ mpq_div_2exp(m_data, m_data, -e);
+ return *this;
+ }
+ gmp_rational& operator = (const char* s)
+ {
+ mpq_set_str(m_data, s, 10);
+ return *this;
+ }
+ void swap(gmp_rational& o)
+ {
+ mpq_swap(m_data, o.m_data);
+ }
+ std::string str(unsigned /*digits*/, bool /*scientific*/)const
+ {
+ void *(*alloc_func_ptr) (size_t);
+ void *(*realloc_func_ptr) (void *, size_t, size_t);
+ void (*free_func_ptr) (void *, size_t);
+ const char* ps = mpq_get_str (0, 10, m_data);
+ std::string s = ps;
+ mp_get_memory_functions(&alloc_func_ptr, &realloc_func_ptr, &free_func_ptr);
+ (*free_func_ptr)((void*)ps, std::strlen(ps) + 1);
+ return s;
+ }
+ ~gmp_rational()
+ {
+ mpq_clear(m_data);
+ }
+ void negate()
+ {
+ mpq_neg(m_data, m_data);
+ }
+ int compare(const gmp_rational& o)const
+ {
+ return mpq_cmp(m_data, o.m_data);
+ }
+ template <class V>
+ int compare(V v)const
+ {
+ gmp_rational d;
+ d = v;
+ return compare(d);
+ }
+ mpq_t& data() { return m_data; }
+ const mpq_t& data()const { return m_data; }
+protected:
+ mpq_t m_data;
+};
+
+inline void add(gmp_rational& t, const gmp_rational& o)
+{
+ mpq_add(t.data(), t.data(), o.data());
+}
+inline void subtract(gmp_rational& t, const gmp_rational& o)
+{
+ mpq_sub(t.data(), t.data(), o.data());
+}
+inline void multiply(gmp_rational& t, const gmp_rational& o)
+{
+ mpq_mul(t.data(), t.data(), o.data());
+}
+inline void divide(gmp_rational& t, const gmp_rational& o)
+{
+ mpq_div(t.data(), t.data(), o.data());
+}
+inline void add(gmp_rational& t, const gmp_rational& p, const gmp_rational& o)
+{
+ mpq_add(t.data(), p.data(), o.data());
+}
+inline void subtract(gmp_rational& t, const gmp_rational& p, const gmp_rational& o)
+{
+ mpq_sub(t.data(), p.data(), o.data());
+}
+inline void multiply(gmp_rational& t, const gmp_rational& p, const gmp_rational& o)
+{
+ mpq_mul(t.data(), p.data(), o.data());
+}
+inline void divide(gmp_rational& t, const gmp_rational& p, const gmp_rational& o)
+{
+ mpq_div(t.data(), p.data(), o.data());
+}
+
+inline bool is_zero(const gmp_rational& val)
+{
+ return mpq_sgn(val.data()) == 0;
+}
+inline int get_sign(const gmp_rational& val)
+{
+ return mpq_sgn(val.data());
+}
+inline void convert_to(double* result, const gmp_rational& val)
+{
+ *result = mpq_get_d(val.data());
+}
+
+inline void eval_abs(gmp_rational& result, const gmp_rational& val)
+{
+ mpq_abs(result.data(), val.data());
+}
+
 template<>
 struct is_extended_integer<gmp_int> : public mpl::true_ {};
 
@@ -1083,6 +1291,7 @@
 typedef big_number<gmp_real<1000> > mpf_real_1000;
 typedef big_number<gmp_real<0> > mpf_real;
 typedef big_number<gmp_int > mpz_int;
+typedef big_number<gmp_rational > mpq_rational;
 
 }} // namespaces
 

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-09-12 04:35:42 EDT (Mon, 12 Sep 2011)
@@ -21,6 +21,8 @@
 
 namespace detail{
 
+long get_default_precision() { return 50; }
+
 template <unsigned digits10>
 struct mpfr_real_imp
 {
@@ -32,8 +34,8 @@
 
    mpfr_real_imp(const mpfr_real_imp& o)
    {
- mpfr_init2(m_data, (((digits10 ? digits10 : mpfr_real_backend<0>::default_precision()) + 1) * 1000L) / 301L);
- mpfr_set(m_data, o.m_data, MPFR_RNDN);
+ mpfr_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpfr_set(m_data, o.m_data, GMP_RNDN);
    }
 #ifndef BOOST_NO_RVALUE_REFERENCES
    mpfr_real_imp(mpfr_real_imp&& o)
@@ -44,7 +46,7 @@
 #endif
    mpfr_real_imp& operator = (const mpfr_real_imp& o)
    {
- mpfr_set(m_data, o.m_data, MPFR_RNDN);
+ mpfr_set(m_data, o.m_data, GMP_RNDN);
       return *this;
    }
 #ifndef BOOST_NO_RVALUE_REFERENCES
@@ -60,17 +62,17 @@
       unsigned shift = 0;
       mpfr_t t;
       mpfr_init2(t, (std::max)(static_cast<unsigned>(std::numeric_limits<boost::uintmax_t>::digits), static_cast<unsigned>(((digits10 + 1) * 1000L) / 301L)));
- mpfr_set_ui(m_data, 0, MPFR_RNDN);
+ mpfr_set_ui(m_data, 0, GMP_RNDN);
       while(i)
       {
- mpfr_set_ui(t, static_cast<unsigned>(i & mask), MPFR_RNDN);
+ mpfr_set_ui(t, static_cast<unsigned>(i & mask), GMP_RNDN);
          long e;
- const char* ps = mpfr_get_str (0, &e, 10, 0, t, MPFR_RNDN);
+ const char* ps = mpfr_get_str (0, &e, 10, 0, t, GMP_RNDN);
          if(shift)
- mpfr_mul_2exp(t, t, shift, MPFR_RNDN);
- ps = mpfr_get_str (0, &e, 10, 0, t, MPFR_RNDN);
- mpfr_add(m_data, m_data, t, MPFR_RNDN);
- ps = mpfr_get_str (0, &e, 10, 0, m_data, MPFR_RNDN);
+ mpfr_mul_2exp(t, t, shift, GMP_RNDN);
+ ps = mpfr_get_str (0, &e, 10, 0, t, GMP_RNDN);
+ mpfr_add(m_data, m_data, t, GMP_RNDN);
+ ps = mpfr_get_str (0, &e, 10, 0, m_data, GMP_RNDN);
          shift += std::numeric_limits<unsigned>::digits;
          i >>= std::numeric_limits<unsigned>::digits;
       }
@@ -82,22 +84,22 @@
       bool neg = i < 0;
       *this = static_cast<boost::uintmax_t>(std::abs(i));
       if(neg)
- mpfr_neg(m_data, m_data, MPFR_RNDN);
+ mpfr_neg(m_data, m_data, GMP_RNDN);
       return *this;
    }
    mpfr_real_imp& operator = (unsigned long i)
    {
- mpfr_set_ui(m_data, i, MPFR_RNDN);
+ mpfr_set_ui(m_data, i, GMP_RNDN);
       return *this;
    }
    mpfr_real_imp& operator = (long i)
    {
- mpfr_set_si(m_data, i, MPFR_RNDN);
+ mpfr_set_si(m_data, i, GMP_RNDN);
       return *this;
    }
    mpfr_real_imp& operator = (double d)
    {
- mpfr_set_d(m_data, d, MPFR_RNDN);
+ mpfr_set_d(m_data, d, GMP_RNDN);
       return *this;
    }
    mpfr_real_imp& operator = (long double a)
@@ -107,12 +109,12 @@
       using std::floor;
 
       if (a == 0) {
- mpfr_set_si(m_data, 0, MPFR_RNDN);
+ mpfr_set_si(m_data, 0, GMP_RNDN);
          return *this;
       }
 
       if (a == 1) {
- mpfr_set_si(m_data, 1, MPFR_RNDN);
+ mpfr_set_si(m_data, 1, GMP_RNDN);
          return *this;
       }
 
@@ -121,7 +123,7 @@
 
       int e;
       long double f, term;
- mpfr_init_set_ui(m_data, 0u, MPFR_RNDN);
+ mpfr_init_set_ui(m_data, 0u, GMP_RNDN);
 
       f = frexp(a, &e);
 
@@ -133,22 +135,22 @@
          f = ldexp(f, shift);
          term = floor(f);
          e -= shift;
- mpfr_mul_2exp(m_data, m_data, shift, MPFR_RNDN);
+ mpfr_mul_2exp(m_data, m_data, shift, GMP_RNDN);
          if(term > 0)
- mpfr_add_ui(m_data, m_data, static_cast<unsigned>(term), MPFR_RNDN);
+ mpfr_add_ui(m_data, m_data, static_cast<unsigned>(term), GMP_RNDN);
          else
- mpfr_sub_ui(m_data, m_data, static_cast<unsigned>(-term), MPFR_RNDN);
+ mpfr_sub_ui(m_data, m_data, static_cast<unsigned>(-term), GMP_RNDN);
          f -= term;
       }
       if(e > 0)
- mpfr_mul_2exp(m_data, m_data, e, MPFR_RNDN);
+ mpfr_mul_2exp(m_data, m_data, e, GMP_RNDN);
       else if(e < 0)
- mpfr_div_2exp(m_data, m_data, -e, MPFR_RNDN);
+ mpfr_div_2exp(m_data, m_data, -e, GMP_RNDN);
       return *this;
    }
    mpfr_real_imp& operator = (const char* s)
    {
- mpfr_set_str(m_data, s, 10, MPFR_RNDN);
+ mpfr_set_str(m_data, s, 10, GMP_RNDN);
       return *this;
    }
    void swap(mpfr_real_imp& o)
@@ -159,7 +161,7 @@
    {
       std::string result;
       mp_exp_t e;
- char* ps = mpfr_get_str (0, &e, 10, digits, m_data, MPFR_RNDN);
+ char* ps = mpfr_get_str (0, &e, 10, digits, m_data, GMP_RNDN);
       std::ptrdiff_t sl = std::strlen(ps);
       unsigned chars = sl;
       if(sl == 0)
@@ -199,7 +201,7 @@
    }
    void negate()
    {
- mpfr_neg(m_data, m_data, MPFR_RNDN);
+ mpfr_neg(m_data, m_data, GMP_RNDN);
    }
    int compare(const mpfr_real_backend<digits10>& o)const
    {
@@ -224,6 +226,11 @@
    const mpfr_t& data()const { return m_data; }
 protected:
    mpfr_t m_data;
+ static unsigned& get_default_precision()
+ {
+ static unsigned val = 50;
+ return val;
+ }
 };
 
 } // namespace detail
@@ -314,83 +321,77 @@
    {
       mpfr_set_prec(this->m_data, (digits10 + 1) * 1000L / 301);
    }
-private:
- static unsigned& get_default_precision()
- {
- static unsigned val = 50;
- return val;
- }
 };
 
 template <unsigned digits10>
 inline void add(mpfr_real_backend<digits10>& result, const mpfr_real_backend<digits10>& o)
 {
- mpfr_add(result.data(), result.data(), o.data(), MPFR_RNDN);
+ mpfr_add(result.data(), result.data(), o.data(), GMP_RNDN);
 }
 template <unsigned digits10>
 inline void subtract(mpfr_real_backend<digits10>& result, const mpfr_real_backend<digits10>& o)
 {
- mpfr_sub(result.data(), result.data(), o.data(), MPFR_RNDN);
+ mpfr_sub(result.data(), result.data(), o.data(), GMP_RNDN);
 }
 template <unsigned digits10>
 inline void multiply(mpfr_real_backend<digits10>& result, const mpfr_real_backend<digits10>& o)
 {
- mpfr_mul(result.data(), result.data(), o.data(), MPFR_RNDN);
+ mpfr_mul(result.data(), result.data(), o.data(), GMP_RNDN);
 }
 template <unsigned digits10>
 inline void divide(mpfr_real_backend<digits10>& result, const mpfr_real_backend<digits10>& o)
 {
- mpfr_div(result.data(), result.data(), o.data(), MPFR_RNDN);
+ mpfr_div(result.data(), result.data(), o.data(), GMP_RNDN);
 }
 template <unsigned digits10>
 inline void add(mpfr_real_backend<digits10>& result, unsigned long i)
 {
- mpfr_add_ui(result.data(), result.data(), i, MPFR_RNDN);
+ mpfr_add_ui(result.data(), result.data(), i, GMP_RNDN);
 }
 template <unsigned digits10>
 inline void subtract(mpfr_real_backend<digits10>& result, unsigned long i)
 {
- mpfr_sub_ui(result.data(), result.data(), i, MPFR_RNDN);
+ mpfr_sub_ui(result.data(), result.data(), i, GMP_RNDN);
 }
 template <unsigned digits10>
 inline void multiply(mpfr_real_backend<digits10>& result, unsigned long i)
 {
- mpfr_mul_ui(result.data(), result.data(), i, MPFR_RNDN);
+ mpfr_mul_ui(result.data(), result.data(), i, GMP_RNDN);
 }
 template <unsigned digits10>
 inline void divide(mpfr_real_backend<digits10>& result, unsigned long i)
 {
- mpfr_div_ui(result.data(), result.data(), i, MPFR_RNDN);
+ mpfr_div_ui(result.data(), result.data(), i, GMP_RNDN);
 }
 template <unsigned digits10>
 inline void add(mpfr_real_backend<digits10>& result, long i)
 {
    if(i > 0)
- mpfr_add_ui(result.data(), result.data(), i, MPFR_RNDN);
+ mpfr_add_ui(result.data(), result.data(), i, GMP_RNDN);
    else
- mpfr_sub_ui(result.data(), result.data(), std::abs(i), MPFR_RNDN);
+ mpfr_sub_ui(result.data(), result.data(), std::abs(i), GMP_RNDN);
 }
 template <unsigned digits10>
 inline void subtract(mpfr_real_backend<digits10>& result, long i)
 {
    if(i > 0)
- mpfr_sub_ui(result.data(), result.data(), i, MPFR_RNDN);
+ mpfr_sub_ui(result.data(), result.data(), i, GMP_RNDN);
    else
- mpfr_add_ui(result.data(), result.data(), std::abs(i), MPFR_RNDN);
+ mpfr_add_ui(result.data(), result.data(), std::abs(i), GMP_RNDN);
 }
 template <unsigned digits10>
 inline void multiply(mpfr_real_backend<digits10>& result, long i)
 {
- mpfr_mul_ui(result.data(), result.data(), std::abs(i), MPFR_RNDN);
+ mpfr_mul_ui(result.data(), result.data(), std::abs(i), GMP_RNDN);
    if(i < 0)
- mpfr_neg(result.data(), result.data(), MPFR_RNDN);
+ mpfr_neg(result.data(), result.data(), GMP_RNDN);
 }
 template <unsigned digits10>
 inline void divide(mpfr_real_backend<digits10>& result, long i)
 {
- mpfr_div_ui(result.data(), result.data(), std::abs(i), MPFR_RNDN);
+ mpfr_div_ui(result.data(), result.data(), std::abs(i), GMP_RNDN);
    if(i < 0)
- mpfr_neg(result.data(), result.data(), MPFR_RNDN);
+ mpfr_neg(result.data(), result.data(), GMP_RNDN);
 }
 //
 // Specialised 3 arg versions of the basic operators:
@@ -398,146 +399,146 @@
 template <unsigned digits10>
 inline void add(mpfr_real_backend<digits10>& a, const mpfr_real_backend<digits10>& x, const mpfr_real_backend<digits10>& y)
 {
- mpfr_add(a.data(), x.data(), y.data(), MPFR_RNDN);
+ mpfr_add(a.data(), x.data(), y.data(), GMP_RNDN);
 }
 template <unsigned digits10>
 inline void add(mpfr_real_backend<digits10>& a, const mpfr_real_backend<digits10>& x, unsigned long y)
 {
- mpfr_add_ui(a.data(), x.data(), y, MPFR_RNDN);
+ mpfr_add_ui(a.data(), x.data(), y, GMP_RNDN);
 }
 template <unsigned digits10>
 inline void add(mpfr_real_backend<digits10>& a, const mpfr_real_backend<digits10>& x, long y)
 {
    if(y < 0)
- mpfr_sub_ui(a.data(), x.data(), -y, MPFR_RNDN);
+ mpfr_sub_ui(a.data(), x.data(), -y, GMP_RNDN);
    else
- mpfr_add_ui(a.data(), x.data(), y, MPFR_RNDN);
+ mpfr_add_ui(a.data(), x.data(), y, GMP_RNDN);
 }
 template <unsigned digits10>
 inline void add(mpfr_real_backend<digits10>& a, unsigned long x, const mpfr_real_backend<digits10>& y)
 {
- mpfr_add_ui(a.data(), y.data(), x, MPFR_RNDN);
+ mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN);
 }
 template <unsigned digits10>
 inline void add(mpfr_real_backend<digits10>& a, long x, const mpfr_real_backend<digits10>& y)
 {
    if(x < 0)
    {
- mpfr_ui_sub(a.data(), -x, y.data(), MPFR_RNDN);
- mpfr_neg(a.data(), a.data(), MPFR_RNDN);
+ mpfr_ui_sub(a.data(), -x, y.data(), GMP_RNDN);
+ mpfr_neg(a.data(), a.data(), GMP_RNDN);
    }
    else
- mpfr_add_ui(a.data(), y.data(), x, MPFR_RNDN);
+ mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN);
 }
 template <unsigned digits10>
 inline void subtract(mpfr_real_backend<digits10>& a, const mpfr_real_backend<digits10>& x, const mpfr_real_backend<digits10>& y)
 {
- mpfr_sub(a.data(), x.data(), y.data(), MPFR_RNDN);
+ mpfr_sub(a.data(), x.data(), y.data(), GMP_RNDN);
 }
 template <unsigned digits10>
 inline void subtract(mpfr_real_backend<digits10>& a, const mpfr_real_backend<digits10>& x, unsigned long y)
 {
- mpfr_sub_ui(a.data(), x.data(), y, MPFR_RNDN);
+ mpfr_sub_ui(a.data(), x.data(), y, GMP_RNDN);
 }
 template <unsigned digits10>
 inline void subtract(mpfr_real_backend<digits10>& a, const mpfr_real_backend<digits10>& x, long y)
 {
    if(y < 0)
- mpfr_add_ui(a.data(), x.data(), -y, MPFR_RNDN);
+ mpfr_add_ui(a.data(), x.data(), -y, GMP_RNDN);
    else
- mpfr_sub_ui(a.data(), x.data(), y, MPFR_RNDN);
+ mpfr_sub_ui(a.data(), x.data(), y, GMP_RNDN);
 }
 template <unsigned digits10>
 inline void subtract(mpfr_real_backend<digits10>& a, unsigned long x, const mpfr_real_backend<digits10>& y)
 {
- mpfr_ui_sub(a.data(), x, y.data(), MPFR_RNDN);
+ mpfr_ui_sub(a.data(), x, y.data(), GMP_RNDN);
 }
 template <unsigned digits10>
 inline void subtract(mpfr_real_backend<digits10>& a, long x, const mpfr_real_backend<digits10>& y)
 {
    if(x < 0)
    {
- mpfr_add_ui(a.data(), y.data(), -x, MPFR_RNDN);
- mpfr_neg(a.data(), a.data(), MPFR_RNDN);
+ mpfr_add_ui(a.data(), y.data(), -x, GMP_RNDN);
+ mpfr_neg(a.data(), a.data(), GMP_RNDN);
    }
    else
- mpfr_ui_sub(a.data(), x, y.data(), MPFR_RNDN);
+ mpfr_ui_sub(a.data(), x, y.data(), GMP_RNDN);
 }
 
 template <unsigned digits10>
 inline void multiply(mpfr_real_backend<digits10>& a, const mpfr_real_backend<digits10>& x, const mpfr_real_backend<digits10>& y)
 {
- mpfr_mul(a.data(), x.data(), y.data(), MPFR_RNDN);
+ mpfr_mul(a.data(), x.data(), y.data(), GMP_RNDN);
 }
 template <unsigned digits10>
 inline void multiply(mpfr_real_backend<digits10>& a, const mpfr_real_backend<digits10>& x, unsigned long y)
 {
- mpfr_mul_ui(a.data(), x.data(), y, MPFR_RNDN);
+ mpfr_mul_ui(a.data(), x.data(), y, GMP_RNDN);
 }
 template <unsigned digits10>
 inline void multiply(mpfr_real_backend<digits10>& a, const mpfr_real_backend<digits10>& x, long y)
 {
    if(y < 0)
    {
- mpfr_mul_ui(a.data(), x.data(), -y, MPFR_RNDN);
+ mpfr_mul_ui(a.data(), x.data(), -y, GMP_RNDN);
       a.negate();
    }
    else
- mpfr_mul_ui(a.data(), x.data(), y, MPFR_RNDN);
+ mpfr_mul_ui(a.data(), x.data(), y, GMP_RNDN);
 }
 template <unsigned digits10>
 inline void multiply(mpfr_real_backend<digits10>& a, unsigned long x, const mpfr_real_backend<digits10>& y)
 {
- mpfr_mul_ui(a.data(), y.data(), x, MPFR_RNDN);
+ mpfr_mul_ui(a.data(), y.data(), x, GMP_RNDN);
 }
 template <unsigned digits10>
 inline void multiply(mpfr_real_backend<digits10>& a, long x, const mpfr_real_backend<digits10>& y)
 {
    if(x < 0)
    {
- mpfr_mul_ui(a.data(), y.data(), -x, MPFR_RNDN);
- mpfr_neg(a.data(), a.data(), MPFR_RNDN);
+ mpfr_mul_ui(a.data(), y.data(), -x, GMP_RNDN);
+ mpfr_neg(a.data(), a.data(), GMP_RNDN);
    }
    else
- mpfr_mul_ui(a.data(), y.data(), x, MPFR_RNDN);
+ mpfr_mul_ui(a.data(), y.data(), x, GMP_RNDN);
 }
 
 template <unsigned digits10>
 inline void divide(mpfr_real_backend<digits10>& a, const mpfr_real_backend<digits10>& x, const mpfr_real_backend<digits10>& y)
 {
- mpfr_div(a.data(), x.data(), y.data(), MPFR_RNDN);
+ mpfr_div(a.data(), x.data(), y.data(), GMP_RNDN);
 }
 template <unsigned digits10>
 inline void divide(mpfr_real_backend<digits10>& a, const mpfr_real_backend<digits10>& x, unsigned long y)
 {
- mpfr_div_ui(a.data(), x.data(), y, MPFR_RNDN);
+ mpfr_div_ui(a.data(), x.data(), y, GMP_RNDN);
 }
 template <unsigned digits10>
 inline void divide(mpfr_real_backend<digits10>& a, const mpfr_real_backend<digits10>& x, long y)
 {
    if(y < 0)
    {
- mpfr_div_ui(a.data(), x.data(), -y, MPFR_RNDN);
+ mpfr_div_ui(a.data(), x.data(), -y, GMP_RNDN);
       a.negate();
    }
    else
- mpfr_div_ui(a.data(), x.data(), y, MPFR_RNDN);
+ mpfr_div_ui(a.data(), x.data(), y, GMP_RNDN);
 }
 template <unsigned digits10>
 inline void divide(mpfr_real_backend<digits10>& a, unsigned long x, const mpfr_real_backend<digits10>& y)
 {
- mpfr_ui_div(a.data(), x, y.data(), MPFR_RNDN);
+ mpfr_ui_div(a.data(), x, y.data(), GMP_RNDN);
 }
 template <unsigned digits10>
 inline void divide(mpfr_real_backend<digits10>& a, long x, const mpfr_real_backend<digits10>& y)
 {
    if(x < 0)
    {
- mpfr_ui_div(a.data(), -x, y.data(), MPFR_RNDN);
- mpfr_neg(a.data(), a.data(), MPFR_RNDN);
+ mpfr_ui_div(a.data(), -x, y.data(), GMP_RNDN);
+ mpfr_neg(a.data(), a.data(), GMP_RNDN);
    }
    else
- mpfr_ui_div(a.data(), x, y.data(), MPFR_RNDN);
+ mpfr_ui_div(a.data(), x, y.data(), GMP_RNDN);
 }
 
 template <unsigned digits10>
@@ -554,34 +555,34 @@
 template <unsigned digits10>
 inline void convert_to(unsigned long* result, const mpfr_real_backend<digits10>& val)
 {
- *result = mpfr_get_ui(val.data(), MPFR_RNDN);
+ *result = mpfr_get_ui(val.data(), GMP_RNDN);
 }
 template <unsigned digits10>
 inline void convert_to(long* result, const mpfr_real_backend<digits10>& val)
 {
- *result = mpfr_get_si(val.data(), MPFR_RNDN);
+ *result = mpfr_get_si(val.data(), GMP_RNDN);
 }
 #ifdef _MPFR_H_HAVE_INTMAX_T
 template <unsigned digits10>
 inline void convert_to(boost::uintmax_t* result, const mpfr_real_backend<digits10>& val)
 {
- *result = mpfr_get_uj(val.data(), MPFR_RNDN);
+ *result = mpfr_get_uj(val.data(), GMP_RNDN);
 }
 template <unsigned digits10>
 inline void convert_to(boost::intmax_t* result, const mpfr_real_backend<digits10>& val)
 {
- *result = mpfr_get_sj(val.data(), MPFR_RNDN);
+ *result = mpfr_get_sj(val.data(), GMP_RNDN);
 }
 #endif
 template <unsigned digits10>
 inline void convert_to(double* result, const mpfr_real_backend<digits10>& val)
 {
- *result = mpfr_get_d(val.data(), MPFR_RNDN);
+ *result = mpfr_get_d(val.data(), GMP_RNDN);
 }
 template <unsigned digits10>
 inline void convert_to(long double* result, const mpfr_real_backend<digits10>& val)
 {
- *result = mpfr_get_ld(val.data(), MPFR_RNDN);
+ *result = mpfr_get_ld(val.data(), GMP_RNDN);
 }
 
 //
@@ -590,19 +591,19 @@
 template <unsigned Digits10>
 inline void eval_sqrt(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& val)
 {
- mpfr_sqrt(result.data(), val.data(), MPFR_RNDN);
+ mpfr_sqrt(result.data(), val.data(), GMP_RNDN);
 }
 
 template <unsigned Digits10>
 inline void eval_abs(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& val)
 {
- mpfr_abs(result.data(), val.data(), MPFR_RNDN);
+ mpfr_abs(result.data(), val.data(), GMP_RNDN);
 }
 
 template <unsigned Digits10>
 inline void eval_fabs(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& val)
 {
- mpfr_abs(result.data(), val.data(), MPFR_RNDN);
+ mpfr_abs(result.data(), val.data(), GMP_RNDN);
 }
 template <unsigned Digits10>
 inline void eval_ceil(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& val)
@@ -623,23 +624,23 @@
 inline void eval_ldexp(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& val, long e)
 {
    if(e > 0)
- mpfr_mul_2exp(result.data(), val.data(), e, MPFR_RNDN);
+ mpfr_mul_2exp(result.data(), val.data(), e, GMP_RNDN);
    else if(e < 0)
- mpfr_div_2exp(result.data(), val.data(), -e, MPFR_RNDN);
+ mpfr_div_2exp(result.data(), val.data(), -e, GMP_RNDN);
 }
 template <unsigned Digits10>
 inline void eval_frexp(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& val, int* e)
 {
    long v;
- mpfr_get_d_2exp(&v, val.data(), MPFR_RNDN);
+ mpfr_get_d_2exp(&v, val.data(), GMP_RNDN);
    *e = v;
- ldexp(result, val, -v);
+ eval_ldexp(result, val, -v);
 }
 template <unsigned Digits10>
 inline void eval_frexp(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& val, long* e)
 {
- mpfr_get_d_2exp(e, val.data(), MPFR_RNDN);
- return ldexp(result, val, -*e);
+ mpfr_get_d_2exp(e, val.data(), GMP_RNDN);
+ return eval_ldexp(result, val, -*e);
 }
 
 template <unsigned Digits10>
@@ -648,6 +649,90 @@
    return mpfr_inf_p(val.data()) ? FP_INFINITE : mpfr_nan_p(val.data()) ? FP_NAN : mpfr_zero_p(val.data()) ? FP_ZERO : FP_NORMAL;
 }
 
+template <unsigned Digits10>
+inline void eval_pow(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& b, const mpfr_real_backend<Digits10>& e)
+{
+ mpfr_pow(result.data(), b.data(), e.data(), GMP_RNDN);
+}
+
+template <unsigned Digits10, class Integer>
+inline typename enable_if<mpl::and_<is_signed<Integer>, mpl::bool_<sizeof(Integer) <= sizeof(long)> > >::type eval_pow(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& b, const Integer& e)
+{
+ mpfr_pow_si(result.data(), b.data(), e, GMP_RNDN);
+}
+
+template <unsigned Digits10, class Integer>
+inline typename enable_if<mpl::and_<is_unsigned<Integer>, mpl::bool_<sizeof(Integer) <= sizeof(long)> > >::type eval_pow(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& b, const Integer& e)
+{
+ mpfr_pow_ui(result.data(), b.data(), e, GMP_RNDN);
+}
+
+template <unsigned Digits10>
+inline void eval_exp(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& arg)
+{
+ mpfr_exp(result.data(), arg.data(), GMP_RNDN);
+}
+
+template <unsigned Digits10>
+inline void eval_log(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& arg)
+{
+ mpfr_log(result.data(), arg.data(), GMP_RNDN);
+}
+
+template <unsigned Digits10>
+inline void eval_sin(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& arg)
+{
+ mpfr_sin(result.data(), arg.data(), GMP_RNDN);
+}
+
+template <unsigned Digits10>
+inline void eval_cos(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& arg)
+{
+ mpfr_cos(result.data(), arg.data(), GMP_RNDN);
+}
+
+template <unsigned Digits10>
+inline void eval_tan(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& arg)
+{
+ mpfr_tan(result.data(), arg.data(), GMP_RNDN);
+}
+
+template <unsigned Digits10>
+inline void eval_asin(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& arg)
+{
+ mpfr_asin(result.data(), arg.data(), GMP_RNDN);
+}
+
+template <unsigned Digits10>
+inline void eval_acos(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& arg)
+{
+ mpfr_acos(result.data(), arg.data(), GMP_RNDN);
+}
+
+template <unsigned Digits10>
+inline void eval_atan(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& arg)
+{
+ mpfr_atan(result.data(), arg.data(), GMP_RNDN);
+}
+
+template <unsigned Digits10>
+inline void eval_sinh(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& arg)
+{
+ mpfr_sinh(result.data(), arg.data(), GMP_RNDN);
+}
+
+template <unsigned Digits10>
+inline void eval_cosh(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& arg)
+{
+ mpfr_cosh(result.data(), arg.data(), GMP_RNDN);
+}
+
+template <unsigned Digits10>
+inline void eval_tanh(mpfr_real_backend<Digits10>& result, const mpfr_real_backend<Digits10>& arg)
+{
+ mpfr_tanh(result.data(), arg.data(), GMP_RNDN);
+}
+
 typedef big_number<mpfr_real_backend<50> > mpfr_real_50;
 typedef big_number<mpfr_real_backend<100> > mpfr_real_100;
 typedef big_number<mpfr_real_backend<500> > mpfr_real_500;
@@ -679,7 +764,7 @@
       {
          value.first = true;
          value.second = 0.5;
- mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), -mpfr_get_emin(), MPFR_RNDN);
+ mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), -mpfr_get_emin(), GMP_RNDN);
       }
       return value.second;
    }
@@ -691,7 +776,7 @@
       {
          value.first = true;
          value.second = 0.5;
- mpfr_mul_2exp(value.second.backend().data(), value.second.backend().data(), mpfr_get_emax(), MPFR_RNDN);
+ mpfr_mul_2exp(value.second.backend().data(), value.second.backend().data(), mpfr_get_emax(), GMP_RNDN);
       }
       return value.second;
    }
@@ -715,7 +800,7 @@
       {
          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);
+ mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), std::numeric_limits<number_type>::digits - 1, GMP_RNDN);
       }
       return value.second;
    }
@@ -729,7 +814,7 @@
       {
          value.first = true;
          value.second = 1;
- mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), digits, MPFR_RNDN);
+ mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), digits, GMP_RNDN);
       }
       return value.second;
    }

Modified: sandbox/big_number/libs/math/test/Jamfile.v2
==============================================================================
--- sandbox/big_number/libs/math/test/Jamfile.v2 (original)
+++ sandbox/big_number/libs/math/test/Jamfile.v2 2011-09-12 04:35:42 EDT (Mon, 12 Sep 2011)
@@ -83,6 +83,14 @@
          [ check-target-builds ../config//has_gmp : : <build>no ]
         : test_arithmetic_mpz ;
 
+run test_arithmetic.cpp gmp
+ : # command line
+ : # input files
+ : # requirements
+ <define>TEST_MPQ
+ [ check-target-builds ../config//has_gmp : : <build>no ]
+ : test_arithmetic_mpq ;
+
 run test_arithmetic.cpp mpfr gmp
         : # command line
         : # input files
@@ -138,6 +146,14 @@
          [ check-target-builds ../config//has_gmp : : <build>no ]
         : test_numeric_limits_mpz ;
 
+run test_numeric_limits.cpp gmp
+ : # command line
+ : # input files
+ : # requirements
+ <define>TEST_MPQ
+ [ check-target-builds ../config//has_gmp : : <build>no ]
+ : test_numeric_limits_mpq ;
+
 run test_numeric_limits.cpp mpfr
         : # command line
         : # input files

Modified: sandbox/big_number/libs/math/test/big_number_concept_check.cpp
==============================================================================
--- sandbox/big_number/libs/math/test/big_number_concept_check.cpp (original)
+++ sandbox/big_number/libs/math/test/big_number_concept_check.cpp 2011-09-12 04:35:42 EDT (Mon, 12 Sep 2011)
@@ -10,7 +10,7 @@
 // all our distributions and special functions on this type.
 //
 #define BOOST_MATH_ASSERT_UNDEFINED_POLICY false
-#define TEST_MPFR
+#define BOOST_MATH_INSTANTIATE_MINIMUM
 
 #ifdef _MSC_VER
 # pragma warning(disable:4800)
@@ -20,19 +20,143 @@
 # pragma warning(disable:4503) // decorated name length exceeded, name was truncated
 #endif
 
-#include <boost/math/concepts/big_number_backend.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
 
 #include <boost/math/concepts/real_type_concept.hpp>
-//#include "compile_test/instantiate.hpp"
-/*
+#include "libs/math/test/compile_test/instantiate.hpp"
+
+void a()
+{
+ using namespace boost;
+ using namespace boost::math;
+ using namespace boost::math::concepts;
+
+ function_requires<DistributionConcept<bernoulli_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<beta_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<binomial_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<cauchy_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<chi_squared_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<exponential_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<extreme_value_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<fisher_f_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<gamma_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<geometric_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<hypergeometric_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<inverse_chi_squared_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<inverse_gamma_distribution<boost::math::mpfr_real_50> > >();
+}
+
+void b()
+{
+ using namespace boost;
+ using namespace boost::math;
+ using namespace boost::math::concepts;
+
+ function_requires<DistributionConcept<inverse_gaussian_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<laplace_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<logistic_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<lognormal_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<negative_binomial_distribution<boost::math::mpfr_real_50> > >();
+}
+
+void c()
+{
+ using namespace boost;
+ using namespace boost::math;
+ using namespace boost::math::concepts;
+
+ function_requires<DistributionConcept<non_central_chi_squared_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<non_central_beta_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<non_central_f_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<non_central_t_distribution<boost::math::mpfr_real_50> > >();
+}
+
+void d()
+{
+ using namespace boost;
+ using namespace boost::math;
+ using namespace boost::math::concepts;
+
+ function_requires<DistributionConcept<normal_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<pareto_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<poisson_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<rayleigh_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<students_t_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<triangular_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<uniform_distribution<boost::math::mpfr_real_50> > >();
+ function_requires<DistributionConcept<weibull_distribution<boost::math::mpfr_real_50> > >();
+}
+
 void foo()
 {
- instantiate(boost::math::ef::e_float());
+#ifdef TEST_BACKEND
+ instantiate(boost::math::big_number_real_architype());
+#endif
+#ifdef TEST_MPF_50
+ instantiate(boost::math::mpf_real_50());
+#endif
+#ifdef TEST_MPF
+ instantiate(boost::math::mpf_real());
+#endif
+#ifdef TEST_MPFR_50
+ instantiate(boost::math::mpfr_real_50());
+#endif
+#ifdef TEST_MPFR
+ instantiate(boost::math::mpfr_real());
+#endif
+#ifdef TEST_E_FLOAT
+ instantiate(boost::math::e_float());
+#endif
 }
-*/
+
 int main()
 {
+#ifdef TEST_BACKEND
    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>));
+#endif
+#ifdef TEST_MPF
+ BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::math::mpf_real>));
+#endif
+#ifdef TEST_MPFR_50
+ BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::math::mpfr_real_50>));
+#endif
+#ifdef TEST_MPFR
+ BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::math::mpfr_real>));
+#endif
+#ifdef TEST_E_FLOAT
+ BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::math::e_float>));
+#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-09-12 04:35:42 EDT (Mon, 12 Sep 2011)
@@ -6,7 +6,7 @@
 #include <boost/detail/lightweight_test.hpp>
 #include <boost/math/special_functions/pow.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)
+#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
@@ -14,6 +14,7 @@
 # define TEST_MPFR
 # define TEST_MPFR_50
 # define TEST_E_FLOAT
+# define TEST_MPQ
 
 #ifdef _MSC_VER
 #pragma message("CAUTION!!: No backend type specified so testing everything.... this will take some time!!")
@@ -24,7 +25,7 @@
 
 #endif
 
-#if defined(TEST_MPF50) || defined(TEST_MPF) || defined(TEST_MPZ)
+#if defined(TEST_MPF50) || defined(TEST_MPF) || defined(TEST_MPZ) || defined(TEST_MPQ)
 #include <boost/math/big_number/gmp.hpp>
 #endif
 #ifdef TEST_BACKEND
@@ -255,7 +256,7 @@
 template <class Real>
 void test_real_ops(const boost::mpl::true_&)
 {
-#if defined(TEST_MPF) || defined(TEST_MPF_50) || defined(TEST_BACKEND)
+#if defined(TEST_MPF) || defined(TEST_MPF_50) || defined(TEST_BACKEND) || defined(TEST_MPFR)
    BOOST_TEST(abs(Real(2)) == 2);
    BOOST_TEST(abs(Real(-2)) == 2);
    BOOST_TEST(fabs(Real(2)) == 2);
@@ -850,6 +851,9 @@
 #ifdef TEST_MPZ
    test<boost::math::mpz_int>();
 #endif
+#ifdef TEST_MPQ
+ test<boost::math::mpq_rational>();
+#endif
 #ifdef TEST_E_FLOAT
    test<boost::math::e_float>();
 #endif

Modified: sandbox/big_number/libs/math/test/test_numeric_limits.cpp
==============================================================================
--- sandbox/big_number/libs/math/test/test_numeric_limits.cpp (original)
+++ sandbox/big_number/libs/math/test/test_numeric_limits.cpp 2011-09-12 04:35:42 EDT (Mon, 12 Sep 2011)
@@ -5,7 +5,7 @@
 
 #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)
+#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
@@ -13,6 +13,7 @@
 # define TEST_MPFR
 # define TEST_MPFR_50
 # define TEST_E_FLOAT
+# define TEST_MPQ
 
 #ifdef _MSC_VER
 #pragma message("CAUTION!!: No backend type specified so testing everything.... this will take some time!!")
@@ -23,7 +24,7 @@
 
 #endif
 
-#if defined(TEST_MPF50) || defined(TEST_MPF) || defined(TEST_MPZ)
+#if defined(TEST_MPF50) || defined(TEST_MPF) || defined(TEST_MPZ) || defined(TEST_MPQ)
 #include <boost/math/big_number/gmp.hpp>
 #endif
 #ifdef TEST_BACKEND
@@ -151,6 +152,9 @@
 #ifdef TEST_MPZ
    test<boost::math::mpz_int>();
 #endif
+#ifdef TEST_MPQ
+ test<boost::math::mpq_rational>();
+#endif
 #ifdef TEST_E_FLOAT
    test<boost::math::e_float>();
 #endif


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