Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74704 - in sandbox/big_number/boost/multiprecision: . concepts detail/functions
From: john_at_[hidden]
Date: 2011-10-04 14:23:27


Author: johnmaddock
Date: 2011-10-04 14:23:26 EDT (Tue, 04 Oct 2011)
New Revision: 74704
URL: http://svn.boost.org/trac/boost/changeset/74704

Log:
Add exponent_type as a requirement for floating point backends.
Made use of that type in code, and suppressed a few warnings.
Text files modified:
   sandbox/big_number/boost/multiprecision/arithmetic_backend.hpp | 1 +
   sandbox/big_number/boost/multiprecision/concepts/mp_number_architypes.hpp | 1 +
   sandbox/big_number/boost/multiprecision/detail/functions/pow.hpp | 21 +++++++++++++--------
   sandbox/big_number/boost/multiprecision/gmp.hpp | 1 +
   sandbox/big_number/boost/multiprecision/mpfr.hpp | 1 +
   5 files changed, 17 insertions(+), 8 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-04 14:23:26 EDT (Tue, 04 Oct 2011)
@@ -21,6 +21,7 @@
    typedef mpl::list<long long> signed_types;
    typedef mpl::list<unsigned long long> unsigned_types;
    typedef mpl::list<long double> real_types;
+ typedef int exponent_type;
 
    arithmetic_backend(){}
    arithmetic_backend(const arithmetic_backend& o)

Modified: sandbox/big_number/boost/multiprecision/concepts/mp_number_architypes.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/concepts/mp_number_architypes.hpp (original)
+++ sandbox/big_number/boost/multiprecision/concepts/mp_number_architypes.hpp 2011-10-04 14:23:26 EDT (Tue, 04 Oct 2011)
@@ -28,6 +28,7 @@
    typedef mpl::list<long long> signed_types;
    typedef mpl::list<unsigned long long> unsigned_types;
    typedef mpl::list<long double> real_types;
+ typedef int exponent_type;
 
    mp_number_backend_real_architype()
    {

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-04 14:23:26 EDT (Tue, 04 Oct 2011)
@@ -143,7 +143,10 @@
       eval_exp(temp, x);
       result = temp;
    }
- typedef typename mpl::front<T::unsigned_types>::type ui_type;
+ typedef typename boost::multiprecision::detail::canonical<unsigned, T>::type ui_type;
+ typedef typename boost::multiprecision::detail::canonical<int, T>::type si_type;
+ typedef typename T::exponent_type exp_type;
+ typedef typename boost::multiprecision::detail::canonical<exp_type, T>::type canonical_exp_type;
    // Handle special arguments.
    int type = eval_fpclassify(x);
    bool isneg = get_sign(x) < 0;
@@ -174,7 +177,7 @@
       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;
+ static const canonical_exp_type 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)
    {
@@ -213,13 +216,13 @@
    if(b_scale)
    {
       divide(result, xx, get_constant_ln2<T>());
- boost::intmax_t n;
+ exp_type 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);
+ static const si_type p2 = static_cast<si_type>(si_type(1) << 11);
 
- multiply(exp_series, get_constant_ln2<T>(), n);
+ multiply(exp_series, get_constant_ln2<T>(), static_cast<canonical_exp_type>(n));
       subtract(exp_series, xx);
       divide(exp_series, p2);
       exp_series.negate();
@@ -257,14 +260,16 @@
       result = temp;
    }
 
- typedef typename boost::multiprecision::detail::canonical<int, T>::type long_type;
+ typedef typename boost::multiprecision::detail::canonical<int, T>::type si_type;
    typedef typename boost::multiprecision::detail::canonical<unsigned, T>::type ui_type;
+ typedef typename T::exponent_type exp_type;
+ typedef typename boost::multiprecision::detail::canonical<exp_type, T>::type canonical_exp_type;
 
- int e;
+ exp_type e;
    T t;
    eval_frexp(t, arg, &e);
    
- multiply(result, get_constant_ln2<T>(), long_type(e));
+ multiply(result, get_constant_ln2<T>(), canonical_exp_type(e));
    subtract(t, ui_type(1)); /* -0.5 <= t <= 0 */
    t.negate(); /* 0 <= t <= 0.5 */
    T pow = t;

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-04 14:23:26 EDT (Tue, 04 Oct 2011)
@@ -28,6 +28,7 @@
    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;
+ typedef long exponent_type;
 
    gmp_real_imp(){}
 

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-04 14:23:26 EDT (Tue, 04 Oct 2011)
@@ -30,6 +30,7 @@
    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;
+ typedef long exponent_type;
 
    mpfr_real_imp(){}
 


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