|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r77312 - in sandbox/big_number: boost/multiprecision boost/multiprecision/concepts boost/multiprecision/detail boost/multiprecision/detail/functions libs/multiprecision/doc libs/multiprecision/test
From: john_at_[hidden]
Date: 2012-03-12 05:18:48
Author: johnmaddock
Date: 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
New Revision: 77312
URL: http://svn.boost.org/trac/boost/changeset/77312
Log:
Reorganisation: rename methods "eval_foo" rather than "foo" to avoid conflict with classes of the same name (GCC bug).
Move backends into sub-namespaces to avoid namespace pollution.
Text files modified:
sandbox/big_number/boost/multiprecision/arithmetic_backend.hpp | 13 +
sandbox/big_number/boost/multiprecision/concepts/mp_number_architypes.hpp | 14 +-
sandbox/big_number/boost/multiprecision/cpp_dec_float.hpp | 39 +++--
sandbox/big_number/boost/multiprecision/cpp_int.hpp | 230 +++++++++++++++++++-------------------
sandbox/big_number/boost/multiprecision/detail/default_ops.hpp | 170 ++++++++++++++--------------
sandbox/big_number/boost/multiprecision/detail/functions/constants.hpp | 46 +++---
sandbox/big_number/boost/multiprecision/detail/functions/pow.hpp | 160 +++++++++++++-------------
sandbox/big_number/boost/multiprecision/detail/functions/trig.hpp | 226 ++++++++++++++++++------------------
sandbox/big_number/boost/multiprecision/fixed_int.hpp | 214 +++++++++++++++++-----------------
sandbox/big_number/boost/multiprecision/gmp.hpp | 235 ++++++++++++++++++++-------------------
sandbox/big_number/boost/multiprecision/mp_number.hpp | 238 ++++++++++++++++++++--------------------
sandbox/big_number/boost/multiprecision/mpfr.hpp | 92 ++++++++-------
sandbox/big_number/boost/multiprecision/rational_adapter.hpp | 23 ++-
sandbox/big_number/boost/multiprecision/tommath.hpp | 75 ++++++------
sandbox/big_number/libs/multiprecision/doc/multiprecision.qbk | 108 +++++++++---------
sandbox/big_number/libs/multiprecision/test/test_arithmetic.cpp | 1
16 files changed, 959 insertions(+), 925 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 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
@@ -15,6 +15,7 @@
namespace boost{
namespace multiprecision{
+namespace backends{
template <class Arithmetic>
struct arithmetic_backend
@@ -97,26 +98,30 @@
};
template <class Arithmetic>
-inline void add(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o)
+inline void eval_add(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o)
{
result.data() += o.data();
}
template <class Arithmetic>
-inline void subtract(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o)
+inline void eval_subtract(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o)
{
result.data() -= o.data();
}
template <class Arithmetic>
-inline void multiply(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o)
+inline void eval_multiply(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o)
{
result.data() *= o.data();
}
template <class Arithmetic>
-inline void divide(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o)
+inline void eval_divide(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o)
{
result.data() /= o.data();
}
+} // namespace backends
+
+using boost::multiprecision::backends::arithmetic_backend;
+
}} // namespaces
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 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
@@ -122,36 +122,36 @@
long double m_value;
};
-inline void add(mp_number_backend_float_architype& result, const mp_number_backend_float_architype& o)
+inline void eval_add(mp_number_backend_float_architype& result, const mp_number_backend_float_architype& o)
{
std::cout << "Addition (" << result.m_value << " += " << o.m_value << ")" << std::endl;
result.m_value += o.m_value;
}
-inline void subtract(mp_number_backend_float_architype& result, const mp_number_backend_float_architype& o)
+inline void eval_subtract(mp_number_backend_float_architype& result, const mp_number_backend_float_architype& o)
{
std::cout << "Subtraction (" << result.m_value << " -= " << o.m_value << ")" << std::endl;
result.m_value -= o.m_value;
}
-inline void multiply(mp_number_backend_float_architype& result, const mp_number_backend_float_architype& o)
+inline void eval_multiply(mp_number_backend_float_architype& result, const mp_number_backend_float_architype& o)
{
std::cout << "Multiplication (" << result.m_value << " *= " << o.m_value << ")" << std::endl;
result.m_value *= o.m_value;
}
-inline void divide(mp_number_backend_float_architype& result, const mp_number_backend_float_architype& o)
+inline void eval_divide(mp_number_backend_float_architype& result, const mp_number_backend_float_architype& o)
{
std::cout << "Division (" << result.m_value << " /= " << o.m_value << ")" << std::endl;
result.m_value /= o.m_value;
}
-inline void convert_to(unsigned long long* result, const mp_number_backend_float_architype& val)
+inline void eval_convert_to(unsigned long long* result, const mp_number_backend_float_architype& val)
{
*result = static_cast<unsigned long long>(val.m_value);
}
-inline void convert_to(long long* result, const mp_number_backend_float_architype& val)
+inline void eval_convert_to(long long* result, const mp_number_backend_float_architype& val)
{
*result = static_cast<long long>(val.m_value);
}
-inline void convert_to(long double* result, mp_number_backend_float_architype& val)
+inline void eval_convert_to(long double* result, mp_number_backend_float_architype& val)
{
*result = val.m_value;
}
Modified: sandbox/big_number/boost/multiprecision/cpp_dec_float.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/cpp_dec_float.hpp (original)
+++ sandbox/big_number/boost/multiprecision/cpp_dec_float.hpp 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
@@ -24,6 +24,7 @@
namespace boost{
namespace multiprecision{
+namespace backends{
template <unsigned Digits10>
class cpp_dec_float
@@ -2535,49 +2536,49 @@
template <unsigned Digits10>
-inline void add(cpp_dec_float<Digits10>& result, const cpp_dec_float<Digits10>& o)
+inline void eval_add(cpp_dec_float<Digits10>& result, const cpp_dec_float<Digits10>& o)
{
result += o;
}
template <unsigned Digits10>
-inline void subtract(cpp_dec_float<Digits10>& result, const cpp_dec_float<Digits10>& o)
+inline void eval_subtract(cpp_dec_float<Digits10>& result, const cpp_dec_float<Digits10>& o)
{
result -= o;
}
template <unsigned Digits10>
-inline void multiply(cpp_dec_float<Digits10>& result, const cpp_dec_float<Digits10>& o)
+inline void eval_multiply(cpp_dec_float<Digits10>& result, const cpp_dec_float<Digits10>& o)
{
result *= o;
}
template <unsigned Digits10>
-inline void divide(cpp_dec_float<Digits10>& result, const cpp_dec_float<Digits10>& o)
+inline void eval_divide(cpp_dec_float<Digits10>& result, const cpp_dec_float<Digits10>& o)
{
result /= o;
}
template <unsigned Digits10>
-inline void add(cpp_dec_float<Digits10>& result, const unsigned long long& o)
+inline void eval_add(cpp_dec_float<Digits10>& result, const unsigned long long& o)
{
result.add_unsigned_long_long(o);
}
template <unsigned Digits10>
-inline void subtract(cpp_dec_float<Digits10>& result, const unsigned long long& o)
+inline void eval_subtract(cpp_dec_float<Digits10>& result, const unsigned long long& o)
{
result.sub_unsigned_long_long(o);
}
template <unsigned Digits10>
-inline void multiply(cpp_dec_float<Digits10>& result, const unsigned long long& o)
+inline void eval_multiply(cpp_dec_float<Digits10>& result, const unsigned long long& o)
{
result.mul_unsigned_long_long(o);
}
template <unsigned Digits10>
-inline void divide(cpp_dec_float<Digits10>& result, const unsigned long long& o)
+inline void eval_divide(cpp_dec_float<Digits10>& result, const unsigned long long& o)
{
result.div_unsigned_long_long(o);
}
template <unsigned Digits10>
-inline void add(cpp_dec_float<Digits10>& result, long long o)
+inline void eval_add(cpp_dec_float<Digits10>& result, long long o)
{
if(o < 0)
result.sub_unsigned_long_long(-o);
@@ -2585,7 +2586,7 @@
result.add_unsigned_long_long(o);
}
template <unsigned Digits10>
-inline void subtract(cpp_dec_float<Digits10>& result, long long o)
+inline void eval_subtract(cpp_dec_float<Digits10>& result, long long o)
{
if(o < 0)
result.add_unsigned_long_long(-o);
@@ -2593,7 +2594,7 @@
result.sub_unsigned_long_long(o);
}
template <unsigned Digits10>
-inline void multiply(cpp_dec_float<Digits10>& result, long long o)
+inline void eval_multiply(cpp_dec_float<Digits10>& result, long long o)
{
if(o < 0)
{
@@ -2604,7 +2605,7 @@
result.mul_unsigned_long_long(o);
}
template <unsigned Digits10>
-inline void divide(cpp_dec_float<Digits10>& result, long long o)
+inline void eval_divide(cpp_dec_float<Digits10>& result, long long o)
{
if(o < 0)
{
@@ -2616,17 +2617,17 @@
}
template <unsigned Digits10>
-inline void convert_to(unsigned long long* result, const cpp_dec_float<Digits10>& val)
+inline void eval_convert_to(unsigned long long* result, const cpp_dec_float<Digits10>& val)
{
*result = val.extract_unsigned_long_long();
}
template <unsigned Digits10>
-inline void convert_to(long long* result, const cpp_dec_float<Digits10>& val)
+inline void eval_convert_to(long long* result, const cpp_dec_float<Digits10>& val)
{
*result = val.extract_signed_long_long();
}
template <unsigned Digits10>
-inline void convert_to(long double* result, cpp_dec_float<Digits10>& val)
+inline void eval_convert_to(long double* result, cpp_dec_float<Digits10>& val)
{
*result = val.extract_long_double();
}
@@ -2799,16 +2800,20 @@
}
template <unsigned Digits10>
-inline bool is_zero(const cpp_dec_float<Digits10>& val)
+inline bool eval_is_zero(const cpp_dec_float<Digits10>& val)
{
return val.iszero();
}
template <unsigned Digits10>
-inline int get_sign(const cpp_dec_float<Digits10>& val)
+inline int eval_get_sign(const cpp_dec_float<Digits10>& val)
{
return val.iszero() ? 0 : val.isneg() ? -1 : 1;
}
+} // namespace backends
+
+using boost::multiprecision::backends::cpp_dec_float;
+
typedef mp_number<cpp_dec_float<50> > cpp_dec_float_50;
typedef mp_number<cpp_dec_float<100> > cpp_dec_float_100;
Modified: sandbox/big_number/boost/multiprecision/cpp_int.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/cpp_int.hpp (original)
+++ sandbox/big_number/boost/multiprecision/cpp_int.hpp 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
@@ -18,6 +18,7 @@
namespace boost{
namespace multiprecision{
+namespace backends{
template <unsigned MinBits = 0, bool Signed = true, class Allocator = std::allocator<limb_type> >
struct cpp_int_backend;
@@ -338,7 +339,7 @@
for(i = 0; i < internal_limb_count; ++i)
m_data[i] = ~m_data[i];
normalize();
- increment(static_cast<cpp_int_backend<MinBits, false, void>& >(*this));
+ eval_increment(static_cast<cpp_int_backend<MinBits, false, void>& >(*this));
}
bool isneg()const
{
@@ -451,8 +452,8 @@
cpp_int_backend& operator = (long double a)
{
- using default_ops::add;
- using default_ops::subtract;
+ using default_ops::eval_add;
+ using default_ops::eval_subtract;
using std::frexp;
using std::ldexp;
using std::floor;
@@ -482,23 +483,23 @@
f = ldexp(f, shift);
term = floor(f);
e -= shift;
- left_shift(*this, shift);
+ eval_left_shift(*this, shift);
if(term > 0)
- add(*this, static_cast<limb_type>(term));
+ eval_add(*this, static_cast<limb_type>(term));
else
- subtract(*this, static_cast<limb_type>(-term));
+ eval_subtract(*this, static_cast<limb_type>(-term));
f -= term;
}
if(e > 0)
- left_shift(*this, e);
+ eval_left_shift(*this, e);
else if(e < 0)
- right_shift(*this, -e);
+ eval_right_shift(*this, -e);
return *this;
}
cpp_int_backend& operator = (const char* s)
{
- using default_ops::multiply;
- using default_ops::add;
+ using default_ops::eval_multiply;
+ using default_ops::eval_add;
std::size_t n = s ? std::strlen(s) : 0;
*this = static_cast<limb_type>(0u);
unsigned radix = 10;
@@ -557,7 +558,7 @@
break;
}
}
- left_shift(*this, block_shift);
+ eval_left_shift(*this, block_shift);
this->limbs()[0] |= block;
}
}
@@ -584,8 +585,8 @@
break;
}
}
- multiply(*this, block_mult);
- add(*this, block);
+ eval_multiply(*this, block_mult);
+ eval_add(*this, block);
}
}
}
@@ -623,7 +624,7 @@
if(c > '9')
c += 'A' - '9' - 1;
result[pos--] = c;
- right_shift(t, shift);
+ eval_right_shift(t, shift);
}
if(Bits % shift)
{
@@ -666,7 +667,7 @@
{
cpp_int_backend block10;
block10 = max_block_10;
- while(get_sign(t) != 0)
+ while(eval_get_sign(t) != 0)
{
cpp_int_backend t2;
divide_unsigned_helper(t2, t, block10, r);
@@ -732,9 +733,9 @@
template <unsigned MinBits, bool Signed, class Allocator>
-inline void add(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& o)
+inline void eval_add(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& o)
{
- add(result, result, o);
+ eval_add(result, result, o);
}
template <unsigned MinBits, bool Signed, class Allocator>
inline void add_unsigned(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, const cpp_int_backend<MinBits, Signed, Allocator>& b)
@@ -795,7 +796,7 @@
result.sign(a.sign());
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void add(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, const cpp_int_backend<MinBits, Signed, Allocator>& b)
+inline void eval_add(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, const cpp_int_backend<MinBits, Signed, Allocator>& b)
{
if(a.sign() != b.sign())
{
@@ -829,7 +830,7 @@
result.normalize();
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void add(cpp_int_backend<MinBits, Signed, Allocator>& result, const limb_type& o)
+inline void eval_add(cpp_int_backend<MinBits, Signed, Allocator>& result, const limb_type& o)
{
if(result.sign())
{
@@ -839,12 +840,12 @@
add_unsigned(result, o);
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void add(cpp_int_backend<MinBits, Signed, Allocator>& result, const signed_limb_type& o)
+inline void eval_add(cpp_int_backend<MinBits, Signed, Allocator>& result, const signed_limb_type& o)
{
if(o < 0)
- subtract(result, static_cast<limb_type>(-o));
+ eval_subtract(result, static_cast<limb_type>(-o));
else if(o > 0)
- add(result, static_cast<limb_type>(o));
+ eval_add(result, static_cast<limb_type>(o));
}
template <unsigned MinBits, bool Signed, class Allocator>
@@ -877,7 +878,7 @@
}
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void subtract(cpp_int_backend<MinBits, Signed, Allocator>& result, const limb_type& o)
+inline void eval_subtract(cpp_int_backend<MinBits, Signed, Allocator>& result, const limb_type& o)
{
if(result.sign())
add_unsigned(result, o);
@@ -885,18 +886,18 @@
subtract_unsigned(result, o);
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void subtract(cpp_int_backend<MinBits, Signed, Allocator>& result, const signed_limb_type& o)
+inline void eval_subtract(cpp_int_backend<MinBits, Signed, Allocator>& result, const signed_limb_type& o)
{
if(o)
{
if(o < 0)
- add(result, static_cast<limb_type>(-o));
+ eval_add(result, static_cast<limb_type>(-o));
else
- subtract(result, static_cast<limb_type>(o));
+ eval_subtract(result, static_cast<limb_type>(o));
}
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void increment(cpp_int_backend<MinBits, Signed, Allocator>& result)
+inline void eval_increment(cpp_int_backend<MinBits, Signed, Allocator>& result)
{
static const limb_type one = 1;
if(!result.sign() && (result.limbs()[0] < cpp_int_backend<MinBits, Signed, Allocator>::max_limb_value))
@@ -904,10 +905,10 @@
else if(result.sign() && result.limbs()[0])
--result.limbs()[0];
else
- add(result, one);
+ eval_add(result, one);
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void decrement(cpp_int_backend<MinBits, Signed, Allocator>& result)
+inline void eval_decrement(cpp_int_backend<MinBits, Signed, Allocator>& result)
{
static const limb_type one = 1;
if(!result.sign() && result.limbs()[0])
@@ -915,12 +916,12 @@
else if(result.sign() && (result.limbs()[0] < cpp_int_backend<MinBits, Signed, Allocator>::max_limb_value))
++result.limbs()[0];
else
- subtract(result, one);
+ eval_subtract(result, one);
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void subtract(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& o)
+inline void eval_subtract(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& o)
{
- subtract(result, result, o);
+ eval_subtract(result, result, o);
}
template <unsigned MinBits, bool Signed, class Allocator>
inline void subtract_unsigned(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, const cpp_int_backend<MinBits, Signed, Allocator>& b)
@@ -996,7 +997,7 @@
result.negate();
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void subtract(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, const cpp_int_backend<MinBits, Signed, Allocator>& b)
+inline void eval_subtract(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, const cpp_int_backend<MinBits, Signed, Allocator>& b)
{
if(a.sign() != b.sign())
{
@@ -1006,7 +1007,7 @@
subtract_unsigned(result, a, b);
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void multiply(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, const cpp_int_backend<MinBits, Signed, Allocator>& b)
+inline void eval_multiply(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, const cpp_int_backend<MinBits, Signed, Allocator>& b)
{
// Very simple long multiplication, only usable for small numbers of limb_type's
// but that's the typical use case for this type anyway:
@@ -1028,7 +1029,7 @@
{
limb_type l = *pa;
result = b;
- multiply(result, l);
+ eval_multiply(result, l);
}
result.sign(s);
return;
@@ -1038,7 +1039,7 @@
limb_type l = *pb;
bool s = b.sign() != a.sign();
result = a;
- multiply(result, l);
+ eval_multiply(result, l);
result.sign(s);
return;
}
@@ -1046,13 +1047,13 @@
if(&result == &a)
{
cpp_int_backend<MinBits, Signed, Allocator> t(a);
- multiply(result, t, b);
+ eval_multiply(result, t, b);
return;
}
if(&result == &b)
{
cpp_int_backend<MinBits, Signed, Allocator> t(b);
- multiply(result, a, t);
+ eval_multiply(result, a, t);
return;
}
@@ -1063,7 +1064,7 @@
std::memset(pr, 0, result.size() * sizeof(limb_type));
for(unsigned i = 0; i < as; ++i)
{
- unsigned inner_limit = (std::min)(result.size() - i, b.size());
+ unsigned inner_limit = cpp_int_backend<MinBits, Signed, Allocator>::variable ? bs : (std::min)(result.size() - i, bs);
for(unsigned j = 0; j < inner_limit; ++j)
{
BOOST_ASSERT(i+j < result.size());
@@ -1083,12 +1084,12 @@
result.sign(a.sign() != b.sign());
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void multiply(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a)
+inline void eval_multiply(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a)
{
- multiply(result, result, a);
+ eval_multiply(result, result, a);
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void multiply(cpp_int_backend<MinBits, Signed, Allocator>& result, cpp_int_backend<MinBits, Signed, Allocator>& a, const limb_type& val)
+inline void eval_multiply(cpp_int_backend<MinBits, Signed, Allocator>& result, cpp_int_backend<MinBits, Signed, Allocator>& a, const limb_type& val)
{
if(!val)
{
@@ -1117,25 +1118,25 @@
result.normalize();
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void multiply(cpp_int_backend<MinBits, Signed, Allocator>& result, const limb_type& val)
+inline void eval_multiply(cpp_int_backend<MinBits, Signed, Allocator>& result, const limb_type& val)
{
- multiply(result, result, val);
+ eval_multiply(result, result, val);
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void multiply(cpp_int_backend<MinBits, Signed, Allocator>& result, cpp_int_backend<MinBits, Signed, Allocator>& a, const signed_limb_type& val)
+inline void eval_multiply(cpp_int_backend<MinBits, Signed, Allocator>& result, cpp_int_backend<MinBits, Signed, Allocator>& a, const signed_limb_type& val)
{
if(val > 0)
- multiply(result, a, static_cast<limb_type>(val));
+ eval_multiply(result, a, static_cast<limb_type>(val));
else
{
- multiply(result, a, static_cast<limb_type>(-val));
+ eval_multiply(result, a, static_cast<limb_type>(-val));
result.negate();
}
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void multiply(cpp_int_backend<MinBits, Signed, Allocator>& result, const signed_limb_type& val)
+inline void eval_multiply(cpp_int_backend<MinBits, Signed, Allocator>& result, const signed_limb_type& val)
{
- multiply(result, result, val);
+ eval_multiply(result, result, val);
}
template <unsigned MinBits, bool Signed, class Allocator>
void divide_unsigned_helper(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& x, const cpp_int_backend<MinBits, Signed, Allocator>& y, cpp_int_backend<MinBits, Signed, Allocator>& r)
@@ -1172,7 +1173,7 @@
*/
- using default_ops::subtract;
+ using default_ops::eval_subtract;
if(&result == &r)
{
@@ -1306,7 +1307,7 @@
t.limbs()[shift] = guess;
for(unsigned i = 0; i < shift; ++i)
t.limbs()[i] = 0;
- subtract(result, t);
+ eval_subtract(result, t);
}
}
else if(cpp_int_backend<MinBits, Signed, Allocator>::max_limb_value - pr[shift] > guess)
@@ -1317,7 +1318,7 @@
t.limbs()[shift] = guess;
for(unsigned i = 0; i < shift; ++i)
t.limbs()[i] = 0;
- add(result, t);
+ eval_add(result, t);
}
//
// Calculate guess * y, we use a fused mutiply-shift O(N) for this
@@ -1346,7 +1347,7 @@
//
// Update r:
//
- subtract(r, t);
+ eval_subtract(r, t);
if(r.isneg())
{
r.negate();
@@ -1376,15 +1377,15 @@
//
// We now just have to normalise the result:
//
- if(r_neg && get_sign(r))
+ if(r_neg && eval_get_sign(r))
{
// We have one too many in the result:
- decrement(result);
+ eval_decrement(result);
r.negate();
if(y.sign())
- subtract(r, y);
+ eval_subtract(r, y);
else
- add(r, y);
+ eval_add(r, y);
}
BOOST_ASSERT(r.compare_unsigned(y) < 0); // remainder must be less than the divisor or our code has failed
@@ -1410,7 +1411,7 @@
// As above, but simplified for integer divisor:
- using default_ops::subtract;
+ using default_ops::eval_subtract;
if(y == 0)
{
@@ -1514,20 +1515,20 @@
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void divide(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, const cpp_int_backend<MinBits, Signed, Allocator>& b)
+inline void eval_divide(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, const cpp_int_backend<MinBits, Signed, Allocator>& b)
{
cpp_int_backend<MinBits, Signed, Allocator> r;
divide_unsigned_helper(result, a, b, r);
result.sign(a.sign() != b.sign());
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void divide(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, limb_type& b)
+inline void eval_divide(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, limb_type& b)
{
cpp_int_backend<MinBits, Signed, Allocator> r;
divide_unsigned_helper(result, a, b, r);
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void divide(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, signed_limb_type& b)
+inline void eval_divide(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, signed_limb_type& b)
{
cpp_int_backend<MinBits, Signed, Allocator> r;
divide_unsigned_helper(result, a, std::abs(b), r);
@@ -1535,65 +1536,65 @@
result.negate();
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void divide(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& b)
+inline void eval_divide(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& b)
{
// There is no in place divide:
cpp_int_backend<MinBits, Signed, Allocator> a(result);
- divide(result, a, b);
+ eval_divide(result, a, b);
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void divide(cpp_int_backend<MinBits, Signed, Allocator>& result, limb_type b)
+inline void eval_divide(cpp_int_backend<MinBits, Signed, Allocator>& result, limb_type b)
{
// There is no in place divide:
cpp_int_backend<MinBits, Signed, Allocator> a(result);
- divide(result, a, b);
+ eval_divide(result, a, b);
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void divide(cpp_int_backend<MinBits, Signed, Allocator>& result, signed_limb_type b)
+inline void eval_divide(cpp_int_backend<MinBits, Signed, Allocator>& result, signed_limb_type b)
{
// There is no in place divide:
cpp_int_backend<MinBits, Signed, Allocator> a(result);
- divide(result, a, b);
+ eval_divide(result, a, b);
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void modulus(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, const cpp_int_backend<MinBits, Signed, Allocator>& b)
+inline void eval_modulus(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, const cpp_int_backend<MinBits, Signed, Allocator>& b)
{
cpp_int_backend<MinBits, Signed, Allocator> r;
divide_unsigned_helper(r, a, b, result);
result.sign(a.sign());
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void modulus(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, limb_type b)
+inline void eval_modulus(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, limb_type b)
{
cpp_int_backend<MinBits, Signed, Allocator> r;
divide_unsigned_helper(r, a, b, result);
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void modulus(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, signed_limb_type b)
+inline void eval_modulus(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, signed_limb_type b)
{
cpp_int_backend<MinBits, Signed, Allocator> r;
divide_unsigned_helper(r, a, static_cast<limb_type>(std::abs(b)), result);
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void modulus(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& b)
+inline void eval_modulus(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& b)
{
// There is no in place divide:
cpp_int_backend<MinBits, Signed, Allocator> a(result);
- modulus(result, a, b);
+ eval_modulus(result, a, b);
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void modulus(cpp_int_backend<MinBits, Signed, Allocator>& result, limb_type b)
+inline void eval_modulus(cpp_int_backend<MinBits, Signed, Allocator>& result, limb_type b)
{
// There is no in place divide:
cpp_int_backend<MinBits, Signed, Allocator> a(result);
- modulus(result, a, b);
+ eval_modulus(result, a, b);
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void modulus(cpp_int_backend<MinBits, Signed, Allocator>& result, signed_limb_type b)
+inline void eval_modulus(cpp_int_backend<MinBits, Signed, Allocator>& result, signed_limb_type b)
{
// There is no in place divide:
cpp_int_backend<MinBits, Signed, Allocator> a(result);
- modulus(result, a, b);
+ eval_modulus(result, a, b);
}
template <unsigned MinBits, bool Signed, class Allocator, class Op>
void bitwise_op(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& o, Op op)
@@ -1726,20 +1727,20 @@
struct bit_xor{ limb_type operator()(limb_type a, limb_type b)const{ return a ^ b; } };
template <unsigned MinBits, bool Signed, class Allocator>
-inline void bitwise_and(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& o)
+inline void eval_bitwise_and(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& o)
{
bitwise_op(result, o, bit_and());
}
#if 0
template <unsigned MinBits, bool Signed, class Allocator>
-inline void bitwise_and(cpp_int_backend<MinBits, Signed, Allocator>& result, limb_type o)
+inline void eval_bitwise_and(cpp_int_backend<MinBits, Signed, Allocator>& result, limb_type o)
{
result.data()[cpp_int_backend<MinBits, Signed, Allocator>::limb_count - 1] &= o;
for(typename cpp_int_backend<MinBits, Signed, Allocator>::data_type::size_type i = 0; i < cpp_int_backend<MinBits, Signed, Allocator>::limb_count - 1; ++i)
result.data()[i] = 0;
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void bitwise_and(cpp_int_backend<MinBits, Signed, Allocator>& result, signed_limb_type o)
+inline void eval_bitwise_and(cpp_int_backend<MinBits, Signed, Allocator>& result, signed_limb_type o)
{
result.data()[cpp_int_backend<MinBits, Signed, Allocator>::limb_count - 1] &= o;
limb_type mask = o < 0 ? cpp_int_backend<MinBits, Signed, Allocator>::max_limb_value : 0;
@@ -1747,35 +1748,35 @@
result.data()[i] &= mask;
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void bitwise_or(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& o)
+inline void eval_bitwise_or(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& o)
{
for(typename cpp_int_backend<MinBits, Signed, Allocator>::data_type::size_type i = 0; i < cpp_int_backend<MinBits, Signed, Allocator>::limb_count; ++i)
result.data()[i] |= o.data()[i];
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void bitwise_or(cpp_int_backend<MinBits, Signed, Allocator>& result, limb_type o)
+inline void eval_bitwise_or(cpp_int_backend<MinBits, Signed, Allocator>& result, limb_type o)
{
result.data()[cpp_int_backend<MinBits, Signed, Allocator>::limb_count - 1] |= o;
}
#endif
template <unsigned MinBits, bool Signed, class Allocator>
-inline void bitwise_or(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& o)
+inline void eval_bitwise_or(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& o)
{
bitwise_op(result, o, bit_or());
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void bitwise_xor(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& o)
+inline void eval_bitwise_xor(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& o)
{
bitwise_op(result, o, bit_xor());
}
#if 0
template <unsigned MinBits, bool Signed, class Allocator>
-inline void bitwise_xor(cpp_int_backend<MinBits, Signed, Allocator>& result, limb_type o)
+inline void eval_bitwise_xor(cpp_int_backend<MinBits, Signed, Allocator>& result, limb_type o)
{
result.data()[cpp_int_backend<MinBits, Signed, Allocator>::limb_count - 1] ^= o;
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void bitwise_xor(cpp_int_backend<MinBits, Signed, Allocator>& result, signed_limb_type o)
+inline void eval_bitwise_xor(cpp_int_backend<MinBits, Signed, Allocator>& result, signed_limb_type o)
{
result.data()[cpp_int_backend<MinBits, Signed, Allocator>::limb_count - 1] ^= o;
limb_type mask = o < 0 ? cpp_int_backend<MinBits, Signed, Allocator>::max_limb_value : 0;
@@ -1784,15 +1785,15 @@
}
#endif
template <unsigned MinBits, bool Signed, class Allocator>
-inline void complement(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& o)
+inline void eval_complement(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& o)
{
// Increment and negate:
result = o;
- increment(result);
+ eval_increment(result);
result.negate();
}
template <unsigned MinBits, bool Signed>
-inline void left_shift(cpp_int_backend<MinBits, Signed, void>& result, double_limb_type s)
+inline void eval_left_shift(cpp_int_backend<MinBits, Signed, void>& result, double_limb_type s)
{
if(!s)
return;
@@ -1868,7 +1869,7 @@
}
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void left_shift(cpp_int_backend<MinBits, Signed, Allocator>& result, double_limb_type s)
+inline void eval_left_shift(cpp_int_backend<MinBits, Signed, Allocator>& result, double_limb_type s)
{
if(!s)
return;
@@ -1925,7 +1926,7 @@
}
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline void right_shift(cpp_int_backend<MinBits, Signed, Allocator>& result, double_limb_type s)
+inline void eval_right_shift(cpp_int_backend<MinBits, Signed, Allocator>& result, double_limb_type s)
{
if(!s)
return;
@@ -1979,7 +1980,7 @@
}
template <class R, unsigned MinBits, bool Signed, class Allocator>
-inline typename enable_if<is_integral<R>, void>::type convert_to(R* result, const cpp_int_backend<MinBits, Signed, Allocator>& backend)
+inline typename enable_if<is_integral<R>, void>::type eval_convert_to(R* result, const cpp_int_backend<MinBits, Signed, Allocator>& backend)
{
*result = static_cast<R>(backend.limbs()[0]);
unsigned shift = cpp_int_backend<MinBits, Signed, Allocator>::limb_bits;
@@ -1997,7 +1998,7 @@
}
template <class R, unsigned MinBits, bool Signed, class Allocator>
-inline typename enable_if<is_floating_point<R>, void>::type convert_to(R* result, const cpp_int_backend<MinBits, Signed, Allocator>& backend)
+inline typename enable_if<is_floating_point<R>, void>::type eval_convert_to(R* result, const cpp_int_backend<MinBits, Signed, Allocator>& backend)
{
typename cpp_int_backend<MinBits, Signed, Allocator>::const_limb_pointer p = backend.limbs();
unsigned shift = cpp_int_backend<MinBits, Signed, Allocator>::limb_bits;
@@ -2012,24 +2013,23 @@
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline bool is_zero(const cpp_int_backend<MinBits, Signed, Allocator>& val)
+inline bool eval_is_zero(const cpp_int_backend<MinBits, Signed, Allocator>& val)
{
return (val.size() == 1) && (val.limbs()[0] == 0);
}
template <unsigned MinBits, bool Signed, class Allocator>
-inline int get_sign(const cpp_int_backend<MinBits, Signed, Allocator>& val)
+inline int eval_get_sign(const cpp_int_backend<MinBits, Signed, Allocator>& val)
{
- return is_zero(val) ? 0 : val.sign() ? -1 : 1;
+ return eval_is_zero(val) ? 0 : val.sign() ? -1 : 1;
}
-namespace detail{
//
// Get the location of the least-significant-bit:
//
template <unsigned MinBits, bool Signed, class Allocator>
inline unsigned get_lsb(const cpp_int_backend<MinBits, Signed, Allocator>& a)
{
- BOOST_ASSERT(get_sign(a) != 0);
+ BOOST_ASSERT(eval_get_sign(a) != 0);
unsigned result = 0;
//
@@ -2051,8 +2051,6 @@
return result + index * cpp_int_backend<MinBits, Signed, Allocator>::limb_bits;
}
-}
-
template <unsigned MinBits, bool Signed, class Allocator>
inline void eval_gcd(cpp_int_backend<MinBits, Signed, Allocator>& result, const cpp_int_backend<MinBits, Signed, Allocator>& a, const cpp_int_backend<MinBits, Signed, Allocator>& b)
{
@@ -2060,7 +2058,7 @@
cpp_int_backend<MinBits, Signed, Allocator> u(a), v(b);
- int s = get_sign(u);
+ int s = eval_get_sign(u);
/* GCD(0,x) := x */
if(s < 0)
@@ -2072,7 +2070,7 @@
result = v;
return;
}
- s = get_sign(v);
+ s = eval_get_sign(v);
if(s < 0)
{
v.negate();
@@ -2086,11 +2084,11 @@
/* Let shift := lg K, where K is the greatest power of 2
dividing both u and v. */
- unsigned us = detail::get_lsb(u);
- unsigned vs = detail::get_lsb(v);
+ unsigned us = get_lsb(u);
+ unsigned vs = get_lsb(v);
shift = (std::min)(us, vs);
- right_shift(u, us);
- right_shift(v, vs);
+ eval_right_shift(u, us);
+ eval_right_shift(v, vs);
do
{
@@ -2098,19 +2096,19 @@
Let u = min(u, v), v = diff(u, v)/2. */
if(u.compare(v) > 0)
u.swap(v);
- subtract(v, u);
+ eval_subtract(v, u);
// Termination condition tries not to do a full compare if possible:
- if(!v.limbs()[0] && is_zero(v))
+ if(!v.limbs()[0] && eval_is_zero(v))
break;
- vs = detail::get_lsb(v);
- right_shift(v, vs);
+ vs = get_lsb(v);
+ eval_right_shift(v, vs);
BOOST_ASSERT((v.limbs()[0] & 1));
BOOST_ASSERT((u.limbs()[0] & 1));
}
while(true);
result = u;
- left_shift(result, shift);
+ eval_left_shift(result, shift);
}
template <unsigned MinBits, bool Signed, class Allocator>
@@ -2119,19 +2117,23 @@
cpp_int_backend<MinBits, Signed, Allocator> t;
eval_gcd(t, a, b);
- if(is_zero(t))
+ if(eval_is_zero(t))
{
result = static_cast<limb_type>(0);
}
else
{
- divide(result, a, t);
- multiply(result, b);
+ eval_divide(result, a, t);
+ eval_multiply(result, b);
}
- if(get_sign(result) < 0)
+ if(eval_get_sign(result) < 0)
result.negate();
}
+} // namespace backends;
+
+using boost::multiprecision::backends::cpp_int_backend;
+
template <unsigned MinBits, bool Signed, class Allocator>
struct number_category<cpp_int_backend<MinBits, Signed, Allocator> > : public mpl::int_<number_kind_integer>{};
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 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
@@ -32,76 +32,76 @@
//
template <class T, class V>
inline typename enable_if<mpl::or_<is_arithmetic<V>, is_convertible<V, const char*>, is_same<V, std::string> > >::type
- add(T& result, V const& v)
+ eval_add(T& result, V const& v)
{
T t;
t = v;
- add(result, t);
+ eval_add(result, t);
}
template <class T, class V>
inline typename enable_if<mpl::or_<is_arithmetic<V>, is_convertible<V, const char*>, is_same<V, std::string> > >::type
- subtract(T& result, V const& v)
+ eval_subtract(T& result, V const& v)
{
T t;
t = v;
- subtract(result, t);
+ eval_subtract(result, t);
}
template <class T, class V>
inline typename enable_if<mpl::or_<is_arithmetic<V>, is_convertible<V, const char*>, is_same<V, std::string> > >::type
- multiply(T& result, V const& v)
+ eval_multiply(T& result, V const& v)
{
T t;
t = v;
- multiply(result, t);
+ eval_multiply(result, t);
}
template <class T, class V>
inline typename enable_if<mpl::or_<is_arithmetic<V>, is_convertible<V, const char*>, is_same<V, std::string> > >::type
- divide(T& result, V const& v)
+ eval_divide(T& result, V const& v)
{
T t;
t = v;
- divide(result, t);
+ eval_divide(result, t);
}
template <class T, class V>
inline typename enable_if<mpl::or_<is_arithmetic<V>, is_convertible<V, const char*>, is_same<V, std::string> > >::type
- modulus(T& result, V const& v)
+ eval_modulus(T& result, V const& v)
{
T t;
t = v;
- modulus(result, t);
+ eval_modulus(result, t);
}
template <class T, class V>
inline typename enable_if<mpl::or_<is_arithmetic<V>, is_convertible<V, const char*>, is_same<V, std::string> > >::type
- bitwise_and(T& result, V const& v)
+ eval_bitwise_and(T& result, V const& v)
{
T t;
t = v;
- bitwise_and(result, t);
+ eval_bitwise_and(result, t);
}
template <class T, class V>
inline typename enable_if<mpl::or_<is_arithmetic<V>, is_convertible<V, const char*>, is_same<V, std::string> > >::type
- bitwise_or(T& result, V const& v)
+ eval_bitwise_or(T& result, V const& v)
{
T t;
t = v;
- bitwise_or(result, t);
+ eval_bitwise_or(result, t);
}
template <class T, class V>
inline typename enable_if<mpl::or_<is_arithmetic<V>, is_convertible<V, const char*>, is_same<V, std::string> > >::type
- bitwise_xor(T& result, V const& v)
+ eval_bitwise_xor(T& result, V const& v)
{
T t;
t = v;
- bitwise_xor(result, t);
+ eval_bitwise_xor(result, t);
}
template <class T, class V>
inline typename enable_if<mpl::or_<is_arithmetic<V>, is_convertible<V, const char*>, is_same<V, std::string> > >::type
- complement(T& result, V const& v)
+ eval_complement(T& result, V const& v)
{
T t;
t = v;
- complement(result, t);
+ eval_complement(result, t);
}
template <class T>
@@ -115,196 +115,196 @@
// Default versions of 3-arg arithmetic functions, these just forward to the 2 arg versions:
//
template <class T, class U, class V>
-inline void add(T& t, const U& u, const V& v)
+inline void eval_add(T& t, const U& u, const V& v)
{
if(is_same_object(t, v))
{
- add(t, u);
+ eval_add(t, u);
}
else if(is_same_object(t, u))
{
- add(t, v);
+ eval_add(t, v);
}
else
{
t = u;
- add(t, v);
+ eval_add(t, v);
}
}
template<class T, class U>
-inline typename disable_if<is_same<T, U> >::type add(T& t, const U& a, const T& b)
+inline typename disable_if<is_same<T, U> >::type eval_add(T& t, const U& a, const T& b)
{
- return add(t, b, a);
+ return eval_add(t, b, a);
}
template <class T, class U, class V>
-inline void subtract(T& t, const U& u, const V& v)
+inline void eval_subtract(T& t, const U& u, const V& v)
{
if(is_same_object(t, u))
- subtract(t, v);
+ eval_subtract(t, v);
else if(is_same_object(t, v))
{
- subtract(t, u);
+ eval_subtract(t, u);
t.negate();
}
else
{
t = u;
- subtract(t, v);
+ eval_subtract(t, v);
}
}
template <class T, class U>
-inline typename disable_if<is_same<T, U> >::type subtract(T& t, const U& a, const T& b)
+inline typename disable_if<is_same<T, U> >::type eval_subtract(T& t, const U& a, const T& b)
{
- subtract(t, b, a);
+ eval_subtract(t, b, a);
t.negate();
}
template <class T, class U, class V>
-inline void multiply(T& t, const U& u, const V& v)
+inline void eval_multiply(T& t, const U& u, const V& v)
{
if(is_same_object(t, u))
- multiply(t, v);
+ eval_multiply(t, v);
else if(is_same_object(t, v))
- multiply(t, u);
+ eval_multiply(t, u);
else
{
t = u;
- multiply(t, v);
+ eval_multiply(t, v);
}
}
template <class T, class U>
-inline typename disable_if<is_same<T, U> >::type multiply(T& t, const U& a, const T& b)
+inline typename disable_if<is_same<T, U> >::type eval_multiply(T& t, const U& a, const T& b)
{
- multiply(t, b, a);
+ eval_multiply(t, b, a);
}
template <class T, class U, class V>
-inline void divide(T& t, const U& u, const V& v)
+inline void eval_divide(T& t, const U& u, const V& v)
{
if(is_same_object(t, u))
- divide(t, v);
+ eval_divide(t, v);
else if(is_same_object(t, v))
{
T temp = t;
- divide(temp, u, v);
+ eval_divide(temp, u, v);
temp.swap(t);
}
else
{
t = u;
- divide(t, v);
+ eval_divide(t, v);
}
}
template <class T, class U, class V>
-inline void modulus(T& t, const U& u, const V& v)
+inline void eval_modulus(T& t, const U& u, const V& v)
{
if(is_same_object(t, u))
- modulus(t, v);
+ eval_modulus(t, v);
else if(is_same_object(t, v))
{
T temp;
- modulus(temp, u, v);
+ eval_modulus(temp, u, v);
temp.swap(t);
}
else
{
t = u;
- modulus(t, v);
+ eval_modulus(t, v);
}
}
template <class T, class U, class V>
-inline void bitwise_and(T& t, const U& u, const V& v)
+inline void eval_bitwise_and(T& t, const U& u, const V& v)
{
if(is_same_object(t, u))
- bitwise_and(t, v);
+ eval_bitwise_and(t, v);
else if(is_same_object(t, v))
- bitwise_and(t, u);
+ eval_bitwise_and(t, u);
else
{
t = u;
- bitwise_and(t, v);
+ eval_bitwise_and(t, v);
}
}
template <class T, class U>
-inline typename disable_if<is_same<T, U> >::type bitwise_and(T& t, const U& a, const T& b)
+inline typename disable_if<is_same<T, U> >::type eval_bitwise_and(T& t, const U& a, const T& b)
{
- bitwise_and(t, b, a);
+ eval_bitwise_and(t, b, a);
}
template <class T, class U, class V>
-inline void bitwise_or(T& t, const U& u, const V& v)
+inline void eval_bitwise_or(T& t, const U& u, const V& v)
{
if(is_same_object(t, u))
- bitwise_or(t, v);
+ eval_bitwise_or(t, v);
else if(is_same_object(t, v))
- bitwise_or(t, u);
+ eval_bitwise_or(t, u);
else
{
t = u;
- bitwise_or(t, v);
+ eval_bitwise_or(t, v);
}
}
template <class T, class U>
-inline typename disable_if<is_same<T, U> >::type bitwise_or(T& t, const U& a, const T& b)
+inline typename disable_if<is_same<T, U> >::type eval_bitwise_or(T& t, const U& a, const T& b)
{
- bitwise_or(t, b, a);
+ eval_bitwise_or(t, b, a);
}
template <class T, class U, class V>
-inline void bitwise_xor(T& t, const U& u, const V& v)
+inline void eval_bitwise_xor(T& t, const U& u, const V& v)
{
if(is_same_object(t, u))
- bitwise_xor(t, v);
+ eval_bitwise_xor(t, v);
else if(is_same_object(t, v))
- bitwise_xor(t, u);
+ eval_bitwise_xor(t, u);
else
{
t = u;
- bitwise_xor(t, v);
+ eval_bitwise_xor(t, v);
}
}
template <class T, class U>
-inline typename disable_if<is_same<T, U> >::type bitwise_xor(T& t, const U& a, const T& b)
+inline typename disable_if<is_same<T, U> >::type eval_bitwise_xor(T& t, const U& a, const T& b)
{
- bitwise_xor(t, b, a);
+ eval_bitwise_xor(t, b, a);
}
template <class T>
-inline void increment(T& val)
+inline void eval_increment(T& val)
{
typedef typename mpl::front<typename T::unsigned_types>::type ui_type;
- add(val, static_cast<ui_type>(1u));
+ eval_add(val, static_cast<ui_type>(1u));
}
template <class T>
-inline void decrement(T& val)
+inline void eval_decrement(T& val)
{
typedef typename mpl::front<typename T::unsigned_types>::type ui_type;
- subtract(val, static_cast<ui_type>(1u));
+ eval_subtract(val, static_cast<ui_type>(1u));
}
template <class T, class V>
-inline void left_shift(T& result, const T& arg, const V val)
+inline void eval_left_shift(T& result, const T& arg, const V val)
{
result = arg;
- left_shift(result, val);
+ eval_left_shift(result, val);
}
template <class T, class V>
-inline void right_shift(T& result, const T& arg, const V val)
+inline void eval_right_shift(T& result, const T& arg, const V val)
{
result = arg;
- right_shift(result, val);
+ eval_right_shift(result, val);
}
template <class T>
-inline bool is_zero(const T& val)
+inline bool eval_is_zero(const T& val)
{
typedef typename mpl::front<typename T::unsigned_types>::type ui_type;
return val.compare(static_cast<ui_type>(0)) == 0;
}
template <class T>
-inline int get_sign(const T& val)
+inline int eval_get_sign(const T& val)
{
typedef typename mpl::front<typename T::unsigned_types>::type ui_type;
return val.compare(static_cast<ui_type>(0));
@@ -316,7 +316,7 @@
result = v1;
T t;
t = v2;
- divide(result, t);
+ eval_divide(result, t);
}
template <class T, class V>
@@ -367,11 +367,11 @@
};
template <class R, class B>
-inline void convert_to(R* result, const B& backend)
+inline void eval_convert_to(R* result, const B& backend)
{
typedef typename calculate_next_larger_type<R, B>::type next_type;
next_type n;
- convert_to(&n, backend);
+ eval_convert_to(&n, backend);
if(std::numeric_limits<R>::is_specialized && (n > (std::numeric_limits<R>::max)()))
{
*result = (std::numeric_limits<R>::max)();
@@ -381,7 +381,7 @@
}
template <class R, class B>
-inline void convert_to(terminal<R>* result, const B& backend)
+inline void eval_convert_to(terminal<R>* result, const B& backend)
{
//
// We ran out of types to try for the convertion, try
@@ -417,7 +417,7 @@
inline int eval_fpclassify(const Backend& arg)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_floating_point, "The fpclassify function is only valid for floating point types.");
- return is_zero(arg) ? FP_ZERO : FP_NORMAL;
+ return eval_is_zero(arg) ? FP_ZERO : FP_NORMAL;
}
template <class T>
@@ -432,13 +432,13 @@
return;
}
T n;
- divide(result, a, b);
- if(get_sign(a) < 0)
+ eval_divide(result, a, b);
+ if(eval_get_sign(a) < 0)
eval_ceil(n, result);
else
eval_floor(n, result);
- multiply(n, b);
- subtract(result, a, n);
+ eval_multiply(n, b);
+ eval_subtract(result, a, n);
}
template <class T>
inline void eval_trunc(T& result, const T& a)
@@ -450,7 +450,7 @@
result = boost::math::policies::raise_rounding_error("boost::multiprecision::trunc<%1%>(%1%)", 0, mp_number<T>(a), 0, boost::math::policies::policy<>()).backend();
return;
}
- if(get_sign(a) < 0)
+ if(eval_get_sign(a) < 0)
eval_ceil(result, a);
else
eval_floor(result, a);
@@ -467,14 +467,14 @@
result = boost::math::policies::raise_rounding_error("boost::multiprecision::round<%1%>(%1%)", 0, mp_number<T>(a), 0, boost::math::policies::policy<>()).backend();
return;
}
- if(get_sign(a) < 0)
+ if(eval_get_sign(a) < 0)
{
- subtract(result, a, fp_type(0.5f));
+ eval_subtract(result, a, fp_type(0.5f));
eval_ceil(result, result);
}
else
{
- add(result, a, fp_type(0.5f));
+ eval_add(result, a, fp_type(0.5f));
eval_floor(result, result);
}
}
Modified: sandbox/big_number/boost/multiprecision/detail/functions/constants.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/detail/functions/constants.hpp (original)
+++ sandbox/big_number/boost/multiprecision/detail/functions/constants.hpp 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
@@ -28,21 +28,21 @@
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);
+ eval_multiply(temp, ui_type(2 * n));
+ eval_multiply(temp, ui_type(2 * n + 1));
+ eval_multiply(num, temp);
+ eval_multiply(denom, temp);
sign = -sign;
- multiply(next_term, n);
- multiply(temp, next_term, next_term);
- multiply(temp, sign);
- add(num, temp);
+ eval_multiply(next_term, n);
+ eval_multiply(temp, next_term, next_term);
+ eval_multiply(temp, sign);
+ eval_add(num, temp);
}
- multiply(denom, ui_type(4));
- multiply(num, ui_type(3));
+ eval_multiply(denom, ui_type(4));
+ eval_multiply(num, ui_type(3));
INSTRUMENT_BACKEND(denom);
INSTRUMENT_BACKEND(num);
- divide(num, denom);
+ eval_divide(num, denom);
INSTRUMENT_BACKEND(num);
}
@@ -60,12 +60,12 @@
denom = ui_type(1);
ui_type i = 2;
do{
- multiply(denom, i);
- multiply(result, i);
- add(result, ui_type(1));
+ eval_multiply(denom, i);
+ eval_multiply(result, i);
+ eval_add(result, ui_type(1));
++i;
}while(denom.compare(lim) <= 0);
- divide(result, denom);
+ eval_divide(result, denom);
}
template <class T>
@@ -91,16 +91,16 @@
do
{
- add(result, A, B);
+ eval_add(result, A, B);
eval_ldexp(result, result, -2);
eval_sqrt(b, B);
- add(a, b);
+ eval_add(a, b);
eval_ldexp(a, a, -1);
- multiply(A, a, a);
- subtract(B, A, result);
+ eval_multiply(A, a, a);
+ eval_subtract(B, A, result);
eval_ldexp(B, B, 1);
- subtract(result, A, B);
- bool neg = get_sign(result) < 0;
+ eval_subtract(result, A, B);
+ bool neg = eval_get_sign(result) < 0;
if(neg)
result.negate();
if(result.compare(lim) <= 0)
@@ -108,13 +108,13 @@
if(neg)
result.negate();
eval_ldexp(result, result, k - 1);
- subtract(D, result);
+ eval_subtract(D, result);
++k;
eval_ldexp(lim, lim, 1);
}
while(true);
- divide(result, B, D);
+ eval_divide(result, B, D);
}
template <class T, const T& (*F)(void)>
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 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
@@ -35,7 +35,7 @@
temp = static_cast<int_type>(1);
T denom;
pow_imp(denom, t, -p, mpl::true_());
- divide(result, temp, denom);
+ eval_divide(result, temp, denom);
return;
}
@@ -48,15 +48,15 @@
result = t;
break;
case 2:
- multiply(result, t, t);
+ eval_multiply(result, t, t);
break;
case 3:
- multiply(result, t, t);
- multiply(result, t);
+ eval_multiply(result, t, t);
+ eval_multiply(result, t);
break;
case 4:
- multiply(result, t, t);
- multiply(result, result);
+ eval_multiply(result, t, t);
+ eval_multiply(result, result);
break;
default:
{
@@ -65,7 +65,7 @@
for(n = static_cast<U>(1); n <= static_cast<U>(p / static_cast<U>(2)); n *= static_cast<U>(2))
{
- multiply(result, result);
+ eval_multiply(result, result);
}
const U p_minus_n = static_cast<U>(p - n);
@@ -75,7 +75,7 @@
{
T temp;
pow_imp(temp, t, p_minus_n, mpl::true_());
- multiply(result, temp);
+ eval_multiply(result, temp);
}
}
}
@@ -106,11 +106,11 @@
T x_pow_n_div_n_fact(x);
- add(H0F0, x_pow_n_div_n_fact, ui_type(1));
+ eval_add(H0F0, x_pow_n_div_n_fact, ui_type(1));
T lim;
eval_ldexp(lim, H0F0, 1 - tol);
- if(get_sign(lim) < 0)
+ if(eval_get_sign(lim) < 0)
lim.negate();
ui_type n;
@@ -118,10 +118,10 @@
// 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);
- add(H0F0, x_pow_n_div_n_fact);
- bool neg = get_sign(x_pow_n_div_n_fact) < 0;
+ eval_multiply(x_pow_n_div_n_fact, x);
+ eval_divide(x_pow_n_div_n_fact, n);
+ eval_add(H0F0, x_pow_n_div_n_fact);
+ bool neg = eval_get_sign(x_pow_n_div_n_fact) < 0;
if(neg)
x_pow_n_div_n_fact.negate();
if(lim.compare(x_pow_n_div_n_fact) > 0)
@@ -154,11 +154,11 @@
T pochham_a (a);
T ap (a);
- multiply(H1F0, pochham_a, x_pow_n_div_n_fact);
- add(H1F0, si_type(1));
+ eval_multiply(H1F0, pochham_a, x_pow_n_div_n_fact);
+ eval_add(H1F0, si_type(1));
T lim;
eval_ldexp(lim, H1F0, 1 - boost::multiprecision::detail::digits2<mp_number<T> >::value);
- if(get_sign(lim) < 0)
+ if(eval_get_sign(lim) < 0)
lim.negate();
si_type n;
@@ -167,13 +167,13 @@
// Series expansion of hyperg_1f0(a; ; x).
for(n = 2; n < boost::multiprecision::detail::digits2<mp_number<T> >::value + 10; n++)
{
- multiply(x_pow_n_div_n_fact, x);
- divide(x_pow_n_div_n_fact, n);
- increment(ap);
- multiply(pochham_a, ap);
- multiply(term, pochham_a, x_pow_n_div_n_fact);
- add(H1F0, term);
- if(get_sign(term) < 0)
+ eval_multiply(x_pow_n_div_n_fact, x);
+ eval_divide(x_pow_n_div_n_fact, n);
+ eval_increment(ap);
+ eval_multiply(pochham_a, ap);
+ eval_multiply(term, pochham_a, x_pow_n_div_n_fact);
+ eval_add(H1F0, term);
+ if(eval_get_sign(term) < 0)
term.negate();
if(lim.compare(term) >= 0)
break;
@@ -201,7 +201,7 @@
// Handle special arguments.
int type = eval_fpclassify(x);
- bool isneg = get_sign(x) < 0;
+ bool isneg = eval_get_sign(x) < 0;
if(type == FP_NAN)
{
result = std::numeric_limits<mp_number<T> >::quiet_NaN().backend();
@@ -250,21 +250,21 @@
exp_series = xx;
result = si_type(1);
if(isneg)
- subtract(result, exp_series);
+ eval_subtract(result, exp_series);
else
- add(result, exp_series);
- multiply(exp_series, xx);
- divide(exp_series, ui_type(k));
- add(result, exp_series);
+ eval_add(result, exp_series);
+ eval_multiply(exp_series, xx);
+ eval_divide(exp_series, ui_type(k));
+ eval_add(result, exp_series);
while(exp_series.compare(lim) > 0)
{
++k;
- multiply(exp_series, xx);
- divide(exp_series, ui_type(k));
+ eval_multiply(exp_series, xx);
+ eval_divide(exp_series, ui_type(k));
if(isneg && (k&1))
- subtract(result, exp_series);
+ eval_subtract(result, exp_series);
else
- add(result, exp_series);
+ eval_add(result, exp_series);
}
return;
}
@@ -272,7 +272,7 @@
// Check for pure-integer arguments which can be either signed or unsigned.
long long ll;
eval_trunc(exp_series, x);
- convert_to(&ll, exp_series);
+ eval_convert_to(&ll, exp_series);
if(x.compare(ll) == 0)
{
detail::pow_imp(result, get_constant_e<T>(), ll, mpl::true_());
@@ -293,23 +293,23 @@
if(b_scale)
{
- divide(result, xx, get_constant_ln2<T>());
+ eval_divide(result, xx, get_constant_ln2<T>());
exp_type n;
- convert_to(&n, result);
+ eval_convert_to(&n, result);
// The scaling is 2^11 = 2048.
static const si_type p2 = static_cast<si_type>(si_type(1) << 11);
- multiply(exp_series, get_constant_ln2<T>(), static_cast<canonical_exp_type>(n));
- subtract(exp_series, xx);
- divide(exp_series, p2);
+ eval_multiply(exp_series, get_constant_ln2<T>(), static_cast<canonical_exp_type>(n));
+ eval_subtract(exp_series, xx);
+ eval_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);
+ eval_multiply(exp_series, result);
}
else
{
@@ -317,7 +317,7 @@
}
if(isneg)
- divide(result, ui_type(1), exp_series);
+ eval_divide(result, ui_type(1), exp_series);
else
result = exp_series;
}
@@ -358,9 +358,9 @@
--e;
}
- multiply(result, get_constant_ln2<T>(), canonical_exp_type(e));
+ eval_multiply(result, get_constant_ln2<T>(), canonical_exp_type(e));
INSTRUMENT_BACKEND(result);
- subtract(t, ui_type(1)); /* -0.3 <= t <= 0.3 */
+ eval_subtract(t, ui_type(1)); /* -0.3 <= t <= 0.3 */
if(!alternate)
t.negate(); /* 0 <= t <= 0.33333 */
T pow = t;
@@ -368,12 +368,12 @@
T t2;
if(alternate)
- add(result, t);
+ eval_add(result, t);
else
- subtract(result, t);
+ eval_subtract(result, t);
- multiply(lim, result, std::numeric_limits<mp_number<T> >::epsilon().backend());
- if(get_sign(lim) < 0)
+ eval_multiply(lim, result, std::numeric_limits<mp_number<T> >::epsilon().backend());
+ if(eval_get_sign(lim) < 0)
lim.negate();
INSTRUMENT_BACKEND(lim);
@@ -381,13 +381,13 @@
do
{
++k;
- multiply(pow, t);
- divide(t2, pow, k);
+ eval_multiply(pow, t);
+ eval_divide(t2, pow, k);
INSTRUMENT_BACKEND(t2);
if(alternate && ((k & 1) != 0))
- add(result, t2);
+ eval_add(result, t2);
else
- subtract(result, t2);
+ eval_subtract(result, t2);
INSTRUMENT_BACKEND(result);
}while(lim.compare(t2) < 0);
}
@@ -415,7 +415,7 @@
{
BOOST_STATIC_ASSERT_MSG(number_category<T>::value == number_kind_floating_point, "The fabs function is only valid for floating point types.");
eval_log(result, arg);
- divide(result, get_constant_log10<T>());
+ eval_divide(result, get_constant_log10<T>());
}
template<typename T>
@@ -457,35 +457,35 @@
default: ;
}
- if(get_sign(a) == 0)
+ if(eval_get_sign(a) == 0)
{
result = si_type(1);
return;
}
long long an;
- convert_to(&an, a);
+ eval_convert_to(&an, a);
const bool bo_a_isint = a.compare(an) == 0;
- if((get_sign(x) < 0) && !bo_a_isint)
+ if((eval_get_sign(x) < 0) && !bo_a_isint)
{
result = std::numeric_limits<mp_number<T> >::quiet_NaN().backend();
}
T t;
T da(a);
- subtract(da, an);
+ eval_subtract(da, an);
if(a.compare(si_type(-1)) < 0)
{
t = a;
t.negate();
eval_pow(da, x, t);
- divide(result, si_type(1), da);
+ eval_divide(result, si_type(1), da);
return;
}
- subtract(da, a, an);
+ eval_subtract(da, a, an);
if(bo_a_isint)
{
@@ -493,13 +493,13 @@
return;
}
- if((get_sign(x) > 0) && (x.compare(fp_type(0.5)) >= 0) && (x.compare(fp_type(0.9)) < 0))
+ if((eval_get_sign(x) > 0) && (x.compare(fp_type(0.5)) >= 0) && (x.compare(fp_type(0.9)) < 0))
{
if(a.compare(fp_type(1e-5f)) <= 0)
{
// Series expansion for small a.
eval_log(t, x);
- multiply(t, a);
+ eval_multiply(t, a);
hyp0F0(result, t);
return;
}
@@ -511,17 +511,17 @@
{
da.negate();
t = si_type(1);
- subtract(t, x);
+ eval_subtract(t, x);
hyp1F0(result, da, t);
detail::pow_imp(t, x, an, mpl::true_());
- multiply(result, t);
+ eval_multiply(result, t);
}
else
{
da = a;
da.negate();
t = si_type(1);
- subtract(t, x);
+ eval_subtract(t, x);
hyp1F0(result, da, t);
}
}
@@ -533,15 +533,15 @@
if(an)
{
eval_log(t, x);
- multiply(t, da);
+ eval_multiply(t, da);
eval_exp(result, t);
detail::pow_imp(t, x, an, mpl::true_());
- multiply(result, t);
+ eval_multiply(result, t);
}
else
{
eval_log(t, x);
- multiply(t, a);
+ eval_multiply(t, a);
eval_exp(result, t);
}
}
@@ -553,12 +553,12 @@
void small_sinh_series(T x, T& result)
{
typedef typename boost::multiprecision::detail::canonical<unsigned, T>::type ui_type;
- bool neg = get_sign(x) < 0;
+ bool neg = eval_get_sign(x) < 0;
if(neg)
x.negate();
T p(x);
T mult(x);
- multiply(mult, x);
+ eval_multiply(mult, x);
result = x;
ui_type k = 1;
@@ -567,10 +567,10 @@
do
{
- multiply(p, mult);
- divide(p, ++k);
- divide(p, ++k);
- add(result, p);
+ eval_multiply(p, mult);
+ eval_divide(p, ++k);
+ eval_divide(p, ++k);
+ eval_add(result, p);
}while(p.compare(lim) >= 0);
if(neg)
result.negate();
@@ -605,12 +605,12 @@
T e_px, e_mx;
- bool small_sinh = get_sign(x) < 0 ? e_px.compare(fp_type(-0.5)) > 0 : e_px.compare(fp_type(0.5)) < 0;
+ bool small_sinh = eval_get_sign(x) < 0 ? e_px.compare(fp_type(-0.5)) > 0 : e_px.compare(fp_type(0.5)) < 0;
if(p_cosh || !small_sinh)
{
eval_exp(e_px, x);
- divide(e_mx, ui_type(1), e_px);
+ eval_divide(e_mx, ui_type(1), e_px);
if(p_sinh)
{
@@ -620,14 +620,14 @@
}
else
{
- subtract(*p_sinh, e_px, e_mx);
- divide(*p_sinh, ui_type(2));
+ eval_subtract(*p_sinh, e_px, e_mx);
+ eval_divide(*p_sinh, ui_type(2));
}
}
if(p_cosh)
{
- add(*p_cosh, e_px, e_mx);
- divide(*p_cosh, ui_type(2));
+ eval_add(*p_cosh, e_px, e_mx);
+ eval_divide(*p_cosh, ui_type(2));
}
}
else
@@ -658,6 +658,6 @@
BOOST_STATIC_ASSERT_MSG(number_category<T>::value == number_kind_floating_point, "The tanh function is only valid for floating point types.");
T c;
detail::sinhcosh(x, &result, &c);
- divide(result, c);
+ eval_divide(result, c);
}
Modified: sandbox/big_number/boost/multiprecision/detail/functions/trig.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/detail/functions/trig.hpp (original)
+++ sandbox/big_number/boost/multiprecision/detail/functions/trig.hpp 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
@@ -29,31 +29,31 @@
T pochham_b (b);
T bp (b);
- divide(result, x_pow_n_div_n_fact, pochham_b);
- add(result, ui_type(1));
+ eval_divide(result, x_pow_n_div_n_fact, pochham_b);
+ eval_add(result, ui_type(1));
si_type n;
T tol;
tol = ui_type(1);
eval_ldexp(tol, tol, 1 - boost::multiprecision::detail::digits2<mp_number<T> >::value);
- multiply(tol, result);
- if(get_sign(tol) < 0)
+ eval_multiply(tol, result);
+ if(eval_get_sign(tol) < 0)
tol.negate();
T term;
// Series expansion of hyperg_0f1(; b; x).
for(n = 2; n < 300; ++n)
{
- multiply(x_pow_n_div_n_fact, x);
- divide(x_pow_n_div_n_fact, n);
- increment(bp);
- multiply(pochham_b, bp);
+ eval_multiply(x_pow_n_div_n_fact, x);
+ eval_divide(x_pow_n_div_n_fact, n);
+ eval_increment(bp);
+ eval_multiply(pochham_b, bp);
- divide(term, x_pow_n_div_n_fact, pochham_b);
- add(result, term);
+ eval_divide(term, x_pow_n_div_n_fact, pochham_b);
+ eval_add(result, term);
- bool neg_term = get_sign(term) < 0;
+ bool neg_term = eval_get_sign(term) < 0;
if(neg_term)
term.negate();
if(term.compare(tol) <= 0)
@@ -103,7 +103,7 @@
// The argument xx will be reduced to 0 <= xx <= pi/2.
bool b_negate_sin = false;
- if(get_sign(x) < 0)
+ if(eval_get_sign(x) < 0)
{
xx.negate();
b_negate_sin = !b_negate_sin;
@@ -113,13 +113,13 @@
// Remove even multiples of pi.
if(xx.compare(get_constant_pi<T>()) > 0)
{
- divide(n_pi, xx, get_constant_pi<T>());
+ eval_divide(n_pi, xx, get_constant_pi<T>());
eval_trunc(n_pi, n_pi);
t = ui_type(2);
eval_fmod(t, n_pi, t);
- const bool b_n_pi_is_even = get_sign(t) == 0;
- multiply(n_pi, get_constant_pi<T>());
- subtract(xx, n_pi);
+ const bool b_n_pi_is_even = eval_get_sign(t) == 0;
+ eval_multiply(n_pi, get_constant_pi<T>());
+ eval_subtract(xx, n_pi);
BOOST_MATH_INSTRUMENT_CODE(xx.str(0, std::ios_base::scientific));
BOOST_MATH_INSTRUMENT_CODE(n_pi.str(0, std::ios_base::scientific));
@@ -135,13 +135,13 @@
eval_ldexp(t, get_constant_pi<T>(), -1);
if(xx.compare(t) > 0)
{
- subtract(xx, get_constant_pi<T>(), xx);
+ eval_subtract(xx, get_constant_pi<T>(), xx);
BOOST_MATH_INSTRUMENT_CODE(xx.str(0, std::ios_base::scientific));
}
- subtract(t, xx);
- const bool b_zero = get_sign(xx) == 0;
- const bool b_pi_half = get_sign(t) == 0;
+ eval_subtract(t, xx);
+ const bool b_zero = eval_get_sign(xx) == 0;
+ const bool b_pi_half = eval_get_sign(t) == 0;
// Check if the reduced argument is very close to 0 or pi/2.
const bool b_near_zero = xx.compare(fp_type(1e-1)) < 0;
@@ -157,18 +157,18 @@
}
else if(b_near_zero)
{
- multiply(t, xx, xx);
- divide(t, si_type(-4));
+ eval_multiply(t, xx, xx);
+ eval_divide(t, si_type(-4));
T t2;
t2 = fp_type(1.5);
hyp0F1(result, t2, t);
BOOST_MATH_INSTRUMENT_CODE(result.str(0, std::ios_base::scientific));
- multiply(result, xx);
+ eval_multiply(result, xx);
}
else if(b_near_pi_half)
{
- multiply(t, t);
- divide(t, si_type(-4));
+ eval_multiply(t, t);
+ eval_divide(t, si_type(-4));
T t2;
t2 = fp_type(0.5);
hyp0F1(result, t2, t);
@@ -184,26 +184,26 @@
static const si_type n_scale = 9;
static const si_type n_three_pow_scale = static_cast<si_type>(19683L);
- divide(xx, n_three_pow_scale);
+ eval_divide(xx, n_three_pow_scale);
// Now with small arguments, we are ready for a series expansion.
- multiply(t, xx, xx);
- divide(t, si_type(-4));
+ eval_multiply(t, xx, xx);
+ eval_divide(t, si_type(-4));
T t2;
t2 = fp_type(1.5);
hyp0F1(result, t2, t);
BOOST_MATH_INSTRUMENT_CODE(result.str(0, std::ios_base::scientific));
- multiply(result, xx);
+ eval_multiply(result, xx);
// Convert back using multiple angle identity.
for(boost::int32_t k = static_cast<boost::int32_t>(0); k < n_scale; k++)
{
// Rescale the cosine value using the multiple angle identity.
- multiply(t2, result, ui_type(3));
- multiply(t, result, result);
- multiply(t, result);
- multiply(t, ui_type(4));
- subtract(result, t2, t);
+ eval_multiply(t2, result, ui_type(3));
+ eval_multiply(t, result, result);
+ eval_multiply(t, result);
+ eval_multiply(t, ui_type(4));
+ eval_subtract(result, t2, t);
}
}
@@ -249,7 +249,7 @@
// The argument xx will be reduced to 0 <= xx <= pi/2.
bool b_negate_cos = false;
- if(get_sign(x) < 0)
+ if(eval_get_sign(x) < 0)
{
xx.negate();
}
@@ -258,18 +258,18 @@
// Remove even multiples of pi.
if(xx.compare(get_constant_pi<T>()) > 0)
{
- divide(t, xx, get_constant_pi<T>());
+ eval_divide(t, xx, get_constant_pi<T>());
eval_trunc(n_pi, t);
BOOST_MATH_INSTRUMENT_CODE(n_pi.str(0, std::ios_base::scientific));
- multiply(t, n_pi, get_constant_pi<T>());
+ eval_multiply(t, n_pi, get_constant_pi<T>());
BOOST_MATH_INSTRUMENT_CODE(t.str(0, std::ios_base::scientific));
- subtract(xx, t);
+ eval_subtract(xx, t);
BOOST_MATH_INSTRUMENT_CODE(xx.str(0, std::ios_base::scientific));
// Adjust signs if the multiple of pi is not even.
t = ui_type(2);
eval_fmod(t, n_pi, t);
- const bool b_n_pi_is_even = get_sign(t) == 0;
+ const bool b_n_pi_is_even = eval_get_sign(t) == 0;
if(!b_n_pi_is_even)
{
@@ -282,17 +282,17 @@
int com = xx.compare(t);
if(com > 0)
{
- subtract(xx, get_constant_pi<T>(), xx);
+ eval_subtract(xx, get_constant_pi<T>(), xx);
b_negate_cos = !b_negate_cos;
BOOST_MATH_INSTRUMENT_CODE(xx.str(0, std::ios_base::scientific));
}
- const bool b_zero = get_sign(xx) == 0;
+ const bool b_zero = eval_get_sign(xx) == 0;
const bool b_pi_half = com == 0;
// Check if the reduced argument is very close to 0 or pi/2.
const bool b_near_zero = xx.compare(fp_type(1e-4)) < 0;
- subtract(t, xx);
+ eval_subtract(t, xx);
const bool b_near_pi_half = t.compare(fp_type(1e-4)) < 0;
if(b_zero)
@@ -305,8 +305,8 @@
}
else if(b_near_zero)
{
- multiply(t, xx, xx);
- divide(t, si_type(-4));
+ eval_multiply(t, xx, xx);
+ eval_divide(t, si_type(-4));
n_pi = fp_type(0.5f);
hyp0F1(result, n_pi, t);
BOOST_MATH_INSTRUMENT_CODE(result.str(0, std::ios_base::scientific));
@@ -314,11 +314,11 @@
else if(b_near_pi_half)
{
T t2(t);
- multiply(t, t);
- divide(t, si_type(-4));
+ eval_multiply(t, t);
+ eval_divide(t, si_type(-4));
n_pi = fp_type(1.5f);
hyp0F1(result, n_pi, t);
- multiply(result, t2);
+ eval_multiply(result, t2);
BOOST_MATH_INSTRUMENT_CODE(result.str(0, std::ios_base::scientific));
}
else
@@ -330,10 +330,10 @@
static const ui_type n_scale = 9;
static const ui_type n_three_pow_scale = 19683;
- divide(xx, n_three_pow_scale);
+ eval_divide(xx, n_three_pow_scale);
- multiply(t, xx, xx);
- divide(t, si_type(-4));
+ eval_multiply(t, xx, xx);
+ eval_divide(t, si_type(-4));
n_pi = fp_type(0.5f);
// Now with small arguments, we are ready for a series expansion.
@@ -343,11 +343,11 @@
// Convert back using multiple angle identity.
for(ui_type k = 0; k < n_scale; k++)
{
- multiply(t, result, result);
- multiply(t, result);
- multiply(t, ui_type(4));
- multiply(result, si_type(-3));
- add(result, t);
+ eval_multiply(t, result, result);
+ eval_multiply(t, result);
+ eval_multiply(t, ui_type(4));
+ eval_multiply(result, si_type(-3));
+ eval_add(result, t);
}
}
if(b_negate_cos)
@@ -361,7 +361,7 @@
T t;
eval_sin(result, x);
eval_cos(t, x);
- divide(result, t);
+ eval_divide(result, t);
}
template <class T>
@@ -385,15 +385,15 @@
T bp (b);
T cp (c);
- multiply(result, pochham_a, pochham_b);
- divide(result, pochham_c);
- multiply(result, x_pow_n_div_n_fact);
- add(result, ui_type(1));
+ eval_multiply(result, pochham_a, pochham_b);
+ eval_divide(result, pochham_c);
+ eval_multiply(result, x_pow_n_div_n_fact);
+ eval_add(result, ui_type(1));
T lim;
eval_ldexp(lim, result, 1 - boost::multiprecision::detail::digits2<mp_number<T> >::value);
- if(get_sign(lim) < 0)
+ if(eval_get_sign(lim) < 0)
lim.negate();
ui_type n;
@@ -402,22 +402,22 @@
// Series expansion of hyperg_2f1(a, b; c; x).
for(n = 2; n < 300; ++n)
{
- multiply(x_pow_n_div_n_fact, x);
- divide(x_pow_n_div_n_fact, n);
+ eval_multiply(x_pow_n_div_n_fact, x);
+ eval_divide(x_pow_n_div_n_fact, n);
- increment(ap);
- multiply(pochham_a, ap);
- increment(bp);
- multiply(pochham_b, bp);
- increment(cp);
- multiply(pochham_c, cp);
-
- multiply(term, pochham_a, pochham_b);
- divide(term, pochham_c);
- multiply(term, x_pow_n_div_n_fact);
- add(result, term);
+ eval_increment(ap);
+ eval_multiply(pochham_a, ap);
+ eval_increment(bp);
+ eval_multiply(pochham_b, bp);
+ eval_increment(cp);
+ eval_multiply(pochham_c, cp);
+
+ eval_multiply(term, pochham_a, pochham_b);
+ eval_divide(term, pochham_c);
+ eval_multiply(term, x_pow_n_div_n_fact);
+ eval_add(result, term);
- if(get_sign(term) < 0)
+ if(eval_get_sign(term) < 0)
term.negate();
if(lim.compare(term) >= 0)
break;
@@ -455,7 +455,7 @@
default: ;
}
- const bool b_neg = get_sign(x) < 0;
+ const bool b_neg = eval_get_sign(x) < 0;
T xx(x);
if(b_neg)
@@ -479,29 +479,29 @@
if(xx.compare(fp_type(1e-4)) < 0)
{
// http://functions.wolfram.com/ElementaryFunctions/ArcSin/26/01/01/
- multiply(xx, xx);
+ eval_multiply(xx, xx);
T t1, t2;
t1 = fp_type(0.5f);
t2 = fp_type(1.5f);
hyp2F1(result, t1, t1, t2, xx);
- multiply(result, x);
+ eval_multiply(result, x);
return;
}
else if(xx.compare(fp_type(1 - 1e-4f)) > 0)
{
T dx1;
T t1, t2;
- subtract(dx1, ui_type(1), xx);
+ eval_subtract(dx1, ui_type(1), xx);
t1 = fp_type(0.5f);
t2 = fp_type(1.5f);
eval_ldexp(dx1, dx1, -1);
hyp2F1(result, t1, t1, t2, dx1);
eval_ldexp(dx1, dx1, 2);
eval_sqrt(t1, dx1);
- multiply(result, t1);
+ eval_multiply(result, t1);
eval_ldexp(t1, get_constant_pi<T>(), -1);
result.negate();
- add(result, t1);
+ eval_add(result, t1);
if(b_neg)
result.negate();
return;
@@ -509,7 +509,7 @@
// Get initial estimate using standard math function asin.
double dd;
- convert_to(&dd, xx);
+ eval_convert_to(&dd, xx);
result = fp_type(std::asin(dd));
@@ -519,15 +519,15 @@
T s, c;
eval_sin(s, result);
eval_cos(c, result);
- subtract(s, xx);
- divide(s, c);
- subtract(result, s);
+ eval_subtract(s, xx);
+ eval_divide(s, c);
+ eval_subtract(result, s);
T lim;
eval_ldexp(lim, result, 1 - boost::multiprecision::detail::digits2<mp_number<T> >::value);
- if(get_sign(s) < 0)
+ if(eval_get_sign(s) < 0)
s.negate();
- if(get_sign(lim) < 0)
+ if(eval_get_sign(lim) < 0)
lim.negate();
if(lim.compare(s) >= 0)
break;
@@ -564,7 +564,7 @@
}
else if(c == 0)
{
- if(get_sign(x) < 0)
+ if(eval_get_sign(x) < 0)
result = get_constant_pi<T>();
else
result = ui_type(0);
@@ -574,7 +574,7 @@
eval_asin(result, x);
T t;
eval_ldexp(t, get_constant_pi<T>(), -1);
- subtract(result, t);
+ eval_subtract(result, t);
result.negate();
}
@@ -597,7 +597,7 @@
result = ui_type(0);
return;
case FP_INFINITE:
- if(get_sign(x) < 0)
+ if(eval_get_sign(x) < 0)
{
eval_ldexp(result, get_constant_pi<T>(), -1);
result.negate();
@@ -608,7 +608,7 @@
default: ;
}
- const bool b_neg = get_sign(x) < 0;
+ const bool b_neg = eval_get_sign(x) < 0;
T xx(x);
if(b_neg)
@@ -620,10 +620,10 @@
t1 = ui_type(1);
t2 = fp_type(0.5f);
t3 = fp_type(1.5f);
- multiply(xx, xx);
+ eval_multiply(xx, xx);
xx.negate();
hyp2F1(result, t1, t2, t3, xx);
- multiply(result, x);
+ eval_multiply(result, x);
return;
}
@@ -633,14 +633,14 @@
t1 = fp_type(0.5f);
t2 = ui_type(1u);
t3 = fp_type(1.5f);
- multiply(xx, xx);
- divide(xx, si_type(-1), xx);
+ eval_multiply(xx, xx);
+ eval_divide(xx, si_type(-1), xx);
hyp2F1(result, t1, t2, t3, xx);
- divide(result, x);
+ eval_divide(result, x);
if(!b_neg)
result.negate();
eval_ldexp(t1, get_constant_pi<T>(), -1);
- add(result, t1);
+ eval_add(result, t1);
if(b_neg)
result.negate();
return;
@@ -649,7 +649,7 @@
// Get initial estimate using standard math function atan.
fp_type d;
- convert_to(&d, xx);
+ eval_convert_to(&d, xx);
result = fp_type(std::atan(d));
// Newton-Raphson iteration
@@ -660,10 +660,10 @@
{
eval_sin(s, result);
eval_cos(c, result);
- multiply(t, xx, c);
- subtract(t, s);
- multiply(s, t, c);
- add(result, s);
+ eval_multiply(t, xx, c);
+ eval_subtract(t, s);
+ eval_multiply(s, t, c);
+ eval_add(result, s);
}
if(b_neg)
result.negate();
@@ -699,7 +699,7 @@
return;
case FP_ZERO:
{
- int c = get_sign(x);
+ int c = eval_get_sign(x);
if(c < 0)
result = get_constant_pi<T>();
else if(c >= 0)
@@ -715,7 +715,7 @@
else
{
eval_ldexp(result, get_constant_pi<T>(), -1);
- if(get_sign(y) < 0)
+ if(eval_get_sign(y) < 0)
result.negate();
}
return;
@@ -730,30 +730,30 @@
case FP_ZERO:
{
eval_ldexp(result, get_constant_pi<T>(), -1);
- if(get_sign(y) < 0)
+ if(eval_get_sign(y) < 0)
result.negate();
return;
}
case FP_INFINITE:
- if(get_sign(x) > 0)
+ if(eval_get_sign(x) > 0)
result = ui_type(0);
else
result = get_constant_pi<T>();
- if(get_sign(y) < 0)
+ if(eval_get_sign(y) < 0)
result.negate();
return;
}
T xx;
- divide(xx, y, x);
- if(get_sign(xx) < 0)
+ eval_divide(xx, y, x);
+ if(eval_get_sign(xx) < 0)
xx.negate();
eval_atan(result, xx);
// Determine quadrant (sign) based on signs of x, y
- const bool y_neg = get_sign(y) < 0;
- const bool x_neg = get_sign(x) < 0;
+ const bool y_neg = eval_get_sign(y) < 0;
+ const bool x_neg = eval_get_sign(x) < 0;
if(y_neg != x_neg)
result.negate();
@@ -761,9 +761,9 @@
if(x_neg)
{
if(y_neg)
- subtract(result, get_constant_pi<T>());
+ eval_subtract(result, get_constant_pi<T>());
else
- add(result, get_constant_pi<T>());
+ eval_add(result, get_constant_pi<T>());
}
}
Modified: sandbox/big_number/boost/multiprecision/fixed_int.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/fixed_int.hpp (original)
+++ sandbox/big_number/boost/multiprecision/fixed_int.hpp 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
@@ -127,17 +127,17 @@
f = ldexp(f, shift);
term = floor(f);
e -= shift;
- left_shift(*this, shift);
+ eval_left_shift(*this, shift);
if(term > 0)
- add(*this, static_cast<limb_type>(term));
+ eval_add(*this, static_cast<limb_type>(term));
else
- subtract(*this, static_cast<limb_type>(-term));
+ eval_subtract(*this, static_cast<limb_type>(-term));
f -= term;
}
if(e > 0)
- left_shift(*this, e);
+ eval_left_shift(*this, e);
else if(e < 0)
- right_shift(*this, -e);
+ eval_right_shift(*this, -e);
data()[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
return *this;
}
@@ -202,7 +202,7 @@
break;
}
}
- left_shift(*this, block_shift);
+ eval_left_shift(*this, block_shift);
m_value[limb_count - 1] |= block;
}
}
@@ -229,8 +229,8 @@
break;
}
}
- multiply(*this, block_mult);
- add(*this, block);
+ eval_multiply(*this, block_mult);
+ eval_add(*this, block);
}
}
}
@@ -265,7 +265,7 @@
if(c > '9')
c += 'A' - '9' - 1;
result[pos--] = c;
- right_shift(t, shift);
+ eval_right_shift(t, shift);
}
if(Bits % shift)
{
@@ -306,7 +306,7 @@
}
else
{
- while(get_sign(t) != 0)
+ while(eval_get_sign(t) != 0)
{
fixed_int t2;
divide_unsigned_helper(t2, t, max_block_10, r);
@@ -376,12 +376,12 @@
};
template <unsigned Bits, bool Signed>
-inline void add(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& o)
+inline void eval_add(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& o)
{
- add(result, result, o);
+ eval_add(result, result, o);
}
template <unsigned Bits, bool Signed>
-inline void add(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, const fixed_int<Bits, Signed>& b)
+inline void eval_add(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, const fixed_int<Bits, Signed>& b)
{
// Addition using modular arithmatic.
// Nothing fancy, just let uintmax_t take the strain:
@@ -395,7 +395,7 @@
result.data()[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
}
template <unsigned Bits, bool Signed>
-inline void add(fixed_int<Bits, Signed>& result, const limb_type& o)
+inline void eval_add(fixed_int<Bits, Signed>& result, const limb_type& o)
{
// Addition using modular arithmatic.
// Nothing fancy, just let uintmax_t take the strain:
@@ -409,15 +409,15 @@
result.data()[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
}
template <unsigned Bits, bool Signed>
-inline void add(fixed_int<Bits, Signed>& result, const signed_limb_type& o)
+inline void eval_add(fixed_int<Bits, Signed>& result, const signed_limb_type& o)
{
if(o < 0)
- subtract(result, static_cast<limb_type>(-o));
+ eval_subtract(result, static_cast<limb_type>(-o));
else if(o > 0)
- add(result, static_cast<limb_type>(o));
+ eval_add(result, static_cast<limb_type>(o));
}
template <unsigned Bits, bool Signed>
-inline void subtract(fixed_int<Bits, Signed>& result, const limb_type& o)
+inline void eval_subtract(fixed_int<Bits, Signed>& result, const limb_type& o)
{
// Subtract using modular arithmatic.
// This is the same code as for addition, with the twist that we negate o "on the fly":
@@ -434,41 +434,41 @@
result.data()[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
}
template <unsigned Bits, bool Signed>
-inline void subtract(fixed_int<Bits, Signed>& result, const signed_limb_type& o)
+inline void eval_subtract(fixed_int<Bits, Signed>& result, const signed_limb_type& o)
{
if(o)
{
if(o < 0)
- add(result, static_cast<limb_type>(-o));
+ eval_add(result, static_cast<limb_type>(-o));
else
- subtract(result, static_cast<limb_type>(o));
+ eval_subtract(result, static_cast<limb_type>(o));
}
}
template <unsigned Bits, bool Signed>
-inline void increment(fixed_int<Bits, Signed>& result)
+inline void eval_increment(fixed_int<Bits, Signed>& result)
{
static const limb_type one = 1;
if(result.data().elems[fixed_int<Bits, Signed>::limb_count - 1] < fixed_int<Bits, Signed>::max_limb_value)
++result.data().elems[fixed_int<Bits, Signed>::limb_count - 1];
else
- add(result, one);
+ eval_add(result, one);
}
template <unsigned Bits, bool Signed>
-inline void decrement(fixed_int<Bits, Signed>& result)
+inline void eval_decrement(fixed_int<Bits, Signed>& result)
{
static const limb_type one = 1;
if(result.data().elems[fixed_int<Bits, Signed>::limb_count - 1])
--result.data().elems[fixed_int<Bits, Signed>::limb_count - 1];
else
- subtract(result, one);
+ eval_subtract(result, one);
}
template <unsigned Bits, bool Signed>
-inline void subtract(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& o)
+inline void eval_subtract(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& o)
{
- subtract(result, result, o);
+ eval_subtract(result, result, o);
}
template <unsigned Bits, bool Signed>
-inline void subtract(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, const fixed_int<Bits, Signed>& b)
+inline void eval_subtract(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, const fixed_int<Bits, Signed>& b)
{
// Subtract using modular arithmatic.
// This is the same code as for addition, with the twist that we negate b "on the fly":
@@ -482,20 +482,20 @@
result.data()[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
}
template <unsigned Bits, bool Signed>
-inline void multiply(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, const fixed_int<Bits, Signed>& b)
+inline void eval_multiply(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, const fixed_int<Bits, Signed>& b)
{
// Very simple long multiplication, only usable for small numbers of limb_type's
// but that's the typical use case for this type anyway:
if(&result == &a)
{
fixed_int<Bits, Signed> t(a);
- multiply(result, t, b);
+ eval_multiply(result, t, b);
return;
}
if(&result == &b)
{
fixed_int<Bits, Signed> t(b);
- multiply(result, a, t);
+ eval_multiply(result, a, t);
return;
}
double_limb_type carry = 0;
@@ -515,14 +515,14 @@
result.data()[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
}
template <unsigned Bits, bool Signed>
-inline void multiply(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a)
+inline void eval_multiply(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a)
{
// There is no in-place multiply:
fixed_int<Bits, Signed> b(result);
- multiply(result, b, a);
+ eval_multiply(result, b, a);
}
template <unsigned Bits, bool Signed>
-inline void multiply(fixed_int<Bits, Signed>& result, const limb_type& a)
+inline void eval_multiply(fixed_int<Bits, Signed>& result, const limb_type& a)
{
double_limb_type carry = 0;
for(int i = fixed_int<Bits, Signed>::limb_count - 1; i >= 0; --i)
@@ -534,13 +534,13 @@
result.data()[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
}
template <unsigned Bits, bool Signed>
-inline void multiply(fixed_int<Bits, Signed>& result, const signed_limb_type& a)
+inline void eval_multiply(fixed_int<Bits, Signed>& result, const signed_limb_type& a)
{
if(a > 0)
- multiply(result, static_cast<limb_type>(a));
+ eval_multiply(result, static_cast<limb_type>(a));
else
{
- multiply(result, static_cast<limb_type>(-a));
+ eval_multiply(result, static_cast<limb_type>(-a));
result.negate();
}
}
@@ -580,17 +580,17 @@
}
- using default_ops::subtract;
+ using default_ops::eval_subtract;
- if (is_zero(y))
+ if (eval_is_zero(y))
{
volatile int i = 0;
i /= i;
return;
}
- if (is_zero(x))
+ if (eval_is_zero(x))
{
r = y;
result = x;
@@ -618,7 +618,7 @@
{
// result is exactly 1:
result = static_cast<limb_type>(1u);
- subtract(r, y);
+ eval_subtract(r, y);
return;
}
@@ -626,18 +626,18 @@
limb_type mask_index = fixed_int<Bits, Signed>::limb_count - 1 - n / fixed_int<Bits, Signed>::limb_bits;
limb_type mask = static_cast<limb_type>(1u) << n % fixed_int<Bits, Signed>::limb_bits;
fixed_int<Bits, Signed> t(y);
- left_shift(t, n);
+ eval_left_shift(t, n);
while(mask_index < fixed_int<Bits, Signed>::limb_count)
{
int comp = r.compare(t);
if(comp >= 0)
{
result.data()[mask_index] |= mask;
- subtract(r, t);
+ eval_subtract(r, t);
if(comp == 0)
break; // no remainder left - we have an exact result!
}
- right_shift(t, 1u);
+ eval_right_shift(t, 1u);
if(0 == (mask >>= 1))
{
++mask_index;
@@ -682,7 +682,7 @@
*/
- using default_ops::subtract;
+ using default_ops::eval_subtract;
if(&result == &r)
{
@@ -812,7 +812,7 @@
{
t = limb_type(0);
t.data()[fixed_int<Bits, Signed>::limb_count - 1 - shift] = guess;
- subtract(result, t);
+ eval_subtract(result, t);
}
}
else if(fixed_int<Bits, Signed>::max_limb_value - result.data()[fixed_int<Bits, Signed>::limb_count - 1 - shift] > guess)
@@ -821,7 +821,7 @@
{
t = limb_type(0);
t.data()[fixed_int<Bits, Signed>::limb_count - 1 - shift] = guess;
- add(result, t);
+ eval_add(result, t);
}
//
// Calculate guess * y, we use a fused mutiply-shift O(N) for this
@@ -840,7 +840,7 @@
//
// Update r:
//
- subtract(r, t);
+ eval_subtract(r, t);
if(r.data()[0] & fixed_int<Bits, Signed>::sign_bit_mask)
{
r.negate();
@@ -857,9 +857,9 @@
if(r_neg)
{
// We have one too many in the result:
- decrement(result);
+ eval_decrement(result);
r.negate();
- add(r, y);
+ eval_add(r, y);
}
BOOST_ASSERT(r.compare(y) < 0); // remainder must be less than the divisor or our code has failed
@@ -885,7 +885,7 @@
// As above, but simplified for integer divisor:
- using default_ops::subtract;
+ using default_ops::eval_subtract;
if(y == 0)
{
@@ -970,7 +970,7 @@
}
template <unsigned Bits, bool Signed>
-inline void divide(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, const fixed_int<Bits, Signed>& b)
+inline void eval_divide(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, const fixed_int<Bits, Signed>& b)
{
fixed_int<Bits, Signed> r;
if(Signed && (a.data()[0] & fixed_int<Bits, Signed>::sign_bit_mask))
@@ -1003,7 +1003,7 @@
}
}
template <unsigned Bits, bool Signed>
-inline void divide(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, limb_type& b)
+inline void eval_divide(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, limb_type& b)
{
fixed_int<Bits, Signed> r;
if(Signed && (a.data()[0] & fixed_int<Bits, Signed>::sign_bit_mask))
@@ -1019,7 +1019,7 @@
}
}
template <unsigned Bits, bool Signed>
-inline void divide(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, signed_limb_type& b)
+inline void eval_divide(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, signed_limb_type& b)
{
fixed_int<Bits, Signed> r;
if(Signed && (a.data()[0] & fixed_int<Bits, Signed>::sign_bit_mask))
@@ -1049,28 +1049,28 @@
}
}
template <unsigned Bits, bool Signed>
-inline void divide(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& b)
+inline void eval_divide(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& b)
{
// There is no in place divide:
fixed_int<Bits, Signed> a(result);
- divide(result, a, b);
+ eval_divide(result, a, b);
}
template <unsigned Bits, bool Signed>
-inline void divide(fixed_int<Bits, Signed>& result, limb_type b)
+inline void eval_divide(fixed_int<Bits, Signed>& result, limb_type b)
{
// There is no in place divide:
fixed_int<Bits, Signed> a(result);
- divide(result, a, b);
+ eval_divide(result, a, b);
}
template <unsigned Bits, bool Signed>
-inline void divide(fixed_int<Bits, Signed>& result, signed_limb_type b)
+inline void eval_divide(fixed_int<Bits, Signed>& result, signed_limb_type b)
{
// There is no in place divide:
fixed_int<Bits, Signed> a(result);
- divide(result, a, b);
+ eval_divide(result, a, b);
}
template <unsigned Bits, bool Signed>
-inline void modulus(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, const fixed_int<Bits, Signed>& b)
+inline void eval_modulus(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, const fixed_int<Bits, Signed>& b)
{
fixed_int<Bits, Signed> r;
if(Signed && (a.data()[0] & fixed_int<Bits, Signed>::sign_bit_mask))
@@ -1103,7 +1103,7 @@
}
}
template <unsigned Bits, bool Signed>
-inline void modulus(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, limb_type b)
+inline void eval_modulus(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, limb_type b)
{
fixed_int<Bits, Signed> r;
if(Signed && (a.data()[0] & fixed_int<Bits, Signed>::sign_bit_mask))
@@ -1119,7 +1119,7 @@
}
}
template <unsigned Bits, bool Signed>
-inline void modulus(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, signed_limb_type b)
+inline void eval_modulus(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& a, signed_limb_type b)
{
fixed_int<Bits, Signed> r;
if(Signed && (a.data()[0] & fixed_int<Bits, Signed>::sign_bit_mask))
@@ -1149,42 +1149,42 @@
}
}
template <unsigned Bits, bool Signed>
-inline void modulus(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& b)
+inline void eval_modulus(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& b)
{
// There is no in place divide:
fixed_int<Bits, Signed> a(result);
- modulus(result, a, b);
+ eval_modulus(result, a, b);
}
template <unsigned Bits, bool Signed>
-inline void modulus(fixed_int<Bits, Signed>& result, limb_type b)
+inline void eval_modulus(fixed_int<Bits, Signed>& result, limb_type b)
{
// There is no in place divide:
fixed_int<Bits, Signed> a(result);
- modulus(result, a, b);
+ eval_modulus(result, a, b);
}
template <unsigned Bits, bool Signed>
-inline void modulus(fixed_int<Bits, Signed>& result, signed_limb_type b)
+inline void eval_modulus(fixed_int<Bits, Signed>& result, signed_limb_type b)
{
// There is no in place divide:
fixed_int<Bits, Signed> a(result);
- modulus(result, a, b);
+ eval_modulus(result, a, b);
}
template <unsigned Bits, bool Signed>
-inline void bitwise_and(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& o)
+inline void eval_bitwise_and(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& o)
{
for(typename fixed_int<Bits, Signed>::data_type::size_type i = 0; i < fixed_int<Bits, Signed>::limb_count; ++i)
result.data()[i] &= o.data()[i];
}
template <unsigned Bits, bool Signed>
-inline void bitwise_and(fixed_int<Bits, Signed>& result, limb_type o)
+inline void eval_bitwise_and(fixed_int<Bits, Signed>& result, limb_type o)
{
result.data()[fixed_int<Bits, Signed>::limb_count - 1] &= o;
for(typename fixed_int<Bits, Signed>::data_type::size_type i = 0; i < fixed_int<Bits, Signed>::limb_count - 1; ++i)
result.data()[i] = 0;
}
template <unsigned Bits, bool Signed>
-inline void bitwise_and(fixed_int<Bits, Signed>& result, signed_limb_type o)
+inline void eval_bitwise_and(fixed_int<Bits, Signed>& result, signed_limb_type o)
{
result.data()[fixed_int<Bits, Signed>::limb_count - 1] &= o;
limb_type mask = o < 0 ? fixed_int<Bits, Signed>::max_limb_value : 0;
@@ -1192,18 +1192,18 @@
result.data()[i] &= mask;
}
template <unsigned Bits, bool Signed>
-inline void bitwise_or(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& o)
+inline void eval_bitwise_or(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& o)
{
for(typename fixed_int<Bits, Signed>::data_type::size_type i = 0; i < fixed_int<Bits, Signed>::limb_count; ++i)
result.data()[i] |= o.data()[i];
}
template <unsigned Bits, bool Signed>
-inline void bitwise_or(fixed_int<Bits, Signed>& result, limb_type o)
+inline void eval_bitwise_or(fixed_int<Bits, Signed>& result, limb_type o)
{
result.data()[fixed_int<Bits, Signed>::limb_count - 1] |= o;
}
template <unsigned Bits, bool Signed>
-inline void bitwise_or(fixed_int<Bits, Signed>& result, signed_limb_type o)
+inline void eval_bitwise_or(fixed_int<Bits, Signed>& result, signed_limb_type o)
{
result.data()[fixed_int<Bits, Signed>::limb_count - 1] |= o;
limb_type mask = o < 0 ? fixed_int<Bits, Signed>::max_limb_value : 0;
@@ -1211,19 +1211,19 @@
result.data()[i] |= mask;
}
template <unsigned Bits, bool Signed>
-inline void bitwise_xor(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& o)
+inline void eval_bitwise_xor(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& o)
{
for(typename fixed_int<Bits, Signed>::data_type::size_type i = 0; i < fixed_int<Bits, Signed>::limb_count; ++i)
result.data()[i] ^= o.data()[i];
result.data()[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
}
template <unsigned Bits, bool Signed>
-inline void bitwise_xor(fixed_int<Bits, Signed>& result, limb_type o)
+inline void eval_bitwise_xor(fixed_int<Bits, Signed>& result, limb_type o)
{
result.data()[fixed_int<Bits, Signed>::limb_count - 1] ^= o;
}
template <unsigned Bits, bool Signed>
-inline void bitwise_xor(fixed_int<Bits, Signed>& result, signed_limb_type o)
+inline void eval_bitwise_xor(fixed_int<Bits, Signed>& result, signed_limb_type o)
{
result.data()[fixed_int<Bits, Signed>::limb_count - 1] ^= o;
limb_type mask = o < 0 ? fixed_int<Bits, Signed>::max_limb_value : 0;
@@ -1231,14 +1231,14 @@
result.data()[i] ^= mask;
}
template <unsigned Bits, bool Signed>
-inline void complement(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& o)
+inline void eval_complement(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& o)
{
for(typename fixed_int<Bits, Signed>::data_type::size_type i = 0; i < fixed_int<Bits, Signed>::limb_count; ++i)
result.data()[i] = ~o.data()[i];
result.data()[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
}
template <unsigned Bits, bool Signed>
-inline void left_shift(fixed_int<Bits, Signed>& result, double_limb_type s)
+inline void eval_left_shift(fixed_int<Bits, Signed>& result, double_limb_type s)
{
if(!s)
return;
@@ -1273,7 +1273,7 @@
result.data()[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
}
template <unsigned Bits, bool Signed>
-inline void right_shift(fixed_int<Bits, Signed>& result, double_limb_type s)
+inline void eval_right_shift(fixed_int<Bits, Signed>& result, double_limb_type s)
{
if(!s)
return;
@@ -1317,22 +1317,22 @@
}
template <class R, unsigned Bits, bool Signed>
-inline typename enable_if<is_integral<R>, void>::type convert_to(R* result, const fixed_int<Bits, Signed>& backend, const mpl::true_&)
+inline typename enable_if<is_integral<R>, void>::type eval_convert_to(R* result, const fixed_int<Bits, Signed>& backend, const mpl::true_&)
{
if(backend.data()[0] & fixed_int<Bits, Signed>::sign_bit_mask)
{
fixed_int<Bits, Signed> t(backend);
t.negate();
- convert_to(result, t, mpl::false_());
+ eval_convert_to(result, t, mpl::false_());
*result = -*result;
return;
}
else
- convert_to(result, backend, mpl::false_());
+ eval_convert_to(result, backend, mpl::false_());
}
template <class R, unsigned Bits, bool Signed>
-inline typename enable_if<is_integral<R>, void>::type convert_to(R* result, const fixed_int<Bits, Signed>& backend, const mpl::false_&)
+inline typename enable_if<is_integral<R>, void>::type eval_convert_to(R* result, const fixed_int<Bits, Signed>& backend, const mpl::false_&)
{
unsigned shift = (fixed_int<Bits, Signed>::limb_count - 1) * fixed_int<Bits, Signed>::limb_bits;
*result = static_cast<limb_type>(0);
@@ -1344,20 +1344,20 @@
}
template <class R, unsigned Bits, bool Signed>
-inline typename enable_if<is_integral<R>, void>::type convert_to(R* result, const fixed_int<Bits, Signed>& backend)
+inline typename enable_if<is_integral<R>, void>::type eval_convert_to(R* result, const fixed_int<Bits, Signed>& backend)
{
typedef mpl::bool_<Signed && std::numeric_limits<R>::is_signed> tag_type;
- convert_to(result, backend, tag_type());
+ eval_convert_to(result, backend, tag_type());
}
template <class R, unsigned Bits, bool Signed>
-inline typename enable_if<is_floating_point<R>, void>::type convert_to(R* result, const fixed_int<Bits, Signed>& backend)
+inline typename enable_if<is_floating_point<R>, void>::type eval_convert_to(R* result, const fixed_int<Bits, Signed>& backend)
{
if(Signed && (backend.data()[0] & fixed_int<Bits, Signed>::sign_bit_mask))
{
fixed_int<Bits, Signed> t(backend);
t.negate();
- convert_to(result, t);
+ eval_convert_to(result, t);
*result = -*result;
return;
}
@@ -1371,7 +1371,7 @@
}
template <unsigned Bits, bool Signed>
-inline bool is_zero(const fixed_int<Bits, Signed>& val)
+inline bool eval_is_zero(const fixed_int<Bits, Signed>& val)
{
for(typename fixed_int<Bits, Signed>::data_type::size_type i = 0; i < fixed_int<Bits, Signed>::limb_count; ++i)
{
@@ -1381,14 +1381,14 @@
return true;
}
template <unsigned Bits>
-inline int get_sign(const fixed_int<Bits, false>& val)
+inline int eval_get_sign(const fixed_int<Bits, false>& val)
{
- return is_zero(val) ? 0 : 1;
+ return eval_is_zero(val) ? 0 : 1;
}
template <unsigned Bits>
-inline int get_sign(const fixed_int<Bits, true>& val)
+inline int eval_get_sign(const fixed_int<Bits, true>& val)
{
- return is_zero(val) ? 0 : val.data()[0] & fixed_int<Bits, true>::sign_bit_mask ? -1 : 1;
+ return eval_is_zero(val) ? 0 : val.data()[0] & fixed_int<Bits, true>::sign_bit_mask ? -1 : 1;
}
namespace detail{
@@ -1398,7 +1398,7 @@
template <unsigned Bits, bool Signed>
inline unsigned get_lsb(const fixed_int<Bits, Signed>& a)
{
- BOOST_ASSERT(get_sign(a) != 0);
+ BOOST_ASSERT(eval_get_sign(a) != 0);
unsigned result = 0;
//
@@ -1429,7 +1429,7 @@
fixed_int<Bits, Signed> u(a), v(b);
- int s = get_sign(u);
+ int s = eval_get_sign(u);
/* GCD(0,x) := x */
if(s < 0)
@@ -1441,7 +1441,7 @@
result = v;
return;
}
- s = get_sign(v);
+ s = eval_get_sign(v);
if(s < 0)
{
v.negate();
@@ -1458,8 +1458,8 @@
unsigned us = detail::get_lsb(u);
unsigned vs = detail::get_lsb(v);
shift = (std::min)(us, vs);
- right_shift(u, us);
- right_shift(v, vs);
+ eval_right_shift(u, us);
+ eval_right_shift(v, vs);
do
{
@@ -1467,19 +1467,19 @@
Let u = min(u, v), v = diff(u, v)/2. */
if(u.compare(v) > 0)
u.swap(v);
- subtract(v, u);
+ eval_subtract(v, u);
// Termination condition tries not to do a full compare if possible:
- if(!v.data()[fixed_int<Bits, Signed>::limb_count - 1] && is_zero(v))
+ if(!v.data()[fixed_int<Bits, Signed>::limb_count - 1] && eval_is_zero(v))
break;
vs = detail::get_lsb(v);
- right_shift(v, vs);
+ eval_right_shift(v, vs);
BOOST_ASSERT((v.data()[fixed_int<Bits, Signed>::limb_count - 1] & 1));
BOOST_ASSERT((u.data()[fixed_int<Bits, Signed>::limb_count - 1] & 1));
}
while(true);
result = u;
- left_shift(result, shift);
+ eval_left_shift(result, shift);
}
template <unsigned Bits, bool Signed>
@@ -1488,16 +1488,16 @@
fixed_int<Bits, Signed> t;
eval_gcd(t, a, b);
- if(is_zero(t))
+ if(eval_is_zero(t))
{
result = static_cast<limb_type>(0);
}
else
{
- divide(result, a, t);
- multiply(result, b);
+ eval_divide(result, a, t);
+ eval_multiply(result, b);
}
- if(get_sign(result) < 0)
+ if(eval_get_sign(result) < 0)
result.negate();
}
Modified: sandbox/big_number/boost/multiprecision/gmp.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/gmp.hpp (original)
+++ sandbox/big_number/boost/multiprecision/gmp.hpp 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
@@ -16,7 +16,9 @@
#include <limits>
#include <climits>
-namespace boost{ namespace multiprecision{
+namespace boost{
+namespace multiprecision{
+namespace backends{
template <unsigned digits10>
struct gmp_float;
@@ -473,47 +475,47 @@
};
template <unsigned digits10>
-inline void add(gmp_float<digits10>& result, const gmp_float<digits10>& o)
+inline void eval_add(gmp_float<digits10>& result, const gmp_float<digits10>& o)
{
mpf_add(result.data(), result.data(), o.data());
}
template <unsigned digits10>
-inline void subtract(gmp_float<digits10>& result, const gmp_float<digits10>& o)
+inline void eval_subtract(gmp_float<digits10>& result, const gmp_float<digits10>& o)
{
mpf_sub(result.data(), result.data(), o.data());
}
template <unsigned digits10>
-inline void multiply(gmp_float<digits10>& result, const gmp_float<digits10>& o)
+inline void eval_multiply(gmp_float<digits10>& result, const gmp_float<digits10>& o)
{
mpf_mul(result.data(), result.data(), o.data());
}
template <unsigned digits10>
-inline void divide(gmp_float<digits10>& result, const gmp_float<digits10>& o)
+inline void eval_divide(gmp_float<digits10>& result, const gmp_float<digits10>& o)
{
mpf_div(result.data(), result.data(), o.data());
}
template <unsigned digits10>
-inline void add(gmp_float<digits10>& result, unsigned long i)
+inline void eval_add(gmp_float<digits10>& result, unsigned long i)
{
mpf_add_ui(result.data(), result.data(), i);
}
template <unsigned digits10>
-inline void subtract(gmp_float<digits10>& result, unsigned long i)
+inline void eval_subtract(gmp_float<digits10>& result, unsigned long i)
{
mpf_sub_ui(result.data(), result.data(), i);
}
template <unsigned digits10>
-inline void multiply(gmp_float<digits10>& result, unsigned long i)
+inline void eval_multiply(gmp_float<digits10>& result, unsigned long i)
{
mpf_mul_ui(result.data(), result.data(), i);
}
template <unsigned digits10>
-inline void divide(gmp_float<digits10>& result, unsigned long i)
+inline void eval_divide(gmp_float<digits10>& result, unsigned long i)
{
mpf_div_ui(result.data(), result.data(), i);
}
template <unsigned digits10>
-inline void add(gmp_float<digits10>& result, long i)
+inline void eval_add(gmp_float<digits10>& result, long i)
{
if(i > 0)
mpf_add_ui(result.data(), result.data(), i);
@@ -521,7 +523,7 @@
mpf_sub_ui(result.data(), result.data(), std::abs(i));
}
template <unsigned digits10>
-inline void subtract(gmp_float<digits10>& result, long i)
+inline void eval_subtract(gmp_float<digits10>& result, long i)
{
if(i > 0)
mpf_sub_ui(result.data(), result.data(), i);
@@ -529,14 +531,14 @@
mpf_add_ui(result.data(), result.data(), std::abs(i));
}
template <unsigned digits10>
-inline void multiply(gmp_float<digits10>& result, long i)
+inline void eval_multiply(gmp_float<digits10>& result, long i)
{
mpf_mul_ui(result.data(), result.data(), std::abs(i));
if(i < 0)
mpf_neg(result.data(), result.data());
}
template <unsigned digits10>
-inline void divide(gmp_float<digits10>& result, long i)
+inline void eval_divide(gmp_float<digits10>& result, long i)
{
mpf_div_ui(result.data(), result.data(), std::abs(i));
if(i < 0)
@@ -546,17 +548,17 @@
// Specialised 3 arg versions of the basic operators:
//
template <unsigned digits10>
-inline void add(gmp_float<digits10>& a, const gmp_float<digits10>& x, const gmp_float<digits10>& y)
+inline void eval_add(gmp_float<digits10>& a, const gmp_float<digits10>& x, const gmp_float<digits10>& y)
{
mpf_add(a.data(), x.data(), y.data());
}
template <unsigned digits10>
-inline void add(gmp_float<digits10>& a, const gmp_float<digits10>& x, unsigned long y)
+inline void eval_add(gmp_float<digits10>& a, const gmp_float<digits10>& x, unsigned long y)
{
mpf_add_ui(a.data(), x.data(), y);
}
template <unsigned digits10>
-inline void add(gmp_float<digits10>& a, const gmp_float<digits10>& x, long y)
+inline void eval_add(gmp_float<digits10>& a, const gmp_float<digits10>& x, long y)
{
if(y < 0)
mpf_sub_ui(a.data(), x.data(), -y);
@@ -564,12 +566,12 @@
mpf_add_ui(a.data(), x.data(), y);
}
template <unsigned digits10>
-inline void add(gmp_float<digits10>& a, unsigned long x, const gmp_float<digits10>& y)
+inline void eval_add(gmp_float<digits10>& a, unsigned long x, const gmp_float<digits10>& y)
{
mpf_add_ui(a.data(), y.data(), x);
}
template <unsigned digits10>
-inline void add(gmp_float<digits10>& a, long x, const gmp_float<digits10>& y)
+inline void eval_add(gmp_float<digits10>& a, long x, const gmp_float<digits10>& y)
{
if(x < 0)
{
@@ -580,17 +582,17 @@
mpf_add_ui(a.data(), y.data(), x);
}
template <unsigned digits10>
-inline void subtract(gmp_float<digits10>& a, const gmp_float<digits10>& x, const gmp_float<digits10>& y)
+inline void eval_subtract(gmp_float<digits10>& a, const gmp_float<digits10>& x, const gmp_float<digits10>& y)
{
mpf_sub(a.data(), x.data(), y.data());
}
template <unsigned digits10>
-inline void subtract(gmp_float<digits10>& a, const gmp_float<digits10>& x, unsigned long y)
+inline void eval_subtract(gmp_float<digits10>& a, const gmp_float<digits10>& x, unsigned long y)
{
mpf_sub_ui(a.data(), x.data(), y);
}
template <unsigned digits10>
-inline void subtract(gmp_float<digits10>& a, const gmp_float<digits10>& x, long y)
+inline void eval_subtract(gmp_float<digits10>& a, const gmp_float<digits10>& x, long y)
{
if(y < 0)
mpf_add_ui(a.data(), x.data(), -y);
@@ -598,12 +600,12 @@
mpf_sub_ui(a.data(), x.data(), y);
}
template <unsigned digits10>
-inline void subtract(gmp_float<digits10>& a, unsigned long x, const gmp_float<digits10>& y)
+inline void eval_subtract(gmp_float<digits10>& a, unsigned long x, const gmp_float<digits10>& y)
{
mpf_ui_sub(a.data(), x, y.data());
}
template <unsigned digits10>
-inline void subtract(gmp_float<digits10>& a, long x, const gmp_float<digits10>& y)
+inline void eval_subtract(gmp_float<digits10>& a, long x, const gmp_float<digits10>& y)
{
if(x < 0)
{
@@ -615,17 +617,17 @@
}
template <unsigned digits10>
-inline void multiply(gmp_float<digits10>& a, const gmp_float<digits10>& x, const gmp_float<digits10>& y)
+inline void eval_multiply(gmp_float<digits10>& a, const gmp_float<digits10>& x, const gmp_float<digits10>& y)
{
mpf_mul(a.data(), x.data(), y.data());
}
template <unsigned digits10>
-inline void multiply(gmp_float<digits10>& a, const gmp_float<digits10>& x, unsigned long y)
+inline void eval_multiply(gmp_float<digits10>& a, const gmp_float<digits10>& x, unsigned long y)
{
mpf_mul_ui(a.data(), x.data(), y);
}
template <unsigned digits10>
-inline void multiply(gmp_float<digits10>& a, const gmp_float<digits10>& x, long y)
+inline void eval_multiply(gmp_float<digits10>& a, const gmp_float<digits10>& x, long y)
{
if(y < 0)
{
@@ -636,12 +638,12 @@
mpf_mul_ui(a.data(), x.data(), y);
}
template <unsigned digits10>
-inline void multiply(gmp_float<digits10>& a, unsigned long x, const gmp_float<digits10>& y)
+inline void eval_multiply(gmp_float<digits10>& a, unsigned long x, const gmp_float<digits10>& y)
{
mpf_mul_ui(a.data(), y.data(), x);
}
template <unsigned digits10>
-inline void multiply(gmp_float<digits10>& a, long x, const gmp_float<digits10>& y)
+inline void eval_multiply(gmp_float<digits10>& a, long x, const gmp_float<digits10>& y)
{
if(x < 0)
{
@@ -653,17 +655,17 @@
}
template <unsigned digits10>
-inline void divide(gmp_float<digits10>& a, const gmp_float<digits10>& x, const gmp_float<digits10>& y)
+inline void eval_divide(gmp_float<digits10>& a, const gmp_float<digits10>& x, const gmp_float<digits10>& y)
{
mpf_div(a.data(), x.data(), y.data());
}
template <unsigned digits10>
-inline void divide(gmp_float<digits10>& a, const gmp_float<digits10>& x, unsigned long y)
+inline void eval_divide(gmp_float<digits10>& a, const gmp_float<digits10>& x, unsigned long y)
{
mpf_div_ui(a.data(), x.data(), y);
}
template <unsigned digits10>
-inline void divide(gmp_float<digits10>& a, const gmp_float<digits10>& x, long y)
+inline void eval_divide(gmp_float<digits10>& a, const gmp_float<digits10>& x, long y)
{
if(y < 0)
{
@@ -674,12 +676,12 @@
mpf_div_ui(a.data(), x.data(), y);
}
template <unsigned digits10>
-inline void divide(gmp_float<digits10>& a, unsigned long x, const gmp_float<digits10>& y)
+inline void eval_divide(gmp_float<digits10>& a, unsigned long x, const gmp_float<digits10>& y)
{
mpf_ui_div(a.data(), x, y.data());
}
template <unsigned digits10>
-inline void divide(gmp_float<digits10>& a, long x, const gmp_float<digits10>& y)
+inline void eval_divide(gmp_float<digits10>& a, long x, const gmp_float<digits10>& y)
{
if(x < 0)
{
@@ -691,18 +693,18 @@
}
template <unsigned digits10>
-inline bool is_zero(const gmp_float<digits10>& val)
+inline bool eval_is_zero(const gmp_float<digits10>& val)
{
return mpf_sgn(val.data()) == 0;
}
template <unsigned digits10>
-inline int get_sign(const gmp_float<digits10>& val)
+inline int eval_get_sign(const gmp_float<digits10>& val)
{
return mpf_sgn(val.data());
}
template <unsigned digits10>
-inline void convert_to(unsigned long* result, const gmp_float<digits10>& val)
+inline void eval_convert_to(unsigned long* result, const gmp_float<digits10>& val)
{
if(0 == mpf_fits_ulong_p(val.data()))
*result = (std::numeric_limits<unsigned long>::max)();
@@ -710,7 +712,7 @@
*result = mpf_get_ui(val.data());
}
template <unsigned digits10>
-inline void convert_to(long* result, const gmp_float<digits10>& val)
+inline void eval_convert_to(long* result, const gmp_float<digits10>& val)
{
if(0 == mpf_fits_slong_p(val.data()))
{
@@ -721,16 +723,16 @@
*result = mpf_get_si(val.data());
}
template <unsigned digits10>
-inline void convert_to(double* result, const gmp_float<digits10>& val)
+inline void eval_convert_to(double* result, const gmp_float<digits10>& val)
{
*result = mpf_get_d(val.data());
}
#ifdef BOOST_HAS_LONG_LONG
template <unsigned digits10>
-inline void convert_to(long long* result, const gmp_float<digits10>& val)
+inline void eval_convert_to(long long* result, const gmp_float<digits10>& val)
{
gmp_float<digits10> t(val);
- if(get_sign(t) < 0)
+ if(eval_get_sign(t) < 0)
t.negate();
long digits = std::numeric_limits<long long>::digits - std::numeric_limits<long>::digits;
@@ -740,7 +742,7 @@
if(!mpf_fits_slong_p(t.data()))
{
- if(get_sign(val) < 0)
+ if(eval_get_sign(val) < 0)
*result = (std::numeric_limits<long long>::min)();
else
*result = (std::numeric_limits<long long>::max)();
@@ -758,11 +760,11 @@
l >>= -digits;
*result |= l;
}
- if(get_sign(val) < 0)
+ if(eval_get_sign(val) < 0)
*result = -*result;
}
template <unsigned digits10>
-inline void convert_to(unsigned long long* result, const gmp_float<digits10>& val)
+inline void eval_convert_to(unsigned long long* result, const gmp_float<digits10>& val)
{
gmp_float<digits10> t(val);
@@ -1094,23 +1096,23 @@
mpz_t m_data;
};
-inline void add(gmp_int& t, const gmp_int& o)
+inline void eval_add(gmp_int& t, const gmp_int& o)
{
mpz_add(t.data(), t.data(), o.data());
}
-inline void subtract(gmp_int& t, const gmp_int& o)
+inline void eval_subtract(gmp_int& t, const gmp_int& o)
{
mpz_sub(t.data(), t.data(), o.data());
}
-inline void multiply(gmp_int& t, const gmp_int& o)
+inline void eval_multiply(gmp_int& t, const gmp_int& o)
{
mpz_mul(t.data(), t.data(), o.data());
}
-inline void divide(gmp_int& t, const gmp_int& o)
+inline void eval_divide(gmp_int& t, const gmp_int& o)
{
mpz_div(t.data(), t.data(), o.data());
}
-inline void modulus(gmp_int& t, const gmp_int& o)
+inline void eval_modulus(gmp_int& t, const gmp_int& o)
{
bool neg = mpz_sgn(t.data()) < 0;
bool neg2 = mpz_sgn(o.data()) < 0;
@@ -1124,19 +1126,19 @@
t.negate();
}
}
-inline void add(gmp_int& t, unsigned long i)
+inline void eval_add(gmp_int& t, unsigned long i)
{
mpz_add_ui(t.data(), t.data(), i);
}
-inline void subtract(gmp_int& t, unsigned long i)
+inline void eval_subtract(gmp_int& t, unsigned long i)
{
mpz_sub_ui(t.data(), t.data(), i);
}
-inline void multiply(gmp_int& t, unsigned long i)
+inline void eval_multiply(gmp_int& t, unsigned long i)
{
mpz_mul_ui(t.data(), t.data(), i);
}
-inline void modulus(gmp_int& t, unsigned long i)
+inline void eval_modulus(gmp_int& t, unsigned long i)
{
bool neg = mpz_sgn(t.data()) < 0;
mpz_mod_ui(t.data(), t.data(), i);
@@ -1147,31 +1149,31 @@
t.negate();
}
}
-inline void divide(gmp_int& t, unsigned long i)
+inline void eval_divide(gmp_int& t, unsigned long i)
{
mpz_div_ui(t.data(), t.data(), i);
}
-inline void add(gmp_int& t, long i)
+inline void eval_add(gmp_int& t, long i)
{
if(i > 0)
mpz_add_ui(t.data(), t.data(), i);
else
mpz_sub_ui(t.data(), t.data(), -i);
}
-inline void subtract(gmp_int& t, long i)
+inline void eval_subtract(gmp_int& t, long i)
{
if(i > 0)
mpz_sub_ui(t.data(), t.data(), i);
else
mpz_add_ui(t.data(), t.data(), -i);
}
-inline void multiply(gmp_int& t, long i)
+inline void eval_multiply(gmp_int& t, long i)
{
mpz_mul_ui(t.data(), t.data(), std::abs(i));
if(i < 0)
mpz_neg(t.data(), t.data());
}
-inline void modulus(gmp_int& t, long i)
+inline void eval_modulus(gmp_int& t, long i)
{
bool neg = mpz_sgn(t.data()) < 0;
bool neg2 = i < 0;
@@ -1190,65 +1192,65 @@
}
}
}
-inline void divide(gmp_int& t, long i)
+inline void eval_divide(gmp_int& t, long i)
{
mpz_div_ui(t.data(), t.data(), std::abs(i));
if(i < 0)
mpz_neg(t.data(), t.data());
}
template <class UI>
-inline void left_shift(gmp_int& t, UI i)
+inline void eval_left_shift(gmp_int& t, UI 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)
+inline void eval_right_shift(gmp_int& t, UI 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)
+inline void eval_left_shift(gmp_int& t, const gmp_int& v, UI 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)
+inline void eval_right_shift(gmp_int& t, const gmp_int& v, UI 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)
+inline void eval_bitwise_and(gmp_int& result, const gmp_int& v)
{
mpz_and(result.data(), result.data(), v.data());
}
-inline void bitwise_or(gmp_int& result, const gmp_int& v)
+inline void eval_bitwise_or(gmp_int& result, const gmp_int& v)
{
mpz_ior(result.data(), result.data(), v.data());
}
-inline void bitwise_xor(gmp_int& result, const gmp_int& v)
+inline void eval_bitwise_xor(gmp_int& result, const gmp_int& v)
{
mpz_xor(result.data(), result.data(), v.data());
}
-inline void add(gmp_int& t, const gmp_int& p, const gmp_int& o)
+inline void eval_add(gmp_int& t, const gmp_int& p, const gmp_int& o)
{
mpz_add(t.data(), p.data(), o.data());
}
-inline void subtract(gmp_int& t, const gmp_int& p, const gmp_int& o)
+inline void eval_subtract(gmp_int& t, const gmp_int& p, const gmp_int& o)
{
mpz_sub(t.data(), p.data(), o.data());
}
-inline void multiply(gmp_int& t, const gmp_int& p, const gmp_int& o)
+inline void eval_multiply(gmp_int& t, const gmp_int& p, const gmp_int& o)
{
mpz_mul(t.data(), p.data(), o.data());
}
-inline void divide(gmp_int& t, const gmp_int& p, const gmp_int& o)
+inline void eval_divide(gmp_int& t, const gmp_int& p, const gmp_int& o)
{
mpz_div(t.data(), p.data(), o.data());
}
-inline void modulus(gmp_int& t, const gmp_int& p, const gmp_int& o)
+inline void eval_modulus(gmp_int& t, const gmp_int& p, const gmp_int& o)
{
bool neg = mpz_sgn(p.data()) < 0;
bool neg2 = mpz_sgn(o.data()) < 0;
@@ -1262,19 +1264,19 @@
t.negate();
}
}
-inline void add(gmp_int& t, const gmp_int& p, unsigned long i)
+inline void eval_add(gmp_int& t, const gmp_int& p, unsigned long i)
{
mpz_add_ui(t.data(), p.data(), i);
}
-inline void subtract(gmp_int& t, const gmp_int& p, unsigned long i)
+inline void eval_subtract(gmp_int& t, const gmp_int& p, unsigned long i)
{
mpz_sub_ui(t.data(), p.data(), i);
}
-inline void multiply(gmp_int& t, const gmp_int& p, unsigned long i)
+inline void eval_multiply(gmp_int& t, const gmp_int& p, unsigned long i)
{
mpz_mul_ui(t.data(), p.data(), i);
}
-inline void modulus(gmp_int& t, const gmp_int& p, unsigned long i)
+inline void eval_modulus(gmp_int& t, const gmp_int& p, unsigned long i)
{
bool neg = mpz_sgn(p.data()) < 0;
mpz_mod_ui(t.data(), p.data(), i);
@@ -1285,31 +1287,31 @@
t.negate();
}
}
-inline void divide(gmp_int& t, const gmp_int& p, unsigned long i)
+inline void eval_divide(gmp_int& t, const gmp_int& p, unsigned long i)
{
mpz_div_ui(t.data(), p.data(), i);
}
-inline void add(gmp_int& t, const gmp_int& p, long i)
+inline void eval_add(gmp_int& t, const gmp_int& p, long i)
{
if(i > 0)
mpz_add_ui(t.data(), p.data(), i);
else
mpz_sub_ui(t.data(), p.data(), -i);
}
-inline void subtract(gmp_int& t, const gmp_int& p, long i)
+inline void eval_subtract(gmp_int& t, const gmp_int& p, long i)
{
if(i > 0)
mpz_sub_ui(t.data(), p.data(), i);
else
mpz_add_ui(t.data(), p.data(), -i);
}
-inline void multiply(gmp_int& t, const gmp_int& p, long i)
+inline void eval_multiply(gmp_int& t, const gmp_int& p, long i)
{
mpz_mul_ui(t.data(), p.data(), std::abs(i));
if(i < 0)
mpz_neg(t.data(), t.data());
}
-inline void modulus(gmp_int& t, const gmp_int& p, long i)
+inline void eval_modulus(gmp_int& t, const gmp_int& p, long i)
{
bool neg = mpz_sgn(p.data()) < 0;
bool neg2 = i < 0;
@@ -1328,42 +1330,42 @@
}
}
}
-inline void divide(gmp_int& t, const gmp_int& p, long i)
+inline void eval_divide(gmp_int& t, const gmp_int& p, long i)
{
mpz_div_ui(t.data(), p.data(), std::abs(i));
if(i < 0)
mpz_neg(t.data(), t.data());
}
-inline void bitwise_and(gmp_int& result, const gmp_int& u, const gmp_int& v)
+inline void eval_bitwise_and(gmp_int& result, const gmp_int& u, const gmp_int& v)
{
mpz_and(result.data(), u.data(), v.data());
}
-inline void bitwise_or(gmp_int& result, const gmp_int& u, const gmp_int& v)
+inline void eval_bitwise_or(gmp_int& result, const gmp_int& u, const gmp_int& v)
{
mpz_ior(result.data(), u.data(), v.data());
}
-inline void bitwise_xor(gmp_int& result, const gmp_int& u, const gmp_int& v)
+inline void eval_bitwise_xor(gmp_int& result, const gmp_int& u, const gmp_int& v)
{
mpz_xor(result.data(), u.data(), v.data());
}
-inline void complement(gmp_int& result, const gmp_int& u)
+inline void eval_complement(gmp_int& result, const gmp_int& u)
{
mpz_com(result.data(), u.data());
}
-inline bool is_zero(const gmp_int& val)
+inline bool eval_is_zero(const gmp_int& val)
{
return mpz_sgn(val.data()) == 0;
}
-inline int get_sign(const gmp_int& val)
+inline int eval_get_sign(const gmp_int& val)
{
return mpz_sgn(val.data());
}
-inline void convert_to(unsigned long* result, const gmp_int& val)
+inline void eval_convert_to(unsigned long* result, const gmp_int& val)
{
if(0 == mpz_fits_ulong_p(val.data()))
{
@@ -1372,7 +1374,7 @@
else
*result = mpz_get_ui(val.data());
}
-inline void convert_to(long* result, const gmp_int& val)
+inline void eval_convert_to(long* result, const gmp_int& val)
{
if(0 == mpz_fits_slong_p(val.data()))
{
@@ -1382,7 +1384,7 @@
else
*result = mpz_get_si(val.data());
}
-inline void convert_to(double* result, const gmp_int& val)
+inline void eval_convert_to(double* result, const gmp_int& val)
{
*result = mpz_get_d(val.data());
}
@@ -1418,7 +1420,7 @@
}
struct gmp_rational;
-void add(gmp_rational& t, const gmp_rational& o);
+void eval_add(gmp_rational& t, const gmp_rational& o);
struct gmp_rational
{
@@ -1503,8 +1505,8 @@
using std::frexp;
using std::ldexp;
using std::floor;
- using default_ops::add;
- using default_ops::subtract;
+ using default_ops::eval_add;
+ using default_ops::eval_subtract;
if (a == 0) {
mpq_set_si(m_data, 0, 1);
@@ -1537,7 +1539,7 @@
e -= shift;
mpq_mul_2exp(m_data, m_data, shift);
t = static_cast<long>(term);
- add(*this, t);
+ eval_add(*this, t);
f -= term;
}
if(e > 0)
@@ -1628,69 +1630,63 @@
return result;
}
-template <>
-struct component_type<mp_number<gmp_rational> >
-{
- typedef mp_number<gmp_int> type;
-};
-
-inline void add(gmp_rational& t, const gmp_rational& o)
+inline void eval_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)
+inline void eval_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)
+inline void eval_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)
+inline void eval_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)
+inline void eval_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)
+inline void eval_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)
+inline void eval_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)
+inline void eval_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)
+inline bool eval_is_zero(const gmp_rational& val)
{
return mpq_sgn(val.data()) == 0;
}
-inline int get_sign(const gmp_rational& val)
+inline int eval_get_sign(const gmp_rational& val)
{
return mpq_sgn(val.data());
}
-inline void convert_to(double* result, const gmp_rational& val)
+inline void eval_convert_to(double* result, const gmp_rational& val)
{
*result = mpq_get_d(val.data());
}
-inline void convert_to(long* result, const gmp_rational& val)
+inline void eval_convert_to(long* result, const gmp_rational& val)
{
double r;
- convert_to(&r, val);
+ eval_convert_to(&r, val);
*result = static_cast<long>(r);
}
-inline void convert_to(unsigned long* result, const gmp_rational& val)
+inline void eval_convert_to(unsigned long* result, const gmp_rational& val)
{
double r;
- convert_to(&r, val);
+ eval_convert_to(&r, val);
*result = static_cast<long>(r);
}
@@ -1788,6 +1784,17 @@
return *this;
}
+} //namespace backends
+
+using boost::multiprecision::backends::gmp_int;
+using boost::multiprecision::backends::gmp_rational;
+using boost::multiprecision::backends::gmp_float;
+
+template <>
+struct component_type<mp_number<gmp_rational> >
+{
+ typedef mp_number<gmp_int> type;
+};
template<>
struct number_category<gmp_int> : public mpl::int_<number_kind_integer>{};
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 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
@@ -150,8 +150,8 @@
typename enable_if<boost::is_arithmetic<V>, mp_number<Backend>& >::type
operator+=(const V& v)
{
- using default_ops::add;
- add(m_backend, canonical_value(v));
+ using default_ops::eval_add;
+ eval_add(m_backend, canonical_value(v));
return *this;
}
@@ -181,8 +181,8 @@
typename enable_if<boost::is_arithmetic<V>, mp_number<Backend>& >::type
operator-=(const V& v)
{
- using default_ops::subtract;
- subtract(m_backend, canonical_value(v));
+ using default_ops::eval_subtract;
+ eval_subtract(m_backend, canonical_value(v));
return *this;
}
@@ -214,8 +214,8 @@
typename enable_if<boost::is_arithmetic<V>, mp_number<Backend>& >::type
operator*=(const V& v)
{
- using default_ops::multiply;
- multiply(m_backend, canonical_value(v));
+ using default_ops::eval_multiply;
+ eval_multiply(m_backend, canonical_value(v));
return *this;
}
@@ -246,8 +246,8 @@
operator%=(const V& v)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The modulus operation is only valid for integer types");
- using default_ops::modulus;
- modulus(m_backend, canonical_value(v));
+ using default_ops::eval_modulus;
+ eval_modulus(m_backend, canonical_value(v));
return *this;
}
@@ -261,31 +261,31 @@
//
mp_number& operator++()
{
- using default_ops::increment;
- increment(m_backend);
+ using default_ops::eval_increment;
+ eval_increment(m_backend);
return *this;
}
mp_number& operator--()
{
- using default_ops::decrement;
- decrement(m_backend);
+ using default_ops::eval_decrement;
+ eval_decrement(m_backend);
return *this;
}
mp_number operator++(int)
{
- using default_ops::increment;
+ using default_ops::eval_increment;
self_type temp(*this);
- increment(m_backend);
+ eval_increment(m_backend);
return temp;
}
mp_number operator--(int)
{
- using default_ops::decrement;
+ using default_ops::eval_decrement;
self_type temp(*this);
- decrement(m_backend);
+ eval_decrement(m_backend);
return temp;
}
@@ -294,7 +294,7 @@
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The left-shift operation is only valid for integer types");
check_shift_range(val, mpl::bool_<(sizeof(V) > sizeof(std::size_t))>(), is_signed<V>());
- left_shift(m_backend, canonical_value(val));
+ eval_left_shift(m_backend, canonical_value(val));
return *this;
}
@@ -303,7 +303,7 @@
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The right-shift operation is only valid for integer types");
check_shift_range(val, mpl::bool_<(sizeof(V) > sizeof(std::size_t))>(), is_signed<V>());
- right_shift(m_backend, canonical_value(val));
+ eval_right_shift(m_backend, canonical_value(val));
return *this;
}
@@ -333,8 +333,8 @@
typename enable_if<boost::is_arithmetic<V>, mp_number<Backend>& >::type
operator/=(const V& v)
{
- using default_ops::divide;
- divide(m_backend, canonical_value(v));
+ using default_ops::eval_divide;
+ eval_divide(m_backend, canonical_value(v));
return *this;
}
@@ -368,8 +368,8 @@
operator&=(const V& v)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise & operation is only valid for integer types");
- using default_ops::bitwise_and;
- bitwise_and(m_backend, canonical_value(v));
+ using default_ops::eval_bitwise_and;
+ eval_bitwise_and(m_backend, canonical_value(v));
return *this;
}
@@ -403,8 +403,8 @@
operator|=(const V& v)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise | operation is only valid for integer types");
- using default_ops::bitwise_or;
- bitwise_or(m_backend, canonical_value(v));
+ using default_ops::eval_bitwise_or;
+ eval_bitwise_or(m_backend, canonical_value(v));
return *this;
}
@@ -436,8 +436,8 @@
operator^=(const V& v)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise ^ operation is only valid for integer types");
- using default_ops::bitwise_xor;
- bitwise_xor(m_backend, canonical_value(v));
+ using default_ops::eval_bitwise_xor;
+ eval_bitwise_xor(m_backend, canonical_value(v));
return *this;
}
//
@@ -462,13 +462,13 @@
//
bool is_zero()const
{
- using default_ops::is_zero;
- return is_zero(m_backend);
+ using default_ops::eval_is_zero;
+ return eval_is_zero(m_backend);
}
int sign()const
{
- using default_ops::get_sign;
- return get_sign(m_backend);
+ using default_ops::eval_get_sign;
+ return eval_get_sign(m_backend);
}
//
// String conversion functions:
@@ -480,9 +480,9 @@
template <class T>
T convert_to()const
{
- using default_ops::convert_to;
+ using default_ops::eval_convert_to;
T result;
- convert_to(&result, m_backend);
+ eval_convert_to(&result, m_backend);
return result;
}
//
@@ -514,9 +514,9 @@
template <class V>
typename enable_if<is_arithmetic<V>, int>::type compare(const V& o)const
{
- using default_ops::get_sign;
+ using default_ops::eval_get_sign;
if(o == 0)
- return get_sign(m_backend);
+ return eval_get_sign(m_backend);
return m_backend.compare(canonical_value(o));
}
Backend& backend()
@@ -554,36 +554,36 @@
template <class Exp>
void do_assign(const Exp& e, const detail::add_immediates&)
{
- using default_ops::add;
- add(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
+ using default_ops::eval_add;
+ eval_add(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
}
/*
template <class Exp>
void do_assign(const Exp& e, const detail::add_and_negate_immediates&)
{
- using default_ops::add;
- add(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
+ using default_ops::eval_add;
+ eval_add(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::subtract_immediates&)
{
- using default_ops::subtract;
- subtract(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
+ using default_ops::eval_subtract;
+ eval_subtract(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
}
template <class Exp>
void do_assign(const Exp& e, const detail::multiply_immediates&)
{
- using default_ops::multiply;
- multiply(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
+ using default_ops::eval_multiply;
+ eval_multiply(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
}
template <class Exp>
void do_assign(const Exp& e, const detail::divide_immediates&)
{
- using default_ops::divide;
- divide(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
+ using default_ops::eval_divide;
+ eval_divide(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
}
template <class Exp>
@@ -768,8 +768,8 @@
void do_assign(const Exp& e, const detail::modulus_immediates&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The modulus operation is only valid for integer types");
- using default_ops::modulus;
- modulus(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
+ using default_ops::eval_modulus;
+ eval_modulus(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
}
template <class Exp>
@@ -813,8 +813,8 @@
void do_assign(const Exp& e, const detail::bitwise_and_immediates&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "Bitwise operations are only valid for integer types");
- using default_ops::bitwise_and;
- bitwise_and(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
+ using default_ops::eval_bitwise_and;
+ eval_bitwise_and(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
}
template <class Exp>
@@ -858,8 +858,8 @@
void do_assign(const Exp& e, const detail::bitwise_or_immediates&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "Bitwise operations are only valid for integer types");
- using default_ops::bitwise_or;
- bitwise_or(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
+ using default_ops::eval_bitwise_or;
+ eval_bitwise_or(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
}
template <class Exp>
@@ -903,8 +903,8 @@
void do_assign(const Exp& e, const detail::bitwise_xor_immediates&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "Bitwise operations are only valid for integer types");
- using default_ops::bitwise_xor;
- bitwise_xor(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
+ using default_ops::eval_bitwise_xor;
+ eval_bitwise_xor(m_backend, canonical_value(e.left().value()), canonical_value(e.right().value()));
}
template <class Exp>
void do_assign(const Exp& e, const detail::terminal&)
@@ -952,51 +952,51 @@
void do_assign(const Exp& e, const detail::bitwise_complement&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise ~ operation is only valid for integer types");
- using default_ops::complement;
+ using default_ops::eval_complement;
self_type temp(e.left());
- complement(m_backend, temp.backend());
+ eval_complement(m_backend, temp.backend());
}
template <class Exp>
void do_assign(const Exp& e, const detail::complement_immediates&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise ~ operation is only valid for integer types");
- using default_ops::complement;
- complement(m_backend, canonical_value(e.left().value()));
+ using default_ops::eval_complement;
+ eval_complement(m_backend, canonical_value(e.left().value()));
}
template <class Exp, class Val>
void do_assign_right_shift(const Exp& e, const Val& val, const detail::terminal&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The right shift operation is only valid for integer types");
- using default_ops::right_shift;
- right_shift(m_backend, canonical_value(e.value()), val);
+ using default_ops::eval_right_shift;
+ eval_right_shift(m_backend, canonical_value(e.value()), val);
}
template <class Exp, class Val>
void do_assign_left_shift(const Exp& e, const Val& val, const detail::terminal&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The left shift operation is only valid for integer types");
- using default_ops::left_shift;
- left_shift(m_backend, canonical_value(e.value()), val);
+ using default_ops::eval_left_shift;
+ eval_left_shift(m_backend, canonical_value(e.value()), val);
}
template <class Exp, class Val, class Tag>
void do_assign_right_shift(const Exp& e, const Val& val, const Tag&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The right shift operation is only valid for integer types");
- using default_ops::right_shift;
+ using default_ops::eval_right_shift;
self_type temp(e);
- right_shift(m_backend, temp.backend(), val);
+ eval_right_shift(m_backend, temp.backend(), val);
}
template <class Exp, class Val, class Tag>
void do_assign_left_shift(const Exp& e, const Val& val, const Tag&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The left shift operation is only valid for integer types");
- using default_ops::left_shift;
+ using default_ops::eval_left_shift;
self_type temp(e);
- left_shift(m_backend, temp.backend(), val);
+ eval_left_shift(m_backend, temp.backend(), val);
}
template <class Exp>
@@ -1059,8 +1059,8 @@
template <class Exp>
void do_add(const Exp& e, const detail::terminal&)
{
- using default_ops::add;
- add(m_backend, canonical_value(e.value()));
+ using default_ops::eval_add;
+ eval_add(m_backend, canonical_value(e.value()));
}
template <class Exp>
@@ -1098,23 +1098,23 @@
template <class Exp>
void do_add(const Exp& e, const detail::add_immediates&)
{
- using default_ops::add;
- add(m_backend, canonical_value(e.left().value()));
- add(m_backend, canonical_value(e.right().value()));
+ using default_ops::eval_add;
+ eval_add(m_backend, canonical_value(e.left().value()));
+ eval_add(m_backend, canonical_value(e.right().value()));
}
template <class Exp>
void do_add(const Exp& e, const detail::subtract_immediates&)
{
- using default_ops::add;
- using default_ops::subtract;
- add(m_backend, canonical_value(e.left().value()));
- subtract(m_backend, canonical_value(e.right().value()));
+ using default_ops::eval_add;
+ using default_ops::eval_subtract;
+ eval_add(m_backend, canonical_value(e.left().value()));
+ eval_subtract(m_backend, canonical_value(e.right().value()));
}
template <class Exp>
void do_subtract(const Exp& e, const detail::terminal&)
{
- using default_ops::subtract;
- subtract(m_backend, canonical_value(e.value()));
+ using default_ops::eval_subtract;
+ eval_subtract(m_backend, canonical_value(e.value()));
}
template <class Exp>
@@ -1144,17 +1144,17 @@
template <class Exp>
void do_subtract(const Exp& e, const detail::add_immediates&)
{
- using default_ops::subtract;
- subtract(m_backend, canonical_value(e.left().value()));
- subtract(m_backend, canonical_value(e.right().value()));
+ using default_ops::eval_subtract;
+ eval_subtract(m_backend, canonical_value(e.left().value()));
+ eval_subtract(m_backend, canonical_value(e.right().value()));
}
template <class Exp>
void do_subtract(const Exp& e, const detail::subtract_immediates&)
{
- using default_ops::add;
- using default_ops::subtract;
- subtract(m_backend, canonical_value(e.left().value()));
- add(m_backend, canonical_value(e.right().value()));
+ using default_ops::eval_add;
+ using default_ops::eval_subtract;
+ eval_subtract(m_backend, canonical_value(e.left().value()));
+ eval_add(m_backend, canonical_value(e.right().value()));
}
template <class Exp, class unknown>
void do_subtract(const Exp& e, const unknown&)
@@ -1166,8 +1166,8 @@
template <class Exp>
void do_multiplies(const Exp& e, const detail::terminal&)
{
- using default_ops::multiply;
- multiply(m_backend, canonical_value(e.value()));
+ using default_ops::eval_multiply;
+ eval_multiply(m_backend, canonical_value(e.value()));
}
template <class Exp>
@@ -1199,31 +1199,31 @@
template <class Exp>
void do_multiplies(const Exp& e, const detail::multiply_immediates&)
{
- using default_ops::multiply;
- multiply(m_backend, canonical_value(e.left().value()));
- multiply(m_backend, canonical_value(e.right().value()));
+ using default_ops::eval_multiply;
+ eval_multiply(m_backend, canonical_value(e.left().value()));
+ eval_multiply(m_backend, canonical_value(e.right().value()));
}
template <class Exp>
void do_multiplies(const Exp& e, const detail::divide_immediates&)
{
- using default_ops::multiply;
- using default_ops::divide;
- multiply(m_backend, canonical_value(e.left().value()));
- divide(m_backend, canonical_value(e.right().value()));
+ using default_ops::eval_multiply;
+ using default_ops::eval_divide;
+ eval_multiply(m_backend, canonical_value(e.left().value()));
+ eval_divide(m_backend, canonical_value(e.right().value()));
}
template <class Exp, class unknown>
void do_multiplies(const Exp& e, const unknown&)
{
- using default_ops::multiply;
+ using default_ops::eval_multiply;
self_type temp(e);
- multiply(m_backend, temp.m_backend);
+ eval_multiply(m_backend, temp.m_backend);
}
template <class Exp>
void do_divide(const Exp& e, const detail::terminal&)
{
- using default_ops::divide;
- divide(m_backend, canonical_value(e.value()));
+ using default_ops::eval_divide;
+ eval_divide(m_backend, canonical_value(e.value()));
}
template <class Exp>
@@ -1255,50 +1255,50 @@
template <class Exp>
void do_divides(const Exp& e, const detail::multiply_immediates&)
{
- using default_ops::divide;
- divide(m_backend, canonical_value(e.left().value()));
- divide(m_backend, canonical_value(e.right().value()));
+ using default_ops::eval_divide;
+ eval_divide(m_backend, canonical_value(e.left().value()));
+ eval_divide(m_backend, canonical_value(e.right().value()));
}
template <class Exp>
void do_divides(const Exp& e, const detail::divide_immediates&)
{
- using default_ops::multiply;
- using default_ops::divide;
- divide(m_backend, canonical_value(e.left().value()));
+ using default_ops::eval_multiply;
+ using default_ops::eval_divide;
+ eval_divide(m_backend, canonical_value(e.left().value()));
mutiply(m_backend, canonical_value(e.right().value()));
}
template <class Exp, class unknown>
void do_divide(const Exp& e, const unknown&)
{
- using default_ops::multiply;
+ using default_ops::eval_multiply;
self_type temp(e);
- divide(m_backend, temp.m_backend);
+ eval_divide(m_backend, temp.m_backend);
}
template <class Exp>
void do_modulus(const Exp& e, const detail::terminal&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The modulus operation is only valid for integer types");
- using default_ops::modulus;
- modulus(m_backend, canonical_value(e.value()));
+ using default_ops::eval_modulus;
+ eval_modulus(m_backend, canonical_value(e.value()));
}
template <class Exp, class Unknown>
void do_modulus(const Exp& e, const Unknown&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The modulus operation is only valid for integer types");
- using default_ops::modulus;
+ using default_ops::eval_modulus;
self_type temp(e);
- modulus(m_backend, canonical_value(temp));
+ eval_modulus(m_backend, canonical_value(temp));
}
template <class Exp>
void do_bitwise_and(const Exp& e, const detail::terminal&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise & operation is only valid for integer types");
- using default_ops::bitwise_and;
- bitwise_and(m_backend, canonical_value(e.value()));
+ using default_ops::eval_bitwise_and;
+ eval_bitwise_and(m_backend, canonical_value(e.value()));
}
template <class Exp>
void do_bitwise_and(const Exp& e, const detail::bitwise_and&)
@@ -1313,17 +1313,17 @@
void do_bitwise_and(const Exp& e, const unknown&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise & operation is only valid for integer types");
- using default_ops::bitwise_and;
+ using default_ops::eval_bitwise_and;
self_type temp(e);
- bitwise_and(m_backend, temp.m_backend);
+ eval_bitwise_and(m_backend, temp.m_backend);
}
template <class Exp>
void do_bitwise_or(const Exp& e, const detail::terminal&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise | operation is only valid for integer types");
- using default_ops::bitwise_or;
- bitwise_or(m_backend, canonical_value(e.value()));
+ using default_ops::eval_bitwise_or;
+ eval_bitwise_or(m_backend, canonical_value(e.value()));
}
template <class Exp>
void do_bitwise_or(const Exp& e, const detail::bitwise_or&)
@@ -1338,17 +1338,17 @@
void do_bitwise_or(const Exp& e, const unknown&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise | operation is only valid for integer types");
- using default_ops::bitwise_or;
+ using default_ops::eval_bitwise_or;
self_type temp(e);
- bitwise_or(m_backend, temp.m_backend);
+ eval_bitwise_or(m_backend, temp.m_backend);
}
template <class Exp>
void do_bitwise_xor(const Exp& e, const detail::terminal&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise ^ operation is only valid for integer types");
- using default_ops::bitwise_xor;
- bitwise_xor(m_backend, canonical_value(e.value()));
+ using default_ops::eval_bitwise_xor;
+ eval_bitwise_xor(m_backend, canonical_value(e.value()));
}
template <class Exp>
void do_bitwise_xor(const Exp& e, const detail::bitwise_xor&)
@@ -1363,9 +1363,9 @@
void do_bitwise_xor(const Exp& e, const unknown&)
{
BOOST_STATIC_ASSERT_MSG(number_category<Backend>::value == number_kind_integer, "The bitwise ^ operation is only valid for integer types");
- using default_ops::bitwise_xor;
+ using default_ops::eval_bitwise_xor;
self_type temp(e);
- bitwise_xor(m_backend, temp.m_backend);
+ eval_bitwise_xor(m_backend, temp.m_backend);
}
// Tests if the expression contains a reference to *this:
Modified: sandbox/big_number/boost/multiprecision/mpfr.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/mpfr.hpp (original)
+++ sandbox/big_number/boost/multiprecision/mpfr.hpp 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
@@ -16,7 +16,9 @@
#include <cmath>
#include <algorithm>
-namespace boost{ namespace multiprecision{
+namespace boost{
+namespace multiprecision{
+namespace backends{
template <unsigned digits10>
struct mpfr_float_backend;
@@ -560,47 +562,47 @@
};
template <unsigned digits10>
-inline void add(mpfr_float_backend<digits10>& result, const mpfr_float_backend<digits10>& o)
+inline void eval_add(mpfr_float_backend<digits10>& result, const mpfr_float_backend<digits10>& o)
{
mpfr_add(result.data(), result.data(), o.data(), GMP_RNDN);
}
template <unsigned digits10>
-inline void subtract(mpfr_float_backend<digits10>& result, const mpfr_float_backend<digits10>& o)
+inline void eval_subtract(mpfr_float_backend<digits10>& result, const mpfr_float_backend<digits10>& o)
{
mpfr_sub(result.data(), result.data(), o.data(), GMP_RNDN);
}
template <unsigned digits10>
-inline void multiply(mpfr_float_backend<digits10>& result, const mpfr_float_backend<digits10>& o)
+inline void eval_multiply(mpfr_float_backend<digits10>& result, const mpfr_float_backend<digits10>& o)
{
mpfr_mul(result.data(), result.data(), o.data(), GMP_RNDN);
}
template <unsigned digits10>
-inline void divide(mpfr_float_backend<digits10>& result, const mpfr_float_backend<digits10>& o)
+inline void eval_divide(mpfr_float_backend<digits10>& result, const mpfr_float_backend<digits10>& o)
{
mpfr_div(result.data(), result.data(), o.data(), GMP_RNDN);
}
template <unsigned digits10>
-inline void add(mpfr_float_backend<digits10>& result, unsigned long i)
+inline void eval_add(mpfr_float_backend<digits10>& result, unsigned long i)
{
mpfr_add_ui(result.data(), result.data(), i, GMP_RNDN);
}
template <unsigned digits10>
-inline void subtract(mpfr_float_backend<digits10>& result, unsigned long i)
+inline void eval_subtract(mpfr_float_backend<digits10>& result, unsigned long i)
{
mpfr_sub_ui(result.data(), result.data(), i, GMP_RNDN);
}
template <unsigned digits10>
-inline void multiply(mpfr_float_backend<digits10>& result, unsigned long i)
+inline void eval_multiply(mpfr_float_backend<digits10>& result, unsigned long i)
{
mpfr_mul_ui(result.data(), result.data(), i, GMP_RNDN);
}
template <unsigned digits10>
-inline void divide(mpfr_float_backend<digits10>& result, unsigned long i)
+inline void eval_divide(mpfr_float_backend<digits10>& result, unsigned long i)
{
mpfr_div_ui(result.data(), result.data(), i, GMP_RNDN);
}
template <unsigned digits10>
-inline void add(mpfr_float_backend<digits10>& result, long i)
+inline void eval_add(mpfr_float_backend<digits10>& result, long i)
{
if(i > 0)
mpfr_add_ui(result.data(), result.data(), i, GMP_RNDN);
@@ -608,7 +610,7 @@
mpfr_sub_ui(result.data(), result.data(), std::abs(i), GMP_RNDN);
}
template <unsigned digits10>
-inline void subtract(mpfr_float_backend<digits10>& result, long i)
+inline void eval_subtract(mpfr_float_backend<digits10>& result, long i)
{
if(i > 0)
mpfr_sub_ui(result.data(), result.data(), i, GMP_RNDN);
@@ -616,14 +618,14 @@
mpfr_add_ui(result.data(), result.data(), std::abs(i), GMP_RNDN);
}
template <unsigned digits10>
-inline void multiply(mpfr_float_backend<digits10>& result, long i)
+inline void eval_multiply(mpfr_float_backend<digits10>& result, long i)
{
mpfr_mul_ui(result.data(), result.data(), std::abs(i), GMP_RNDN);
if(i < 0)
mpfr_neg(result.data(), result.data(), GMP_RNDN);
}
template <unsigned digits10>
-inline void divide(mpfr_float_backend<digits10>& result, long i)
+inline void eval_divide(mpfr_float_backend<digits10>& result, long i)
{
mpfr_div_ui(result.data(), result.data(), std::abs(i), GMP_RNDN);
if(i < 0)
@@ -633,17 +635,17 @@
// Specialised 3 arg versions of the basic operators:
//
template <unsigned digits10>
-inline void add(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, const mpfr_float_backend<digits10>& y)
+inline void eval_add(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, const mpfr_float_backend<digits10>& y)
{
mpfr_add(a.data(), x.data(), y.data(), GMP_RNDN);
}
template <unsigned digits10>
-inline void add(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, unsigned long y)
+inline void eval_add(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, unsigned long y)
{
mpfr_add_ui(a.data(), x.data(), y, GMP_RNDN);
}
template <unsigned digits10>
-inline void add(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, long y)
+inline void eval_add(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, long y)
{
if(y < 0)
mpfr_sub_ui(a.data(), x.data(), -y, GMP_RNDN);
@@ -651,12 +653,12 @@
mpfr_add_ui(a.data(), x.data(), y, GMP_RNDN);
}
template <unsigned digits10>
-inline void add(mpfr_float_backend<digits10>& a, unsigned long x, const mpfr_float_backend<digits10>& y)
+inline void eval_add(mpfr_float_backend<digits10>& a, unsigned long x, const mpfr_float_backend<digits10>& y)
{
mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN);
}
template <unsigned digits10>
-inline void add(mpfr_float_backend<digits10>& a, long x, const mpfr_float_backend<digits10>& y)
+inline void eval_add(mpfr_float_backend<digits10>& a, long x, const mpfr_float_backend<digits10>& y)
{
if(x < 0)
{
@@ -667,17 +669,17 @@
mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN);
}
template <unsigned digits10>
-inline void subtract(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, const mpfr_float_backend<digits10>& y)
+inline void eval_subtract(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, const mpfr_float_backend<digits10>& y)
{
mpfr_sub(a.data(), x.data(), y.data(), GMP_RNDN);
}
template <unsigned digits10>
-inline void subtract(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, unsigned long y)
+inline void eval_subtract(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, unsigned long y)
{
mpfr_sub_ui(a.data(), x.data(), y, GMP_RNDN);
}
template <unsigned digits10>
-inline void subtract(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, long y)
+inline void eval_subtract(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, long y)
{
if(y < 0)
mpfr_add_ui(a.data(), x.data(), -y, GMP_RNDN);
@@ -685,12 +687,12 @@
mpfr_sub_ui(a.data(), x.data(), y, GMP_RNDN);
}
template <unsigned digits10>
-inline void subtract(mpfr_float_backend<digits10>& a, unsigned long x, const mpfr_float_backend<digits10>& y)
+inline void eval_subtract(mpfr_float_backend<digits10>& a, unsigned long x, const mpfr_float_backend<digits10>& y)
{
mpfr_ui_sub(a.data(), x, y.data(), GMP_RNDN);
}
template <unsigned digits10>
-inline void subtract(mpfr_float_backend<digits10>& a, long x, const mpfr_float_backend<digits10>& y)
+inline void eval_subtract(mpfr_float_backend<digits10>& a, long x, const mpfr_float_backend<digits10>& y)
{
if(x < 0)
{
@@ -702,17 +704,17 @@
}
template <unsigned digits10>
-inline void multiply(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, const mpfr_float_backend<digits10>& y)
+inline void eval_multiply(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, const mpfr_float_backend<digits10>& y)
{
mpfr_mul(a.data(), x.data(), y.data(), GMP_RNDN);
}
template <unsigned digits10>
-inline void multiply(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, unsigned long y)
+inline void eval_multiply(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, unsigned long y)
{
mpfr_mul_ui(a.data(), x.data(), y, GMP_RNDN);
}
template <unsigned digits10>
-inline void multiply(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, long y)
+inline void eval_multiply(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, long y)
{
if(y < 0)
{
@@ -723,12 +725,12 @@
mpfr_mul_ui(a.data(), x.data(), y, GMP_RNDN);
}
template <unsigned digits10>
-inline void multiply(mpfr_float_backend<digits10>& a, unsigned long x, const mpfr_float_backend<digits10>& y)
+inline void eval_multiply(mpfr_float_backend<digits10>& a, unsigned long x, const mpfr_float_backend<digits10>& y)
{
mpfr_mul_ui(a.data(), y.data(), x, GMP_RNDN);
}
template <unsigned digits10>
-inline void multiply(mpfr_float_backend<digits10>& a, long x, const mpfr_float_backend<digits10>& y)
+inline void eval_multiply(mpfr_float_backend<digits10>& a, long x, const mpfr_float_backend<digits10>& y)
{
if(x < 0)
{
@@ -740,17 +742,17 @@
}
template <unsigned digits10>
-inline void divide(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, const mpfr_float_backend<digits10>& y)
+inline void eval_divide(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, const mpfr_float_backend<digits10>& y)
{
mpfr_div(a.data(), x.data(), y.data(), GMP_RNDN);
}
template <unsigned digits10>
-inline void divide(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, unsigned long y)
+inline void eval_divide(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, unsigned long y)
{
mpfr_div_ui(a.data(), x.data(), y, GMP_RNDN);
}
template <unsigned digits10>
-inline void divide(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, long y)
+inline void eval_divide(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, long y)
{
if(y < 0)
{
@@ -761,12 +763,12 @@
mpfr_div_ui(a.data(), x.data(), y, GMP_RNDN);
}
template <unsigned digits10>
-inline void divide(mpfr_float_backend<digits10>& a, unsigned long x, const mpfr_float_backend<digits10>& y)
+inline void eval_divide(mpfr_float_backend<digits10>& a, unsigned long x, const mpfr_float_backend<digits10>& y)
{
mpfr_ui_div(a.data(), x, y.data(), GMP_RNDN);
}
template <unsigned digits10>
-inline void divide(mpfr_float_backend<digits10>& a, long x, const mpfr_float_backend<digits10>& y)
+inline void eval_divide(mpfr_float_backend<digits10>& a, long x, const mpfr_float_backend<digits10>& y)
{
if(x < 0)
{
@@ -778,45 +780,45 @@
}
template <unsigned digits10>
-inline bool is_zero(const mpfr_float_backend<digits10>& val)
+inline bool eval_is_zero(const mpfr_float_backend<digits10>& val)
{
return 0 != mpfr_zero_p(val.data());
}
template <unsigned digits10>
-inline int get_sign(const mpfr_float_backend<digits10>& val)
+inline int eval_get_sign(const mpfr_float_backend<digits10>& val)
{
return mpfr_sgn(val.data());
}
template <unsigned digits10>
-inline void convert_to(unsigned long* result, const mpfr_float_backend<digits10>& val)
+inline void eval_convert_to(unsigned long* result, const mpfr_float_backend<digits10>& val)
{
*result = mpfr_get_ui(val.data(), GMP_RNDN);
}
template <unsigned digits10>
-inline void convert_to(long* result, const mpfr_float_backend<digits10>& val)
+inline void eval_convert_to(long* result, const mpfr_float_backend<digits10>& val)
{
*result = mpfr_get_si(val.data(), GMP_RNDN);
}
#ifdef _MPFR_H_HAVE_INTMAX_T
template <unsigned digits10>
-inline void convert_to(unsigned long long* result, const mpfr_float_backend<digits10>& val)
+inline void eval_convert_to(unsigned long long* result, const mpfr_float_backend<digits10>& val)
{
*result = mpfr_get_uj(val.data(), GMP_RNDN);
}
template <unsigned digits10>
-inline void convert_to(long long* result, const mpfr_float_backend<digits10>& val)
+inline void eval_convert_to(long long* result, const mpfr_float_backend<digits10>& val)
{
*result = mpfr_get_sj(val.data(), GMP_RNDN);
}
#endif
template <unsigned digits10>
-inline void convert_to(double* result, const mpfr_float_backend<digits10>& val)
+inline void eval_convert_to(double* result, const mpfr_float_backend<digits10>& val)
{
*result = mpfr_get_d(val.data(), GMP_RNDN);
}
template <unsigned digits10>
-inline void convert_to(long double* result, const mpfr_float_backend<digits10>& val)
+inline void eval_convert_to(long double* result, const mpfr_float_backend<digits10>& val)
{
*result = mpfr_get_ld(val.data(), GMP_RNDN);
}
@@ -988,13 +990,17 @@
mpfr_tanh(result.data(), arg.data(), GMP_RNDN);
}
+} // namespace backends
+
+using boost::multiprecision::backends::mpfr_float_backend;
+
typedef mp_number<mpfr_float_backend<50> > mpfr_float_50;
typedef mp_number<mpfr_float_backend<100> > mpfr_float_100;
typedef mp_number<mpfr_float_backend<500> > mpfr_float_500;
typedef mp_number<mpfr_float_backend<1000> > mpfr_float_1000;
typedef mp_number<mpfr_float_backend<0> > mpfr_float;
-} // namespace boost
+} // namespace multiprecision
namespace math{
@@ -1003,7 +1009,7 @@
template <>
inline int digits<boost::multiprecision::mpfr_float>()
{
- return boost::multiprecision::detail::get_default_precision();
+ return boost::multiprecision::backends::detail::get_default_precision();
}
}
Modified: sandbox/big_number/boost/multiprecision/rational_adapter.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/rational_adapter.hpp (original)
+++ sandbox/big_number/boost/multiprecision/rational_adapter.hpp 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
@@ -16,6 +16,7 @@
namespace boost{
namespace multiprecision{
+namespace backends{
template <class IntBackend>
struct rational_adapter
@@ -123,42 +124,42 @@
};
template <class IntBackend>
-inline void add(rational_adapter<IntBackend>& result, const rational_adapter<IntBackend>& o)
+inline void eval_add(rational_adapter<IntBackend>& result, const rational_adapter<IntBackend>& o)
{
result.data() += o.data();
}
template <class IntBackend>
-inline void subtract(rational_adapter<IntBackend>& result, const rational_adapter<IntBackend>& o)
+inline void eval_subtract(rational_adapter<IntBackend>& result, const rational_adapter<IntBackend>& o)
{
result.data() -= o.data();
}
template <class IntBackend>
-inline void multiply(rational_adapter<IntBackend>& result, const rational_adapter<IntBackend>& o)
+inline void eval_multiply(rational_adapter<IntBackend>& result, const rational_adapter<IntBackend>& o)
{
result.data() *= o.data();
}
template <class IntBackend>
-inline void divide(rational_adapter<IntBackend>& result, const rational_adapter<IntBackend>& o)
+inline void eval_divide(rational_adapter<IntBackend>& result, const rational_adapter<IntBackend>& o)
{
result.data() /= o.data();
}
template <class R, class IntBackend>
-inline void convert_to(R* result, const rational_adapter<IntBackend>& backend)
+inline void eval_convert_to(R* result, const rational_adapter<IntBackend>& backend)
{
*result = backend.data().numerator().template convert_to<R>();
*result /= backend.data().denominator().template convert_to<R>();
}
template <class IntBackend>
-inline bool is_zero(const rational_adapter<IntBackend>& val)
+inline bool eval_is_zero(const rational_adapter<IntBackend>& val)
{
- return is_zero(val.data().numerator().backend());
+ return eval_is_zero(val.data().numerator().backend());
}
template <class IntBackend>
-inline int get_sign(const rational_adapter<IntBackend>& val)
+inline int eval_get_sign(const rational_adapter<IntBackend>& val)
{
- return get_sign(val.data().numerator().backend());
+ return eval_get_sign(val.data().numerator().backend());
}
template <class IntBackend>
@@ -181,6 +182,10 @@
template<class IntBackend>
struct number_category<rational_adapter<IntBackend> > : public mpl::int_<number_kind_rational>{};
+} // namespace backends
+
+using boost::multiprecision::backends::rational_adapter;
+
template <class T>
struct component_type<rational_adapter<T> >
{
Modified: sandbox/big_number/boost/multiprecision/tommath.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/tommath.hpp (original)
+++ sandbox/big_number/boost/multiprecision/tommath.hpp 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
@@ -17,7 +17,7 @@
#include <limits>
#include <climits>
-namespace boost{ namespace multiprecision{
+namespace boost{ namespace multiprecision{ namespace backends{
namespace detail{
@@ -241,31 +241,31 @@
if(SIGN(&x.data()))\
BOOST_THROW_EXCEPTION(std::runtime_error("Bitwise operations on libtommath negative valued integers are disabled as they produce unpredictable results"))
-int get_sign(const tommath_int& val);
+int eval_get_sign(const tommath_int& val);
-inline void add(tommath_int& t, const tommath_int& o)
+inline void eval_add(tommath_int& t, const tommath_int& o)
{
detail::check_tommath_result(mp_add(&t.data(), const_cast< ::mp_int*>(&o.data()), &t.data()));
}
-inline void subtract(tommath_int& t, const tommath_int& o)
+inline void eval_subtract(tommath_int& t, const tommath_int& o)
{
detail::check_tommath_result(mp_sub(&t.data(), const_cast< ::mp_int*>(&o.data()), &t.data()));
}
-inline void multiply(tommath_int& t, const tommath_int& o)
+inline void eval_multiply(tommath_int& t, const tommath_int& o)
{
detail::check_tommath_result(mp_mul(&t.data(), const_cast< ::mp_int*>(&o.data()), &t.data()));
}
-inline void divide(tommath_int& t, const tommath_int& o)
+inline void eval_divide(tommath_int& t, const tommath_int& o)
{
tommath_int temp;
detail::check_tommath_result(mp_div(&t.data(), const_cast< ::mp_int*>(&o.data()), &t.data(), &temp.data()));
}
-inline void modulus(tommath_int& t, const tommath_int& o)
+inline void eval_modulus(tommath_int& t, const tommath_int& o)
{
- bool neg = get_sign(t) < 0;
- bool neg2 = get_sign(o) < 0;
+ bool neg = eval_get_sign(t) < 0;
+ bool neg2 = eval_get_sign(o) < 0;
detail::check_tommath_result(mp_mod(&t.data(), const_cast< ::mp_int*>(&o.data()), &t.data()));
- if((neg != neg2) && (get_sign(t) != 0))
+ if((neg != neg2) && (eval_get_sign(t) != 0))
{
t.negate();
detail::check_tommath_result(mp_add(&t.data(), const_cast< ::mp_int*>(&o.data()), &t.data()));
@@ -277,72 +277,72 @@
}
}
template <class UI>
-inline void left_shift(tommath_int& t, UI i)
+inline void eval_left_shift(tommath_int& t, UI i)
{
detail::check_tommath_result(mp_mul_2d(&t.data(), static_cast<unsigned>(i), &t.data()));
}
template <class UI>
-inline void right_shift(tommath_int& t, UI i)
+inline void eval_right_shift(tommath_int& t, UI i)
{
tommath_int d;
detail::check_tommath_result(mp_div_2d(&t.data(), static_cast<unsigned>(i), &t.data(), &d.data()));
}
template <class UI>
-inline void left_shift(tommath_int& t, const tommath_int& v, UI i)
+inline void eval_left_shift(tommath_int& t, const tommath_int& v, UI i)
{
detail::check_tommath_result(mp_mul_2d(const_cast< ::mp_int*>(&v.data()), static_cast<unsigned>(i), &t.data()));
}
template <class UI>
-inline void right_shift(tommath_int& t, const tommath_int& v, UI i)
+inline void eval_right_shift(tommath_int& t, const tommath_int& v, UI i)
{
tommath_int d;
detail::check_tommath_result(mp_div_2d(const_cast< ::mp_int*>(&v.data()), static_cast<unsigned long>(i), &t.data(), &d.data()));
}
-inline void bitwise_and(tommath_int& result, const tommath_int& v)
+inline void eval_bitwise_and(tommath_int& result, const tommath_int& v)
{
BOOST_MP_TOMMATH_BIT_OP_CHECK(result);
BOOST_MP_TOMMATH_BIT_OP_CHECK(v);
detail::check_tommath_result(mp_and(&result.data(), const_cast< ::mp_int*>(&v.data()), &result.data()));
}
-inline void bitwise_or(tommath_int& result, const tommath_int& v)
+inline void eval_bitwise_or(tommath_int& result, const tommath_int& v)
{
BOOST_MP_TOMMATH_BIT_OP_CHECK(result);
BOOST_MP_TOMMATH_BIT_OP_CHECK(v);
detail::check_tommath_result(mp_or(&result.data(), const_cast< ::mp_int*>(&v.data()), &result.data()));
}
-inline void bitwise_xor(tommath_int& result, const tommath_int& v)
+inline void eval_bitwise_xor(tommath_int& result, const tommath_int& v)
{
BOOST_MP_TOMMATH_BIT_OP_CHECK(result);
BOOST_MP_TOMMATH_BIT_OP_CHECK(v);
detail::check_tommath_result(mp_xor(&result.data(), const_cast< ::mp_int*>(&v.data()), &result.data()));
}
-inline void add(tommath_int& t, const tommath_int& p, const tommath_int& o)
+inline void eval_add(tommath_int& t, const tommath_int& p, const tommath_int& o)
{
detail::check_tommath_result(mp_add(const_cast< ::mp_int*>(&p.data()), const_cast< ::mp_int*>(&o.data()), &t.data()));
}
-inline void subtract(tommath_int& t, const tommath_int& p, const tommath_int& o)
+inline void eval_subtract(tommath_int& t, const tommath_int& p, const tommath_int& o)
{
detail::check_tommath_result(mp_sub(const_cast< ::mp_int*>(&p.data()), const_cast< ::mp_int*>(&o.data()), &t.data()));
}
-inline void multiply(tommath_int& t, const tommath_int& p, const tommath_int& o)
+inline void eval_multiply(tommath_int& t, const tommath_int& p, const tommath_int& o)
{
detail::check_tommath_result(mp_mul(const_cast< ::mp_int*>(&p.data()), const_cast< ::mp_int*>(&o.data()), &t.data()));
}
-inline void divide(tommath_int& t, const tommath_int& p, const tommath_int& o)
+inline void eval_divide(tommath_int& t, const tommath_int& p, const tommath_int& o)
{
tommath_int d;
detail::check_tommath_result(mp_div(const_cast< ::mp_int*>(&p.data()), const_cast< ::mp_int*>(&o.data()), &t.data(), &d.data()));
}
-inline void modulus(tommath_int& t, const tommath_int& p, const tommath_int& o)
+inline void eval_modulus(tommath_int& t, const tommath_int& p, const tommath_int& o)
{
- bool neg = get_sign(p) < 0;
- bool neg2 = get_sign(o) < 0;
+ bool neg = eval_get_sign(p) < 0;
+ bool neg2 = eval_get_sign(o) < 0;
detail::check_tommath_result(mp_mod(const_cast< ::mp_int*>(&p.data()), const_cast< ::mp_int*>(&o.data()), &t.data()));
- if((neg != neg2) && (get_sign(t) != 0))
+ if((neg != neg2) && (eval_get_sign(t) != 0))
{
t.negate();
detail::check_tommath_result(mp_add(&t.data(), const_cast< ::mp_int*>(&o.data()), &t.data()));
@@ -354,28 +354,28 @@
}
}
-inline void bitwise_and(tommath_int& result, const tommath_int& u, const tommath_int& v)
+inline void eval_bitwise_and(tommath_int& result, const tommath_int& u, const tommath_int& v)
{
BOOST_MP_TOMMATH_BIT_OP_CHECK(u);
BOOST_MP_TOMMATH_BIT_OP_CHECK(v);
detail::check_tommath_result(mp_and(const_cast< ::mp_int*>(&u.data()), const_cast< ::mp_int*>(&v.data()), &result.data()));
}
-inline void bitwise_or(tommath_int& result, const tommath_int& u, const tommath_int& v)
+inline void eval_bitwise_or(tommath_int& result, const tommath_int& u, const tommath_int& v)
{
BOOST_MP_TOMMATH_BIT_OP_CHECK(u);
BOOST_MP_TOMMATH_BIT_OP_CHECK(v);
detail::check_tommath_result(mp_or(const_cast< ::mp_int*>(&u.data()), const_cast< ::mp_int*>(&v.data()), &result.data()));
}
-inline void bitwise_xor(tommath_int& result, const tommath_int& u, const tommath_int& v)
+inline void eval_bitwise_xor(tommath_int& result, const tommath_int& u, const tommath_int& v)
{
BOOST_MP_TOMMATH_BIT_OP_CHECK(u);
BOOST_MP_TOMMATH_BIT_OP_CHECK(v);
detail::check_tommath_result(mp_xor(const_cast< ::mp_int*>(&u.data()), const_cast< ::mp_int*>(&v.data()), &result.data()));
}
/*
-inline void complement(tommath_int& result, const tommath_int& u)
+inline void eval_complement(tommath_int& result, const tommath_int& u)
{
//
// Although this code works, it doesn't really do what the user might expect....
@@ -400,32 +400,32 @@
// Create a mask providing the extra bits we need and add to result:
tommath_int mask;
mask = static_cast<long long>((1u << padding) - 1);
- left_shift(mask, shift);
+ eval_left_shift(mask, shift);
add(result, mask);
}
*/
-inline bool is_zero(const tommath_int& val)
+inline bool eval_is_zero(const tommath_int& val)
{
return mp_iszero(&val.data());
}
-inline int get_sign(const tommath_int& val)
+inline int eval_get_sign(const tommath_int& val)
{
return mp_iszero(&val.data()) ? 0 : SIGN(&val.data()) ? -1 : 1;
}
template <class A>
-inline void convert_to(A* result, const tommath_int& val)
+inline void eval_convert_to(A* result, const tommath_int& val)
{
*result = boost::lexical_cast<A>(val.str(0, std::ios_base::fmtflags(0)));
}
-inline void convert_to(char* result, const tommath_int& val)
+inline void eval_convert_to(char* result, const tommath_int& val)
{
*result = static_cast<char>(boost::lexical_cast<int>(val.str(0, std::ios_base::fmtflags(0))));
}
-inline void convert_to(unsigned char* result, const tommath_int& val)
+inline void eval_convert_to(unsigned char* result, const tommath_int& val)
{
*result = static_cast<unsigned char>(boost::lexical_cast<unsigned>(val.str(0, std::ios_base::fmtflags(0))));
}
-inline void convert_to(signed char* result, const tommath_int& val)
+inline void eval_convert_to(signed char* result, const tommath_int& val)
{
*result = static_cast<signed char>(boost::lexical_cast<int>(val.str(0, std::ios_base::fmtflags(0))));
}
@@ -442,6 +442,9 @@
detail::check_tommath_result(mp_lcm(const_cast< ::mp_int*>(&a.data()), const_cast< ::mp_int*>(&b.data()), const_cast< ::mp_int*>(&result.data())));
}
+} // namespace backends
+
+using boost::multiprecision::backends::tommath_int;
template<>
struct number_category<tommath_int> : public mpl::int_<number_kind_integer>{};
Modified: sandbox/big_number/libs/multiprecision/doc/multiprecision.qbk
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/multiprecision.qbk (original)
+++ sandbox/big_number/libs/multiprecision/doc/multiprecision.qbk 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
@@ -621,13 +621,13 @@
// swap:
void swap(mp_number& other);
// Sign:
- bool is_zero()const;
+ bool eval_is_zero()const;
int sign()const;
// string conversion:
std::string str()const;
// Generic conversion mechanism
template <class T>
- T convert_to()const;
+ T eval_convert_to()const;
// precision control:
static unsigned default_precision();
static void default_precision(unsigned digits10);
@@ -801,7 +801,7 @@
Swaps `*this` with `other`.
- bool is_zero()const;
+ bool eval_is_zero()const;
Returns `true` is `*this` is zero, otherwise `false`.
@@ -816,7 +816,7 @@
if /scientific/ is true.
template <class T>
- T convert_to()const;
+ T eval_convert_to()const;
Provides a generic conversion mechanism to convert `*this` to type `T`. Type `T` may be any arithmetic type.
Optionally other types may also be supported by specific `Backend` types.
@@ -1043,18 +1043,18 @@
[[`cb.compare(a)`][`int`][Compares `cb` and `a`, returns a value less than zero if `cb < a`, a value greater than zero if `cb > a` and zero
if `cb == a`. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`add(b, cb)`][`void`][Adds `cb` to `b`.]]
-[[`subtract(b, cb)`][`void`][Subtracts `cb` from `b`.]]
-[[`multiply(b, cb)`][`void`][Multiplies `b` by `cb`.]]
-[[`divide(b, cb)`][`void`][Divides `b` by `cb`.]]
-[[`modulus(b, cb)`][`void`][Computes `b %= cb`, only required when `B` is an integer type.]]
-[[`bitwise_and(b, cb)`][`void`][Computes `b &= cb`, only required when `B` is an integer type.]]
-[[`bitwise_or(b, cb)`][`void`][Computes `b |= cb`, only required when `B` is an integer type.]]
-[[`bitwise_xor(b, cb)`][`void`][Computes `b ^= cb`, only required when `B` is an integer type.]]
-[[`complement(b, cb)`][`void`][Computes the ones-complement of `cb` and stores the result in `b`, only required when `B` is an integer type.]]
-[[`left_shift(b, ui)`][`void`][Computes `b <<= ui`, only required when `B` is an integer type.]]
-[[`right_shift(b, ui)`][`void`][Computes `b >>= ui`, only required when `B` is an integer type.]]
-[[`convert_to(pa, cb)`][`void`][Converts `cb` to the type of `*pa` and store the result in `*pa`. Type `B` shall support
+[[`eval_add(b, cb)`][`void`][Adds `cb` to `b`.]]
+[[`eval_subtract(b, cb)`][`void`][Subtracts `cb` from `b`.]]
+[[`eval_multiply(b, cb)`][`void`][Multiplies `b` by `cb`.]]
+[[`eval_divide(b, cb)`][`void`][Divides `b` by `cb`.]]
+[[`eval_modulus(b, cb)`][`void`][Computes `b %= cb`, only required when `B` is an integer type.]]
+[[`eval_bitwise_and(b, cb)`][`void`][Computes `b &= cb`, only required when `B` is an integer type.]]
+[[`eval_bitwise_or(b, cb)`][`void`][Computes `b |= cb`, only required when `B` is an integer type.]]
+[[`eval_bitwise_xor(b, cb)`][`void`][Computes `b ^= cb`, only required when `B` is an integer type.]]
+[[`eval_complement(b, cb)`][`void`][Computes the ones-complement of `cb` and stores the result in `b`, only required when `B` is an integer type.]]
+[[`eval_left_shift(b, ui)`][`void`][Computes `b <<= ui`, only required when `B` is an integer type.]]
+[[`eval_right_shift(b, ui)`][`void`][Computes `b >>= ui`, only required when `B` is an integer type.]]
+[[`eval_convert_to(pa, cb)`][`void`][Converts `cb` to the type of `*pa` and store the result in `*pa`. Type `B` shall support
conversion to at least types `std::intmax_t`, `std::uintmax_t` and `long long`.
Conversion to other arithmetic types can then be synthesised using other operations.
Conversions to other types are entirely optional.]]
@@ -1075,68 +1075,68 @@
Only applies to rational and complex number types.]]
[[`assign_components(b, b2, b2)`][`void`][Assigns to `b` the two components in the following arguments.
Only applies to rational and complex number types.]]
-[[`add(b, a)`][`void`][Adds `a` to `b`. The type of `a` shall be listed in one of the type lists
+[[`eval_add(b, a)`][`void`][Adds `a` to `b`. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`subtract(b, a)`][`void`][Subtracts `a` from `b`. The type of `a` shall be listed in one of the type lists
+[[`eval_subtract(b, a)`][`void`][Subtracts `a` from `b`. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`multiply(b, a)`][`void`][Multiplies `b` by `a`. The type of `a` shall be listed in one of the type lists
+[[`eval_multiply(b, a)`][`void`][Multiplies `b` by `a`. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`divide(b, a)`][`void`][Divides `b` by `a`. The type of `a` shall be listed in one of the type lists
+[[`eval_divide(b, a)`][`void`][Divides `b` by `a`. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`modulus(b, a)`][`void`][Computes `b %= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
+[[`eval_modulus(b, a)`][`void`][Computes `b %= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`bitwise_and(b, a)`][`void`][Computes `b &= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
+[[`eval_bitwise_and(b, a)`][`void`][Computes `b &= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`bitwise_or(b, a)`][`void`][Computes `b |= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
+[[`eval_bitwise_or(b, a)`][`void`][Computes `b |= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`bitwise_xor(b, a)`][`void`][Computes `b ^= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
+[[`eval_bitwise_xor(b, a)`][`void`][Computes `b ^= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`add(b, cb, cb2)`][`void`][Add `cb` to `cb2` and stores the result in `b`.]]
-[[`subtract(b, cb, cb2)`][`void`][Subtracts `cb2` from `cb` and stores the result in `b`.]]
-[[`multiply(b, cb, cb2)`][`void`][Multiplies `cb` by `cb2` and stores the result in `b`.]]
-[[`divide(b, cb, cb2)`][`void`][Divides `cb` by `cb2` and stores the result in `b`.]]
-[[`add(b, cb, a)`][`void`][Add `cb` to `a` and stores the result in `b`. The type of `a` shall be listed in one of the type lists
+[[`eval_add(b, cb, cb2)`][`void`][Add `cb` to `cb2` and stores the result in `b`.]]
+[[`eval_subtract(b, cb, cb2)`][`void`][Subtracts `cb2` from `cb` and stores the result in `b`.]]
+[[`eval_multiply(b, cb, cb2)`][`void`][Multiplies `cb` by `cb2` and stores the result in `b`.]]
+[[`eval_divide(b, cb, cb2)`][`void`][Divides `cb` by `cb2` and stores the result in `b`.]]
+[[`eval_add(b, cb, a)`][`void`][Add `cb` to `a` and stores the result in `b`. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`subtract(b, cb, a)`][`void`][Subtracts `a` from `cb` and stores the result in `b`. The type of `a` shall be listed in one of the type lists
+[[`eval_subtract(b, cb, a)`][`void`][Subtracts `a` from `cb` and stores the result in `b`. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`multiply(b, cb, a)`][`void`][Multiplies `cb` by `a` and stores the result in `b`. The type of `a` shall be listed in one of the type lists
+[[`eval_multiply(b, cb, a)`][`void`][Multiplies `cb` by `a` and stores the result in `b`. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`divide(b, cb, a)`][`void`][Divides `cb` by `a` and stores the result in `b`. The type of `a` shall be listed in one of the type lists
+[[`eval_divide(b, cb, a)`][`void`][Divides `cb` by `a` and stores the result in `b`. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`modulus(b, cb, cb2)`][`void`][Computes `cb % cb2` and stores the result in `b`, only required when `B` is an integer type.]]
-[[`bitwise_and(b, cb, cb2)`][`void`][Computes `cb & cb2` and stores the result in `b`, only required when `B` is an integer type.]]
-[[`bitwise_or(b, cb, cb2)`][`void`][Computes `cb | cb2` and stores the result in `b`, only required when `B` is an integer type.]]
-[[`bitwise_xor(b, cb, cb2)`][`void`][Computes `cb ^ cb2` and stores the result in `b`, only required when `B` is an integer type.]]
-[[`add(b, a, cb)`][`void`][Add `a` to `cb` and stores the result in `b`. The type of `a` shall be listed in one of the type lists
+[[`eval_modulus(b, cb, cb2)`][`void`][Computes `cb % cb2` and stores the result in `b`, only required when `B` is an integer type.]]
+[[`eval_bitwise_and(b, cb, cb2)`][`void`][Computes `cb & cb2` and stores the result in `b`, only required when `B` is an integer type.]]
+[[`eval_bitwise_or(b, cb, cb2)`][`void`][Computes `cb | cb2` and stores the result in `b`, only required when `B` is an integer type.]]
+[[`eval_bitwise_xor(b, cb, cb2)`][`void`][Computes `cb ^ cb2` and stores the result in `b`, only required when `B` is an integer type.]]
+[[`eval_add(b, a, cb)`][`void`][Add `a` to `cb` and stores the result in `b`. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`subtract(b, a, cb)`][`void`][Subtracts `cb` from `a` and stores the result in `b`. The type of `a` shall be listed in one of the type lists
+[[`eval_subtract(b, a, cb)`][`void`][Subtracts `cb` from `a` and stores the result in `b`. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`multiply(b, a, cb)`][`void`][Multiplies `a` by `cb` and stores the result in `b`. The type of `a` shall be listed in one of the type lists
+[[`eval_multiply(b, a, cb)`][`void`][Multiplies `a` by `cb` and stores the result in `b`. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`divide(b, a, cb)`][`void`][Divides `a` by `cb` and stores the result in `b`. The type of `a` shall be listed in one of the type lists
+[[`eval_divide(b, a, cb)`][`void`][Divides `a` by `cb` and stores the result in `b`. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`modulus(b, cb, a)`][`void`][Computes `cb % a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
+[[`eval_modulus(b, cb, a)`][`void`][Computes `cb % a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`bitwise_and(b, cb, a)`][`void`][Computes `cb & a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
+[[`eval_bitwise_and(b, cb, a)`][`void`][Computes `cb & a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`bitwise_or(b, cb, a)`][`void`][Computes `cb | a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
+[[`eval_bitwise_or(b, cb, a)`][`void`][Computes `cb | a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`bitwise_xor(b, cb, a)`][`void`][Computes `cb ^ a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
+[[`eval_bitwise_xor(b, cb, a)`][`void`][Computes `cb ^ a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`modulus(b, a, cb)`][`void`][Computes `cb % a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
+[[`eval_modulus(b, a, cb)`][`void`][Computes `cb % a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`bitwise_and(b, a, cb)`][`void`][Computes `cb & a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
+[[`eval_bitwise_and(b, a, cb)`][`void`][Computes `cb & a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`bitwise_or(b, a, cb)`][`void`][Computes `cb | a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
+[[`eval_bitwise_or(b, a, cb)`][`void`][Computes `cb | a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`bitwise_xor(b, a, cb)`][`void`][Computes `a ^ cb` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
+[[`eval_bitwise_xor(b, a, cb)`][`void`][Computes `a ^ cb` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
`B::signed_types`, `B::unsigned_types` or `B::float_types`.]]
-[[`left_shift(b, cb, ui)`][`void`][Computes `cb << ui` and stores the result in `b`, only required when `B` is an integer type.]]
-[[`right_shift(b, cb, ui)`][`void`][Computes `cb >> ui` and stores the result in `b`, only required when `B` is an integer type.]]
-[[`increment(b)`][void][Increments the value of `b` by one.]]
-[[`decrement(b)`][void][Decrements the value of `b` by one.]]
-[[`is_zero(cb)`][`bool`][Returns `true` if `cb` is zero, otherwise `false`]]
-[[`get_sign(cb)`][`int`][Returns a value < zero if `cb` is negative, a value > zero if `cb` is positive, and zero if `cb` is zero.]]
+[[`eval_left_shift(b, cb, ui)`][`void`][Computes `cb << ui` and stores the result in `b`, only required when `B` is an integer type.]]
+[[`eval_right_shift(b, cb, ui)`][`void`][Computes `cb >> ui` and stores the result in `b`, only required when `B` is an integer type.]]
+[[`eval_increment(b)`][void][Increments the value of `b` by one.]]
+[[`eval_decrement(b)`][void][Decrements the value of `b` by one.]]
+[[`eval_is_zero(cb)`][`bool`][Returns `true` if `cb` is zero, otherwise `false`]]
+[[`eval_get_sign(cb)`][`int`][Returns a value < zero if `cb` is negative, a value > zero if `cb` is positive, and zero if `cb` is zero.]]
[[`eval_abs(b, cb)`][`void`][Set `b` to the absolute value of `cb`.]]
[[`eval_fabs(b, cb)`][`void`][Set `b` to the absolute value of `cb`.]]
[[`eval_fpclassify(cb)`][`int`][Returns one of the same values returned by `std::fpclassify`. Only required when `B` is an floating-point type.]]
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 2012-03-12 05:18:44 EDT (Mon, 12 Mar 2012)
@@ -1049,6 +1049,7 @@
test<boost::multiprecision::cpp_int>();
test<boost::multiprecision::mp_number<boost::multiprecision::cpp_int_backend<256, true, void> > >();
test<boost::multiprecision::mp_number<boost::multiprecision::cpp_int_backend<256, false, void> > >();
+ test<boost::multiprecision::cpp_rational>();
#endif
#ifdef TEST_CPP_INT_BR
test<boost::multiprecision::cpp_rational>();
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