|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54932 - in sandbox/mp_math: boost/mp_math boost/mp_math/integer boost/mp_math/integer/detail boost/mp_math/integer/detail/base libs/mp_math/doc libs/mp_math/doc/html libs/mp_math/doc/html/mp_int libs/mp_math/test libs/mp_math/test/gmp_integer libs/mp_math/test/libtom_integer libs/mp_math/test/unbounded/signed libs/mp_math/test/unbounded/unsigned libs/mp_math/tools/benchmark
From: baraclese_at_[hidden]
Date: 2009-07-13 16:23:26
Author: baraclese
Date: 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
New Revision: 54932
URL: http://svn.boost.org/trac/boost/changeset/54932
Log:
* more test coverage, added libtommath tests
* libtommath backend now depends on a custom modified libtommath library
* many fixes
* added serialization for gmp_integer and libtom_integer
* updated docs
* remove primitive_ops with the word_type template parameter and adjusted all
remaining places where word_type was used
* refactored common stream i/o code into detail/stream_io.hpp
* added multiprecision_integer_tag in order to tag types
* removed rvalue swaps
Added:
sandbox/mp_math/libs/mp_math/doc/integer.qbk
- copied, changed from r54215, /sandbox/mp_math/libs/mp_math/doc/mp_int.qbk
sandbox/mp_math/libs/mp_math/doc/unbounded_int_reference.qbk
- copied, changed from r54215, /sandbox/mp_math/libs/mp_math/doc/mp_int_reference.qbk
sandbox/mp_math/libs/mp_math/doc/unbounded_traits_reference.qbk
- copied, changed from r54215, /sandbox/mp_math/libs/mp_math/doc/mp_int_traits_reference.qbk
sandbox/mp_math/libs/mp_math/doc/uniform_integer_bits_reference.qbk
- copied, changed from r54215, /sandbox/mp_math/libs/mp_math/doc/uniform_mp_int_bits_reference.qbk
sandbox/mp_math/libs/mp_math/doc/uniform_integer_reference.qbk
- copied, changed from r54215, /sandbox/mp_math/libs/mp_math/doc/uniform_mp_int_reference.qbk
sandbox/mp_math/libs/mp_math/test/gmp_integer/integral_ops.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/gmp_integer/prerequisite.hpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/gmp_integer/serialization.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/gmp_integer/to_integral.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/gmp_integer/to_string.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/
sandbox/mp_math/libs/mp_math/test/libtom_integer/abs.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/add.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/assign.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/bitwise_ops.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/bool_conversion.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/ctors.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/gcd.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/jacobi.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/lcm.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/modinv.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/modpow.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/mul.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/pow.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/shift.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/sqr.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/sub.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/libtom_integer/swap.cpp (contents, props changed)
sandbox/mp_math/libs/mp_math/test/unbounded/signed/to_string.cpp
- copied, changed from r54215, /sandbox/mp_math/libs/mp_math/test/unbounded/signed/string_ops.cpp
Removed:
sandbox/mp_math/libs/mp_math/doc/html/mp_int/
sandbox/mp_math/libs/mp_math/doc/mp_int.qbk
sandbox/mp_math/libs/mp_math/doc/mp_int_reference.qbk
sandbox/mp_math/libs/mp_math/doc/mp_int_traits_reference.qbk
sandbox/mp_math/libs/mp_math/doc/uniform_mp_int_bits_reference.qbk
sandbox/mp_math/libs/mp_math/doc/uniform_mp_int_reference.qbk
sandbox/mp_math/libs/mp_math/test/unbounded/signed/string_ops.cpp
Text files modified:
sandbox/mp_math/boost/mp_math/integer/detail/base/bitwise_ops.hpp | 3
sandbox/mp_math/boost/mp_math/integer/detail/base/divider.hpp | 37
sandbox/mp_math/boost/mp_math/integer/detail/base/primitive_ops.hpp | 1390 ++-------------------------------------
sandbox/mp_math/boost/mp_math/integer/detail/base/unbounded_int_integral.hpp | 34
sandbox/mp_math/boost/mp_math/integer/detail/base/unbounded_uint.hpp | 50 -
sandbox/mp_math/boost/mp_math/integer/detail/divider.hpp | 6
sandbox/mp_math/boost/mp_math/integer/detail/jacobi.hpp | 3
sandbox/mp_math/boost/mp_math/integer/detail/modpow.hpp | 4
sandbox/mp_math/boost/mp_math/integer/detail/modular_reduction.hpp | 5
sandbox/mp_math/boost/mp_math/integer/detail/multiplier.hpp | 10
sandbox/mp_math/boost/mp_math/integer/detail/unbounded_int_integral.hpp | 119 ++
sandbox/mp_math/boost/mp_math/integer/gmp_integer.hpp | 340 ++++++++
sandbox/mp_math/boost/mp_math/integer/libtom_integer.hpp | 360 +++++----
sandbox/mp_math/boost/mp_math/integer/prime.hpp | 14
sandbox/mp_math/boost/mp_math/integer/random.hpp | 4
sandbox/mp_math/boost/mp_math/integer/unbounded.hpp | 2
sandbox/mp_math/boost/mp_math/integer/unbounded_int.hpp | 129 --
sandbox/mp_math/boost/mp_math/integer/unbounded_traits.hpp | 95 --
sandbox/mp_math/boost/mp_math/integer/unbounded_uint.hpp | 90 --
sandbox/mp_math/boost/mp_math/integer_serialization.hpp | 56 +
sandbox/mp_math/libs/mp_math/doc/html/index.html | 101 +-
sandbox/mp_math/libs/mp_math/doc/implementation_notes.qbk | 28
sandbox/mp_math/libs/mp_math/doc/integer.qbk | 15
sandbox/mp_math/libs/mp_math/doc/introduction.qbk | 32
sandbox/mp_math/libs/mp_math/doc/jamfile.v2 | 8
sandbox/mp_math/libs/mp_math/doc/primality_tests_reference.qbk | 24
sandbox/mp_math/libs/mp_math/doc/tutorial.qbk | 77 +
sandbox/mp_math/libs/mp_math/doc/unbounded_int_reference.qbk | 717 ++++++++++---------
sandbox/mp_math/libs/mp_math/doc/unbounded_traits_reference.qbk | 10
sandbox/mp_math/libs/mp_math/doc/uniform_integer_bits_reference.qbk | 24
sandbox/mp_math/libs/mp_math/doc/uniform_integer_reference.qbk | 24
sandbox/mp_math/libs/mp_math/test/gmp_integer/modpow.cpp | 9
sandbox/mp_math/libs/mp_math/test/gmp_integer/swap.cpp | 14
sandbox/mp_math/libs/mp_math/test/jamfile.v2 | 10
sandbox/mp_math/libs/mp_math/test/unbounded/signed/ctors.cpp | 33
sandbox/mp_math/libs/mp_math/test/unbounded/signed/integral_ops.cpp | 36
sandbox/mp_math/libs/mp_math/test/unbounded/signed/jamfile.v2 | 2
sandbox/mp_math/libs/mp_math/test/unbounded/signed/modpow.cpp | 9
sandbox/mp_math/libs/mp_math/test/unbounded/signed/prerequisite.hpp | 15
sandbox/mp_math/libs/mp_math/test/unbounded/signed/prime.cpp | 6
sandbox/mp_math/libs/mp_math/test/unbounded/signed/swap.cpp | 14
sandbox/mp_math/libs/mp_math/test/unbounded/signed/to_string.cpp | 16
sandbox/mp_math/libs/mp_math/test/unbounded/unsigned/ctors.cpp | 19
sandbox/mp_math/libs/mp_math/test/unbounded/unsigned/string_ops.cpp | 16
sandbox/mp_math/libs/mp_math/tools/benchmark/jamfile.v2 | 2
45 files changed, 1562 insertions(+), 2450 deletions(-)
Modified: sandbox/mp_math/boost/mp_math/integer/detail/base/bitwise_ops.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/detail/base/bitwise_ops.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/detail/base/bitwise_ops.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -86,6 +86,7 @@
for (; i < x.size() - 1; ++i)
z[i] = ~x[i];
+ // handle last digit
unsigned count = 0;
digit_type bit = digit_type(1) << (ApInt::traits_type::radix_bits - 1);
@@ -94,8 +95,6 @@
{
bit >>= 1;
++count;
- if (count > 40)
- break;
}
else
count = ApInt::traits_type::radix_bits - 1;
Modified: sandbox/mp_math/boost/mp_math/integer/detail/base/divider.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/detail/base/divider.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/detail/base/divider.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -37,7 +37,7 @@
// clear high bits
const digit_type mask =
- (1 << (static_cast<digit_type>(n % traits_type::radix_bits))) - 1;
+ (digit_type(1) << (static_cast<digit_type>(n % traits_type::radix_bits))) - 1;
z[n / traits_type::radix_bits] &= mask;
@@ -60,40 +60,9 @@
template<class ApInt>
inline void divider<ApInt>::divide_by_3(ApInt& z)
{
- typedef typename traits_type::word_type word_type;
+ ApInt::traits_type::ops_type::divide_by_3(z.digits(), z.size());
- // b = 2^radix_bits / 3
- static const word_type b = (word_type(1) << traits_type::radix_bits) / 3;
-
- word_type w = 0;
- for (typename ApInt::reverse_iterator d = z.rbegin(); d != z.rend(); ++d)
- {
- w = (w << static_cast<word_type>(traits_type::radix_bits))
- | static_cast<word_type>(*d);
-
- word_type t;
- if (w >= 3U)
- {
- // multiply w by [1/3]
- t = (w * b) >> static_cast<word_type>(traits_type::radix_bits);
-
- // now subtract 3 * [w/3] from w, to get the remainder
- w -= t+t+t;
-
- // fixup the remainder as required since the optimization is not exact.
- while (w >= 3U)
- {
- t += 1;
- w -= 3;
- }
- }
- else
- t = 0;
-
- *d = static_cast<digit_type>(t);
- }
-
- z.clamp(); // TODO clamp_high_digit should suffice
+ z.clamp_high_digit();
}
Modified: sandbox/mp_math/boost/mp_math/integer/detail/base/primitive_ops.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/detail/base/primitive_ops.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/detail/base/primitive_ops.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -21,1286 +21,6 @@
// this struct contains some basic arithmetic algorithms
// which can be implemented via assembly rather easily
-#ifdef BOOST_MP_MATH_PRIMITIVE_OPS_OLD
-template<typename DigitT, typename WordT, typename SizeT>
-struct basic_primitive_ops
-{
- typedef DigitT digit_type;
- typedef WordT word_type;
- typedef SizeT size_type;
-
- static const word_type digit_bits = std::numeric_limits<digit_type>::digits;
-
- // ADD ------------------------------------
- // z = x + y, returns carry
- static digit_type add(digit_type& z, digit_type x, digit_type y);
- // z += x, returns carry
- static digit_type add(digit_type& z, digit_type x);
- // z += x * y, returns carry
- static digit_type multiply_add(digit_type& z_hi, digit_type& z_lo,
- digit_type x, digit_type y);
- // z = x * y, returns high part of the product
- static digit_type mul(digit_type& z, digit_type x, digit_type y);
-
- // add y to the digits in x and store result in z
- // xlen must be > 0
- // returns: the last carry (it will not get stored in z)
- static digit_type add_single_digit(digit_type* z,
- const digit_type* x, size_type xlen,
- digit_type y);
-
- // z = x + y, returns last carry
- static digit_type add_digits(digit_type* z,
- const digit_type* x,
- const digit_type* y,
- size_type num);
-
- // ripples the carry c up through n digits of x and stores results in z
- // returns the number of digits the carry rippled through and stores the last
- // carry in c. If there isn't a last carry then c will be 0.
- static size_type ripple_carry(digit_type* z,
- const digit_type* x,
- size_type n,
- digit_type& c);
-
- // z = x + y, where xlen >= ylen
- // returns last carry
- static digit_type add_smaller_magnitude(digit_type* z,
- const digit_type* x, size_type xlen,
- const digit_type* y, size_type ylen);
-
- // SUB ------------------------------------
-
- // subtracts x from the digits in y and store result in z
- static void subtract_single_digit(digit_type* z,
- const digit_type* x, size_type xlen,
- digit_type y);
-
- // z = x - y, returns last borrow
- static digit_type subtract_digits(digit_type* z,
- const digit_type* x,
- const digit_type* y,
- size_type num);
-
- // ripples the borrow up through n digits of x and stores results in z
- // returns the number of digits the borrow rippled through
- static size_type ripple_borrow(digit_type* z,
- const digit_type* x,
- size_type n,
- digit_type borrow);
-
- // z = x - y, where x >= y
- static void sub_smaller_magnitude(digit_type* z,
- const digit_type* x, size_type xlen,
- const digit_type* y, size_type ylen);
-
- // MUL ------------------------------------
-
- // multiply y of length ylen with x and store result in z
- // returns: the last carry (it will not get stored in z)
- static digit_type multiply_by_digit(digit_type* z,
- const digit_type* x, size_type xlen,
- digit_type y);
-
- // z = x * 2
- static digit_type multiply_by_two(digit_type* z,
- const digit_type* x, size_type len);
-
- // z = x * y
- static void classic_mul(digit_type* z, const digit_type* x, size_type xlen,
- const digit_type* y, size_type ylen);
-
- // z = x * y; precondition: xlen >= ylen
- static void comba_mul(digit_type* z, const digit_type* x, size_type xlen,
- const digit_type* y, size_type ylen);
-
- // z = x * y; for numbers of the same size
- static void comba_mul(digit_type* z,
- const digit_type* x,
- const digit_type* y, size_type xylen);
-
- // z = x * y; precondition: xlen >= ylen and workspace must have at least ylen
- // digits this function is only used by the integral ops interaction code, it
- // allows x and z to be the same pointer.
- static void comba_mul(digit_type* z, const digit_type* x, size_type xlen,
- const digit_type* y, size_type ylen,
- digit_type* workspace);
-
- // computes the lower num digits of the product of x and y
- static void comba_mul_lo(digit_type* z, const digit_type* x, size_type xlen,
- const digit_type* y, size_type ylen,
- size_type num);
-
- // computes the high product of x and y without num least significant digits
- // basically the result is: z = (x*y) >> radix^num
- static void comba_mul_hi(digit_type* z, const digit_type* x, size_type xlen,
- const digit_type* y, size_type ylen,
- size_type num);
-
- // SQR ------------------------------------
-
- // z = x * x;
- static void comba_sqr(digit_type* z, const digit_type* x, size_type xlen);
-
- // MADD ------------------------------------
-
- // z = z + x * y
- static digit_type multiply_add_digits(digit_type* z,
- const digit_type* x,
- digit_type y,
- size_type n);
-
- // DIV -------------------------------------
-
- // z = x / 2
- static void divide_by_two(digit_type* z, const digit_type* x, size_type len);
-
- // z = x / y
- // returns remainder
- static digit_type divide_by_digit(digit_type* z,
- const digit_type* x, size_type xlen,
- digit_type y);
-
- // q = x/y, r = x%y; workspace must have length of ylen + 1
- static void divide(digit_type* q, digit_type* r,
- const digit_type* x, size_type xlen,
- const digit_type* y, size_type ylen,
- digit_type* workspace);
-
- // SHIFT -----------------------------------
-
- // shifts x by n bits to the left, where n > 0 && n < digit_bits
- // returns carry
- static digit_type shift_bits_left(digit_type* x, size_type xlen, size_type n);
-
- // shifts x by n bits to the right, where n > 0 && n < digit_bits
- static void shift_bits_right(digit_type* x, size_type xlen, size_type n);
-
- // CMP -------------------------------------
-
- // returns 1 if x > y
- // returns 0 if x == y
- // returns -1 if x < y
- static int compare_magnitude(const digit_type* x, size_type xlen,
- const digit_type* y, size_type ylen);
-};
-
-
-
-template<typename D, typename W, typename S>
-inline
-D basic_primitive_ops<D,W,S>::add(digit_type& z, digit_type x, digit_type y)
-{
- z = x + y;
- return z < x;
-}
-
-template<typename D, typename W, typename S>
-inline
-D basic_primitive_ops<D,W,S>::add(digit_type& z, digit_type x)
-{
- z += x;
- return z < x;
-}
-
-template<typename D, typename W, typename S>
-inline
-D basic_primitive_ops<D,W,S>::multiply_add(digit_type& z_hi, digit_type& z_lo,
- digit_type x, digit_type y)
-{
- static const digit_type lo_mask = (1 << digit_bits / 2) - 1;
-
- const digit_type x_lo = x & lo_mask;
- const digit_type x_hi = x >> digit_bits/2;
- const digit_type y_lo = y & lo_mask;
- const digit_type y_hi = y >> digit_bits/2;
-
- const digit_type z0 = x_lo * y_lo;
- const digit_type z1 = x_lo * y_hi;
- const digit_type z2 = x_hi * y_lo;
- const digit_type z3 = x_hi * y_hi;
-
- digit_type z12 = z1 + (z0 >> digit_bits/2);
- const digit_type carry = add(z12, z2);
-
- const digit_type w_lo = (z12 << digit_bits/2) + (z0 & lo_mask);
- const digit_type w_hi = z3 + (carry << digit_bits/2) + (z12 >> digit_bits/2);
-
- digit_type u = add(z_lo, w_lo);
- digit_type v = add(z_hi, u);
-
- return v + add(z_hi, w_hi);
-}
-
-template<typename D, typename W, typename S>
-inline
-D basic_primitive_ops<D,W,S>::mul(digit_type& z_lo, digit_type x, digit_type y)
-{
- static const digit_type lo_mask = (1 << digit_bits / 2) - 1;
- static const digit_type hi_mask = lo_mask << (digit_bits / 2);
-
- const digit_type x_lo = x & lo_mask;
- const digit_type x_hi = x & hi_mask;
- const digit_type y_lo = y & lo_mask;
- const digit_type y_hi = y & hi_mask;
-
- // do a normal school multiplication on the 'half digits'
- const digit_type z0 = x_lo * y_lo;
- const digit_type z1 = x_lo * y_hi;
- const digit_type z2 = x_hi * y_lo;
- const digit_type z3 = x_hi * y_hi;
-
- digit_type z12 = z1 + (z0 & hi_mask);
- const digit_type carry = add(z12, z2);
-
- z_lo = (z12 << digit_bits/2) | (z0 & lo_mask);
-
- const digit_type z_hi = z3 + (carry << digit_bits/2) + (z12 & hi_mask);
-
- return z_hi;
-}
-
-//////////////////////////////////////////////////////////////
-template<typename D, typename W, typename S>
-inline
-D basic_primitive_ops<D,W,S>::add_single_digit(digit_type* z,
- const digit_type* x,
- size_type xlen,
- digit_type y)
-{
- word_type carry = static_cast<word_type>(*x++) + y;
- *z++ = static_cast<digit_type>(carry);
- carry >>= digit_bits;
-
- while (carry && --xlen)
- {
- carry += static_cast<word_type>(*x++);
- *z++ = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
-
- return static_cast<digit_type>(carry);
-}
-
-
-template<typename D, typename W, typename S>
-inline
-D basic_primitive_ops<D,W,S>::add_digits(digit_type* z,
- const digit_type* x,
- const digit_type* y, size_type n)
-{
- word_type carry = 0;
-
- while (n--)
- {
- carry += static_cast<word_type>(*x++) + static_cast<word_type>(*y++);
- *z++ = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
-
- return static_cast<digit_type>(carry);
-}
-
-template<typename D, typename W, typename S>
-inline
-S basic_primitive_ops<D,W,S>::ripple_carry(digit_type* z,
- const digit_type* x,
- size_type n,
- digit_type& carry)
-{
- word_type c = carry;
- size_type i = 0;
-
- for (; c && (i < n); ++i)
- {
- c += static_cast<word_type>(*x++);
- *z++ = static_cast<digit_type>(c);
- c >>= digit_bits;
- }
-
- carry = static_cast<digit_type>(c);
-
- return i;
-}
-
-template<typename D, typename W, typename S>
-inline
-D basic_primitive_ops<D,W,S>::add_smaller_magnitude(digit_type* z,
- const digit_type* x,
- size_type xlen,
- const digit_type* y,
- size_type ylen)
-{
- digit_type carry = add_digits(z, x, y, ylen);
-
- size_type n = ripple_carry(z + ylen, x + ylen, xlen - ylen, carry);
-
- n += ylen;
-
- if (n < xlen && z != x)
- std::memcpy(z + n, x + n, sizeof(digit_type) * (xlen - n));
-
- return carry;
-}
-
-template<typename D, typename W, typename S>
-inline
-void
-basic_primitive_ops<D,W,S>::subtract_single_digit(digit_type* z,
- const digit_type* y,
- size_type ylen,
- digit_type x)
-{
- word_type borrow = static_cast<word_type>(*y++) - x;
- *z++ = static_cast<digit_type>(borrow);
- borrow >>= static_cast<word_type>(std::numeric_limits<word_type>::digits - 1);
-
- while (borrow && --ylen)
- {
- borrow = static_cast<word_type>(*y++) - borrow;
- *z++ = static_cast<digit_type>(borrow);
- borrow >>= static_cast<word_type>(std::numeric_limits<word_type>::digits - 1);
- }
-}
-
-template<typename D, typename W, typename S>
-inline
-D basic_primitive_ops<D,W,S>::subtract_digits(digit_type* z,
- const digit_type* x,
- const digit_type* y,
- size_type n)
-{
- word_type borrow = 0;
-
- while (n--)
- {
- borrow = static_cast<word_type>(*x++) - static_cast<word_type>(*y++) - borrow;
- *z++ = static_cast<digit_type>(borrow);
- borrow >>= std::numeric_limits<word_type>::digits - 1;
- }
-
- return static_cast<digit_type>(borrow);
-}
-
-template<typename D, typename W, typename S>
-inline
-S basic_primitive_ops<D,W,S>::ripple_borrow(digit_type* z,
- const digit_type* x,
- size_type n,
- digit_type borrow)
-{
- word_type b = borrow;
- size_type i = 0;
- for (; b && (i < n); ++i)
- {
- b = static_cast<word_type>(*x++) - b;
- *z++ = static_cast<digit_type>(b);
- b >>= std::numeric_limits<word_type>::digits - 1;
- }
-
- return i;
-}
-
-template<typename D, typename W, typename S>
-inline
-void basic_primitive_ops<D,W,S>::sub_smaller_magnitude(
- digit_type* z,
- const digit_type* x, size_type xlen,
- const digit_type* y, size_type ylen)
-{
- const digit_type borrow = subtract_digits(z, x, y, ylen);
-
- size_type n = ripple_borrow(z + ylen, x + ylen, xlen - ylen, borrow);
-
- if (z != x)
- {
- n += ylen;
- std::memcpy(z + n, x + n, (xlen - n) * sizeof(digit_type));
- }
-}
-
-template<typename D, typename W, typename S>
-inline
-D basic_primitive_ops<D,W,S>::multiply_by_digit(digit_type* z,
- const digit_type* y,
- size_type ylen,
- digit_type x)
-{
- digit_type carry = 0;
-
- while (ylen--)
- {
- const word_type tmp = static_cast<word_type>(carry)
- + static_cast<word_type>(*y++)
- * static_cast<word_type>(x);
- *z++ = static_cast<digit_type>(tmp);
- carry = static_cast<digit_type>(tmp >> digit_bits);
- }
-
- return carry;
-}
-
-template<typename D, typename W, typename S>
-inline
-D basic_primitive_ops<D,W,S>::multiply_by_two(digit_type* z,
- const digit_type* x, size_type n)
-{
- static const digit_type one = 1U;
-
- digit_type carry = 0;
-
- while (n--)
- {
- // get carry bit for next iteration
- const digit_type r = *x >> (static_cast<digit_type>(digit_bits) - one);
-
- *z++ = (*x++ << one) | carry;
-
- carry = r;
- }
-
- return carry;
-}
-
-template<typename D, typename W, typename S>
-void
-basic_primitive_ops<D,W,S>::classic_mul(
- digit_type* z, const digit_type* x, size_type xlen,
- const digit_type* y, size_type ylen)
-{
- // phase 1
- word_type tmp = static_cast<word_type>(x[0]) * static_cast<word_type>(y[0]);
- z[0] = static_cast<digit_type>(tmp);
-
- for (size_type i = 1; i < xlen; ++i)
- {
- tmp = (tmp >> digit_bits)
- + static_cast<word_type>(x[i])
- * static_cast<word_type>(y[0]);
- z[i] = static_cast<digit_type>(tmp);
- }
-
- tmp >>= digit_bits;
- z[xlen] = static_cast<digit_type>(tmp);
-
- // phase 2
- for (size_type i = 1; i < ylen; ++i)
- {
- tmp = static_cast<word_type>(y[i])
- * static_cast<word_type>(x[0])
- + static_cast<word_type>(z[i]);
- z[i] = static_cast<digit_type>(tmp);
-
- for (size_type j = 1; j < xlen; ++j)
- {
- tmp = (tmp >> digit_bits)
- + static_cast<word_type>(y[i]) * static_cast<word_type>(x[j])
- + static_cast<word_type>(z[i+j]);
- z[i+j] = static_cast<digit_type>(tmp);
- }
-
- tmp >>= digit_bits;
- z[i + xlen] = static_cast<digit_type>(tmp);
- }
-}
-
-
-// K = 2 ^ (alpha - (2*beta-1))
-// alpha = num bits of word_type, beta = num bits of digit_type
-// calculation works in 3 phases
-// 65432
-// x 223
-//----------------------------------
-// | 18 15 | 12 9 6
-// 12 | 10 8 | 6 4
-// 12 10 | 8 6 | 4
-// | |
-// phase: 3 | 2 | 1
-//
-// TODO handle too long columns => carry may overflow. This can happen if
-// digit_type is 8bit; in that case delegate to classic_mul routine in
-// operator *= (). Just check if (smaller number).used_ >= overflow_count.
-template<typename D, typename W, typename S>
-void
-basic_primitive_ops<D,W,S>::comba_mul(digit_type* z,
- const digit_type* x, size_type xlen,
- const digit_type* y, size_type ylen)
-{
- assert(xlen >= ylen);
-
- // instead of initializing acc and carry with zero and entering the loop below
- // we manually calculate the first low digit of the result here
- // acc is the accumulator for each column
- word_type acc = static_cast<word_type>(*x) * static_cast<word_type>(*y++);
- word_type carry = acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
-
- // phase 1
- for (size_type i = 1; i < ylen; ++i)
- {
- for (size_type j = 0; j <= i; ++j)
- {
- acc += static_cast<word_type>(*x++) * static_cast<word_type>(*y--);
- carry += acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- }
-
- x -= i + 1;
- y += i + 2;
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
-
- // phase 2
- --y; // now y is at index ylen - 1
- for (size_type i = 0; i < xlen - ylen; ++i)
- {
- ++x;
-
- for (size_type j = 0; j < ylen; ++j)
- {
- acc += static_cast<word_type>(*x++) * static_cast<word_type>(*y--);
- carry += acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- }
-
- x -= ylen;
- y += ylen;
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
-
- // phase 3
- for (size_type i = 0; i < ylen - 1; ++i)
- {
- ++x;
-
- for (size_type j = i + 1; j < ylen; ++j)
- {
- acc += static_cast<word_type>(*x++) * static_cast<word_type>(*y--);
- carry += acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- }
-
- x -= ylen - 1 - i;
- y += ylen - 1 - i;
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
-
- *z = static_cast<digit_type>(acc);
-}
-
-template<typename D, typename W, typename S>
-void
-basic_primitive_ops<D,W,S>::comba_mul(digit_type* z,
- const digit_type* x,
- const digit_type* y, size_type xylen)
-{
- // phase 1
- // instead of initializing acc and carry with zero and entering the loop below
- // we manually calculate the first low digit of the result here
- word_type acc = static_cast<word_type>(*x) * static_cast<word_type>(*y++);
- word_type carry = acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
-
- for (size_type i = 1; i < xylen; ++i)
- {
- for (size_type j = 0; j <= i; ++j)
- {
- acc += static_cast<word_type>(*x++) * static_cast<word_type>(*y--);
- carry += acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- }
-
- x -= i + 1;
- y += i + 2;
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
- --y;
- // phase 2
- while (--xylen)
- {
- ++x;
- for (size_type j = 0; j < xylen; ++j)
- {
- acc += static_cast<word_type>(*x++) * static_cast<word_type>(*y--);
- carry += acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- }
-
- x -= xylen;
- y += xylen;
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
-
- *z = static_cast<digit_type>(acc);
-}
-
-template<typename D, typename W, typename S>
-void
-basic_primitive_ops<D,W,S>::comba_mul(digit_type* z,
- const digit_type* x, size_type xlen,
- const digit_type* y, size_type ylen,
- digit_type* workspace)
-{
- assert(xlen >= ylen);
-
- digit_type* w = workspace;
- word_type acc = 0; // accumulator for each column
- word_type carry = 0;
-
- // phase 1
- for (size_type i = 0; i < ylen; ++i)
- {
- const digit_type* a = x;
- const digit_type* b = y + i;
-
- for (size_type j = 0; j <= i; ++j)
- {
- acc += static_cast<word_type>(*a++) * static_cast<word_type>(*b--);
- carry += acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- }
-
- *w++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
-
- w -= ylen;
-
- // phase 2
- for (size_type i = 0; i < xlen - ylen; ++i)
- {
- const digit_type* a = x + 1 + i;
- const digit_type* b = y + ylen - 1;
-
- for (size_type j = 0; j < ylen; ++j)
- {
- acc += static_cast<word_type>(*a++) * static_cast<word_type>(*b--);
- carry += acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- }
-
- *z++ = *w;
- *w++ = static_cast<digit_type>(acc);
-
- if (static_cast<size_type>(w - workspace) == ylen)
- w -= ylen;
-
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
-
- // phase 3
- for (size_type i = 0; i < ylen - 1; ++i)
- {
- const digit_type* a = x + xlen - (ylen - 1);
- const digit_type* b = y + ylen - 1;
-
- for (size_type j = i + 1; j < ylen; ++j)
- {
- acc += static_cast<word_type>(*a++) * static_cast<word_type>(*b--);
- carry += acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- }
-
- *z++ = *w;
- *w++ = static_cast<digit_type>(acc);
-
- if (static_cast<size_type>(w - workspace) == ylen)
- w -= ylen;
-
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
-
- const digit_type* ws_index = w;
-
- while (w < (workspace + ylen))
- *z++ = *w++;
-
- w = workspace;
-
- while (w < ws_index)
- *z++ = *w++;
-
- *z = static_cast<digit_type>(acc);
-}
-
-template<typename D, typename W, typename S>
-void
-basic_primitive_ops<D,W,S>::comba_mul_lo(digit_type* z,
- const digit_type* x, size_type xlen,
- const digit_type* y, size_type ylen,
- size_type num)
-{
- //assert(xlen >= ylen);
- assert(num <= (xlen + ylen));
-
- word_type acc = 0; // accumulator for each column
- word_type carry = 0;
-
- // phase 1
- if (num)
- {
- const size_type m = ylen < num ? ylen : num;
- for (size_type i = 0; i < m; ++i)
- {
- const digit_type* a = x;
- const digit_type* b = y + i;
-
- for (size_type j = 0; j <= i; ++j)
- {
- acc += static_cast<word_type>(*a++) * static_cast<word_type>(*b--);
- carry += acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- }
-
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
- }
-
- // phase 2
- if (num >= ylen)
- {
- const size_type m = xlen - ylen < num ? xlen - ylen : num;
- for (size_type i = 0; i < m; ++i)
- {
- const digit_type* a = x + 1 + i;
- const digit_type* b = y + ylen - 1;
-
- for (size_type j = 0; j < ylen; ++j)
- {
- acc += static_cast<word_type>(*a++) * static_cast<word_type>(*b--);
- carry += acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- }
-
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
- }
-
- // phase 3
- if (num >= xlen + ylen)
- {
- const size_type m = ylen - 1 < num ? ylen - 1 : num;
- for (size_type i = 0; i < m; ++i)
- {
- const digit_type* a = x + xlen - (ylen - 1);
- const digit_type* b = y + ylen - 1;
-
- for (size_type j = i + 1; j < ylen; ++j)
- {
- acc += static_cast<word_type>(*a++) * static_cast<word_type>(*b--);
- carry += acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- }
-
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
- }
-
- *z = static_cast<digit_type>(acc);
-}
-
-template<typename D, typename W, typename S>
-void
-basic_primitive_ops<D,W,S>::comba_mul_hi(digit_type* z,
- const digit_type* x, size_type xlen,
- const digit_type* y, size_type ylen,
- size_type num)
-{
- //assert(xlen >= ylen);
- assert(num > 0);
- assert(num < (xlen + ylen));
-
- word_type acc = 0; // accumulator for each column
- word_type carry = 0;
-
- // phase 1
- if (num < ylen)
- {
- for (size_type i = num; i < ylen; ++i)
- {
- const digit_type* a = x;
- const digit_type* b = y + i;
-
- for (size_type j = 0; j <= i; ++j)
- {
- acc += static_cast<word_type>(*a++) * static_cast<word_type>(*b--);
- carry += acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- }
-
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
- }
-
- // phase 2
- if (num < xlen)
- {
- for (size_type i = num - ylen; i < xlen - ylen; ++i)
- {
- const digit_type* a = x + 1 + i;
- const digit_type* b = y + ylen - 1;
-
- for (size_type j = 0; j < ylen; ++j)
- {
- acc += static_cast<word_type>(*a++) * static_cast<word_type>(*b--);
- carry += acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- }
-
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
- }
-
- // phase 3
- if (num < (xlen + ylen))
- {
- for (size_type i = num - (xlen + ylen); i < ylen - 1; ++i)
- {
- const digit_type* a = x + xlen - (ylen - 1);
- const digit_type* b = y + ylen - 1;
-
- for (size_type j = i + 1; j < ylen; ++j)
- {
- acc += static_cast<word_type>(*a++) * static_cast<word_type>(*b--);
- carry += acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- }
-
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
- }
-
- *z = static_cast<digit_type>(acc);
-}
-
-template<typename D, typename W, typename S>
-void
-basic_primitive_ops<D,W,S>::comba_sqr(digit_type* z,
- const digit_type* x,
- size_type xlen)
-{
-/* word_type acc = 0;
- word_type carry = 0;
- word_type acc2;
-
- for (size_type i = 0; i < xlen; ++i)
- {
- // even colum
- acc += static_cast<word_type>(x[i]) * static_cast<word_type>(x[i]);
-
- const digit_type* a = x + i;
- const digit_type* b = x + i;
-
- acc2 = 0;
- for (size_type j = 0; j < (i - n&1) >> 1; ++j)
- {
- acc2 += static_cast<word_type>(*(--a)) * static_cast<word_type>(*(--b));
- carry += acc2 >> digit_bits;
- acc2 = static_cast<digit_type>(acc2);
- }
-
- acc += acc2 + acc2;
-
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
-
- // odd column
- const digit_type* a = x + i;
- const digit_type* b = x + i + 1;
-
- acc2 = 0;
- for (size_type j = 0; j <= i; ++j)
- {
- acc2 += static_cast<word_type>(*a++) * static_cast<word_type>(*b--);
- carry += acc2 >> digit_bits;
- acc2 = static_cast<digit_type>(acc2);
- }
-
- acc += acc2 + acc2;
-
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
-
- *z = static_cast<digit_type>(acc);*/
-
- word_type acc = 0; // accumulator for each column
- word_type carry = 0;
-
- // phase 1
- for (size_type i = 0; i < xlen; ++i)
- {
- const digit_type* a = x;
- const digit_type* b = x + i;
-
- for (size_type j = 0; j <= i; ++j)
- {
- acc += static_cast<word_type>(*a++) * static_cast<word_type>(*b--);
- carry += acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- }
-
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
-
- // phase 2
- for (size_type i = 1; i < xlen; ++i)
- {
- const digit_type* a = x + i;
- const digit_type* b = x + xlen - 1;
-
- for (size_type j = 0; j < xlen - i; ++j)
- {
- acc += static_cast<word_type>(*a++) * static_cast<word_type>(*b--);
- carry += acc >> digit_bits;
- acc = static_cast<digit_type>(acc);
- }
-
- *z++ = static_cast<digit_type>(acc);
- acc = static_cast<digit_type>(carry);
- carry >>= digit_bits;
- }
-
- *z = static_cast<digit_type>(acc);
-}
-
-template<typename D, typename W, typename S>
-D basic_primitive_ops<D,W,S>::multiply_add_digits(digit_type* z,
- const digit_type* x,
- digit_type y,
- size_type n)
-{
- digit_type carry = 0;
- while (n--)
- {
- const word_type r = static_cast<word_type>(*z)
- + static_cast<word_type>(*x)
- * static_cast<word_type>(y)
- + static_cast<word_type>(carry);
-
- *z = static_cast<digit_type>(r);
- carry = static_cast<digit_type>(r >> digit_bits);
- ++z;
- ++x;
- }
-
- return carry;
-}
-
-
-template<typename D, typename W, typename S>
-inline
-void basic_primitive_ops<D,W,S>::divide_by_two(digit_type* z,
- const digit_type* x, size_type n)
-{
- z += n - 1;
- x += n - 1;
-
- digit_type carry = 0;
-
- while (n--)
- {
- // get carry for next iteration
- const digit_type r = *x & 1;
-
- *z-- = (*x-- >> 1) | (carry << (digit_bits - 1));
-
- carry = r;
- }
-}
-/*
-// divides half digits [x1, x2, x3] by [y1, y2] and returns remainder
-template<typename D, typename W, typename S>
-D basic_primitive_ops<D,W,S>::divide_half_digits(
- digit_type& q,
- digit_type x12, digit_type x3,
- digit_type y1, digit_type y2)
-{
- q = x12 / y1;
- const digit_type c = x12 - q * y1;
- const digit_type D = q * y2;
-
- digit_type R = (c << digit_bits / 2) | x3;
-
- if (R < D) // R is too large by at most 2
- {
- const digit_type y = (y1 << digit_bits / 2) | y2;
- --q;
- R += y;
- if (R < D)
- {
- --q;
- R += y;
- }
- }
-
- return R - D;
-}
-
-// divide two digit number x by one digit number y
-// returns remainder
-// q = x / y , r = x % y
-template<typename D, typename W, typename S>
-D basic_primitive_ops<D,W,S>::divide(digit_type& q,
- digit_type x_hi, digit_type x_lo,
- digit_type y)
-{
- static const digit_type lo_mask = (1 << digit_bits / 2) - 1;
- static const digit_type hi_mask = lo_mask << (digit_bits / 2);
-
- digit_type q1, q2;
- const digit_type r = divide_half_digits(q1, x_hi, x_lo & hi_mask,
- y & hi_mask, y & lo_mask);
- const digit_type s = divide_half_digits(q2, r, x_lo & lo_mask,
- y & hi_mask, y & lo_mask);
- q = (q1 << digit_bits / 2) & q2;
- return s;
-}*/
-
-template<typename D, typename W, typename S>
-D basic_primitive_ops<D,W,S>::divide_by_digit(digit_type* z,
- const digit_type* x, size_type n,
- digit_type y)
-{
-/* z += n - 1;
- x += n - 1;
-
- while (n--)
- {
- if ()
- }*/
-
- z += n - 1;
- x += n - 1;
-
- word_type w = 0;
-
- while (n--)
- {
- w = (w << digit_bits) | static_cast<word_type>(*x--);
- //this turned out to be slower:
- //const digit_type q = static_cast<digit_type>(w / y);
- //w -= q * y;
- //*z-- = q;
- digit_type q;
- if (w >= y)
- {
- q = static_cast<digit_type>(w / y);
- w -= q * y;
- }
- else
- q = 0;
- *z-- = q;
- }
-
- return static_cast<digit_type>(w);
-}
-
-// This is basically a Knuth division with the difference that we form the trial
-// quotient by using a 3 digit by 2 digit division instead of a 2 by 1. This has
-// the effect of limiting the error in q_hat to 1 instead of 2.
-/*template<typename D, typename W, typename S>
-void basic_primitive_ops<D,W,S>::divide(digit_type* q, digit_type* r,
- const digit_type* x, size_type xlen,
- const digit_type* y, size_type ylen,
- digit_type* ws)
-{
- assert(xlen >= 3);
- assert(ylen >= 2);
-
- if (y[ylen-1] & (1 << (digit_bits-1))) // if y is already normalized
- {
- digit_type q_estimate =
- div3by2(x[xlen - 1], x[xlen - 2], x[xlen - 3],
- y[ylen - 1], y[ylen - 2]);
-
- // multiply subtract in place
- digit_type* ws_ptr = ws;
- digit_type borrow = 0;
- for (size_type i = 0; i < ylen; ++i)
- {
- const word_type tmp = static_cast<word_type>(*y++)
- * static_cast<word_type>(q_estimate);
- *ws_ptr++ = x_ptr - static_cast<digit_type>(tmp);
- borrow = static_cast<digit_type>(tmp >> digit_bits);
- }
-
- return borrow;
- }
- else
- {
- //count leading zero bits
- norm = 1;
-
- // store normalized y at ws[0] and normalized x at ws[ylen]
- digit_type q_estimate =
- div3by2(ws[xlen - 1], ws[xlen - 2], ws[xlen - 3],
- ws[ylen - 1], ws[ylen - 2]);
- }
-
-
- // TODO normalize in place or store normalized y at ws and let wslen be
- // ylen * 2 + 1.
-
- const digit_type* x_beg = x;
- x += xlen - 3;
-
- digit_type q_hat = div3by2(x, y + ylen - 2);
- *(ws + ylen) = multiply_by_digit(ws, y, ylen, q_hat);
-
- const digit_type borrow = subtract_digits(ws, x, ws, ylen + 1);
- if (borrow)
- {
- ++q_hat;
- add_digits(ws, ws, y, ylen);
- }
-
- *q++ = q_hat;
- --x;
-
- ++ws;
-
- // TODO need to multiply_subtract otherwise I'd need a second buffer to hold
- // the result of multiply_by_digit
- while (x != x_beg)
- {
- digit_type q_hat = div3by2(ws, y + ylen - 2);
- *(ws + ylen) = multiply_by_digit(ws, y, ylen, q_hat);
-
- const digit_type borrow = subtract_digits(ws, x, ws, ylen + 1);
- if (borrow)
- {
- ++q_hat;
- add_digits(ws, ws, y, ylen);
- }
-
- *q++ = q_hat;
- --x;
- *(ws - 1) = *x;
- }
-}*/
-
-template<typename D, typename W, typename S>
-D basic_primitive_ops<D,W,S>::shift_bits_left(digit_type* x,
- size_type xlen,
- size_type n)
-{
- assert(n > 0 && n < digit_bits);
-
- // shift for msbs
- const digit_type shift = digit_bits - n;
-
- digit_type carry = 0;
- while (xlen--)
- {
- const digit_type c = (*x >> shift);
- *x = (*x << n) | carry;
- carry = c;
- ++x;
- }
-
- return carry;
-}
-
-template<typename D, typename W, typename S>
-void basic_primitive_ops<D,W,S>::shift_bits_right(digit_type* x,
- size_type xlen,
- size_type n)
-{
- assert(n > 0 && n < digit_bits);
-
- const digit_type mask = (digit_type(1) << n) - 1;
-
- // shift for lsb
- const digit_type shift = digit_bits - n;
-
- x += xlen;
-
- digit_type carry = 0;
- while (xlen--)
- {
- --x;
- const digit_type c = *x & mask;
- *x = (*x >> n) | (carry << shift);
- carry = c;
- }
-}
-
-template<typename D, typename W, typename S>
-int basic_primitive_ops<D,W,S>::compare_magnitude(const digit_type* x,
- size_type xlen,
- const digit_type* y,
- size_type ylen)
-{
- if (xlen > ylen)
- return 1;
-
- if (xlen < ylen)
- return -1;
-
- // compare all digits
- x += xlen;
- y += ylen;
- while (xlen--)
- {
- --x; --y;
- if (*x > *y)
- return 1;
- if (*x < *y)
- return -1;
- }
-
- return 0;
-}
-
-
-// This exists to ease development of primitive_ops specializations. If a
-// specialized function isn't available yet, the compiler will just choose the
-// inherited one. It also means that whenever we add a new function to
-// basic_primitive_ops no code will break since it will be available to all
-// specializations as well.
-template<typename D, typename W, typename S>
-struct primitive_ops : basic_primitive_ops<D,W,S>
-{};
-
-
-#else
-
template<typename DigitT, typename SizeT>
struct basic_primitive_ops
{
@@ -1447,6 +167,10 @@
// DIV -------------------------------------
+ // q = x / y
+ static void div2by1(digit_type& q,
+ digit_type x_hi, digit_type x_lo, digit_type y);
+
// z = x / 2
static void divide_by_two(digit_type* z, const digit_type* x, size_type len);
@@ -1456,6 +180,8 @@
const digit_type* x, size_type xlen,
digit_type y);
+ static void divide_by_3(digit_type* z, size_type len);
+
// SHIFT -----------------------------------
// shifts x by n bits to the left, where n > 0 && n < digit_bits
@@ -1654,7 +380,7 @@
inline
D basic_primitive_ops<D,S>::mul(digit_type& z_lo, digit_type x, digit_type y)
{
- static const digit_type lo_mask = (1 << digit_bits / 2) - 1;
+ static const digit_type lo_mask = (digit_type(1) << digit_bits / 2) - 1;
const digit_type x_lo = x & lo_mask;
const digit_type x_hi = x >> digit_bits/2;
@@ -1707,16 +433,14 @@
D basic_primitive_ops<D,S>::multiply_by_two(digit_type* z,
const digit_type* x, size_type n)
{
- static const digit_type one = 1U;
-
digit_type carry = 0;
while (n--)
{
// get carry bit for next iteration
- const digit_type r = *x >> (digit_bits - one);
+ const digit_type r = *x >> (digit_bits - 1);
- *z++ = (*x++ << one) | carry;
+ *z++ = (*x++ << 1) | carry;
carry = r;
}
@@ -1974,7 +698,7 @@
const digit_type* y, size_type ylen,
size_type num)
{
- //assert(xlen >= ylen);
+ assert(xlen >= ylen);
assert(num <= (xlen + ylen));
digit_type acc_hi = 0; // accumulator for each column
@@ -2204,7 +928,7 @@
D basic_primitive_ops<D,S>::multiply_add(digit_type& z_hi, digit_type& z_lo,
digit_type x, digit_type y)
{
- static const digit_type lo_mask = (1 << digit_bits / 2) - 1;
+ static const digit_type lo_mask = (digit_type(1) << digit_bits / 2) - 1;
const digit_type x_lo = x & lo_mask;
const digit_type x_hi = x >> digit_bits/2;
@@ -2233,7 +957,7 @@
D basic_primitive_ops<D,S>::multiply_add(digit_type& z,
digit_type x, digit_type y)
{
- static const digit_type lo_mask = (1 << digit_bits / 2) - 1;
+ static const digit_type lo_mask = (digit_type(1) << digit_bits / 2) - 1;
const digit_type x_lo = x & lo_mask;
const digit_type x_hi = x >> digit_bits/2;
@@ -2274,6 +998,82 @@
}
template<typename D, typename S>
+void basic_primitive_ops<D,S>::div2by1(digit_type& q,
+ digit_type x_hi, digit_type x_lo,
+ digit_type y)
+{
+ static const digit_type lo_mask = (digit_type(1) << digit_bits / 2) - 1;
+ static const digit_type hi_mask = lo_mask << (digit_bits / 2);
+ static const digit_type hi_bit = digit_type(1) << (digit_bits - 1);
+ static const digit_type d2 = digit_bits / 2;
+
+ if (x_hi || x_lo >= y) // if x >= y
+ {
+ if (y & hi_bit) // if y is normalized
+ {
+ digit_type q_hi, q_lo;
+ const digit_type rem = divide_half_digits(
+ q_hi,
+ x_hi, (x_lo & hi_mask) >> d2,
+ (y & hi_mask) >> d2, y & lo_mask);
+
+ divide_half_digits(
+ q_lo,
+ rem, x_lo & lo_mask,
+ (y & hi_mask) >> d2, y & lo_mask);
+
+ if (x_hi >= y)
+ ++q_lo;
+
+ q = (q_hi << d2) | q_lo;
+ }
+ else
+ {
+ // count leading zeros
+ unsigned norm = 0;
+ while (!(y & hi_bit))
+ {
+ ++norm;
+ y <<= 1;
+ }
+
+ // normalize the number
+ const digit_type shift = digit_bits - norm;
+
+ digit_type w_hi, w_lo;
+
+ w_hi = x_hi >> shift;
+ if (w_hi)
+ w_lo = (x_hi << norm) | (x_lo >> shift);
+ else
+ {
+ w_hi = (x_hi << norm) | (x_lo >> shift);
+ w_lo = x_lo << norm;
+ }
+
+ // Do a 2 digit by 1 digit division -> [w_hi, w_lo] / y
+ digit_type q_hi, q_lo;
+ const digit_type rem = divide_half_digits(
+ q_hi,
+ w_hi, (w_lo & hi_mask) >> d2,
+ (y & hi_mask) >> d2, y & lo_mask);
+
+ divide_half_digits(
+ q_lo,
+ rem, w_lo & lo_mask,
+ (y & hi_mask) >> d2, y & lo_mask);
+
+ if (w_hi >= y)
+ ++q_lo;
+
+ q = (q_hi << d2) | q_lo;
+ }
+ }
+ else
+ q = 0;
+}
+
+template<typename D, typename S>
inline
void basic_primitive_ops<D,S>::divide_by_two(digit_type* z,
const digit_type* x, size_type n)
@@ -2304,9 +1104,9 @@
*z = *x / y;
return *x % y;
}*/
- static const digit_type lo_mask = (1 << digit_bits / 2) - 1;
+ static const digit_type lo_mask = (digit_type(1) << digit_bits / 2) - 1;
static const digit_type hi_mask = lo_mask << (digit_bits / 2);
- static const digit_type hi_bit = 1 << (digit_bits - 1);
+ static const digit_type hi_bit = digit_type(1) << (digit_bits - 1);
static const digit_type d2 = digit_bits / 2;
z += n - 1;
@@ -2437,6 +1237,12 @@
}
template<typename D, typename S>
+void basic_primitive_ops<D,S>::divide_by_3(digit_type* z, size_type len)
+{
+ divide_by_digit(z, z, len, 3);
+}
+
+template<typename D, typename S>
D basic_primitive_ops<D,S>::shift_bits_left(digit_type* x,
size_type xlen,
size_type n)
@@ -2513,8 +1319,6 @@
struct primitive_ops : basic_primitive_ops<D,S>
{};
-#endif
-
@@ -2525,7 +1329,7 @@
#if defined(__GNU__)
#if defined(__386__)
- #include <boost/mp_math/mp_int/detail/base/asm/x86/gnu_386_primitive_ops.hpp>
+ #include <boost/mp_math/integer/detail/base/asm/x86/gnu_386_primitive_ops.hpp>
#endif
#endif
Modified: sandbox/mp_math/boost/mp_math/integer/detail/base/unbounded_int_integral.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/detail/base/unbounded_int_integral.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/detail/base/unbounded_int_integral.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -276,7 +276,39 @@
if (lhs.sign_bit() == get_sign_bit(rhs))
magnitude_type_integral_ops::add(lhs, get_absolute(rhs));
else
- impl_type::subtract(lhs, get_absolute(rhs));
+ {
+ if (lhs.is_positive())
+ {
+ const typename unbounded_int_type::digit_type x = get_absolute(rhs);
+ if (lhs.size() == 1)
+ {
+ if (lhs[0] >= x)
+ lhs[0] -= x;
+ else
+ {
+ lhs[0] = x - lhs[0];
+ lhs.set_sign_bit(1);
+ }
+ }
+ else
+ magnitude_type_integral_ops::subtract(lhs, x);
+ }
+ else
+ {
+ if (lhs.size() == 1)
+ {
+ if (lhs[0] > rhs)
+ lhs[0] -= rhs;
+ else
+ {
+ lhs[0] = rhs - lhs[0];
+ lhs.set_sign_bit(0);
+ }
+ }
+ else
+ magnitude_type_integral_ops::add(lhs, rhs);
+ }
+ }
}
static void subtract(unbounded_int_type& lhs, integral_type rhs);
Modified: sandbox/mp_math/boost/mp_math/integer/detail/base/unbounded_uint.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/detail/base/unbounded_uint.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/detail/base/unbounded_uint.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -9,12 +9,12 @@
#include <algorithm> // swap
#include <cassert>
-#include <iostream>
#include <iterator> // reverse_iterator
#include <boost/config.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/mp_math/integer/detail/base/adder.hpp>
#include <boost/mp_math/integer/detail/base/bitwise_ops.hpp>
+#include <boost/mp_math/integer/detail/base/print_digits.hpp>
#include <boost/mp_math/integer/detail/base/shifter.hpp>
#include <boost/mp_math/integer/detail/base/to_integral.hpp>
#include <boost/mp_math/integer/detail/base/unbounded_uint_integral.hpp>
@@ -65,11 +65,7 @@
digits_(d), size_(size), capacity_(capacity)
{}
- #ifdef BOOST_HAS_RVALUE_REFS
- void swap(unbounded_uint_common&& rhs);
- #else
void swap(unbounded_uint_common& rhs);
- #endif
iterator begin() { return digits_; }
iterator end () { return digits_ + size_; }
@@ -299,11 +295,7 @@
template<class Traits>
-#ifdef BOOST_HAS_RVALUE_REFS
-void unbounded_uint_common<Traits>::swap(unbounded_uint_common&& rhs)
-#else
void unbounded_uint_common<Traits>::swap(unbounded_uint_common& rhs)
-#endif
{
std::swap(digits_, rhs.digits_ );
std::swap(size_, rhs.size_ );
@@ -317,22 +309,6 @@
x.swap(y);
}
-#ifdef BOOST_HAS_RVALUE_REFS
-template<class Traits>
-inline void swap(unbounded_uint_common<Traits>&& x,
- unbounded_uint_common<Traits>& y)
-{
- x.swap(y);
-}
-
-template<class Traits>
-inline void swap(unbounded_uint_common<Traits>& x,
- unbounded_uint_common<Traits>&& y)
-{
- x.swap(y);
-}
-#endif
-
// This is used to ensure that leading zero digits are trimmed.
template<class Traits>
void unbounded_uint_common<Traits>::clamp()
@@ -491,30 +467,10 @@
}
template<class Traits>
+inline
void unbounded_uint_common<Traits>::print(bool all) const
{
- using std::cout;
- cout << size_ << "{";
- for (size_type i = 0; i < size(); ++i)
- {
- cout << static_cast<typename traits_type::word_type>(digits()[i]);
- if (i < size() - 1)
- cout << ",";
- }
- cout << "}";
-
- if (all)
- {
- cout << capacity() - size() << "{";
- for (size_type i = size(); i < capacity(); ++i)
- {
- cout << static_cast<typename traits_type::word_type>(digits()[i]);
- if (i < capacity() - 1)
- cout << ",";
- }
- cout << "}";
- }
- cout << "\n";
+ print_digits(*this, all);
}
Modified: sandbox/mp_math/boost/mp_math/integer/detail/divider.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/detail/divider.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/detail/divider.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -44,8 +44,6 @@
void divider<ApInt>::classic_divide(const ApInt& a, const ApInt& b,
ApInt& q, ApInt* remainder)
{
- typedef typename traits_type::word_type word_type;
-
if (!b)
throw std::domain_error("unbounded::divide: division by zero");
@@ -145,11 +143,13 @@
q[offset] = traits_type::max_digit_value;
else
{
+ ops_type::div2by1(q[offset], x[i], x[i - 1], y[t]);
+ /*typedef unsigned long long word_type;
word_type tmp = static_cast<word_type>(x[i])
<< static_cast<word_type>(traits_type::radix_bits);
tmp |= x[i - 1];
tmp /= y[t];
- q[offset] = static_cast<digit_type>(tmp);
+ q[offset] = static_cast<digit_type>(tmp);*/
}
// now fixup quotient estimation
Modified: sandbox/mp_math/boost/mp_math/integer/detail/jacobi.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/detail/jacobi.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/detail/jacobi.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -23,8 +23,6 @@
if (p <= digit_type(0))
throw std::domain_error("jacobi: p must be greater than 0");
- std::cout << "a = "; a.print();
- std::cout << "p = "; p.print();
if (!a)
return 0;
@@ -60,7 +58,6 @@
if (((p[0] & 3) == 3) && ((a1[0] & 3) == 3))
s = -s;
- std::cout << "a1 = "; a1.print();
if (a1 == digit_type(1))
return s;
else
Modified: sandbox/mp_math/boost/mp_math/integer/detail/modpow.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/detail/modpow.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/detail/modpow.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -81,7 +81,7 @@
return mod_restricted_dr;
// if all bits until the most significant digit are set
- if (count == m.size() - 2)
+ if (count && count == m.size() - 2)
{
bool all_bits_set = true;
@@ -97,7 +97,9 @@
mask <<= 1;
}
if (all_bits_set)
+ {
return mod_unrestricted_dr;
+ }
}
// if more than half of the bits are set
Modified: sandbox/mp_math/boost/mp_math/integer/detail/modular_reduction.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/detail/modular_reduction.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/detail/modular_reduction.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -74,9 +74,10 @@
// q = q * m mod radix^(k+1)
//q.mul_digits(m, k + 1);
+
ApInt tmp; tmp.reserve(k + 1);
- ops_type::comba_mul_lo(tmp.digits(), q.digits(), q.size(),
- m.digits(), m.size(), k + 1);
+ ops_type::comba_mul_lo(tmp.digits(), m.digits(), m.size(),
+ q.digits(), q.size(), k + 1);
swap(tmp, q);
x -= q;
Modified: sandbox/mp_math/boost/mp_math/integer/detail/multiplier.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/detail/multiplier.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/detail/multiplier.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -728,10 +728,14 @@
z.set_size(1);
z.set_sign_bit(0);
}
- else if ((*b)[0] == 1U)
- z = *a;
else
- ApInt::template integral_ops<digit_type>::multiply(z, *a, (*b)[0]);
+ {
+ if ((*b)[0] == 1U)
+ z = *a;
+ else
+ ApInt::template integral_ops<digit_type>::multiply(z, *a, (*b)[0]);
+ z.set_sign_bit(x.sign_bit() ^ y.sign_bit());
+ }
}
else
{
Modified: sandbox/mp_math/boost/mp_math/integer/detail/unbounded_int_integral.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/detail/unbounded_int_integral.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/detail/unbounded_int_integral.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -174,6 +174,8 @@
typename unbounded_int_type::digit_type
>::type integral_type;
+ typedef typename unbounded_int_type::traits_type traits_type;
+
typedef typename unbounded_int_type::digit_type unsigned_integral_type;
typedef base::unbounded_int_integral_ops<
@@ -213,30 +215,9 @@
return base_integral_ops_type::less(lhs, rhs);
}
- static void add(unbounded_int_type& lhs, integral_type rhs)
- {
- if (rhs >= 0)
- {
- lhs.reserve(lhs.size() + 1);
- base::unbounded_int_integral_ops<
- unbounded_int_type,
- unsigned_integral_type
- >::add(lhs, static_cast<unsigned_integral_type>(rhs));
- }
- else
- base::unbounded_int_integral_ops<
- unbounded_int_type,
- unsigned_integral_type
- >::subtract(lhs, static_cast<unsigned_integral_type>(-rhs));
- }
+ static void add(unbounded_int_type& lhs, integral_type rhs);
- static void subtract(unbounded_int_type& lhs, integral_type rhs)
- {
- if (rhs >= 0)
- base_integral_ops_type::subtract(lhs, static_cast<unsigned_integral_type>(rhs));
- else
- base_integral_ops_type::add(lhs, static_cast<unsigned_integral_type>(-rhs));
- }
+ static void subtract(unbounded_int_type& lhs, integral_type rhs);
static void multiply(unbounded_int_type& lhs, integral_type rhs)
{
@@ -284,6 +265,83 @@
};
+template<class UnboundedInt>
+void unbounded_int_integral_ops_impl<
+ UnboundedInt,
+ typename make_signed<typename UnboundedInt::digit_type>::type,
+ true
+>::add(unbounded_int_type& lhs, integral_type rhs)
+{
+ if (rhs >= 0)
+ {
+ lhs.reserve(lhs.size() + 1);
+ base::unbounded_int_integral_ops<
+ unbounded_int_type,
+ unsigned_integral_type
+ >::add(lhs, static_cast<unsigned_integral_type>(rhs));
+ }
+ else
+ base::unbounded_int_integral_ops<
+ unbounded_int_type,
+ unsigned_integral_type
+ >::subtract(lhs, static_cast<unsigned_integral_type>(-rhs));
+}
+
+template<class UnboundedInt>
+void unbounded_int_integral_ops_impl<
+ UnboundedInt,
+ typename make_signed<typename UnboundedInt::digit_type>::type,
+ true
+>::subtract(unbounded_int_type& lhs, integral_type rhs)
+{
+ if (lhs.is_positive())
+ {
+ if (rhs >= 0)
+ base_integral_ops_type::subtract(lhs, static_cast<unsigned_integral_type>(rhs));
+ else
+ {
+ lhs.reserve(lhs.size() + 1);
+ base::unbounded_uint_integral_ops<
+ unbounded_int_type,
+ unsigned_integral_type
+ >::add(lhs, static_cast<unsigned_integral_type>(-rhs));
+ }
+ }
+ else
+ {
+ if (rhs >= 0)
+ {
+ lhs.reserve(lhs.size() + 1);
+ base::unbounded_uint_integral_ops<
+ unbounded_int_type,
+ unsigned_integral_type
+ >::add(lhs, static_cast<unsigned_integral_type>(rhs));
+ }
+ else
+ {
+ const unsigned_integral_type abs_rhs =
+ static_cast<unsigned_integral_type>(-rhs);
+
+ if (lhs.size() == 1)
+ {
+ if (lhs[0] < abs_rhs) // example: -4 - (-5) = 1
+ {
+ lhs[0] = abs_rhs - lhs[0];
+ lhs.set_sign_bit(0);
+ }
+ else // example -4 - (-1) = -3
+ lhs[0] -= abs_rhs;
+ }
+ else
+ base::unbounded_uint_integral_ops<
+ unbounded_int_type,
+ unsigned_integral_type
+ >::subtract(lhs, abs_rhs);
+ }
+ }
+}
+
+
// 3
template<class UnboundedInt, typename IntegralT>
struct unbounded_int_integral_ops_impl<
@@ -458,7 +516,7 @@
if (lhs.sign_bit() == get_sign_bit(rhs))
unbounded_uint_integral_ops_type::add(lhs, get_absolute(rhs));
else
- subtract_smaller(lhs, get_absolute(rhs), get_sign_bit(rhs));
+ subtract_smaller(lhs, get_absolute(rhs));
}
static void subtract(unbounded_int_type& lhs, integral_type rhs)
@@ -466,7 +524,7 @@
if (lhs.sign_bit() != get_sign_bit(rhs))
unbounded_uint_integral_ops_type::add(lhs, get_absolute(rhs));
else
- subtract_smaller(lhs, get_absolute(rhs), ~lhs.sign_bit());
+ subtract_smaller(lhs, get_absolute(rhs));
}
static void multiply(unbounded_int_type& lhs, integral_type rhs)
@@ -519,8 +577,7 @@
}
static void subtract_smaller(unbounded_int_type& lhs,
- unsigned_integral_type rhs,
- bool final_sign);
+ unsigned_integral_type rhs);
};
@@ -533,10 +590,8 @@
void
unbounded_int_integral_ops_impl<
UnboundedInt, IntegralT, true
->::subtract_smaller(unbounded_int_type& lhs,
- unsigned_integral_type rhs,
- bool final_sign)
-{
+>::subtract_smaller(unbounded_int_type& lhs, unsigned_integral_type rhs)
+{ // need helper class that holds these constants...?
static const unsigned radix_bits = traits_type::radix_bits;
static const unsigned q =
@@ -566,7 +621,7 @@
x = &tmp;
y = &lhs;
lhs.reserve(tmp.size());
- lhs.set_sign_bit(final_sign);
+ lhs.set_sign_bit(!lhs.sign_bit());
}
traits_type::ops_type::sub_smaller_magnitude(
Modified: sandbox/mp_math/boost/mp_math/integer/gmp_integer.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/gmp_integer.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/gmp_integer.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -9,6 +9,10 @@
#include <gmp.h>
#include <boost/config.hpp>
#include <boost/mp_math/integer/contexts.hpp>
+#include <boost/mp_math/integer/gmp_integer_fwd.hpp>
+#include <boost/mp_math/integer/multiprecision_integer_tag.hpp>
+#include <boost/mp_math/integer/detail/stream_io.hpp>
+#include <boost/mp_math/integer/detail/base/print_digits.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/utility/enable_if.hpp>
#include <cstring> // strlen
@@ -46,9 +50,6 @@
};
-template<class Behavior = gmp_behavior>
-class gmp_integer;
-
namespace detail {
@@ -119,9 +120,29 @@
mpz_mod_ui(z.get_mpz_t(), z.get_mpz_t(), x);
}
- static void bitwise_or(gmp_integer_type& z, integral_type x);
- static void bitwise_and(gmp_integer_type& z, integral_type x);
- static void bitwise_xor(gmp_integer_type& z, integral_type x);
+ static void bitwise_or(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ gmp_integer_type::behavior_type::bitwise_or(z.get_mpz_t(),
+ z.get_mpz_t(),
+ tmp.get_mpz_t());
+ }
+
+ static void bitwise_and(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ gmp_integer_type::behavior_type::bitwise_and(z.get_mpz_t(),
+ z.get_mpz_t(),
+ tmp.get_mpz_t());
+ }
+
+ static void bitwise_xor(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ gmp_integer_type::behavior_type::bitwise_xor(z.get_mpz_t(),
+ z.get_mpz_t(),
+ tmp.get_mpz_t());
+ }
};
@@ -156,12 +177,18 @@
static void add(gmp_integer_type& z, integral_type x)
{
- mpz_add_ui(z.get_mpz_t(), z.get_mpz_t(), x);
+ if (x >= 0)
+ mpz_add_ui(z.get_mpz_t(), z.get_mpz_t(), x);
+ else
+ mpz_sub_ui(z.get_mpz_t(), z.get_mpz_t(), -x);
}
static void subtract(gmp_integer_type& z, integral_type x)
{
- mpz_sub_ui(z.get_mpz_t(), z.get_mpz_t(), x);
+ if (x >= 0)
+ mpz_sub_ui(z.get_mpz_t(), z.get_mpz_t(), x);
+ else
+ mpz_add_ui(z.get_mpz_t(), z.get_mpz_t(), -x);
}
static void multiply(gmp_integer_type& z, integral_type x)
@@ -179,9 +206,219 @@
mpz_mod_ui(z.get_mpz_t(), z.get_mpz_t(), x);
}
- static void bitwise_or(gmp_integer_type& z, integral_type x);
- static void bitwise_and(gmp_integer_type& z, integral_type x);
- static void bitwise_xor(gmp_integer_type& z, integral_type x);
+ static void bitwise_or(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ gmp_integer_type::behavior_type::bitwise_or(z.get_mpz_t(),
+ z.get_mpz_t(),
+ tmp.get_mpz_t());
+ }
+
+ static void bitwise_and(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ gmp_integer_type::behavior_type::bitwise_and(z.get_mpz_t(),
+ z.get_mpz_t(),
+ tmp.get_mpz_t());
+ }
+
+ static void bitwise_xor(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ gmp_integer_type::behavior_type::bitwise_xor(z.get_mpz_t(),
+ z.get_mpz_t(),
+ tmp.get_mpz_t());
+ }
+};
+
+
+template<
+ class B,
+ typename IntegralT
+>
+struct gmp_integer_integral_ops<gmp_integer<B>, IntegralT, false, false>
+{
+ typedef gmp_integer<B> gmp_integer_type;
+ typedef IntegralT integral_type;
+
+ static void init(gmp_integer_type& z, integral_type x)
+ {
+ mpz_init(z.get_mpz_t());
+ mpz_import(z.get_mpz_t(),
+ 1, // count
+ -1, // -1 = least significant first
+ sizeof(integral_type),
+ 0, // 0 = host endianness
+ 0, // no nail bits
+ &x);
+ }
+
+ static void assign(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ z = tmp;
+ }
+
+ static bool equal(const gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ return z == tmp;
+ }
+
+ static bool less(const gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ return z < tmp;
+ }
+
+ static void add(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ z += tmp;
+ }
+
+ static void subtract(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ z -= tmp;
+ }
+
+ static void multiply(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ z *= tmp;
+ }
+
+ static void divide(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ z /= tmp;
+ }
+
+ static void modulo(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ z %= tmp;
+ }
+
+ static void bitwise_or(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ gmp_integer_type::behavior_type::bitwise_or(z.get_mpz_t(),
+ z.get_mpz_t(),
+ tmp.get_mpz_t());
+ }
+
+ static void bitwise_and(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ gmp_integer_type::behavior_type::bitwise_and(z.get_mpz_t(),
+ z.get_mpz_t(),
+ tmp.get_mpz_t());
+ }
+
+ static void bitwise_xor(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ gmp_integer_type::behavior_type::bitwise_xor(z.get_mpz_t(),
+ z.get_mpz_t(),
+ tmp.get_mpz_t());
+ }
+};
+
+
+template<
+ class B,
+ typename IntegralT
+>
+struct gmp_integer_integral_ops<gmp_integer<B>, IntegralT, true, false>
+{
+ typedef gmp_integer<B> gmp_integer_type;
+ typedef IntegralT integral_type;
+
+ static void init(gmp_integer_type& z, integral_type x)
+ {
+ mpz_init(z.get_mpz_t());
+ mpz_import(z.get_mpz_t(),
+ 1, // count
+ -1, // -1 = least significant first
+ sizeof(integral_type),
+ 0, // 0 = host endianness
+ 0, // no nail bits
+ &x);
+ }
+
+ static void assign(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ z = tmp;
+ }
+
+ static bool equal(const gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ return z == tmp;
+ }
+
+ static bool less(const gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ return z < tmp;
+ }
+
+ static void add(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ z += tmp;
+ }
+
+ static void subtract(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ z -= tmp;
+ }
+
+ static void multiply(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ z *= tmp;
+ }
+
+ static void divide(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ z /= tmp;
+ }
+
+ static void modulo(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ z %= tmp;
+ }
+
+ static void bitwise_or(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ gmp_integer_type::behavior_type::bitwise_or(z.get_mpz_t(),
+ z.get_mpz_t(),
+ tmp.get_mpz_t());
+ }
+
+ static void bitwise_and(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ gmp_integer_type::behavior_type::bitwise_and(z.get_mpz_t(),
+ z.get_mpz_t(),
+ tmp.get_mpz_t());
+ }
+
+ static void bitwise_xor(gmp_integer_type& z, integral_type x)
+ {
+ const gmp_integer_type tmp(x);
+ gmp_integer_type::behavior_type::bitwise_xor(z.get_mpz_t(),
+ z.get_mpz_t(),
+ tmp.get_mpz_t());
+ }
};
@@ -218,6 +455,47 @@
};
+template<class B, typename IntegralT>
+struct gmp_integer_to_integral<B, IntegralT, false, false>
+{
+ static IntegralT convert(const gmp_integer<B>& x)
+ {
+ // need to init to zero because GMP will early out in mpz_export and not
+ // write to value if the value of x is zero.
+ IntegralT value = 0;
+ mpz_export(&value,
+ 0, // count
+ -1, // -1 = least significant first
+ sizeof(IntegralT),
+ 0, // 0 = host endianness
+ 0, // 0 nail bits
+ x.get_mpz_t());
+ return value;
+ }
+};
+
+
+template<class B, typename IntegralT>
+struct gmp_integer_to_integral<B, IntegralT, true, false>
+{
+ static IntegralT convert(const gmp_integer<B>& x)
+ {
+ IntegralT value;
+ mpz_export(&value,
+ 0, // count
+ -1, // -1 = least significant first
+ sizeof(IntegralT),
+ 0, // 0 = host endianness
+ 0, // 0 nail bits
+ x.get_mpz_t());
+ if (x.sign() == 1)
+ return value;
+ else
+ return -value;
+ }
+};
+
+
struct gmp_integer_traits
{
@@ -269,6 +547,8 @@
public:
+ typedef multiprecision_integer_tag tag;
+
static const bool is_signed = true;
static const bool is_bounded = false;
@@ -424,11 +704,7 @@
void assign(RandomAccessIterator first, RandomAccessIterator last,
std::ios_base::fmtflags);
- #ifndef BOOST_NO_RVALUE_REFERENCES
- void swap(gmp_integer&& other)
- #else
void swap(gmp_integer& other)
- #endif
{
mpz_swap(val_, other.val_);
}
@@ -454,11 +730,20 @@
bool is_positive() const { return mpz_sgn(val_) >= 0; }
bool is_negative() const { return mpz_sgn(val_) < 0; }
+ int sign() const { return is_positive() ? 1 : -1; }
+ bool sign_bit() const { return is_positive() ? 0 : 1; }
+
// These two functions use the same signature as GMP's mpz_class
mpz_ptr get_mpz_t() { return val_; }
mpz_srcptr get_mpz_t() const { return val_; }
- size_type size() const { return mpz_size(val_); }
+ size_type size () const { return mpz_size(val_); }
+
+ void set_size(size_type s) { val_->_mp_size = static_cast<int>(s); }
+
+ size_type capacity() const { return static_cast<size_type>(val_->_mp_alloc); }
+
+ void reserve(size_type n) { mpz_realloc(val_, n); }
digit_type* digits() { return val_->_mp_d; }
const digit_type* digits() const { return val_->_mp_d; }
@@ -606,6 +891,11 @@
const detail::gmp_allocated_string tmp(mpz_get_str(0, radix, val_));
return StringT(tmp.str, tmp.str + tmp.len - 1);
}
+
+ void print(bool all = false) const
+ {
+ detail::base::print_digits(*this, all);
+ }
};
@@ -701,19 +991,6 @@
lhs.swap(rhs);
}
-#ifndef BOOST_NO_RVALUE_REFERENCES
-template<class B>
-inline void swap(gmp_integer<B>&& lhs, gmp_integer<B>& rhs)
-{
- lhs.swap(rhs);
-}
-template<class B>
-inline void swap(gmp_integer<B>& lhs, gmp_integer<B>&& rhs)
-{
- lhs.swap(rhs);
-}
-#endif
-
template<class B>
inline gmp_integer<B>
@@ -1300,8 +1577,9 @@
// Input/Output
template<class B, typename charT, class traits>
std::basic_istream<charT, traits>&
-operator >> (std::basic_istream<charT, traits>& is, gmp_integer<B>&)
+operator >> (std::basic_istream<charT, traits>& is, gmp_integer<B>& x)
{
+ detail::stream_io<gmp_integer<B> >::read(x, is);
return is;
}
@@ -1441,8 +1719,6 @@
-
-
} // namespace mp_math
} // namespace boost
Modified: sandbox/mp_math/boost/mp_math/integer/libtom_integer.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/libtom_integer.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/libtom_integer.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -9,9 +9,12 @@
#include <tommath.h>
#include <boost/config.hpp>
#include <boost/mp_math/integer/contexts.hpp>
+#include <boost/mp_math/integer/libtom_integer_fwd.hpp>
+#include <boost/mp_math/integer/multiprecision_integer_tag.hpp>
+#include <boost/mp_math/integer/detail/stream_io.hpp>
+#include <boost/mp_math/integer/detail/base/print_digits.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/utility/enable_if.hpp>
-#include <cstring> // strlen
#include <iostream>
#include <limits>
#include <stdexcept>
@@ -21,33 +24,35 @@
struct boost_behavior
{
- static void bitwise_or(mp_int* z, mp_int* x, mp_int* y);
- static void bitwise_and(mp_int* z, mp_int* x, mp_int* y);
- static void bitwise_xor(mp_int* z, mp_int* x, mp_int* y);
+ static void bitwise_or(mp_int* z, const mp_int* x, const mp_int* y);
+ static void bitwise_and(mp_int* z, const mp_int* x, const mp_int* y);
+ static void bitwise_xor(mp_int* z, const mp_int* x, const mp_int* y);
+ static void compl_bits(mp_int* z, const mp_int* x);
};
struct libtom_behavior
{
- static void bitwise_or(mp_int* z, mp_int* x, mp_int* y)
+ static void bitwise_or(mp_int* z, const mp_int* x, const mp_int* y)
{
mp_or(x, y, z);
}
- static void bitwise_and(mp_int* z, mp_int* x, mp_int* y)
+ static void bitwise_and(mp_int* z, const mp_int* x, const mp_int* y)
{
mp_and(x, y, z);
}
- static void bitwise_xor(mp_int* z, mp_int* x, mp_int* y)
+ static void bitwise_xor(mp_int* z, const mp_int* x, const mp_int* y)
{
mp_xor(x, y, z);
}
-};
-
-template<class Behavior = libtom_behavior>
-class libtom_integer;
+ static void compl_bits(mp_int* z, const mp_int* x)
+ {
+ mp_compl(x, z);
+ }
+};
namespace detail {
@@ -56,11 +61,9 @@
class B,
typename IntegralT,
bool IsSigned = std::numeric_limits<IntegralT>::is_signed,
- bool FitsIntoLongInt =
- IsSigned ? (std::numeric_limits<IntegralT>::digits <=
- std::numeric_limits<signed long int>::digits)
- : (std::numeric_limits<IntegralT>::digits <=
- std::numeric_limits<unsigned long int>::digits)
+ bool FitsIntoMpDigit =
+ (std::numeric_limits<IntegralT>::digits <=
+ std::numeric_limits<mp_digit>::digits)
>
struct libtom_integer_integral_ops;
@@ -72,51 +75,51 @@
struct libtom_integer_integral_ops<libtom_integer<B>, IntegralT, false, true>
{
typedef libtom_integer<B> libtom_integer_type;
- typedef IntegralT integral_type;
+ typedef IntegralT integral_type;
static void init(libtom_integer_type& z, integral_type x)
{
- mpz_init_set_ui(z.get_mp_int(), x);
+ mp_init_set(&z.get_mp_int(), x);
}
static void assign(libtom_integer_type& z, integral_type x)
{
- mpz_set_ui(z.get_mp_int(), x);
+ mp_set(&z.get_mp_int(), x);
}
static bool equal(const libtom_integer_type& z, integral_type x)
{
- return mpz_cmp_ui(z.get_mp_int(), x) == 0;
+ return mp_cmp_d(&z.get_mp_int(), x) == MP_EQ;
}
static bool less(const libtom_integer_type& z, integral_type x)
{
- return mpz_cmp_ui(z.get_mp_int(), x) < 0;
+ return mp_cmp_d(&z.get_mp_int(), x) == MP_LT;
}
static void add(libtom_integer_type& z, integral_type x)
{
- mpz_add_ui(z.get_mp_int(), z.get_mp_int(), x);
+ mp_add_d(&z.get_mp_int(), x, z.get_mp_int());
}
static void subtract(libtom_integer_type& z, integral_type x)
{
- mpz_sub_ui(z.get_mp_int(), z.get_mp_int(), x);
+ mp_sub_d(&z.get_mp_int(), x, z.get_mp_int());
}
static void multiply(libtom_integer_type& z, integral_type x)
{
- mpz_mul_ui(z.get_mp_int(), z.get_mp_int(), x);
+ mp_mul_d(&z.get_mp_int(), x, z.get_mp_int());
}
static void divide(libtom_integer_type& z, integral_type x)
{
- mp_intdiv_q_ui(z.get_mp_int(), z.get_mp_int(), x);
+ mp_div_d(&z.get_mp_int(), x, z.get_mp_int(), 0);
}
static void modulo(libtom_integer_type& z, integral_type x)
{
- mpz_mod_ui(z.get_mp_int(), z.get_mp_int(), x);
+ mp_mod_d(&z.get_mp_int(), x, z.get_mp_int());
}
static void bitwise_or(libtom_integer_type& z, integral_type x);
@@ -132,51 +135,51 @@
struct libtom_integer_integral_ops<libtom_integer<B>, IntegralT, true, true>
{
typedef libtom_integer<B> libtom_integer_type;
- typedef IntegralT integral_type;
+ typedef IntegralT integral_type;
static void init(libtom_integer_type& z, integral_type x)
{
- mpz_init_set_si(z.get_mp_int(), x);
+ mp_init_set(&z.get_mp_int(), x);
}
static void assign(libtom_integer_type& z, integral_type x)
{
- mpz_set_si(z.get_mp_int(), x);
+ mp_set(&z.get_mp_int(), x);
}
static bool equal(const libtom_integer_type& z, integral_type x)
{
- return mpz_cmp_si(z.get_mp_int(), x) == 0;
+ return mp_cmp_d(&z.get_mp_int(), x) == MP_EQ;
}
static bool less(const libtom_integer_type& z, integral_type x)
{
- return mpz_cmp_si(z.get_mp_int(), x) < 0;
+ return mp_cmp_d(&z.get_mp_int(), x) == MP_LT;
}
static void add(libtom_integer_type& z, integral_type x)
{
- mpz_add_ui(z.get_mp_int(), z.get_mp_int(), x);
+ mp_add_d(&z.get_mp_int(), x, z.get_mp_int());
}
static void subtract(libtom_integer_type& z, integral_type x)
{
- mpz_sub_ui(z.get_mp_int(), z.get_mp_int(), x);
+ mp_sub_d(&z.get_mp_int(), x, z.get_mp_int());
}
static void multiply(libtom_integer_type& z, integral_type x)
{
- mpz_mul_si(z.get_mp_int(), z.get_mp_int(), x);
+ mp_mul_d(&z.get_mp_int(), x, z.get_mp_int());
}
static void divide(libtom_integer_type& z, integral_type x)
{
- mp_intdiv_q_ui(z.get_mp_int(), z.get_mp_int(), x);
+ mp_div_d(&z.get_mp_int(), x, z.get_mp_int(), 0);
}
static void modulo(libtom_integer_type& z, integral_type x)
{
- mpz_mod_ui(z.get_mp_int(), z.get_mp_int(), x);
+ mp_mod_d(&z.get_mp_int(), x, z.get_mp_int());
}
static void bitwise_or(libtom_integer_type& z, integral_type x);
@@ -203,7 +206,8 @@
{
static IntegralT convert(const libtom_integer<B>& x)
{
- return static_cast<IntegralT>(mpz_get_ui(x.get_mp_int()));
+ const unsigned long y = mp_get_int(&x.get_mp_int());
+ return static_cast<IntegralT>(y);
}
};
@@ -213,7 +217,11 @@
{
static IntegralT convert(const libtom_integer<B>& x)
{
- return static_cast<IntegralT>(mpz_get_si(x.get_mp_int()));
+ unsigned long y = mp_get_int(&x.get_mp_int());
+ std::cout << "y = " << y << std::endl;
+ if (x.is_negative())
+ y = -y;
+ return static_cast<IntegralT>(y);
}
};
@@ -224,32 +232,25 @@
typedef mp_digit digit_type;
typedef std::size_t size_type;
- static const size_type digit_bits = GMP_LIMB_BITS;
- static const size_type radix_bits = GMP_NUMB_BITS;
- static const digit_type max_digit_value = GMP_NUMB_MAX;
+ static const size_type digit_bits = CHAR_BIT * sizeof(mp_digit);
+ static const size_type radix_bits = DIGIT_BIT;
+ static const digit_type max_digit_value = MP_DIGIT_MAX;
};
-extern "C"
-{
- typedef void (*libtom_free_func)(void *, size_t);
-}
-
struct libtom_allocated_string
{
- char* str;
- const std::size_t len;
-
- libtom_allocated_string(char *s)
+ char* str;
+ libtom_allocated_string(const mp_int* a, int radix, int length)
:
- str(s), len(std::strlen(s) + 1)
- {}
+ str(static_cast<char*>(XMALLOC(length)))
+ {
+ mp_toradix(a, str, radix);
+ }
~libtom_allocated_string()
{
- libtom_free_func f;
- mp_get_memory_functions (0, 0, &f);
- (*f)(str, len);
+ XFREE(str);
}
};
@@ -259,7 +260,7 @@
// libtom_original or libtom_boost
-// differences: bitwise ops
+// differences: TODO
template<class Behavior>
class libtom_integer
{
@@ -267,6 +268,8 @@
public:
+ typedef multiprecision_integer_tag tag;
+
static const bool is_signed = true;
static const bool is_bounded = false;
@@ -326,11 +329,12 @@
#ifndef BOOST_NO_RVALUE_REFERENCES
libtom_integer(libtom_integer&& copy)
{
- val_.alloc = copy.val_.alloc;
val_.used = copy.val_.used;
+ val_.alloc = copy.val_.alloc;
+ val_.sign = copy.val_.sign;
val_.dp = copy.val_.dp;
- copy.val_.alloc = 0;
copy.val_.used = 0;
+ copy.val_.alloc = 0;
copy.val_.dp = 0;
}
#endif
@@ -342,7 +346,7 @@
libtom_integer& operator = (const libtom_integer& rhs)
{
- mp_copy(&rhs.val_, &val);
+ mp_copy(&rhs.val_, &val_);
return *this;
}
@@ -366,7 +370,7 @@
template<typename charT>
libtom_integer& operator = (const charT* s)
{
- if (mpz_set_str(val_, s, 0) == 0)
+ if (mp_read_radix(&val_, s, 0) == MP_OKAY)
return *this;
else
throw std::invalid_argument(
@@ -376,45 +380,28 @@
template<typename charT, class traits, class alloc>
libtom_integer& operator = (const std::basic_string<charT,traits,alloc>& s)
{
- if (mpz_set_str(val_, s.c_str(), 0) == 0)
+ if (mp_read_radix(&val_, s, 0) == MP_OKAY)
return *this;
else
throw std::invalid_argument(
- "boost::mp_math::libtom_integer: operator = (const charT*)");
+ "boost::mp_math::libtom_integer: "
+ "operator = (const std::basic_string<charT,traits,alloc>&)");
}
template<typename charT>
void assign(const charT* s, std::ios_base::fmtflags f)
{
- unsigned radix;
- if (f & std::ios_base::hex)
- radix = 16;
- else if (f & std::ios_base::oct)
- radix = 8;
- else
- radix = 10;
- if (mp_read_radix(&val_, s, radix) == -1)
- throw std::invalid_argument(
- "boost::mp_math::libtom_integer::assign: illformatted string)");
+ construct_from_string(s, f);
}
- // TODO dispatch std::string to mpz_set_string, but dispatch other string
+ // TODO dispatch std::string to mp_read_radix, but dispatch other string
// types to detail/string_converter? Could do that but would need support for
- // NAIL bits.
+ // nail bits.
template<typename charT, class traits, class alloc>
void assign(const std::basic_string<charT,traits,alloc>& s,
std::ios_base::fmtflags f)
{
- unsigned radix;
- if (f & std::ios_base::hex)
- radix = 16;
- else if (f & std::ios_base::oct)
- radix = 8;
- else
- radix = 10;
- if (mp_read_radix(&val_, s.c_str(), radix) == -1)
- throw std::invalid_argument(
- "boost::mp_math::libtom_integer::assign: illformatted string)");
+ construct_from_string(s.c_str(), f);
}
@@ -422,11 +409,7 @@
void assign(RandomAccessIterator first, RandomAccessIterator last,
std::ios_base::fmtflags);
- #ifndef BOOST_NO_RVALUE_REFERENCES
- void swap(libtom_integer&& other)
- #else
void swap(libtom_integer& other)
- #endif
{
mp_exch(&val_, &other.val_);
}
@@ -449,14 +432,22 @@
bool is_even() const { return mp_iseven(&val_); }
bool is_odd () const { return mp_isodd(&val_); }
- bool is_positive() const { return val_.sign >= 0; }
- bool is_negative() const { return val_.sign < 0; }
+ bool is_positive() const { return val_.sign == MP_ZPOS; }
+ bool is_negative() const { return val_.sign == MP_NEG; }
// These two functions use the same signature as GMP's mpz_class
mp_int& get_mp_int() { return val_; }
const mp_int& get_mp_int() const { return val_; }
- size_type size() const { return statc_cast<size_type>(val_.used); }
+ size_type size() const { return static_cast<size_type>(val_.used); }
+
+ void set_size(size_type s) { val_.used = static_cast<int>(s); }
+
+ size_type capacity() const { return static_cast<size_type>(val_.alloc); }
+
+ void reserve(size_type n) { mp_grow(&val_, static_cast<int>(n)); }
+
+ void clamp() { mp_clamp(&val_); }
digit_type* digits() { return val_.dp; }
const digit_type* digits() const { return val_.dp; }
@@ -502,14 +493,12 @@
libtom_integer& operator >>= (size_type n)
{
- mp_mul_2d(&val_, n, &val_, 0);
+ mp_div_2d(&val_, n, &val_, 0);
return *this;
}
libtom_integer& operator - () { mp_neg(&val_, &val_); return *this; }
- libtom_integer& operator ~ () { mpz_cmp(val_, val_); return *this; }
-
libtom_integer& operator += (const libtom_integer& rhs)
{
mp_add(&val_, &rhs.val_, &val_);
@@ -601,33 +590,41 @@
else
radix = 10;
- const detail::libtom_allocated_string tmp(mpz_get_str(0, radix, val_));
- return StringT(tmp.str, tmp.str + tmp.len - 1);
+ int length;
+ mp_radix_size(&val_, radix, &length);
+ const detail::libtom_allocated_string tmp(&val_, radix, length);
+ return StringT(tmp.str, tmp.str + length - 1);
}
+
+ void print(bool all = false) const
+ {
+ detail::base::print_digits(*this, all);
+ }
+
+private:
+
+ void construct_from_string(const char*);
+ void construct_from_string(const char*, std::ios_base::fmtflags);
};
+
template<class B>
-libtom_integer<B>::libtom_integer(const char* s)
+void libtom_integer<B>::construct_from_string(const char* s)
{
- mp_init(&val_);
- if (*s != '\0')
+ if (mp_read_radix(&val_, s, 0) != MP_OKAY)
{
- if (mpz_init_set_str(val_, s, 0))
- {
- if (val_->_mp_d)
- mpz_clear(val_);
- throw std::invalid_argument(
- "boost::mp_math::libtom_integer::libtom_integer(const char*)");
- }
+ if (val_.dp)
+ mp_clear(&val_);
+ throw std::invalid_argument(
+ "boost::mp_math::libtom_integer::construct_from_string(const char*)");
}
}
template<class B>
-libtom_integer<B>::libtom_integer(const char* s, std::ios_base::fmtflags f)
+void libtom_integer<B>::construct_from_string(const char* s, std::ios_base::fmtflags f)
{
- mp_init(&val_);
- unsigned radix;
+ int radix;
if (f & std::ios_base::hex)
radix = 16;
else if (f & std::ios_base::oct)
@@ -635,78 +632,102 @@
else
radix = 10;
+ static const char* msg =
+ "boost::mp_math::libtom_integer::"
+ "construct_from_string(const char*, std::ios_base::fmtflags)";
+
+ int sign;
if (*s != '\0')
{
- if (mpz_init_set_str(val_, s, radix))
+ if (*s == '-')
{
- if (val_->_mp_d)
- mpz_clear(val_);
- throw std::invalid_argument(
- "boost::mp_math::libtom_integer::"
- "libtom_integer(const char*, std::ios_base::fmtflags)");
+ sign = MP_NEG;
+ ++s;
+ }
+ else
+ {
+ if (f & std::ios_base::showpos)
+ {
+ if (*s == '+')
+ ++s;
+ else
+ throw std::invalid_argument(msg);
+ }
+ sign = MP_ZPOS;
}
}
-}
-template<class B>
-libtom_integer<B>::libtom_integer(const std::string& s)
-{
- mp_init(&val_);
- if (!s.empty())
+ if (f & std::ios_base::showbase)
{
- if (mpz_init_set_str(val_, s.c_str(), 0))
+ bool err = false;
+ if (*s != '\0')
{
- if (val_->_mp_d)
- mpz_clear(val_);
- throw std::invalid_argument(
- "boost::mp_math::libtom_integer::libtom_integer(const std::string&)");
+ if (*s == '0')
+ {
+ if (radix == 10)
+ err = true;
+ else if (radix == 16)
+ {
+ ++s;
+ if (*s != '\0' && (*s == 'x' || *s == 'X'))
+ ++s;
+ else
+ err = true;
+ }
+ }
+ else if (radix == 8 || radix == 16)
+ err = true;
}
+
+ if (err)
+ throw std::invalid_argument(msg);
+ }
+
+ if (mp_read_radix(&val_, s, radix) != MP_OKAY)
+ {
+ if (val_.dp)
+ mp_clear(&val_);
+ throw std::invalid_argument(msg);
}
+
+ val_.sign = sign;
}
template<class B>
-libtom_integer<B>::libtom_integer(const std::string& s, std::ios_base::fmtflags f)
+libtom_integer<B>::libtom_integer(const char* s)
{
mp_init(&val_);
- unsigned radix;
- if (f & std::ios_base::hex)
- radix = 16;
- else if (f & std::ios_base::oct)
- radix = 8;
- else
- radix = 10;
+ construct_from_string(s);
+}
- if (!s.empty())
- {
- if (mpz_init_set_str(val_, s.c_str(), radix))
- {
- if (val_->_mp_d)
- mpz_clear(val_);
- throw std::invalid_argument(
- "boost::mp_math::libtom_integer::"
- "libtom_integer(const std::string&, std::ios_base::fmtflags)");
- }
- }
+template<class B>
+libtom_integer<B>::libtom_integer(const char* s, std::ios_base::fmtflags f)
+{
+ mp_init(&val_);
+ construct_from_string(s, f);
}
template<class B>
-inline void swap(libtom_integer<B>& lhs, libtom_integer<B>& rhs)
+libtom_integer<B>::libtom_integer(const std::string& s)
{
- lhs.swap(rhs);
+ mp_init(&val_);
+ if (!s.empty())
+ construct_from_string(s.c_str());
}
-#ifndef BOOST_NO_RVALUE_REFERENCES
template<class B>
-inline void swap(libtom_integer<B>&& lhs, libtom_integer<B>& rhs)
+libtom_integer<B>::libtom_integer(const std::string& s, std::ios_base::fmtflags f)
{
- lhs.swap(rhs);
+ mp_init(&val_);
+ if (!s.empty())
+ construct_from_string(s.c_str());
}
+
template<class B>
-inline void swap(libtom_integer<B>& lhs, libtom_integer<B>&& rhs)
+inline void swap(libtom_integer<B>& lhs, libtom_integer<B>& rhs)
{
lhs.swap(rhs);
}
-#endif
template<class B>
@@ -715,7 +736,7 @@
typename libtom_integer<B>::size_type n)
{
libtom_integer<B> nrv;
- mpz_mul_2exp(nrv.get_mp_int(), x.get_mp_int(), n);
+ mp_mul_2d(&x.get_mp_int(), n, &nrv.get_mp_int());
return nrv;
}
@@ -725,7 +746,7 @@
typename libtom_integer<B>::size_type n)
{
libtom_integer<B> nrv;
- mp_intdiv_q_2exp(nrv.get_mp_int(), x.get_mp_int(), n);
+ mp_div_2d(&x.get_mp_int(), n, &nrv.get_mp_int(), 0);
return nrv;
}
@@ -775,7 +796,7 @@
operator % (const libtom_integer<B>& lhs, const libtom_integer<B>& rhs)
{
libtom_integer<B> nrv;
- mp_div(&lhs.get_mp_int(), &rhs.get_mp_int(), 0, &nrv.get_mp_int());
+ mp_mod(&lhs.get_mp_int(), &rhs.get_mp_int(), &nrv.get_mp_int());
return nrv;
}
@@ -785,7 +806,7 @@
operator | (const libtom_integer<B>& lhs, const libtom_integer<B>& rhs)
{
libtom_integer<B> nrv;
- B::bitwise_or(nrv.get_mp_int(), lhs.get_mp_int(), rhs.get_mp_int());
+ B::bitwise_or(&nrv.get_mp_int(), &lhs.get_mp_int(), &rhs.get_mp_int());
return nrv;
}
@@ -795,7 +816,7 @@
operator & (const libtom_integer<B>& lhs, const libtom_integer<B>& rhs)
{
libtom_integer<B> nrv;
- B::bitwise_and(nrv.get_mp_int(), lhs.get_mp_int(), rhs.get_mp_int());
+ B::bitwise_and(&nrv.get_mp_int(), &lhs.get_mp_int(), &rhs.get_mp_int());
return nrv;
}
@@ -805,10 +826,20 @@
operator ^ (const libtom_integer<B>& lhs, const libtom_integer<B>& rhs)
{
libtom_integer<B> nrv;
- B::bitwise_xor(nrv.get_mp_int(), lhs.get_mp_int(), rhs.get_mp_int());
+ B::bitwise_xor(&nrv.get_mp_int(), &lhs.get_mp_int(), &rhs.get_mp_int());
+ return nrv;
+}
+
+template<class B>
+inline
+libtom_integer<B> operator ~ (const libtom_integer<B>& x)
+{
+ libtom_integer<B> nrv;
+ B::compl_bits(&nrv.get_mp_int(), &x.get_mp_int());
return nrv;
}
+
// Arithmetic and bitwise operators involving integral types
template<class B>
template<typename IntegralT>
@@ -1008,12 +1039,12 @@
}
// compare unbounded_int to integral
-/*template<class B, typename IntegralT>
+template<class B, typename IntegralT>
inline
typename enable_if<is_integral<IntegralT>, bool>::type
operator == (const libtom_integer<B>& lhs, IntegralT rhs)
{
- return detail::unbounded_int_integral_ops<
+ return detail::libtom_integer_integral_ops<
libtom_integer<B>, IntegralT>::equal(lhs, rhs);
}
@@ -1030,7 +1061,7 @@
typename enable_if<is_integral<IntegralT>, bool>::type
operator < (const libtom_integer<B>& lhs, IntegralT rhs)
{
- return detail::unbounded_int_integral_ops<
+ return detail::libtom_integer_integral_ops<
libtom_integer<B>, IntegralT>::less(lhs, rhs);
}
@@ -1105,7 +1136,7 @@
operator >= (IntegralT lhs, const libtom_integer<B>& rhs)
{
return rhs <= lhs;
-}*/
+}
// compare unbounded_int to const charT*
template<class B, typename charT>
@@ -1294,8 +1325,9 @@
// Input/Output
template<class B, typename charT, class traits>
std::basic_istream<charT, traits>&
-operator >> (std::basic_istream<charT, traits>& is, libtom_integer<B>&)
+operator >> (std::basic_istream<charT, traits>& is, libtom_integer<B>& x)
{
+ detail::stream_io<libtom_integer<B> >::read(x, is);
return is;
}
@@ -1399,7 +1431,7 @@
nth_root(const libtom_integer<B>& n, const libtom_integer<B>& x)
{
libtom_integer<B> nrv;
- mp_n_root(&x.get_mp_int(), n, &nrv.get_mp_int());
+ mp_n_root(&x.get_mp_int(), n.template to_integral<mp_digit>(), &nrv.get_mp_int());
return nrv;
}
Modified: sandbox/mp_math/boost/mp_math/integer/prime.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/prime.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/prime.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -322,17 +322,13 @@
{
prime_generator<PrimalityTest, Dist> prime_gen(bits_-1, test_);
result_type p;
+
do
{
- do
- {
- p = prime_gen(eng);
- detail::multiplier<result_type>::multiply_by_2(p);
- ++p;
- } while (!is_prime(p, test_));
- // Catch extremely rare case, this occurs if the carry from ++p ripples
- // through the whole number thereby adding one more bit to it.
- } while (p.precision() > bits_);
+ p = prime_gen(eng);
+ detail::multiplier<result_type>::multiply_by_2(p);
+ ++p;
+ } while (!is_prime(p, test_));
return p;
}
Modified: sandbox/mp_math/boost/mp_math/integer/random.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/random.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/random.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -178,8 +178,8 @@
}
-}
-}
+} // namespace mp_math
+} // namespace boost
#endif
Modified: sandbox/mp_math/boost/mp_math/integer/unbounded.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/unbounded.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/unbounded.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -33,6 +33,8 @@
unbounded_uint<Alloc,Traits>
>::type base_type;
+ typedef typename base_type::tag tag;
+
// these constants are used by the numeric_limits specialization
static const bool is_signed = IsSigned;
static const bool is_bounded = false;
Modified: sandbox/mp_math/boost/mp_math/integer/unbounded_int.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/unbounded_int.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/unbounded_int.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -8,9 +8,11 @@
#include <boost/config.hpp>
#include <boost/mp_math/integer/contexts.hpp>
+#include <boost/mp_math/integer/multiprecision_integer_tag.hpp>
#include <boost/mp_math/integer/unbounded_traits.hpp>
#include <boost/mp_math/integer/detail/adder.hpp>
#include <boost/mp_math/integer/detail/bitwise_ops.hpp>
+#include <boost/mp_math/integer/detail/digit_converter.hpp>
#include <boost/mp_math/integer/detail/divider.hpp>
#include <boost/mp_math/integer/detail/gcd.hpp>
#include <boost/mp_math/integer/detail/jacobi.hpp>
@@ -19,6 +21,7 @@
#include <boost/mp_math/integer/detail/modpow.hpp>
#include <boost/mp_math/integer/detail/power.hpp>
#include <boost/mp_math/integer/detail/root.hpp>
+#include <boost/mp_math/integer/detail/stream_io.hpp>
#include <boost/mp_math/integer/detail/string_conversion.hpp>
#include <boost/mp_math/integer/detail/unbounded_int_integral.hpp>
#include <boost/mp_math/integer/detail/base/unbounded_int.hpp>
@@ -32,7 +35,7 @@
>
struct unbounded_int
:
- /*typename*/ Alloc::template rebind<typename Traits::digit_type>::other,
+ Alloc::template rebind<typename Traits::digit_type>::other,
detail::base::unbounded_int<Traits>
{
protected:
@@ -44,6 +47,8 @@
public:
+ typedef multiprecision_integer_tag tag;
+
template<typename IntegralT>
struct integral_ops
:
@@ -98,6 +103,15 @@
std::ios_base::fmtflags f,
const allocator_type& a = allocator_type());
+ template<class ApInt>
+ unbounded_int(const ApInt& x,
+ typename enable_if<
+ mpl::and_<
+ mpl::not_<is_same<traits_type, typename ApInt::traits_type> >,
+ is_same<typename ApInt::tag, multiprecision_integer_tag>
+ >
+ >::type* dummy = 0);
+
unbounded_int(const unbounded_int& copy);
#ifndef BOOST_NO_RVALUE_REFERENCES
@@ -133,11 +147,7 @@
void assign(RandomAccessIterator first, RandomAccessIterator last,
std::ios_base::fmtflags);
- #ifndef BOOST_NO_RVALUE_REFERENCES
- void swap(unbounded_int&& other)
- #else
void swap(unbounded_int& other)
- #endif
{
base_type::swap(other);
}
@@ -253,19 +263,6 @@
lhs.swap(rhs);
}
-#ifndef BOOST_NO_RVALUE_REFERENCES
-template<class A, class T>
-inline void swap(unbounded_int<A,T>&& lhs, unbounded_int<A,T>& rhs)
-{
- lhs.swap(rhs);
-}
-template<class A, class T>
-inline void swap(unbounded_int<A,T>& lhs, unbounded_int<A,T>&& rhs)
-{
- lhs.swap(rhs);
-}
-#endif
-
template<class A, class T>
unbounded_int<A,T>::unbounded_int()
@@ -354,6 +351,23 @@
init_from_string(s.begin(), s.end(), f);
}
+template<class A, class T>
+template<class ApInt>
+unbounded_int<A,T>::unbounded_int(
+ const ApInt& x,
+ typename enable_if<
+ mpl::and_<
+ mpl::not_<is_same<traits_type, typename ApInt::traits_type> >,
+ is_same<typename ApInt::tag, multiprecision_integer_tag>
+ >
+ >::type*)
+:
+ base_type(0, 0, 0)
+{
+ detail::digit_converter<unbounded_int<A,T>, ApInt>::convert(*this, x);
+ //set_sign_bit(x.sign_bit());
+}
+
template<class A, class T>
unbounded_int<A,T>::unbounded_int(const unbounded_int& copy)
@@ -1238,84 +1252,7 @@
std::basic_istream<charT, traits>&
operator >> (std::basic_istream<charT, traits>& is, unbounded_int<A,T>& x)
{
- typename std::basic_istream<charT, traits>::sentry sentry(is);
- if (!sentry)
- return is;
-
- // TODO we read into a string first which costs memory and std::string
- // allocator is not under user control. We should convert incoming digits
- // directly. Actually we should check what is the fastest way.
- std::string s;
-
- const std::istreambuf_iterator<charT, traits> end;
- std::istreambuf_iterator<charT, traits> c(is);
-
- if (*c == '+' || *c == '-')
- {
- s.push_back(*c);
- ++c;
- }
-
- int base;
- if (*c == '0')
- {
- base = 8;
- s.push_back(*c);
- ++c;
- if (*c == 'x' || *c == 'X')
- {
- base = 16;
- s.push_back(*c);
- ++c;
- }
- }
- else if (*c >= '0' && *c <= '9')
- base = 10;
- else
- {
- is.setstate(std::ios_base::failbit);
- return is;
- }
-
- switch (base)
- {
- case 8:
- while (c != end)
- {
- if (*c >= '0' && *c <= '7')
- s.push_back(*c);
- else
- break;
- ++c;
- }
- break;
- case 10:
- while (c != end)
- {
- if (*c >= '0' && *c <= '9')
- s.push_back(*c);
- else
- break;
- ++c;
- }
- break;
- case 16:
- while (c != end)
- {
- if ((*c >= '0' && *c <= '9') ||
- (*c >= 'A' && *c <= 'F') ||
- (*c >= 'a' && *c <= 'f'))
- s.push_back(*c);
- else
- break;
- ++c;
- }
- break;
- }
-
- const unbounded_int<A,T> tmp(s.begin(), s.end());
- x = tmp;
-
+ detail::stream_io<unbounded_int<A,T> >::read(x, is);
return is;
}
Modified: sandbox/mp_math/boost/mp_math/integer/unbounded_traits.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/unbounded_traits.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/unbounded_traits.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -9,80 +9,29 @@
#include <cstddef> // size_t
#include <limits>
#include <boost/config.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/mpl/back.hpp>
-#include <boost/mpl/bool.hpp>
-#include <boost/mpl/deref.hpp>
-#include <boost/mpl/lower_bound.hpp>
-#include <boost/mpl/vector.hpp>
#include <boost/mp_math/integer/detail/base/primitive_ops.hpp>
namespace boost {
namespace mp_math {
-namespace detail {
-
-typedef mpl::vector<
- unsigned char,
- unsigned short,
- unsigned int,
- unsigned long int
- #ifdef BOOST_HAS_LONG_LONG
- ,
- unsigned long long int
- #endif
-> unsigned_type_vec;
-
-template<typename T1, typename T2>
-struct cmp_digits
-:
-mpl::bool_<
- std::numeric_limits<T1>::digits < std::numeric_limits<T2>::digits/2
->
-{
-};
-
-// we could also choose unsigned int (since this is propably the
-// fastest unsigned integer type) as digit_type then
-// try to find a larger type as word_type
-// if none exists set unsigned int as word_type and choose next
-// smaller type as digit_type
-struct choose
-{
- typedef mpl::back<unsigned_type_vec>::type word_type;
- typedef mpl::deref<
- mpl::lower_bound<
- unsigned_type_vec, word_type, cmp_digits<mpl::_1,mpl::_2>
- >::type
- >::type digit_type;
-};
-
-} // namespace detail
-
-
template<
- typename DigitT = detail::choose::digit_type,
- typename WordT = detail::choose::word_type,
+ typename DigitT =
+ #ifndef BOOST_HAS_LONG_LONG
+ unsigned long int
+ #else
+ unsigned long long int
+ #endif
+ ,
typename SizeT = std::size_t,
bool debug = false
>
struct unbounded_traits
{
- BOOST_STATIC_ASSERT(
- std::numeric_limits<DigitT>::digits <= std::numeric_limits<WordT>::digits/2
- );
-
typedef DigitT digit_type;
- typedef WordT word_type;
typedef SizeT size_type;
-#ifdef BOOST_MP_MATH_PRIMITIVE_OPS_OLD
- typedef detail::base::primitive_ops<
- digit_type, word_type, size_type> ops_type;
-#else
typedef detail::base::primitive_ops<digit_type, size_type> ops_type;
-#endif
static const bool enable_debug_mode = debug;
@@ -97,21 +46,21 @@
};
-template<typename D, typename W, typename S, bool b>
-typename unbounded_traits<D,W,S,b>::size_type
-unbounded_traits<D,W,S,b>::toom_mul_threshold = 350;
-
-template<typename D, typename W, typename S, bool b>
-typename unbounded_traits<D,W,S,b>::size_type
-unbounded_traits<D,W,S,b>::toom_sqr_threshold = 400;
-
-template<typename D, typename W, typename S, bool b>
-typename unbounded_traits<D,W,S,b>::size_type
-unbounded_traits<D,W,S,b>::karatsuba_mul_threshold = 80;
-
-template<typename D, typename W, typename S, bool b>
-typename unbounded_traits<D,W,S,b>::size_type
-unbounded_traits<D,W,S,b>::karatsuba_sqr_threshold = 120;
+template<typename D, typename S, bool b>
+typename unbounded_traits<D,S,b>::size_type
+unbounded_traits<D,S,b>::toom_mul_threshold = 350;
+
+template<typename D, typename S, bool b>
+typename unbounded_traits<D,S,b>::size_type
+unbounded_traits<D,S,b>::toom_sqr_threshold = 400;
+
+template<typename D, typename S, bool b>
+typename unbounded_traits<D,S,b>::size_type
+unbounded_traits<D,S,b>::karatsuba_mul_threshold = 80;
+
+template<typename D, typename S, bool b>
+typename unbounded_traits<D,S,b>::size_type
+unbounded_traits<D,S,b>::karatsuba_sqr_threshold = 120;
Modified: sandbox/mp_math/boost/mp_math/integer/unbounded_uint.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer/unbounded_uint.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer/unbounded_uint.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -8,6 +8,7 @@
#include <boost/config.hpp>
#include <boost/mp_math/integer/contexts.hpp>
+#include <boost/mp_math/integer/multiprecision_integer_tag.hpp>
#include <boost/mp_math/integer/unbounded_traits.hpp>
#include <boost/mp_math/integer/detail/adder.hpp>
#include <boost/mp_math/integer/detail/bitwise_ops.hpp>
@@ -18,6 +19,7 @@
#include <boost/mp_math/integer/detail/multiplier.hpp>
#include <boost/mp_math/integer/detail/power.hpp>
#include <boost/mp_math/integer/detail/root.hpp>
+#include <boost/mp_math/integer/detail/stream_io.hpp>
#include <boost/mp_math/integer/detail/string_conversion.hpp>
#include <boost/mp_math/integer/detail/unbounded_uint_integral.hpp>
#include <boost/mp_math/integer/detail/base/unbounded_uint.hpp>
@@ -31,7 +33,7 @@
>
struct unbounded_uint
:
- /*typename*/ Alloc::template rebind<typename Traits::digit_type>::other,
+ Alloc::template rebind<typename Traits::digit_type>::other,
detail::base::unbounded_uint<Traits>
{
protected:
@@ -43,6 +45,8 @@
public:
+ typedef multiprecision_integer_tag tag;
+
template<typename IntegralT>
struct integral_ops
:
@@ -131,11 +135,7 @@
void assign(RandomAccessIterator first, RandomAccessIterator last,
std::ios_base::fmtflags);
- #ifndef BOOST_NO_RVALUE_REFERENCES
- void swap(unbounded_uint&& other)
- #else
void swap(unbounded_uint& other)
- #endif
{
base_type::swap(other);
}
@@ -1500,85 +1500,7 @@
std::basic_istream<charT, traits>&
operator >> (std::basic_istream<charT, traits>& is, unbounded_uint<A,T>& x)
{
- typename std::basic_istream<charT, traits>::sentry sentry(is);
- if (!sentry)
- return is;
-
- // TODO we read into a string first which costs memory and std::string
- // allocator is not under user control. We should convert incoming digits
- // directly. Actually we should check what is the fastest way.
- std::string s;
-
- const std::istreambuf_iterator<charT, traits> end;
- std::istreambuf_iterator<charT, traits> c(is);
-
- // TODO we should stop if we see a minus sign
- if (*c == '+' || *c == '-')
- {
- s.push_back(*c);
- ++c;
- }
-
- int base;
- if (*c == '0')
- {
- base = 8;
- s.push_back(*c);
- ++c;
- if (*c == 'x' || *c == 'X')
- {
- base = 16;
- s.push_back(*c);
- ++c;
- }
- }
- else if (*c >= '0' && *c <= '9')
- base = 10;
- else
- {
- is.setstate(std::ios_base::failbit);
- return is;
- }
-
- switch (base)
- {
- case 8:
- while (c != end)
- {
- if (*c >= '0' && *c <= '7')
- s.push_back(*c);
- else
- break;
- ++c;
- }
- break;
- case 10:
- while (c != end)
- {
- if (*c >= '0' && *c <= '9')
- s.push_back(*c);
- else
- break;
- ++c;
- }
- break;
- case 16:
- while (c != end)
- {
- if ((*c >= '0' && *c <= '9') ||
- (*c >= 'A' && *c <= 'F') ||
- (*c >= 'a' && *c <= 'f'))
- s.push_back(*c);
- else
- break;
- ++c;
- }
- break;
- }
-
- const unbounded_uint<A,T> tmp(s.begin(), s.end());
- x = tmp;
-
+ detail::stream_io<unbounded_uint<A,T> >::read(x, is);
return is;
}
Modified: sandbox/mp_math/boost/mp_math/integer_serialization.hpp
==============================================================================
--- sandbox/mp_math/boost/mp_math/integer_serialization.hpp (original)
+++ sandbox/mp_math/boost/mp_math/integer_serialization.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -6,7 +6,9 @@
#ifndef BOOST_MP_MATH_INTEGER_SERIALIZATION_HPP
#define BOOST_MP_MATH_INTEGER_SERIALIZATION_HPP
+#include <boost/mp_math/integer/gmp_integer_fwd.hpp>
#include <boost/mp_math/integer/integer_fwd.hpp>
+#include <boost/mp_math/integer/libtom_integer_fwd.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/string.hpp>
@@ -86,6 +88,60 @@
ar & base_object<Type>(x);
}
+template<class Archive, class B>
+void save(Archive& ar,
+ const boost::mp_math::gmp_integer<B>& x,
+ const unsigned int /*version*/)
+{
+ const std::string s = x.template to_string<std::string>(std::ios_base::hex);
+ ar & s;
+}
+
+template<class Archive, class B>
+void load(Archive& ar,
+ boost::mp_math::gmp_integer<B>& x,
+ const unsigned int /*version*/)
+{
+ std::string s;
+ ar & s;
+ x.template assign(s, std::ios_base::hex);
+}
+
+template<class Archive, class B>
+inline void serialize(Archive& ar,
+ boost::mp_math::gmp_integer<B>& x,
+ const unsigned int version)
+{
+ split_free(ar, x, version);
+}
+
+template<class Archive, class B>
+void save(Archive& ar,
+ const boost::mp_math::libtom_integer<B>& x,
+ const unsigned int /*version*/)
+{
+ const std::string s = x.template to_string<std::string>(std::ios_base::hex);
+ ar & s;
+}
+
+template<class Archive, class B>
+void load(Archive& ar,
+ boost::mp_math::libtom_integer<B>& x,
+ const unsigned int /*version*/)
+{
+ std::string s;
+ ar & s;
+ x.template assign(s, std::ios_base::hex);
+}
+
+template<class Archive, class B>
+inline void serialize(Archive& ar,
+ boost::mp_math::libtom_integer<B>& x,
+ const unsigned int version)
+{
+ split_free(ar, x, version);
+}
+
} // namespace serialization
} // namespace boost
Modified: sandbox/mp_math/libs/mp_math/doc/html/index.html
==============================================================================
--- sandbox/mp_math/libs/mp_math/doc/html/index.html (original)
+++ sandbox/mp_math/libs/mp_math/doc/html/index.html 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -1,11 +1,11 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-<title>Chapter 1. mp_int</title>
+<title>Chapter 1. integer</title>
<link rel="stylesheet" href="boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
-<link rel="home" href="index.html" title="Chapter 1. mp_int">
-<link rel="next" href="mp_int/tutorial.html" title="Tutorial">
+<link rel="home" href="index.html" title="Chapter 1. integer">
+<link rel="next" href="integer/tutorial.html" title="Tutorial">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
@@ -17,17 +17,17 @@
<td align="center">More</td>
</tr></table>
<hr>
-<div class="spirit-nav"><a accesskey="n" href="mp_int/tutorial.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a></div>
+<div class="spirit-nav"><a accesskey="n" href="integer/tutorial.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a></div>
<div class="chapter" lang="en">
<div class="titlepage"><div>
<div><h2 class="title">
-<a name="mp_int"></a>Chapter 1. mp_int</h2></div>
+<a name="integer"></a>Chapter 1. integer</h2></div>
<div><div class="author"><h3 class="author">
<span class="firstname">Kevin</span> <span class="surname">Sopp</span>
</h3></div></div>
<div><p class="copyright">Copyright © 2008 - 2009 Kevin Sopp</p></div>
<div><div class="legalnotice">
-<a name="id3115998"></a><p>
+<a name="id2611140"></a><p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
</p>
@@ -36,73 +36,88 @@
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
-<dt><span class="section">Introduction</span></dt>
-<dt><span class="section">Tutorial</span></dt>
+<dt><span class="section">Introduction</span></dt>
+<dt><span class="section">Tutorial</span></dt>
<dd><dl>
-<dt><span class="section">General use</span></dt>
-<dt><span class="section"><a href="mp_int/tutorial.html#mp_int.tutorial.random_number_generation">Random number
+<dt><span class="section">General use</span></dt>
+<dt><span class="section"><a href="integer/tutorial.html#integer.tutorial.random_number_generation">Random number
generation</a></span></dt>
-<dt><span class="section">Primality testing</span></dt>
-<dt><span class="section"><a href="mp_int/tutorial.html#mp_int.tutorial.prime_number_generation">Prime number
+<dt><span class="section">Primality testing</span></dt>
+<dt><span class="section"><a href="integer/tutorial.html#integer.tutorial.prime_number_generation">Prime number
generation</a></span></dt>
+<dt><span class="section"><a href="integer/tutorial.html#integer.tutorial.using_the_gmp_backend">Using the GMP
+ backend</a></span></dt>
</dl></dd>
-<dt><span class="section">Performance</span></dt>
+<dt><span class="section">Performance</span></dt>
<dd><dl>
-<dt><span class="section">Tips</span></dt>
-<dt><span class="section">Measurements</span></dt>
+<dt><span class="section">Tips</span></dt>
+<dt><span class="section">Measurements</span></dt>
</dl></dd>
-<dt><span class="section">Implementation notes</span></dt>
+<dt><span class="section">Implementation notes</span></dt>
<dd><dl>
-<dt><span class="section"><a href="mp_int/implementation_notes.html#mp_int.implementation_notes.mp_int_structure">mp_int
+<dt><span class="section"><a href="integer/implementation_notes.html#integer.implementation_notes.integer_structure">integer
structure</a></span></dt>
-<dt><span class="section">Semantics</span></dt>
+<dt><span class="section">Semantics</span></dt>
</dl></dd>
-<dt><span class="section">mp_int reference</span></dt>
-<dt><span class="section">mp_int_traits reference</span></dt>
-<dt><span class="section">uniform_mp_int reference</span></dt>
-<dt><span class="section"><a href="mp_int/uniform_mp_int_bits_reference.html">uniform_mp_int_bits
+<dt><span class="section">integer reference</span></dt>
+<dt><span class="section">unbounded_int reference</span></dt>
+<dt><span class="section">unbounded_traits reference</span></dt>
+<dt><span class="section">uniform_integer reference</span></dt>
+<dt><span class="section"><a href="integer/uniform_integer_bits_reference.html">uniform_integer_bits
reference</a></span></dt>
-<dt><span class="section">Primality Tests reference</span></dt>
+<dt><span class="section">Primality Tests reference</span></dt>
<dd><dl>
-<dt><span class="section">primality_division_test</span></dt>
-<dt><span class="section">primality_fermat_test</span></dt>
-<dt><span class="section">primality_miller_rabin_test</span></dt>
+<dt><span class="section">primality_division_test</span></dt>
+<dt><span class="section">primality_fermat_test</span></dt>
+<dt><span class="section">primality_miller_rabin_test</span></dt>
</dl></dd>
-<dt><span class="section">Bibliography</span></dt>
+<dt><span class="section">Bibliography</span></dt>
</dl>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="mp_int.introduction"></a><a class="link" href="index.html#mp_int.introduction" title="Introduction">Introduction</a>
+<a name="integer.introduction"></a><a class="link" href="index.html#integer.introduction" title="Introduction">Introduction</a>
</h2></div></div></div>
<p>
- This library provides the <code class="computeroutput"><span class="identifier">mp_int</span></code>
- class template for arbitrary precision signed integers. These integers grow
- dynamically as needed. Additionally, special functions which are necessary
- for the implementation of public key cryptography such as prime generation
- are provided.
+ Note: This library is not an official boost library, it has not been reviewed
+ yet.
</p>
-<a name="mp_int.introduction.acknowledgement"></a><h4>
-<a name="id3155549"></a>
- <a class="link" href="index.html#mp_int.introduction.acknowledgement">Acknowledgement</a>
+<p>
+ The <code class="computeroutput"><span class="identifier">mp_math</span></code> library is the
+ namespace for all multiple precision arithmetic types. Such types have the
+ ability to grow dynamically as needed and thus provide arbitrary precision.
+ Currently, only unbounded integer types are provided via the <code class="computeroutput"><span class="identifier">integer</span></code> class template.
+ </p>
+<p>
+ This class template acts as a frontend for different backends. The most complete
+ backend is the native Boost one that you get without any effort on your part
+ by simply including the <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">mp_math</span><span class="special">/</span><span class="identifier">integer</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
+ header file. It is also the slowest. The other backends are a GMP backend and
+ a backend that is based on the libtommath library. Since I have become the
+ new maintainer of libtommath I am in the process of making custom adjustments
+ to libtommath in order for it to provide a more complete C++ experience.
+ </p>
+<p>
+ Read on in order to find out how to use the different backends and of course
+ about how to use these integer types.
+ </p>
+<a name="integer.introduction.acknowledgement"></a><h4>
+<a name="id2611223"></a>
+ <a class="link" href="index.html#integer.introduction.acknowledgement">Acknowledgement</a>
</h4>
<p>
This library originally started as a port of the C code of libtommath. Without
- the huge amount of work done by its author Tom St. Denis, this library wouldn't
+ the huge amount of work done by its author Tom St Denis, this library wouldn't
have been possible. Not only does he provide free C code, but also a very detailed
pdf document of over 200 pages explaining the algorithms used in his code.
- Both his documentation and his code were placed in the public domain. In the
- spirit of his work the code of the <code class="computeroutput"><span class="identifier">mp_int</span></code>
- library and its documentation are placed in the <span class="bold"><strong>public
- domain</strong></span> as well.
</p>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: January 17, 2009 at 00:01:17 GMT</small></p></td>
+<td align="left"><p><small>Last revised: July 13, 2009 at 20:10:20 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
-<div class="spirit-nav"><a accesskey="n" href="mp_int/tutorial.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a></div>
+<div class="spirit-nav"><a accesskey="n" href="integer/tutorial.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a></div>
</body>
</html>
Modified: sandbox/mp_math/libs/mp_math/doc/implementation_notes.qbk
==============================================================================
--- sandbox/mp_math/libs/mp_math/doc/implementation_notes.qbk (original)
+++ sandbox/mp_math/libs/mp_math/doc/implementation_notes.qbk 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -1,24 +1,24 @@
-[/ Copyright Kevin Sopp 2008.
+[/ Copyright Kevin Sopp 2008 - 2009.
/ Distributed under the Boost Software License, Version 1.0.
/ (See accompanying file LICENSE_1_0.txt or copy at
/ http://www.boost.org/LICENSE_1_0.txt)]
[section Implementation notes]
-[section mp_int structure]
+[section integer structure]
-An `mp_int` is handled in a sign plus magnitude representation which looks like
+An `integer` is handled in a sign plus magnitude representation which looks like
this:
- struct mp_int
+ struct integer
{
digit_type* digits_;
- size_type used_, capacity_;
- int sign_;
+ size_type size_, capacity_;
};
-The least significant digit of the number always lives at `digits_[0]` while the
-most significant lives at `digits_[used_ - 1]`.
+The sign is stored in the high bit of `capacity_` which is 0 for positive and 1
+for negative integers. The least significant digit of the number always lives at `digits_[0]` while the
+most significant lives at `digits_[size_ - 1]`.
Libtommath on which this code is ultimately based chose a `digit_type`
representation which does not use all of its bits, instead some bits are
@@ -27,18 +27,18 @@
bits in the `digit_type` but needs explicit carry handling in the code. This
makes normal c++ code a tad slower. However it makes it much easier to write
assembler routines since most CPUs provide instructions that allow the handling
-of carries in place. This is what GMP does as well. It is possible that a
-`digit_type` representation similar to libtommath's returns someday which can
-then be enabled via a different `mp_int_traits` class template.
+of carries in place. It is possible that a `digit_type` representation similar
+to libtommath's returns someday which can then be enabled via a different
+traits class template.
-[endsect][/How mp_int structure]
+[endsect][/integer structure]
[section Semantics]
-* An integer with a value of zero has a `used_` count of 1 and `digits_[0]`
+* An `integer` with a value of zero has a `size_` of 1 and `digits_[0]`
holds the value 0.
-* An unitialized integer has no value and all operations on it except for
+* An unitialized `integer` has no value and all operations on it except for
initializing or swapping are undefined.
[endsect][/Semantics]
Copied: sandbox/mp_math/libs/mp_math/doc/integer.qbk (from r54215, /sandbox/mp_math/libs/mp_math/doc/mp_int.qbk)
==============================================================================
--- /sandbox/mp_math/libs/mp_math/doc/mp_int.qbk (original)
+++ sandbox/mp_math/libs/mp_math/doc/integer.qbk 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -3,10 +3,10 @@
/ (See accompanying file LICENSE_1_0.txt or copy at
/ http://www.boost.org/LICENSE_1_0.txt)]
-[library mp_int
+[library integer
[quickbook 1.4]
- [id mp_int]
- [dirname mp_int]
+ [id integer]
+ [dirname integer]
[copyright 2008 - 2009 Kevin Sopp]
[purpose multi precision integer arithmetic]
[authors [Sopp, Kevin]]
@@ -20,10 +20,11 @@
[include tutorial.qbk]
[include performance.qbk]
[include implementation_notes.qbk]
-[include mp_int_reference.qbk]
-[include mp_int_traits_reference.qbk]
-[include uniform_mp_int_reference.qbk]
-[include uniform_mp_int_bits_reference.qbk]
+[include integer_reference.qbk]
+[include unbounded_int_reference.qbk]
+[include unbounded_traits_reference.qbk]
+[include uniform_integer_reference.qbk]
+[include uniform_integer_bits_reference.qbk]
[include primality_tests_reference.qbk]
[include bibliography.qbk]
Modified: sandbox/mp_math/libs/mp_math/doc/introduction.qbk
==============================================================================
--- sandbox/mp_math/libs/mp_math/doc/introduction.qbk (original)
+++ sandbox/mp_math/libs/mp_math/doc/introduction.qbk 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -1,23 +1,35 @@
-[/ Copyright Kevin Sopp 2008.
+[/ Copyright Kevin Sopp 2008 - 2009.
/ Distributed under the Boost Software License, Version 1.0.
/ (See accompanying file LICENSE_1_0.txt or copy at
/ http://www.boost.org/LICENSE_1_0.txt)]
[section Introduction]
-This library provides the `mp_int` class template for arbitrary precision signed
-integers. These integers grow dynamically as needed. Additionally, special
-functions which are necessary for the implementation of public key cryptography
-such as prime generation are provided.
+Note: This library is not an official boost library, it has not been reviewed
+yet.
+
+The `mp_math` library is the namespace for all multiple precision arithmetic
+types. Such types have the ability to grow dynamically as needed and thus
+provide arbitrary precision. Currently, only unbounded integer types are provided
+via the `integer` class template.
+
+This class template acts as a frontend for different backends. The most complete
+backend is the native Boost one that you get without any effort on your part by
+simply including the `<boost/mp_math/integer.hpp>` header file. It is also the
+slowest. The other backends are a GMP backend and a backend that is based on the
+libtommath library. Since I have become the new maintainer of libtommath I am in
+the process of making custom adjustments to libtommath in order for it to
+provide a more complete C++ experience.
+
+Read on in order to find out how to use the different backends and of course
+about how to use these integer types.
+
[heading Acknowledgement]
This library originally started as a port of the C code of libtommath. Without
-the huge amount of work done by its author Tom St. Denis, this library wouldn't
+the huge amount of work done by its author Tom St Denis, this library wouldn't
have been possible. Not only does he provide free C code, but also a very
detailed pdf document of over 200 pages explaining the algorithms used in his
-code. Both his documentation and his code were placed in the public domain. In
-the spirit of his work the code of the `mp_int` library and its documentation
-are placed in the [*public domain] as well.
-
+code.
[endsect]
Modified: sandbox/mp_math/libs/mp_math/doc/jamfile.v2
==============================================================================
--- sandbox/mp_math/libs/mp_math/doc/jamfile.v2 (original)
+++ sandbox/mp_math/libs/mp_math/doc/jamfile.v2 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -1,4 +1,4 @@
-# Copyright Kevin Sopp 2008.
+# Copyright Kevin Sopp 2008 - 2009.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
@@ -6,16 +6,16 @@
import quickbook ;
-xml mp_int : mp_int.qbk ;
+xml integer : integer.qbk ;
#boostbook standalone
# :
-# mp_int mp_int
+# integer integer
# ;
boostbook standalone
:
- mp_int
+ integer
:
<xsl:param>boost.root=../../../..
<xsl:param>boost.libraries=../../../../libs/libraries.htm
Deleted: sandbox/mp_math/libs/mp_math/doc/mp_int.qbk
==============================================================================
--- sandbox/mp_math/libs/mp_math/doc/mp_int.qbk 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
+++ (empty file)
@@ -1,29 +0,0 @@
-[/ Copyright Kevin Sopp 2008 - 2009.
- / Distributed under the Boost Software License, Version 1.0.
- / (See accompanying file LICENSE_1_0.txt or copy at
- / http://www.boost.org/LICENSE_1_0.txt)]
-
-[library mp_int
- [quickbook 1.4]
- [id mp_int]
- [dirname mp_int]
- [copyright 2008 - 2009 Kevin Sopp]
- [purpose multi precision integer arithmetic]
- [authors [Sopp, Kevin]]
- [license Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENSE_1_0.txt or copy at
- [@http://www.boost.org/LICENSE_1_0.txt]]
- [source-mode c++]
-]
-
-[include introduction.qbk]
-[include tutorial.qbk]
-[include performance.qbk]
-[include implementation_notes.qbk]
-[include mp_int_reference.qbk]
-[include mp_int_traits_reference.qbk]
-[include uniform_mp_int_reference.qbk]
-[include uniform_mp_int_bits_reference.qbk]
-[include primality_tests_reference.qbk]
-[include bibliography.qbk]
-
Deleted: sandbox/mp_math/libs/mp_math/doc/mp_int_reference.qbk
==============================================================================
--- sandbox/mp_math/libs/mp_math/doc/mp_int_reference.qbk 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
+++ (empty file)
@@ -1,1376 +0,0 @@
-[/ Copyright Kevin Sopp 2008 - 2009.
- / Distributed under the Boost Software License, Version 1.0.
- / (See accompanying file LICENSE_1_0.txt or copy at
- / http://www.boost.org/LICENSE_1_0.txt)]
-
-[section mp_int reference]
-
-[heading Synopsis]
-
- // <boost/mp_math/mp_int.hpp>
- namespace boost {
- namespace mp_math {
-
- template<
- class Allocator = std::allocator<void>,
- class Traits = mp_int_traits<>
- >
- struct mp_int
- {
- typedef Allocator allocator_type;
- typedef Traits traits_type;
- typedef typename base_allocator_type::size_type size_type;
-
- // ctor/cctor/dtor/assign
- mp_int();
-
- explicit mp_int(const allocator_type& a);
-
- template<typename IntegralT>
- mp_int(IntegralT,
- const allocator_type& a = allocator_type(),
- typename enable_if<is_integral<IntegralT> >::type* dummy = 0);
-
- template<typename charT>
- mp_int(const charT*, const allocator_type& a = allocator_type());
-
- template<typename charT>
- mp_int(const charT*,
- std::ios_base::fmtflags,
- const allocator_type& a = allocator_type());
-
- template<typename charT, class traits, class Alloc>
- mp_int(const std::basic_string<charT,traits,Alloc>&,
- const allocator_type& a = allocator_type());
-
- template<typename charT, class traits, class Alloc>
- mp_int(const std::basic_string<charT,traits,Alloc>&,
- std::ios_base::fmtflags,
- const allocator_type& a = allocator_type());
-
- template<typename RandomAccessIterator>
- mp_int(RandomAccessIterator first,
- RandomAccessIterator last,
- const allocator_type& a = allocator_type());
-
- template<typename RandomAccessIterator>
- mp_int(RandomAccessIterator first,
- RandomAccessIterator last,
- std::ios_base::fmtflags f,
- const allocator_type& a = allocator_type());
-
- mp_int(const mp_int& copy);
-
- #ifdef BOOST_HAS_RVALUE_REFS
- mp_int(mp_int&& copy);
- #endif
-
- ~mp_int();
-
- mp_int& operator = (const mp_int& rhs);
-
- #ifdef BOOST_HAS_RVALUE_REFS
- mp_int& operator = (mp_int&& rhs);
- #endif
-
- template<typename IntegralT>
- mp_int& operator = (IntegralT rhs);
-
- template<typename charT>
- mp_int& operator = (const charT*);
-
- template<typename charT, class traits, class Alloc>
- mp_int& operator = (const std::basic_string<charT,traits,Alloc>&);
-
- template<typename charT>
- void assign(const charT*, std::ios_base::fmtflags);
-
- template<typename charT, class traits, class Alloc>
- void assign(const std::basic_string<charT,traits,Alloc>&,
- std::ios_base::fmtflags);
-
- template<typename RandomAccessIterator>
- void assign(RandomAccessIterator first, RandomAccessIterator last,
- std::ios_base::fmtflags);
-
- // modifiers
- #ifdef BOOST_HAS_RVALUE_REFS
- void swap(mp_int&& other);
- #else
- void swap(mp_int& other);
- #endif
-
- // increment/decrement
- mp_int& operator ++();
- mp_int& operator --();
- mp_int operator ++(int);
- mp_int operator --(int);
-
- // shifting
- mp_int& operator <<= (size_type);
- mp_int& operator >>= (size_type);
-
- // unary negate
- mp_int& operator - ();
-
- // arithmetic operators
- mp_int& operator += (const mp_int& x);
- mp_int& operator -= (const mp_int& x);
- mp_int& operator *= (const mp_int& x);
- mp_int& operator /= (const mp_int& x);
- mp_int& operator %= (const mp_int& x);
-
- // bitwise operators
- mp_int& operator |= (const mp_int& x);
- mp_int& operator &= (const mp_int& x);
- mp_int& operator ^= (const mp_int& x);
-
- // operators involving integral types
- template<typename IntegralT> mp_int& operator += (IntegralT x);
- template<typename IntegralT> mp_int& operator -= (IntegralT x);
- template<typename IntegralT> mp_int& operator *= (IntegralT x);
- template<typename IntegralT> mp_int& operator /= (IntegralT x);
- template<typename IntegralT> mp_int& operator %= (IntegralT x);
- template<typename IntegralT> mp_int& operator |= (IntegralT x);
- template<typename IntegralT> mp_int& operator &= (IntegralT x);
- template<typename IntegralT> mp_int& operator ^= (IntegralT x);
-
- // operators involving character strings
- template<typename charT> mp_int& operator += (const charT*);
- template<typename charT> mp_int& operator -= (const charT*);
- template<typename charT> mp_int& operator *= (const charT*);
- template<typename charT> mp_int& operator /= (const charT*);
- template<typename charT> mp_int& operator %= (const charT*);
- template<typename charT> mp_int& operator |= (const charT*);
- template<typename charT> mp_int& operator &= (const charT*);
- template<typename charT> mp_int& operator ^= (const charT*);
-
- // operators involving std::basic_string
- template<typename charT, class traits, class Alloc>
- mp_int& operator += (const std::basic_string<charT,traits,Alloc>& s);
- template<typename charT, class traits, class Alloc>
- mp_int& operator -= (const std::basic_string<charT,traits,Alloc>& s);
- template<typename charT, class traits, class Alloc>
- mp_int& operator *= (const std::basic_string<charT,traits,Alloc>& s);
- template<typename charT, class traits, class Alloc>
- mp_int& operator /= (const std::basic_string<charT,traits,Alloc>& s);
- template<typename charT, class traits, class Alloc>
- mp_int& operator %= (const std::basic_string<charT,traits,Alloc>& s);
- template<typename charT, class traits, class Alloc>
- mp_int& operator |= (const std::basic_string<charT,traits,Alloc>& s);
- template<typename charT, class traits, class Alloc>
- mp_int& operator &= (const std::basic_string<charT,traits,Alloc>& s);
- template<typename charT, class traits, class Alloc>
- mp_int& operator ^= (const std::basic_string<charT,traits,Alloc>& s);
-
- // observers
- allocator_type get_allocator() const;
-
- bool is_even() const;
- bool is_odd () const;
-
- bool is_positive() const;
- bool is_negative() const;
-
- size_type precision() const;
-
- operator unspecified_bool_type() const;
-
- std::string to_string(std::ios_base::fmtflags f = std::ios_base::dec) const;
-
- template<typename IntegralT>
- IntegralT to_integral() const;
-
- // low level access
- typedef traits_type::digit_type digit_type;
- typedef traits_type::word_type word_type;
-
- digit_type& operator[](size_type i);
- const digit_type& operator[](size_type i) const;
-
- digit_type& at(size_type i);
- const digit_type& at(size_type i) const;
- };
-
-
- // non-member functions
-
- #ifdef BOOST_HAS_RVALUE_REFS
- template<class A, class T>
- void swap(mp_int<A,T>&&, mp_int<A,T>&&);
- #else
- void swap(mp_int<A,T>&, mp_int<A,T>&);
- #endif
-
- template<class A, class T>
- mp_int<A,T> operator << (const mp_int<A,T>&, typename mp_int<A,T>::size_type);
-
- template<class A, class T>
- mp_int<A,T> operator >> (const mp_int<A,T>&, typename mp_int<A,T>::size_type);
-
- template<class A, class T>
- mp_int<A,T> operator - (const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> operator + (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> operator - (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> operator * (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> operator / (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> operator % (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> operator | (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> operator & (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> operator ^ (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T, typename IntegralT>
- mp_int<A,T> operator + (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- mp_int<A,T> operator - (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- mp_int<A,T> operator * (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- mp_int<A,T> operator / (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- mp_int<A,T> operator % (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- mp_int<A,T> operator | (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- mp_int<A,T> operator & (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- mp_int<A,T> operator ^ (const mp_int<A,T>&, IntegralT);
-
-
- // Comparison operators
-
- template<class A, class T>
- bool operator == (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- bool operator != (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- bool operator < (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- bool operator > (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- bool operator <= (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- bool operator >= (const mp_int<A,T>&, const mp_int<A,T>&);
-
- // Comparison between mp_int and std::basic_string
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator == (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator != (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator < (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator > (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator <= (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator >= (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
-
- // Comparison between std::basic_string and mp_int
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator == (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator != (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator < (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator > (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator <= (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator >= (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
-
- // Comparison between mp_int and const charT*
-
- template<class A, class T>
- bool operator == (const mp_int<A,T>&, const charT*);
-
- template<class A, class T>
- bool operator != (const mp_int<A,T>&, const charT*);
-
- template<class A, class T>
- bool operator < (const mp_int<A,T>&, const charT*);
-
- template<class A, class T>
- bool operator > (const mp_int<A,T>&, const charT*);
-
- template<class A, class T>
- bool operator <= (const mp_int<A,T>&, const charT*);
-
- template<class A, class T>
- bool operator >= (const mp_int<A,T>&, const charT*);
-
- // Comparison between const charT* and mp_int
-
- template<class A, class T>
- bool operator == (const charT*, const mp_int<A,T>&);
-
- template<class A, class T>
- bool operator != (const charT*, const mp_int<A,T>&);
-
- template<class A, class T>
- bool operator < (const charT*, const mp_int<A,T>&);
-
- template<class A, class T>
- bool operator > (const charT*, const mp_int<A,T>&);
-
- template<class A, class T>
- bool operator <= (const charT*, const mp_int<A,T>&);
-
- template<class A, class T>
- bool operator >= (const charT*, const mp_int<A,T>&);
-
- // Comparison between mp_int and integral type
-
- template<class A, class T, typename IntegralT>
- bool operator == (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- bool operator != (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- bool operator < (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- bool operator > (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- bool operator <= (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- bool operator >= (const mp_int<A,T>&, IntegralT);
-
- // Comparison between integral type and mp_int
-
- template<class A, class T, typename IntegralT>
- bool operator == (IntegralT, const mp_int<A,T>&);
-
- template<class A, class T, typename IntegralT>
- bool operator != (IntegralT, const mp_int<A,T>&);
-
- template<class A, class T, typename IntegralT>
- bool operator < (IntegralT, const mp_int<A,T>&);
-
- template<class A, class T, typename IntegralT>
- bool operator > (IntegralT, const mp_int<A,T>&);
-
- template<class A, class T, typename IntegralT>
- bool operator <= (IntegralT, const mp_int<A,T>&);
-
- template<class A, class T, typename IntegralT>
- bool operator >= (IntegralT, const mp_int<A,T>&);
-
-
- // Stream I/O
-
- template<class A, class T, typename charT, class traits>
- std::basic_istream<charT, traits>&
- operator >> (std::basic_istream<charT, traits>& is, mp_int<A,T>& x);
-
- template<class A, class T, typename charT, class traits>
- std::basic_ostream<charT, traits>&
- operator << (std::basic_ostream<charT, traits>& os, const mp_int<A,T>& x);
-
-
- // Special functions
-
- template<class A, class T>
- mp_int<A,T> abs(const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> gcd(const mp_int<A,T>& a, const mp_int<A,T>& b);
-
- template<class A, class T>
- mp_int<A,T> lcm(const mp_int<A,T>& a, const mp_int<A,T>& b);
-
- template<class A, class T>
- int jacobi(const mp_int<A,T>& a, const mp_int<A,T>& p);
-
- template<class A, class T>
- mp_int<A,T> pow(const mp_int<A,T>& x, typename mp_int<A,T>::digit_type n);
-
- template<class A, class T>
- mp_int<A,T> pow(const mp_int<A,T>& x, const mp_int<A,T>& n);
-
- template<class A, class T>
- mp_int<A,T> modpow(const mp_int<A,T>& base, const mp_int<A,T>& exp, const mp_int<A,T>& mod);
-
- template<class A, class T>
- mp_int<A,T> sqrt(const mp_int<A,T>& x);
-
- template<class A, class T>
- mp_int<A,T> nth_root(const mp_int<A,T>& x, typename mp_int<A,T>::digit_type n);
-
- template<class A, class T>
- mp_int<A,T> nth_root(const mp_int<A,T>& x, const mp_int<A,T>& n);
-
-
- } // namespace mp_math
- } // namespace boost
-
-
-[h3 Construction from / assignment to a string object]
-In a constructor or assignment operation without the possibility to specify the base
-of the string argument the base of the number is deduced from the string. If the
-string starts with `0x` or `0X` then the number will be treated as hexadecimal
-value. If the string starts with `0` then the number will be treated as octal
-value else it will be treated as decimal value. An optional `-` sign is allowed
-as the first character in the string to indicate a negative value.
-
-In a constructor or assignment operation with the ability to specify the format
-of the string argument via a `std::ios_base::fmtflags` parameter, possible
-formatting flags are:
-
-* `std::ios_base::showbase`
-* `std::ios_base::dec`
-* `std::ios_base::hex`
-* `std::ios_base::oct`
-
-
-[heading Construct/Copy/Destroy/Assign]
-
- mp_int();
-
-* [*Effects:] Constructs an empty `mp_int` object, such an uninitialized
-`mp_int` has no value, i.e. it is /not/ zero.
-* [*Complexity:] O(1).
-* [*Throws:] Nothing.
-
-
- explicit mp_int(const allocator_type& a);
-
-* [*Effects:] Constructs an empty `mp_int` object and initializes its allocator
-with `a`, such an uninitialized `mp_int` has no value, i.e. it is /not/ zero.
-* [*Complexity:] O(1).
-* [*Throws:] Nothing.
-
-
- template<typename IntegralT>
- mp_int(IntegralT x,
- const allocator_type& a = allocator_type(),
- typename enable_if<is_integral<IntegralT> >::type* dummy = 0);
-
-* [*Effects:] Constructs an `mp_int` object from an integral type. The value of
-the object is that of the integral type.
-* [*Complexity:] O(N) where N is the number of bits of IntegralT.
-* [*Throws: ] `std::bad_alloc`.
-
-
- template<typename charT>
- mp_int(const charT* s, const allocator_type& a = allocator_type());
-
-* [*Requires: ] `s` points to a valid number formatted as string or to an empty
-string.
-* [*Effects:] Constructs an `mp_int` object from a string.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::invalid_argument` if the string contains an invalid character.
-
-
- template<typename charT>
- mp_int(const charT* s,
- std::ios_base::fmtflags f,
- const allocator_type& a = allocator_type());
-
-* [*Requires: ] `s` points to a valid number formatted according to the flags in
-`f` or `s` is an empty string.
-* [*Effects:] Constructs an `mp_int` object from a string.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::invalid_argument` if the string contains an invalid character or if an
- unrecognized formatting flag was set.
-
-
- template<typename charT, class traits, class Alloc>
- mp_int(const std::basic_string<charT,traits,Alloc>& s,
- const allocator_type& a = allocator_type());
-
-* [*Requires: ] `s` contains a valid number formatted as string or `s` is an
-empty string.
-* [*Effects:] Constructs an `mp_int` object from a string.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::invalid_argument` if the string contains an invalid character.
-
-
- template<typename charT, class traits, class Alloc>
- mp_int(const std::basic_string<charT,traits,Alloc>& s,
- std::ios_base::fmtflags f,
- const allocator_type& a = allocator_type());
-
-* [*Requires: ] `s` contains a valid number formatted according to the flags in
-`f` or `s` is an empty string.
-* [*Effects:] Constructs an `mp_int` object from a string.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::invalid_argument` if the string contains an invalid character or if an
- unrecognized formatting flag was set.
-
-
- template<typename RandomAccessIterator>
- mp_int(RandomAccessIterator first,
- RandomAccessIterator last,
- const allocator_type& a = allocator_type());
-
-* [*Requires: ] `first` and `last` are iterators into a string.
-* [*Effects:] Constructs an `mp_int` object from two iterators.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::invalid_argument` if the string contains an invalid character.
-
-
- template<typename RandomAccessIterator>
- mp_int(RandomAccessIterator first,
- RandomAccessIterator last,
- std::ios_base::fmtflags f,
- const allocator_type& a = allocator_type());
-
-* [*Requires: ] `first` and `last` are iterators into a string formatted
-according to the formatting flags in `f`.
-* [*Effects:] Constructs an `mp_int` object from two iterators.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::invalid_argument` if the string contains an invalid character or if an
- unrecognized formatting flag was set.
-
-
- mp_int(const mp_int& copy);
-
-* [*Effects:] Constructs a copy of a given `mp_int`.
-* [*Complexity:] O(N), where N is the number of digits in `copy`.
-* [*Throws: ] `std::bad_alloc`.
-
-
- mp_int(mp_int&& copy);
-
-* [*Effects:] Constructs an `mp_int` by moving `copy` into `*this`.
-* [*Complexity:] O(1).
-* [*Throws:] Nothing.
-
-
- ~mp_int();
-
-* [*Effects:] Destroys `*this`.
-* [*Complexity:] O(1).
-* [*Throws:] Nothing.
-
-
- mp_int& operator = (const mp_int& rhs);
-
-* [*Effects:] Copies the value of `rhs` into `*this`.
-* [*Returns: ] `*this`.
-* [*Complexity:] O(N).
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- mp_int& operator = (mp_int&& rhs);
-
-* [*Effects: ] `*this` obtains the value of `rhs`.
-* [*Returns: ] `*this`.
-* [*Complexity:] O(1).
-* [*Throws:] Nothing.
-
-
- template<typename IntegralT>
- mp_int& operator = (IntegralT rhs);
-
-* [*Effects: ] `*this` obtains the value of `rhs`.
-* [*Returns: ] `*this`.
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] basic.
-
-
- template<typename charT>
- mp_int& operator = (const charT* s);
-
-* [*Requires: ] `s` points to a valid number formatted as string or to an empty
-string.
-* [*Effects:] `*this = mp_int(s);`.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::invalid_argument` if the string contains an invalid character.
-* [*Exception safety:] basic.
-
-
- template<typename charT, class traits, class Alloc>
- mp_int& operator = (const std::basic_string<charT,traits,Alloc>& s);
-
-* [*Requires: ] `s` points to a valid number formatted as string or to an empty
-string.
-* [*Effects:] `*this = mp_int(s);`.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::invalid_argument` if the string contains an invalid character.
-* [*Exception safety:] basic.
-
-
- template<typename charT>
- void assign(const charT* s, std::ios_base::fmtflags);
-
-* [*Requires: ] `s` points to a valid number formatted according to the flags in
-`f` or `s` is an empty string.
-* [*Effects:] Constructs an `mp_int` object from a string.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::invalid_argument` if the string contains an invalid character or if an
- unrecognized formatting flag was set.
-* [*Exception safety:] basic.
-
-
- template<typename charT, class traits, class Alloc>
- void assign(const std::basic_string<charT,traits,Alloc>& s, std::ios_base::fmtflags f);
-
-* [*Requires: ] `s` contains a valid number formatted according to the flags in
-`f` or `s` is an empty string.
-* [*Effects:] Constructs an `mp_int` object from a string.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::invalid_argument` if the string contains an invalid character or if an
- unrecognized formatting flag was set.
-* [*Exception safety:] basic.
-
-
- template<typename RandomAccessIterator>
- void assign(RandomAccessIterator first, RandomAccessIterator last, std::ios_base::fmtflags f);
-
-* [*Requires: ] `first` and `last` are iterators into a string formatted
-according to the formatting flags in `f`.
-* [*Effects:] Constructs an `mp_int` object from two iterators.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::invalid_argument` if the string contains an invalid character or if an
- unrecognized formatting flag was set.
-* [*Exception safety:] basic.
-
-
-[heading Modifiers]
-
- void swap(mp_int&& other);
-
-* [*Effects:] Swaps the value of `other` and `*this`.
-* [*Complexity:] O(1).
-* [*Exception safety:] nothrow.
-
-
- void swap(mp_int& other);
-
-* [*Effects:] Swaps the value of `other` and `*this`.
-* [*Complexity:] O(1).
-* [*Exception safety:] nothrow.
-
-
-[heading Increment/decrement]
-
- mp_int& operator ++();
-
-* [*Effects:]
-``
-*this += 1;
-return *this;
-``
-* [*Returns: ] `*this`.
-* [*Complexity:] best case is O(1), worst case is O(N) - this happens when the
-addition causes a carry bit to ripple through all digits subsequently.
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- mp_int& operator --();
-
-* [*Effects:]
-``
-*this -= 1;
-return *this;
-``
-* [*Returns: ] `*this`.
-* [*Complexity:] best case is O(1), worst case is O(N) - this happens when the
-subtraction causes a borrow bit to ripple through all digits subsequently.
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- mp_int operator ++(int);
-
-* [*Effects:]
-``
-mp_int tmp(*this);
-*this += 1;
-return tmp;
-``
-* [*Returns:] The value of `*this` before incrementation.
-* [*Complexity:] O(N).
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- mp_int operator --(int);
-
-* [*Effects:]
-``
-mp_int tmp(*this);
-*this -= 1;
-return tmp;
-``
-* [*Returns:] The value of `*this` before decrementation.
-* [*Complexity:] O(N).
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
-[heading Shifting]
-
- mp_int& operator <<= (size_type x);
-
-* [*Effects:] Shift `*this` by `x` bits to the left.
-* [*Returns: ] `*this`.
-* [*Complexity:] O(N).
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- mp_int& operator >>= (size_type x);
-
-* [*Effects:] Shift `*this` by `x` bits to the right.
-* [*Returns: ] `*this`.
-* [*Complexity:] O(N).
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
-[heading Unary negate]
-
- mp_int& operator - ();
-
-* [*Effects:] Negates `*this`.
-* [*Returns: ] `*this`.
-* [*Complexity:] O(1).
-* [*Exception safety:] nothrow.
-
-
-[heading Arithmetic operators]
-
- mp_int& operator += (const mp_int& x);
-
-* [*Effects:] Adds `x` to `*this`.
-* [*Returns: ] `*this`.
-* [*Complexity:] O(N).
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- mp_int& operator -= (const mp_int& x);
-
-
-* [*Effects:] Subtracts `x` from `*this`.
-* [*Returns: ] `*this`.
-* [*Complexity:] O(N).
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- mp_int& operator *= (const mp_int& x);
-
-* [*Effects:] Multiplies `*this` by `x`.
-* [*Returns: ] `*this`.
-* [*Complexity:] If `&x == this` then a squaring algorithm will be used.
-Different multiplication algorithms are chosen for numbers of different size.
-The thresholds can be tuned via the `mp_int_traits` class template parameter.
- * Small numbers: Comba algorithm O(N^2).
- * Midsize numbers: Karatsuba algorithm O(N^log2(3)) ~ O(N^1.585).
- * Large numbers: Toom-Cook algorithm O(N^(log(5)/log(3))) ~ O(N^1.465).
-
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- mp_int& operator /= (const mp_int& x);
-
-* [*Requires: ] `x != 0`.
-* [*Effects:] Divides `*this` by `x`.
-* [*Returns: ] `*this`.
-* [*Throws: ]
- * `std::bad_alloc`
- * `std::domain_error` if `x == 0`.
-
-* [*Exception safety:] strong.
-
-
- mp_int& operator %= (const mp_int& x);
-
-* [*Requires: ] `x != 0`.
-* [*Effects:] Modulus `*this` by `x`.
-* [*Returns: ] `*this`.
-* [*Throws: ]
- * `std::bad_alloc`
- * `std::domain_error` if `x == 0`.
-
-* [*Exception safety:] strong.
-
-
-[heading Bitwise operators]
-
- mp_int& operator |= (const mp_int& x);
-
-* [*Effects: ] `*this` OR `x`.
-* [*Returns: ] `*this`.
-* [*Complexity:] O(N).
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- mp_int& operator &= (const mp_int& x);
-
-* [*Effects: ] `*this` AND `x`.
-* [*Returns: ] `*this`.
-* [*Complexity:] O(N).
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- mp_int& operator ^= (const mp_int& x);
-
-* [*Effects: ] `*this` XOR `x`.
-* [*Returns: ] `*this`.
-* [*Complexity:] O(N).
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
-[heading Operators involving integral types]
-
- template<typename IntegralT> mp_int& operator += (IntegralT x);
-
-* [*Effects:] Adds `x` to `*this`.
-* [*Returns: ] `*this`.
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- template<typename IntegralT> mp_int& operator -= (IntegralT x);
-
-* [*Effects:] Subtracts `x` to `*this`.
-* [*Returns: ] `*this`.
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- template<typename IntegralT> mp_int& operator *= (IntegralT x);
-
-* [*Effects:] Multiplies `*this` by `x`.
-* [*Returns: ] `*this`.
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- template<typename IntegralT> mp_int& operator /= (IntegralT x);
-
-* [*Effects:] Divides `*this` by `x`.
-* [*Returns: ] `*this`.
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- template<typename IntegralT> mp_int& operator %= (IntegralT x);
-
-* [*Effects: ] `*this` modulo `x`.
-* [*Returns: ] `*this`.
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- template<typename IntegralT> mp_int& operator |= (IntegralT x);
-
-* [*Effects:] Applies the bitwise or operation on `*this` and the absolute of `x`.
-* [*Returns: ] `*this`.
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- template<typename IntegralT> mp_int& operator &= (IntegralT x);
-
-* [*Effects:] Applies the bitwise and operation on `*this` and the absolute of `x`.
-* [*Returns: ] `*this`.
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- template<typename IntegralT> mp_int& operator ^= (IntegralT x);
-
-* [*Effects:] Applies the bitwise xor operation on `*this` and the absolute of `x`.
-* [*Returns: ] `*this`.
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
-[heading Operators involving charT strings]
-
- template<typename charT> mp_int& operator += (const charT* s);
- template<typename charT> mp_int& operator -= (const charT* s);
- template<typename charT> mp_int& operator *= (const charT* s);
- template<typename charT> mp_int& operator /= (const charT* s);
- template<typename charT> mp_int& operator %= (const charT* s);
- template<typename charT> mp_int& operator |= (const charT* s);
- template<typename charT> mp_int& operator &= (const charT* s);
- template<typename charT> mp_int& operator ^= (const charT* s);
-
-[heading Operators involving std::basic_string]
-
- template<typename charT, class traits, class Alloc>
- mp_int& operator += (const std::basic_string<charT,traits,Alloc>& s);
- template<typename charT, class traits, class Alloc>
- mp_int& operator -= (const std::basic_string<charT,traits,Alloc>& s);
- template<typename charT, class traits, class Alloc>
- mp_int& operator *= (const std::basic_string<charT,traits,Alloc>& s);
- template<typename charT, class traits, class Alloc>
- mp_int& operator /= (const std::basic_string<charT,traits,Alloc>& s);
- template<typename charT, class traits, class Alloc>
- mp_int& operator %= (const std::basic_string<charT,traits,Alloc>& s);
- template<typename charT, class traits, class Alloc>
- mp_int& operator |= (const std::basic_string<charT,traits,Alloc>& s);
- template<typename charT, class traits, class Alloc>
- mp_int& operator &= (const std::basic_string<charT,traits,Alloc>& s);
- template<typename charT, class traits, class Alloc>
- mp_int& operator ^= (const std::basic_string<charT,traits,Alloc>& s);
-
-
-[heading Observers]
-
- allocator_type get_allocator() const;
-
-* [*Returns: ] A copy of the allocator.
-* [*Complexity:] O(1).
-* [*Throws:] Nothing if allocator copy constructor is nothrow.
-
-
- bool is_even() const;
-
-* [*Complexity:] O(1).
-* [*Throws:] Nothing.
-
-
- bool is_odd () const;
-
-* [*Complexity:] O(1).
-* [*Throws:] Nothing.
-
-
- bool is_positive() const;
-
-* [*Complexity:] O(1).
-* [*Throws:] Nothing.
-
-
- bool is_negative() const;
-
-* [*Complexity:] O(1).
-* [*Throws:] Nothing.
-
-
- size_type precision() const;
-
-* [*Returns:] The number of bits used by the absolute value of *this.
-* [*Complexity:] O(N).
-* [*Throws:] Nothing.
-
- operator unspecified_bool_type() const;
-
-* [*Returns: ] `*this != 0`.
-* [*Complexity:] O(1).
-* [*Throws:] Nothing.
-
-
- std::string to_string(std::ios_base::fmtflags f = std::ios_base::dec) const;
-
-* [*Effects:] Converts `*this` to a `std::string`, formatting of the string is
-done according to the `std::ios_base::fmtflags` parameter. Possible formatting
-flags are:
- * `std::ios_base::showpos`
- * `std::ios_base::showbase`
- * `std::ios_base::dec`
- * `std::ios_base::hex`
- * `std::ios_base::oct`
- * `std::ios_base::uppercase`
-
-* [*Returns: ] `*this` converted to a `std::string` object.
-* [*Throws: ] `std::bad_alloc`.
-* [*Exception safety:] strong.
-
-
- template<typename IntegralT>
- IntegralT to_integral() const;
-
-* [*Returns: ] `*this` converted to an object of type `IntegralT`.
-* [*Complexity:] O(1).
-* [*Throws: ] `std::overflow_error` if `IntegralT` does not have enough
-precision to hold the result.
-* [*Exception safety:] strong.
-
-
-
-[heading Non-member functions]
-
- template<class A, class T>
- void swap(mp_int<A,T>&&, mp_int<A,T>&&);
-
- template<class A, class T>
- mp_int<A,T> operator << (const mp_int<A,T>&, typename mp_int<A,T>::size_type);
-
- template<class A, class T>
- mp_int<A,T> operator >> (const mp_int<A,T>&, typename mp_int<A,T>::size_type);
-
- template<class A, class T>
- mp_int<A,T> operator - (const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> operator + (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> operator - (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> operator * (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> operator / (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> operator % (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> operator | (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> operator & (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- mp_int<A,T> operator ^ (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T, typename IntegralT>
- mp_int<A,T> operator + (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- mp_int<A,T> operator - (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- mp_int<A,T> operator * (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- mp_int<A,T> operator / (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- mp_int<A,T> operator % (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- mp_int<A,T> operator | (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- mp_int<A,T> operator & (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- mp_int<A,T> operator ^ (const mp_int<A,T>&, IntegralT);
-
-These functions are implemented in terms of their respective member functions.
-
-
-[heading Comparison operators]
-
- template<class A, class T>
- bool operator == (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- bool operator != (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- bool operator < (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- bool operator > (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- bool operator <= (const mp_int<A,T>&, const mp_int<A,T>&);
-
- template<class A, class T>
- bool operator >= (const mp_int<A,T>&, const mp_int<A,T>&);
-
-* [*Effects:] These operators compare the numeric value of their arguments and
-return a truth value based on that evaluation.
-* [*Throws:] Nothing.
-
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator == (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator != (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator < (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator > (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator <= (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator >= (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
-
-* [*Effects:] Converts the string argument to an `mp_int` object and compares it
-to the object on the left side of the expression.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::invalid_argument` if the string contains an invalid character.
-
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator == (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator != (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator < (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator > (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator <= (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
-
- template<class A, class T, class charT, class Traits, class Alloc>
- bool operator >= (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
-
-* [*Effects:] Converts the string argument to an `mp_int` object and compares it
-to the object on the right side of the expression.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::invalid_argument` if the string contains an invalid character.
-
-
- template<class A, class T, typename charT>
- bool operator == (const mp_int<A,T>&, const charT*);
-
- template<class A, class T, typename charT>
- bool operator != (const mp_int<A,T>&, const charT*);
-
- template<class A, class T, typename charT>
- bool operator < (const mp_int<A,T>&, const charT*);
-
- template<class A, class T, typename charT>
- bool operator > (const mp_int<A,T>&, const charT*);
-
- template<class A, class T, typename charT>
- bool operator <= (const mp_int<A,T>&, const charT*);
-
- template<class A, class T, typename charT>
- bool operator >= (const mp_int<A,T>&, const charT*);
-
-* [*Effects:] Converts the string argument to an `mp_int` object and compares it
-to the object on the left side of the expression.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::invalid_argument` if the string contains an invalid character.
-
-
- template<class A, class T, typename charT>
- bool operator == (const charT*, const mp_int<A,T>&);
-
- template<class A, class T, typename charT>
- bool operator != (const charT*, const mp_int<A,T>&);
-
- template<class A, class T, typename charT>
- bool operator < (const charT*, const mp_int<A,T>&);
-
- template<class A, class T, typename charT>
- bool operator > (const charT*, const mp_int<A,T>&);
-
- template<class A, class T, typename charT>
- bool operator <= (const charT*, const mp_int<A,T>&);
-
- template<class A, class T, typename charT>
- bool operator >= (const charT*, const mp_int<A,T>&);
-
-* [*Effects:] Converts the string argument to an `mp_int` object and compares it
-to the object on the right side of the expression.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::invalid_argument` if the string contains an invalid character.
-
-
- template<class A, class T, typename IntegralT>
- bool operator == (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- bool operator != (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- bool operator < (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- bool operator > (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- bool operator <= (const mp_int<A,T>&, IntegralT);
-
- template<class A, class T, typename IntegralT>
- bool operator >= (const mp_int<A,T>&, IntegralT);
-
-* [*Effects:] Converts the integral argument to an `mp_int` object and compares it
-to the object on the left side of the expression.
-* [*Throws: ] `std::bad_alloc`.
-
-
- template<class A, class T, typename IntegralT>
- bool operator == (IntegralT, const mp_int<A,T>&);
-
- template<class A, class T, typename IntegralT>
- bool operator != (IntegralT, const mp_int<A,T>&);
-
- template<class A, class T, typename IntegralT>
- bool operator < (IntegralT, const mp_int<A,T>&);
-
- template<class A, class T, typename IntegralT>
- bool operator > (IntegralT, const mp_int<A,T>&);
-
- template<class A, class T, typename IntegralT>
- bool operator <= (IntegralT, const mp_int<A,T>&);
-
- template<class A, class T, typename IntegralT>
- bool operator >= (IntegralT, const mp_int<A,T>&);
-
-* [*Effects:] Converts the integral argument to an `mp_int` object and compares it
-to the object on the right side of the expression.
-* [*Throws: ] `std::bad_alloc`.
-
-
-[heading Stream I/O]
-
- template<class A, class T, typename charT, class traits>
- std::basic_istream<charT, traits>&
- operator >> (std::basic_istream<charT, traits>& is, mp_int<A,T>& x);
-
- template<class A, class T, typename charT, class traits>
- std::basic_ostream<charT, traits>&
- operator << (std::basic_ostream<charT, traits>& os, const mp_int<A,T>& x);
-
-
-[heading Special functions]
-
- template<class A, class T>
- mp_int<A,T> abs(const mp_int<A,T>& x);
-
-* [*Returns:] The positive value of `x`.
-* [*Complexity:] O(1).
-* [*Throws: ] `std::bad_alloc`.
-
-
- template<class A, class T>
- mp_int<A,T> gcd(const mp_int<A,T>& a, const mp_int<A,T>& b);
-
-* [*Returns:] The greatest common divisor of `a` and `b`.
-* [*Complexity:] O((log2(AB))^2).
-* [*Throws: ] `std::bad_alloc`.
-
-
- template<class A, class T>
- mp_int<A,T> lcm(const mp_int<A,T>& a, const mp_int<A,T>& b);
-
-* [*Returns:] The least common multiple of `a` and `b`.
-* [*Complexity:] O((log2(AB))^2).
-* [*Throws: ] `std::bad_alloc`.
-
-
- template<class A, class T>
- int jacobi(const mp_int<A,T>& a, const mp_int<A,T>& p);
-
-* [*Returns:] The Jacobi symbol of integer `a` and positive odd integer `p`.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::domain_error` if `p` is negative.
-
-
- template<class A, class T>
- mp_int<A,T> pow(const mp_int<A,T>& x, typename mp_int<A,T>::digit_type n);
-
- template<class A, class T>
- mp_int<A,T> pow(const mp_int<A,T>& x, const mp_int<A,T>& n);
-
-* [*Returns:] The `n`th power of `x`.
-* [*Throws: ] `std::bad_alloc`.
-
-
- template<class A, class T>
- mp_int<A,T> modpow(const mp_int<A,T>& base,
- const mp_int<A,T>& exp,
- const mp_int<A,T>& mod);
-
-
-* [*Returns: ] `(base ^ exp) % mod`.
-* [*Throws: ] `std::bad_alloc`.
-
-
- template<class A, class T>
- mp_int<A,T> sqrt(const mp_int<A,T>& x);
-
-* [*Returns:] The square root of `x`.
-* [*Throws:]
- * `std::bad_alloc`
- * `std::domain_error` if `x` is negative.
-
-
- template<class A, class T>
- mp_int<A,T> nth_root(const mp_int<A,T>& x, typename mp_int<A,T>::digit_type n);
-
- template<class A, class T>
- mp_int<A,T> nth_root(const mp_int<A,T>& x, const mp_int<A,T>& n);
-
-* [*Returns:] The `n`th root of `x`.
-* [*Complexity:] O(log(N)).
-* [*Throws:]
- * `std::bad_alloc`
- * `std::domain_error` if `x` is negative and `n` is odd.
-
-
-[endsect][/mp_int reference]
-
Deleted: sandbox/mp_math/libs/mp_math/doc/mp_int_traits_reference.qbk
==============================================================================
--- sandbox/mp_math/libs/mp_math/doc/mp_int_traits_reference.qbk 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
+++ (empty file)
@@ -1,37 +0,0 @@
-[/ Copyright Kevin Sopp 2008.
- / Distributed under the Boost Software License, Version 1.0.
- / (See accompanying file LICENSE_1_0.txt or copy at
- / http://www.boost.org/LICENSE_1_0.txt)]
-
-[section mp_int_traits reference]
-
-The second template parameter to mp_int is a type which allows to customize some
-of mp_int's internal workings.
-
-[heading Synopsis]
-``
-// <boost/mp_math/mp_int/traits.hpp>
-namespace boost {
-namespace mp_math {
-
-template<
- typename Digit = implementation defined,
- typename Word = implementation defined
->
-struct mp_int_traits
-{
- typedef std::size_t size_type;
- typedef Digit digit_type;
- typedef Word word_type;
-
- static size_type toom_mul_cutoff; // default: 350
- static size_type toom_sqr_cutoff; // default: 400
- static size_type karatsuba_mul_cutoff; // default: 80
- static size_type karatsuba_sqr_cutoff; // default: 120
-};
-
-} // namespace mp_math
-} // namespace boost
-``
-[endsect][/mp_int_traits reference]
-
Modified: sandbox/mp_math/libs/mp_math/doc/primality_tests_reference.qbk
==============================================================================
--- sandbox/mp_math/libs/mp_math/doc/primality_tests_reference.qbk (original)
+++ sandbox/mp_math/libs/mp_math/doc/primality_tests_reference.qbk 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -15,20 +15,20 @@
[heading Synopsis]
- // <boost/mp_math/mp_int.hpp>
+ // <boost/mp_math/integer.hpp>
struct primality_division_test
{
typedef bool result_type;
template<class A, class T>
- bool operator()(const mp_int<A,T>& p) const;
+ bool operator()(const integer<A,T>& p) const;
};
[h3 Members]
template<class A, class T>
- bool operator()(const mp_int<A,T>& p) const;
+ bool operator()(const integer<A,T>& p) const;
* [*Effects:] Returns true if `p` is probably prime. Returns false if `p`
is definitely composite.
@@ -54,8 +54,8 @@
[heading Synopsis]
- // <boost/mp_math/mp_int.hpp>
- template<class Distribution = uniform_mp_int<> >
+ // <boost/mp_math/integer.hpp>
+ template<class Distribution = uniform_integer<> >
struct primality_fermat_test
{
typedef Distribution distribution_type;
@@ -64,7 +64,7 @@
explicit primality_fermat_test(unsigned int rounds);
template<class Engine, class A, class T>
- bool operator()(Engine& e, const mp_int<A,T>& p) const;
+ bool operator()(Engine& e, const integer<A,T>& p) const;
};
@@ -76,7 +76,7 @@
of test rounds given by `r`.
template<class Engine, class A, class T>
- bool operator()(Engine& e, const mp_int<A,T>& p) const;
+ bool operator()(Engine& e, const integer<A,T>& p) const;
* [*Effects:] Returns true if `p` is probably prime. Returns false if `p`
is definitely composite.
@@ -91,8 +91,8 @@
[heading Synopsis]
- // <boost/mp_math/mp_int.hpp>
- template<class Distribution = uniform_mp_int<> >
+ // <boost/mp_math/integer.hpp>
+ template<class Distribution = uniform_integer<> >
struct primality_miller_rabin_test
{
typedef Distribution distribution_type;
@@ -101,7 +101,7 @@
explicit primality_miller_rabin_test(unsigned int r = 0);
template<class Engine, class A, class T>
- bool operator()(Engine& e, const mp_int<A,T>& p) const;
+ bool operator()(Engine& e, const integer<A,T>& p) const;
static unsigned int recommended_number_of_rounds(unsigned bits);
};
@@ -116,7 +116,7 @@
object will use the recommended number of rounds.
template<class Engine, class A, class T>
- bool operator()(Engine& e, const mp_int<A,T>& p) const;
+ bool operator()(Engine& e, const integer<A,T>& p) const;
* [*Requires: ] `p` is odd.
* [*Effects:] Returns true if `p` is probably prime. Returns false if `p`
@@ -132,5 +132,5 @@
-[endsect][/uniform_mp_int_bits reference]
+[endsect][/Primality Tests reference]
Modified: sandbox/mp_math/libs/mp_math/doc/tutorial.qbk
==============================================================================
--- sandbox/mp_math/libs/mp_math/doc/tutorial.qbk (original)
+++ sandbox/mp_math/libs/mp_math/doc/tutorial.qbk 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -9,12 +9,12 @@
[section General use]
The only header you need to include to use the library is
-`<boost/mp_math/mp_int.hpp>`. This is a header-only library so deployment is easy.
-All functions and objects of this library live in namespace `boost::mp_math`.
+`<boost/mp_math/integer.hpp>`. This is a header-only library so deployment is easy.
+All functions and types of this library live in namespace `boost::mp_math`.
#include <iostream>
#include <string>
- #include <boost/mp_math/mp_int.hpp>
+ #include <boost/mp_math/integer.hpp>
using namespace boost::mp_math;
using namespace std;
@@ -22,17 +22,17 @@
int main()
{
// init from string
- mp_int<> x("93423894782394782347823947289374");
+ integer<> x("93423894782394782347823947289374");
// init from integral type
- mp_int<> y = 2340;
- mp_int<> z = x * y;
+ integer<> y = 2340;
+ integer<> z = x * y;
// stream output reacts to stream flags
cout << hex << z << endl;
// automatic detection of radix using the base prefix 0x
z = "0xaaaabbbbccccddddeeeeffff222255557777";
-
+
z /= y;
// explicit conversion to string according to formatting flags
@@ -45,11 +45,11 @@
// std::overflow_error if int does not have enough precision to hold the
// result
int result = z.to_integral<int>();
-
+
return result;
}
-In most cases the `mp_int` type will behave like a built in integral type.
+In most cases the `integer` type will behave like a built in integral type.
[endsect][/General use]
@@ -58,20 +58,20 @@
The random number generators have interfaces similar to Boost.Random. Including
`<boost/random.hpp>` is not necessary because it is used internally by the
-`mp_int` random machinery. The random number engine `mt19937` that we use from
+`integer` random machinery. The random number engine `mt19937` that we use from
here on lives in namespace `boost`.
- const mp_int<> min(0U);
- const mp_int<> max("0x8974651231456456564");
-
+ const integer<> min(0U);
+ const integer<> max("0x8974651231456456564");
+
uniform_mp_int<> generator(min, max);
-
+
// Choose a random number engine.
mt19937 e;
// Now generate a random number.
- mp_int<> r = generator(e);
+ integer<> r = generator(e);
Another probably more useful alternative is to generate random numbers of a
@@ -82,7 +82,7 @@
uniform_mp_int_bits<> generator(2048);
mt19937 e;
- mp_int<> r = generator(e);
+ integer<> r = generator(e);
Note that the numbers will always be 2048 bits large, i.e. the 2048th bit is
always set to 1.
@@ -102,7 +102,7 @@
functor. That is necessary because the test functor's function invocation
operator needs the random number engine. The operator looks like this:
- bool operator()(Engine& e, const mp_int<>& p) const;
+ bool operator()(Engine& e, const integer<>& p) const;
We need to bind the random number engine to the first parameter slot. Let's do
it!
@@ -114,7 +114,7 @@
mt19937 rng;
// Create a random 1024 bit candidate number.
- mp_int<> p = uniform_mp_int_bits<>(1024)(rng);
+ integer<> p = uniform_mp_int_bits<>(1024)(rng);
bool is_p_prime = is_prime(p, bind(test, rng, _1));
@@ -140,7 +140,7 @@
mt19937 rng;
// Now create a prime.
- mp_int<> prime = generator(rng);
+ integer<> prime = generator(rng);
[endsect][/prime_generator]
@@ -166,7 +166,7 @@
// lead to lifetime problems.
template<
class Engine = mt19937,
- class Distribution = uniform_mp_int_bits<>
+ class Distribution = uniform_integer_bits<>
>
struct primality_test
{
@@ -176,7 +176,7 @@
explicit tester(const Engine& e = Engine()) : rng(e) {}
- bool operator()(const mp_int<>& p)
+ bool operator()(const integer<>& p)
{
return test1(p) && test2(rng, p);
}
@@ -187,22 +187,49 @@
mt19937 rng;
// Create a generator for safe primes with 128 bits precision.
- typedef safe_prime_generator<primality_test<>, uniform_mp_int_bits<> >
+ typedef safe_prime_generator<primality_test<>, uniform_integer_bits<> >
generator_type;
-
+
generator_type generator(128, primality_test<>(rng));
- mp_int<> prime = generator(rng);
+ integer<> prime = generator(rng);
Remember, the generated numbers are ['probably] prime.
[endsect][/safe_prime_generator]
-
[endsect][/Prime number generation]
+[section Using the GMP backend]
+First, in addition to `<boost/mp_math/integer.hpp>` include the file
+`<boost/mp_math/gmp.hpp>`. Then define your integer type like this:
+
+ typedef boost::mp_math::integer<boost::mp_math::gmp_integer<> > gmp_int_type;
+
+You then need to link manually to the GMP library.
+
+This type is more limited than the native backend:
+
+* does not work with the primality tests and the random number generation
+ templates
+* a few other things don't work yet or don't work correctly
+
+and features slightly different semantics:
+
+* will default initialize to zero
+* will behave on bitwise operations like a two's complement integer
+
+and it has the annoying C gotcha of raising a signal on
+division by zero. I am not sure about the repercussions of catching that signal
+and translating it to a C++ exception, so I'm just leaving it as it is right
+now. In addition to that you will have to be prepared to catch exceptions
+thrown by the C++ wrapper code.
+
+[endsect][/Using the GMP backend]
+
+
[endsect][/Tutorial]
Copied: sandbox/mp_math/libs/mp_math/doc/unbounded_int_reference.qbk (from r54215, /sandbox/mp_math/libs/mp_math/doc/mp_int_reference.qbk)
==============================================================================
--- /sandbox/mp_math/libs/mp_math/doc/mp_int_reference.qbk (original)
+++ sandbox/mp_math/libs/mp_math/doc/unbounded_int_reference.qbk 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -3,90 +3,108 @@
/ (See accompanying file LICENSE_1_0.txt or copy at
/ http://www.boost.org/LICENSE_1_0.txt)]
-[section mp_int reference]
+[section unbounded_int reference]
[heading Synopsis]
- // <boost/mp_math/mp_int.hpp>
+ // <boost/mp_math/unbounded_int.hpp>
namespace boost {
namespace mp_math {
template<
class Allocator = std::allocator<void>,
- class Traits = mp_int_traits<>
+ class Traits = unbounded_traits<>
>
- struct mp_int
+ struct unbounded_int
{
- typedef Allocator allocator_type;
- typedef Traits traits_type;
- typedef typename base_allocator_type::size_type size_type;
+ typedef multiprecision_integer_tag tag;
- // ctor/cctor/dtor/assign
- mp_int();
+ typedef Alloc allocator_type;
+ typedef Traits traits_type;
+ typedef typename traits_type::digit_type digit_type;
+ typedef typename allocator_type::size_type size_type;
+
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_iterator;
+ typedef typename base_type::reverse_iterator reverse_iterator;
+ typedef typename base_type::const_reverse_iterator const_reverse_iterator;
- explicit mp_int(const allocator_type& a);
+ // ctor/cctor/dtor/assign
+ unbounded_int();
+
+ explicit unbounded_int(const allocator_type& a);
template<typename IntegralT>
- mp_int(IntegralT,
+ unbounded_int(IntegralT,
const allocator_type& a = allocator_type(),
typename enable_if<is_integral<IntegralT> >::type* dummy = 0);
template<typename charT>
- mp_int(const charT*, const allocator_type& a = allocator_type());
+ unbounded_int(const charT*, const allocator_type& a = allocator_type());
template<typename charT>
- mp_int(const charT*,
- std::ios_base::fmtflags,
- const allocator_type& a = allocator_type());
-
- template<typename charT, class traits, class Alloc>
- mp_int(const std::basic_string<charT,traits,Alloc>&,
- const allocator_type& a = allocator_type());
-
- template<typename charT, class traits, class Alloc>
- mp_int(const std::basic_string<charT,traits,Alloc>&,
- std::ios_base::fmtflags,
- const allocator_type& a = allocator_type());
+ unbounded_int(const charT*,
+ std::ios_base::fmtflags,
+ const allocator_type& a = allocator_type());
+
+ template<typename charT, class traits, class alloc>
+ unbounded_int(const std::basic_string<charT,traits,alloc>&,
+ const allocator_type& a = allocator_type());
+
+ template<typename charT, class traits, class alloc>
+ unbounded_int(const std::basic_string<charT,traits,alloc>&,
+ std::ios_base::fmtflags,
+ const allocator_type& a = allocator_type());
template<typename RandomAccessIterator>
- mp_int(RandomAccessIterator first,
- RandomAccessIterator last,
- const allocator_type& a = allocator_type());
+ unbounded_int(RandomAccessIterator first,
+ RandomAccessIterator last,
+ const allocator_type& a = allocator_type());
template<typename RandomAccessIterator>
- mp_int(RandomAccessIterator first,
- RandomAccessIterator last,
- std::ios_base::fmtflags f,
- const allocator_type& a = allocator_type());
+ unbounded_int(RandomAccessIterator first,
+ RandomAccessIterator last,
+ std::ios_base::fmtflags f,
+ const allocator_type& a = allocator_type());
+
+ template<class ApInt>
+ unbounded_int(const ApInt& x,
+ typename enable_if<
+ mpl::and_<
+ mpl::not_<is_same<traits_type, typename ApInt::traits_type> >,
+ is_same<typename ApInt::tag, multiprecision_integer_tag>
+ >
+ >::type* dummy = 0);
- mp_int(const mp_int& copy);
+ unbounded_int(const unbounded_int& copy);
- #ifdef BOOST_HAS_RVALUE_REFS
- mp_int(mp_int&& copy);
+ #ifndef BOOST_NO_RVALUE_REFERENCES
+ unbounded_int(unbounded_int&& copy);
#endif
- ~mp_int();
+ ~unbounded_int();
- mp_int& operator = (const mp_int& rhs);
+ unbounded_int& operator = (const unbounded_int& rhs);
- #ifdef BOOST_HAS_RVALUE_REFS
- mp_int& operator = (mp_int&& rhs);
+ #ifndef BOOST_NO_RVALUE_REFERENCES
+ unbounded_int& operator = (unbounded_int&& rhs);
#endif
template<typename IntegralT>
- mp_int& operator = (IntegralT rhs);
+ typename enable_if<is_integral<IntegralT>, unbounded_int&>::type
+ operator = (IntegralT rhs);
template<typename charT>
- mp_int& operator = (const charT*);
+ unbounded_int& operator = (const charT*);
- template<typename charT, class traits, class Alloc>
- mp_int& operator = (const std::basic_string<charT,traits,Alloc>&);
+ template<typename charT, class traits, class alloc>
+ unbounded_int& operator = (const std::basic_string<charT,traits,alloc>&);
template<typename charT>
void assign(const charT*, std::ios_base::fmtflags);
- template<typename charT, class traits, class Alloc>
- void assign(const std::basic_string<charT,traits,Alloc>&,
+ template<typename charT, class traits, class alloc>
+ void assign(const std::basic_string<charT,traits,alloc>&,
std::ios_base::fmtflags);
template<typename RandomAccessIterator>
@@ -94,74 +112,70 @@
std::ios_base::fmtflags);
// modifiers
- #ifdef BOOST_HAS_RVALUE_REFS
- void swap(mp_int&& other);
- #else
- void swap(mp_int& other);
- #endif
+ void swap(unbounded_int& other);
// increment/decrement
- mp_int& operator ++();
- mp_int& operator --();
- mp_int operator ++(int);
- mp_int operator --(int);
+ unbounded_int& operator ++();
+ unbounded_int& operator --();
+ unbounded_int operator ++(int);
+ unbounded_int operator --(int);
// shifting
- mp_int& operator <<= (size_type);
- mp_int& operator >>= (size_type);
+ unbounded_int& operator <<= (size_type);
+ unbounded_int& operator >>= (size_type);
// unary negate
- mp_int& operator - ();
+ unbounded_int& operator - ();
// arithmetic operators
- mp_int& operator += (const mp_int& x);
- mp_int& operator -= (const mp_int& x);
- mp_int& operator *= (const mp_int& x);
- mp_int& operator /= (const mp_int& x);
- mp_int& operator %= (const mp_int& x);
+ unbounded_int& operator += (const unbounded_int& x);
+ unbounded_int& operator -= (const unbounded_int& x);
+ unbounded_int& operator *= (const unbounded_int& x);
+ unbounded_int& operator /= (const unbounded_int& x);
+ unbounded_int& operator %= (const unbounded_int& x);
// bitwise operators
- mp_int& operator |= (const mp_int& x);
- mp_int& operator &= (const mp_int& x);
- mp_int& operator ^= (const mp_int& x);
+ unbounded_int& operator |= (const unbounded_int& x);
+ unbounded_int& operator &= (const unbounded_int& x);
+ unbounded_int& operator ^= (const unbounded_int& x);
// operators involving integral types
- template<typename IntegralT> mp_int& operator += (IntegralT x);
- template<typename IntegralT> mp_int& operator -= (IntegralT x);
- template<typename IntegralT> mp_int& operator *= (IntegralT x);
- template<typename IntegralT> mp_int& operator /= (IntegralT x);
- template<typename IntegralT> mp_int& operator %= (IntegralT x);
- template<typename IntegralT> mp_int& operator |= (IntegralT x);
- template<typename IntegralT> mp_int& operator &= (IntegralT x);
- template<typename IntegralT> mp_int& operator ^= (IntegralT x);
+ template<typename IntegralT> unbounded_int& operator += (IntegralT x);
+ template<typename IntegralT> unbounded_int& operator -= (IntegralT x);
+ template<typename IntegralT> unbounded_int& operator *= (IntegralT x);
+ template<typename IntegralT> unbounded_int& operator /= (IntegralT x);
+ template<typename IntegralT> unbounded_int& operator %= (IntegralT x);
+ template<typename IntegralT> unbounded_int& operator |= (IntegralT x);
+ template<typename IntegralT> unbounded_int& operator &= (IntegralT x);
+ template<typename IntegralT> unbounded_int& operator ^= (IntegralT x);
// operators involving character strings
- template<typename charT> mp_int& operator += (const charT*);
- template<typename charT> mp_int& operator -= (const charT*);
- template<typename charT> mp_int& operator *= (const charT*);
- template<typename charT> mp_int& operator /= (const charT*);
- template<typename charT> mp_int& operator %= (const charT*);
- template<typename charT> mp_int& operator |= (const charT*);
- template<typename charT> mp_int& operator &= (const charT*);
- template<typename charT> mp_int& operator ^= (const charT*);
+ template<typename charT> unbounded_int& operator += (const charT*);
+ template<typename charT> unbounded_int& operator -= (const charT*);
+ template<typename charT> unbounded_int& operator *= (const charT*);
+ template<typename charT> unbounded_int& operator /= (const charT*);
+ template<typename charT> unbounded_int& operator %= (const charT*);
+ template<typename charT> unbounded_int& operator |= (const charT*);
+ template<typename charT> unbounded_int& operator &= (const charT*);
+ template<typename charT> unbounded_int& operator ^= (const charT*);
// operators involving std::basic_string
template<typename charT, class traits, class Alloc>
- mp_int& operator += (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator += (const std::basic_string<charT,traits,Alloc>& s);
template<typename charT, class traits, class Alloc>
- mp_int& operator -= (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator -= (const std::basic_string<charT,traits,Alloc>& s);
template<typename charT, class traits, class Alloc>
- mp_int& operator *= (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator *= (const std::basic_string<charT,traits,Alloc>& s);
template<typename charT, class traits, class Alloc>
- mp_int& operator /= (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator /= (const std::basic_string<charT,traits,Alloc>& s);
template<typename charT, class traits, class Alloc>
- mp_int& operator %= (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator %= (const std::basic_string<charT,traits,Alloc>& s);
template<typename charT, class traits, class Alloc>
- mp_int& operator |= (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator |= (const std::basic_string<charT,traits,Alloc>& s);
template<typename charT, class traits, class Alloc>
- mp_int& operator &= (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator &= (const std::basic_string<charT,traits,Alloc>& s);
template<typename charT, class traits, class Alloc>
- mp_int& operator ^= (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator ^= (const std::basic_string<charT,traits,Alloc>& s);
// observers
allocator_type get_allocator() const;
@@ -172,9 +186,16 @@
bool is_positive() const;
bool is_negative() const;
+ bool is_initialized () const;
+ bool is_uninitialized() const;
+
size_type precision() const;
+ #ifdef BOOST_NO_EXPLICIT_CONVERSION_OPERATORS
operator unspecified_bool_type() const;
+ #else
+ explicit operator bool() const;
+ #endif
std::string to_string(std::ios_base::fmtflags f = std::ios_base::dec) const;
@@ -182,267 +203,277 @@
IntegralT to_integral() const;
// low level access
- typedef traits_type::digit_type digit_type;
- typedef traits_type::word_type word_type;
-
digit_type& operator[](size_type i);
const digit_type& operator[](size_type i) const;
digit_type& at(size_type i);
const digit_type& at(size_type i) const;
+
+ void clamp();
+ void clamp_high_digit();
+
+ void set_bit (size_type bit);
+ void clear_bit (size_type bit);
+ void set_bits (size_type beg, size_type end);
+ void clear_bits(size_type beg, size_type end);
+
+ void truncate(size_type prec);
+
+ size_type precision() const;
+ void set_precision(size_type bits);
+
+ size_type count_trailing_zero_bits() const;
+
+ void print(bool all = false) const;
};
// non-member functions
- #ifdef BOOST_HAS_RVALUE_REFS
template<class A, class T>
- void swap(mp_int<A,T>&&, mp_int<A,T>&&);
- #else
- void swap(mp_int<A,T>&, mp_int<A,T>&);
- #endif
+ void swap(unbounded_int<A,T>&, unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator << (const mp_int<A,T>&, typename mp_int<A,T>::size_type);
+ unbounded_int<A,T> operator << (const unbounded_int<A,T>&, typename unbounded_int<A,T>::size_type);
template<class A, class T>
- mp_int<A,T> operator >> (const mp_int<A,T>&, typename mp_int<A,T>::size_type);
+ unbounded_int<A,T> operator >> (const unbounded_int<A,T>&, typename unbounded_int<A,T>::size_type);
template<class A, class T>
- mp_int<A,T> operator - (const mp_int<A,T>&);
+ unbounded_int<A,T> operator - (const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator + (const mp_int<A,T>&, const mp_int<A,T>&);
+ unbounded_int<A,T> operator + (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator - (const mp_int<A,T>&, const mp_int<A,T>&);
+ unbounded_int<A,T> operator - (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator * (const mp_int<A,T>&, const mp_int<A,T>&);
+ unbounded_int<A,T> operator * (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator / (const mp_int<A,T>&, const mp_int<A,T>&);
+ unbounded_int<A,T> operator / (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator % (const mp_int<A,T>&, const mp_int<A,T>&);
+ unbounded_int<A,T> operator % (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator | (const mp_int<A,T>&, const mp_int<A,T>&);
+ unbounded_int<A,T> operator | (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator & (const mp_int<A,T>&, const mp_int<A,T>&);
+ unbounded_int<A,T> operator & (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator ^ (const mp_int<A,T>&, const mp_int<A,T>&);
+ unbounded_int<A,T> operator ^ (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T, typename IntegralT>
- mp_int<A,T> operator + (const mp_int<A,T>&, IntegralT);
+ unbounded_int<A,T> operator + (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- mp_int<A,T> operator - (const mp_int<A,T>&, IntegralT);
+ unbounded_int<A,T> operator - (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- mp_int<A,T> operator * (const mp_int<A,T>&, IntegralT);
+ unbounded_int<A,T> operator * (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- mp_int<A,T> operator / (const mp_int<A,T>&, IntegralT);
+ unbounded_int<A,T> operator / (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- mp_int<A,T> operator % (const mp_int<A,T>&, IntegralT);
+ unbounded_int<A,T> operator % (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- mp_int<A,T> operator | (const mp_int<A,T>&, IntegralT);
+ unbounded_int<A,T> operator | (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- mp_int<A,T> operator & (const mp_int<A,T>&, IntegralT);
+ unbounded_int<A,T> operator & (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- mp_int<A,T> operator ^ (const mp_int<A,T>&, IntegralT);
+ unbounded_int<A,T> operator ^ (const unbounded_int<A,T>&, IntegralT);
// Comparison operators
template<class A, class T>
- bool operator == (const mp_int<A,T>&, const mp_int<A,T>&);
+ bool operator == (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- bool operator != (const mp_int<A,T>&, const mp_int<A,T>&);
+ bool operator != (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- bool operator < (const mp_int<A,T>&, const mp_int<A,T>&);
+ bool operator < (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- bool operator > (const mp_int<A,T>&, const mp_int<A,T>&);
+ bool operator > (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- bool operator <= (const mp_int<A,T>&, const mp_int<A,T>&);
+ bool operator <= (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- bool operator >= (const mp_int<A,T>&, const mp_int<A,T>&);
+ bool operator >= (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
- // Comparison between mp_int and std::basic_string
+ // Comparison between unbounded_int and std::basic_string
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator == (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
+ bool operator == (const unbounded_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator != (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
+ bool operator != (const unbounded_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator < (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
+ bool operator < (const unbounded_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator > (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
+ bool operator > (const unbounded_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator <= (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
+ bool operator <= (const unbounded_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator >= (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
+ bool operator >= (const unbounded_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
- // Comparison between std::basic_string and mp_int
+ // Comparison between std::basic_string and unbounded_int
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator == (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
+ bool operator == (const std::basic_string<charT,Traits,Alloc>&, const unbounded_int<A,T>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator != (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
+ bool operator != (const std::basic_string<charT,Traits,Alloc>&, const unbounded_int<A,T>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator < (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
+ bool operator < (const std::basic_string<charT,Traits,Alloc>&, const unbounded_int<A,T>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator > (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
+ bool operator > (const std::basic_string<charT,Traits,Alloc>&, const unbounded_int<A,T>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator <= (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
+ bool operator <= (const std::basic_string<charT,Traits,Alloc>&, const unbounded_int<A,T>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator >= (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
+ bool operator >= (const std::basic_string<charT,Traits,Alloc>&, const unbounded_int<A,T>&);
- // Comparison between mp_int and const charT*
+ // Comparison between unbounded_int and const charT*
template<class A, class T>
- bool operator == (const mp_int<A,T>&, const charT*);
+ bool operator == (const unbounded_int<A,T>&, const charT*);
template<class A, class T>
- bool operator != (const mp_int<A,T>&, const charT*);
+ bool operator != (const unbounded_int<A,T>&, const charT*);
template<class A, class T>
- bool operator < (const mp_int<A,T>&, const charT*);
+ bool operator < (const unbounded_int<A,T>&, const charT*);
template<class A, class T>
- bool operator > (const mp_int<A,T>&, const charT*);
+ bool operator > (const unbounded_int<A,T>&, const charT*);
template<class A, class T>
- bool operator <= (const mp_int<A,T>&, const charT*);
+ bool operator <= (const unbounded_int<A,T>&, const charT*);
template<class A, class T>
- bool operator >= (const mp_int<A,T>&, const charT*);
+ bool operator >= (const unbounded_int<A,T>&, const charT*);
- // Comparison between const charT* and mp_int
+ // Comparison between const charT* and unbounded_int
template<class A, class T>
- bool operator == (const charT*, const mp_int<A,T>&);
+ bool operator == (const charT*, const unbounded_int<A,T>&);
template<class A, class T>
- bool operator != (const charT*, const mp_int<A,T>&);
+ bool operator != (const charT*, const unbounded_int<A,T>&);
template<class A, class T>
- bool operator < (const charT*, const mp_int<A,T>&);
+ bool operator < (const charT*, const unbounded_int<A,T>&);
template<class A, class T>
- bool operator > (const charT*, const mp_int<A,T>&);
+ bool operator > (const charT*, const unbounded_int<A,T>&);
template<class A, class T>
- bool operator <= (const charT*, const mp_int<A,T>&);
+ bool operator <= (const charT*, const unbounded_int<A,T>&);
template<class A, class T>
- bool operator >= (const charT*, const mp_int<A,T>&);
+ bool operator >= (const charT*, const unbounded_int<A,T>&);
- // Comparison between mp_int and integral type
+ // Comparison between unbounded_int and integral type
template<class A, class T, typename IntegralT>
- bool operator == (const mp_int<A,T>&, IntegralT);
+ bool operator == (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- bool operator != (const mp_int<A,T>&, IntegralT);
+ bool operator != (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- bool operator < (const mp_int<A,T>&, IntegralT);
+ bool operator < (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- bool operator > (const mp_int<A,T>&, IntegralT);
+ bool operator > (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- bool operator <= (const mp_int<A,T>&, IntegralT);
+ bool operator <= (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- bool operator >= (const mp_int<A,T>&, IntegralT);
+ bool operator >= (const unbounded_int<A,T>&, IntegralT);
- // Comparison between integral type and mp_int
+ // Comparison between integral type and unbounded_int
template<class A, class T, typename IntegralT>
- bool operator == (IntegralT, const mp_int<A,T>&);
+ bool operator == (IntegralT, const unbounded_int<A,T>&);
template<class A, class T, typename IntegralT>
- bool operator != (IntegralT, const mp_int<A,T>&);
+ bool operator != (IntegralT, const unbounded_int<A,T>&);
template<class A, class T, typename IntegralT>
- bool operator < (IntegralT, const mp_int<A,T>&);
+ bool operator < (IntegralT, const unbounded_int<A,T>&);
template<class A, class T, typename IntegralT>
- bool operator > (IntegralT, const mp_int<A,T>&);
+ bool operator > (IntegralT, const unbounded_int<A,T>&);
template<class A, class T, typename IntegralT>
- bool operator <= (IntegralT, const mp_int<A,T>&);
+ bool operator <= (IntegralT, const unbounded_int<A,T>&);
template<class A, class T, typename IntegralT>
- bool operator >= (IntegralT, const mp_int<A,T>&);
+ bool operator >= (IntegralT, const unbounded_int<A,T>&);
// Stream I/O
template<class A, class T, typename charT, class traits>
std::basic_istream<charT, traits>&
- operator >> (std::basic_istream<charT, traits>& is, mp_int<A,T>& x);
+ operator >> (std::basic_istream<charT, traits>& is, unbounded_int<A,T>& x);
template<class A, class T, typename charT, class traits>
std::basic_ostream<charT, traits>&
- operator << (std::basic_ostream<charT, traits>& os, const mp_int<A,T>& x);
+ operator << (std::basic_ostream<charT, traits>& os, const unbounded_int<A,T>& x);
// Special functions
template<class A, class T>
- mp_int<A,T> abs(const mp_int<A,T>&);
+ unbounded_int<A,T> abs(const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> gcd(const mp_int<A,T>& a, const mp_int<A,T>& b);
+ unbounded_int<A,T> gcd(const unbounded_int<A,T>& a, const unbounded_int<A,T>& b);
template<class A, class T>
- mp_int<A,T> lcm(const mp_int<A,T>& a, const mp_int<A,T>& b);
+ unbounded_int<A,T> lcm(const unbounded_int<A,T>& a, const unbounded_int<A,T>& b);
template<class A, class T>
- int jacobi(const mp_int<A,T>& a, const mp_int<A,T>& p);
+ int jacobi(const unbounded_int<A,T>& a, const unbounded_int<A,T>& p);
template<class A, class T>
- mp_int<A,T> pow(const mp_int<A,T>& x, typename mp_int<A,T>::digit_type n);
+ unbounded_int<A,T> pow(const unbounded_int<A,T>& x, typename unbounded_int<A,T>::digit_type n);
template<class A, class T>
- mp_int<A,T> pow(const mp_int<A,T>& x, const mp_int<A,T>& n);
+ unbounded_int<A,T> pow(const unbounded_int<A,T>& x, const unbounded_int<A,T>& n);
template<class A, class T>
- mp_int<A,T> modpow(const mp_int<A,T>& base, const mp_int<A,T>& exp, const mp_int<A,T>& mod);
+ unbounded_int<A,T> modpow(const unbounded_int<A,T>& base, const unbounded_int<A,T>& exp, const unbounded_int<A,T>& mod);
template<class A, class T>
- mp_int<A,T> sqrt(const mp_int<A,T>& x);
+ unbounded_int<A,T> sqrt(const unbounded_int<A,T>& x);
template<class A, class T>
- mp_int<A,T> nth_root(const mp_int<A,T>& x, typename mp_int<A,T>::digit_type n);
+ unbounded_int<A,T> nth_root(const unbounded_int<A,T>& x, typename unbounded_int<A,T>::digit_type n);
template<class A, class T>
- mp_int<A,T> nth_root(const mp_int<A,T>& x, const mp_int<A,T>& n);
+ unbounded_int<A,T> nth_root(const unbounded_int<A,T>& x, const unbounded_int<A,T>& n);
} // namespace mp_math
@@ -451,11 +482,13 @@
[h3 Construction from / assignment to a string object]
In a constructor or assignment operation without the possibility to specify the base
-of the string argument the base of the number is deduced from the string. If the
-string starts with `0x` or `0X` then the number will be treated as hexadecimal
-value. If the string starts with `0` then the number will be treated as octal
-value else it will be treated as decimal value. An optional `-` sign is allowed
-as the first character in the string to indicate a negative value.
+of the string argument the base of the number is deduced from the string prefix.
+
+* `0` - octal
+* `0x`, `0X` - hexadecimal
+
+An optional `-` sign is allowed as the first character in the string to indicate
+a negative value.
In a constructor or assignment operation with the ability to specify the format
of the string argument via a `std::ios_base::fmtflags` parameter, possible
@@ -469,52 +502,52 @@
[heading Construct/Copy/Destroy/Assign]
- mp_int();
+ unbounded_int();
-* [*Effects:] Constructs an empty `mp_int` object, such an uninitialized
-`mp_int` has no value, i.e. it is /not/ zero.
+* [*Effects:] Constructs an empty `unbounded_int` object, such an uninitialized
+`unbounded_int` has no value, i.e. it is /not/ zero.
* [*Complexity:] O(1).
* [*Throws:] Nothing.
- explicit mp_int(const allocator_type& a);
+ explicit unbounded_int(const allocator_type& a);
-* [*Effects:] Constructs an empty `mp_int` object and initializes its allocator
-with `a`, such an uninitialized `mp_int` has no value, i.e. it is /not/ zero.
+* [*Effects:] Constructs an empty `unbounded_int` object and initializes its allocator
+with `a`, such an uninitialized `unbounded_int` has no value, i.e. it is /not/ zero.
* [*Complexity:] O(1).
* [*Throws:] Nothing.
template<typename IntegralT>
- mp_int(IntegralT x,
+ unbounded_int(IntegralT x,
const allocator_type& a = allocator_type(),
typename enable_if<is_integral<IntegralT> >::type* dummy = 0);
-* [*Effects:] Constructs an `mp_int` object from an integral type. The value of
+* [*Effects:] Constructs an `unbounded_int` object from an integral type. The value of
the object is that of the integral type.
* [*Complexity:] O(N) where N is the number of bits of IntegralT.
* [*Throws: ] `std::bad_alloc`.
template<typename charT>
- mp_int(const charT* s, const allocator_type& a = allocator_type());
+ unbounded_int(const charT* s, const allocator_type& a = allocator_type());
* [*Requires: ] `s` points to a valid number formatted as string or to an empty
string.
-* [*Effects:] Constructs an `mp_int` object from a string.
+* [*Effects:] Constructs an `unbounded_int` object from a string.
* [*Throws:]
* `std::bad_alloc`
* `std::invalid_argument` if the string contains an invalid character.
template<typename charT>
- mp_int(const charT* s,
+ unbounded_int(const charT* s,
std::ios_base::fmtflags f,
const allocator_type& a = allocator_type());
* [*Requires: ] `s` points to a valid number formatted according to the flags in
`f` or `s` is an empty string.
-* [*Effects:] Constructs an `mp_int` object from a string.
+* [*Effects:] Constructs an `unbounded_int` object from a string.
* [*Throws:]
* `std::bad_alloc`
* `std::invalid_argument` if the string contains an invalid character or if an
@@ -522,25 +555,25 @@
template<typename charT, class traits, class Alloc>
- mp_int(const std::basic_string<charT,traits,Alloc>& s,
+ unbounded_int(const std::basic_string<charT,traits,Alloc>& s,
const allocator_type& a = allocator_type());
* [*Requires: ] `s` contains a valid number formatted as string or `s` is an
empty string.
-* [*Effects:] Constructs an `mp_int` object from a string.
+* [*Effects:] Constructs an `unbounded_int` object from a string.
* [*Throws:]
* `std::bad_alloc`
* `std::invalid_argument` if the string contains an invalid character.
template<typename charT, class traits, class Alloc>
- mp_int(const std::basic_string<charT,traits,Alloc>& s,
+ unbounded_int(const std::basic_string<charT,traits,Alloc>& s,
std::ios_base::fmtflags f,
const allocator_type& a = allocator_type());
* [*Requires: ] `s` contains a valid number formatted according to the flags in
`f` or `s` is an empty string.
-* [*Effects:] Constructs an `mp_int` object from a string.
+* [*Effects:] Constructs an `unbounded_int` object from a string.
* [*Throws:]
* `std::bad_alloc`
* `std::invalid_argument` if the string contains an invalid character or if an
@@ -548,54 +581,54 @@
template<typename RandomAccessIterator>
- mp_int(RandomAccessIterator first,
+ unbounded_int(RandomAccessIterator first,
RandomAccessIterator last,
const allocator_type& a = allocator_type());
* [*Requires: ] `first` and `last` are iterators into a string.
-* [*Effects:] Constructs an `mp_int` object from two iterators.
+* [*Effects:] Constructs an `unbounded_int` object from two iterators.
* [*Throws:]
* `std::bad_alloc`
* `std::invalid_argument` if the string contains an invalid character.
template<typename RandomAccessIterator>
- mp_int(RandomAccessIterator first,
+ unbounded_int(RandomAccessIterator first,
RandomAccessIterator last,
std::ios_base::fmtflags f,
const allocator_type& a = allocator_type());
* [*Requires: ] `first` and `last` are iterators into a string formatted
according to the formatting flags in `f`.
-* [*Effects:] Constructs an `mp_int` object from two iterators.
+* [*Effects:] Constructs an `unbounded_int` object from two iterators.
* [*Throws:]
* `std::bad_alloc`
* `std::invalid_argument` if the string contains an invalid character or if an
unrecognized formatting flag was set.
- mp_int(const mp_int& copy);
+ unbounded_int(const unbounded_int& copy);
-* [*Effects:] Constructs a copy of a given `mp_int`.
+* [*Effects:] Constructs a copy of a given `unbounded_int`.
* [*Complexity:] O(N), where N is the number of digits in `copy`.
* [*Throws: ] `std::bad_alloc`.
- mp_int(mp_int&& copy);
+ unbounded_int(unbounded_int&& copy);
-* [*Effects:] Constructs an `mp_int` by moving `copy` into `*this`.
+* [*Effects:] Constructs an `unbounded_int` by moving `copy` into `*this`.
* [*Complexity:] O(1).
* [*Throws:] Nothing.
- ~mp_int();
+ ~unbounded_int();
* [*Effects:] Destroys `*this`.
* [*Complexity:] O(1).
* [*Throws:] Nothing.
- mp_int& operator = (const mp_int& rhs);
+ unbounded_int& operator = (const unbounded_int& rhs);
* [*Effects:] Copies the value of `rhs` into `*this`.
* [*Returns: ] `*this`.
@@ -604,7 +637,7 @@
* [*Exception safety:] strong.
- mp_int& operator = (mp_int&& rhs);
+ unbounded_int& operator = (unbounded_int&& rhs);
* [*Effects: ] `*this` obtains the value of `rhs`.
* [*Returns: ] `*this`.
@@ -613,7 +646,7 @@
template<typename IntegralT>
- mp_int& operator = (IntegralT rhs);
+ unbounded_int& operator = (IntegralT rhs);
* [*Effects: ] `*this` obtains the value of `rhs`.
* [*Returns: ] `*this`.
@@ -622,11 +655,11 @@
template<typename charT>
- mp_int& operator = (const charT* s);
+ unbounded_int& operator = (const charT* s);
* [*Requires: ] `s` points to a valid number formatted as string or to an empty
string.
-* [*Effects:] `*this = mp_int(s);`.
+* [*Effects:] `*this = unbounded_int(s);`.
* [*Throws:]
* `std::bad_alloc`
* `std::invalid_argument` if the string contains an invalid character.
@@ -634,11 +667,11 @@
template<typename charT, class traits, class Alloc>
- mp_int& operator = (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator = (const std::basic_string<charT,traits,Alloc>& s);
* [*Requires: ] `s` points to a valid number formatted as string or to an empty
string.
-* [*Effects:] `*this = mp_int(s);`.
+* [*Effects:] `*this = unbounded_int(s);`.
* [*Throws:]
* `std::bad_alloc`
* `std::invalid_argument` if the string contains an invalid character.
@@ -650,7 +683,7 @@
* [*Requires: ] `s` points to a valid number formatted according to the flags in
`f` or `s` is an empty string.
-* [*Effects:] Constructs an `mp_int` object from a string.
+* [*Effects:] Constructs an `unbounded_int` object from a string.
* [*Throws:]
* `std::bad_alloc`
* `std::invalid_argument` if the string contains an invalid character or if an
@@ -663,7 +696,7 @@
* [*Requires: ] `s` contains a valid number formatted according to the flags in
`f` or `s` is an empty string.
-* [*Effects:] Constructs an `mp_int` object from a string.
+* [*Effects:] Constructs an `unbounded_int` object from a string.
* [*Throws:]
* `std::bad_alloc`
* `std::invalid_argument` if the string contains an invalid character or if an
@@ -676,7 +709,7 @@
* [*Requires: ] `first` and `last` are iterators into a string formatted
according to the formatting flags in `f`.
-* [*Effects:] Constructs an `mp_int` object from two iterators.
+* [*Effects:] Constructs an `unbounded_int` object from two iterators.
* [*Throws:]
* `std::bad_alloc`
* `std::invalid_argument` if the string contains an invalid character or if an
@@ -686,14 +719,14 @@
[heading Modifiers]
- void swap(mp_int&& other);
+ void swap(unbounded_int&& other);
* [*Effects:] Swaps the value of `other` and `*this`.
* [*Complexity:] O(1).
* [*Exception safety:] nothrow.
- void swap(mp_int& other);
+ void swap(unbounded_int& other);
* [*Effects:] Swaps the value of `other` and `*this`.
* [*Complexity:] O(1).
@@ -702,7 +735,7 @@
[heading Increment/decrement]
- mp_int& operator ++();
+ unbounded_int& operator ++();
* [*Effects:]
``
@@ -716,7 +749,7 @@
* [*Exception safety:] strong.
- mp_int& operator --();
+ unbounded_int& operator --();
* [*Effects:]
``
@@ -730,11 +763,11 @@
* [*Exception safety:] strong.
- mp_int operator ++(int);
+ unbounded_int operator ++(int);
* [*Effects:]
``
-mp_int tmp(*this);
+unbounded_int tmp(*this);
*this += 1;
return tmp;
``
@@ -744,11 +777,11 @@
* [*Exception safety:] strong.
- mp_int operator --(int);
+ unbounded_int operator --(int);
* [*Effects:]
``
-mp_int tmp(*this);
+unbounded_int tmp(*this);
*this -= 1;
return tmp;
``
@@ -760,7 +793,7 @@
[heading Shifting]
- mp_int& operator <<= (size_type x);
+ unbounded_int& operator <<= (size_type x);
* [*Effects:] Shift `*this` by `x` bits to the left.
* [*Returns: ] `*this`.
@@ -769,7 +802,7 @@
* [*Exception safety:] strong.
- mp_int& operator >>= (size_type x);
+ unbounded_int& operator >>= (size_type x);
* [*Effects:] Shift `*this` by `x` bits to the right.
* [*Returns: ] `*this`.
@@ -780,7 +813,7 @@
[heading Unary negate]
- mp_int& operator - ();
+ unbounded_int& operator - ();
* [*Effects:] Negates `*this`.
* [*Returns: ] `*this`.
@@ -790,7 +823,7 @@
[heading Arithmetic operators]
- mp_int& operator += (const mp_int& x);
+ unbounded_int& operator += (const unbounded_int& x);
* [*Effects:] Adds `x` to `*this`.
* [*Returns: ] `*this`.
@@ -799,7 +832,7 @@
* [*Exception safety:] strong.
- mp_int& operator -= (const mp_int& x);
+ unbounded_int& operator -= (const unbounded_int& x);
* [*Effects:] Subtracts `x` from `*this`.
@@ -809,13 +842,13 @@
* [*Exception safety:] strong.
- mp_int& operator *= (const mp_int& x);
+ unbounded_int& operator *= (const unbounded_int& x);
* [*Effects:] Multiplies `*this` by `x`.
* [*Returns: ] `*this`.
* [*Complexity:] If `&x == this` then a squaring algorithm will be used.
Different multiplication algorithms are chosen for numbers of different size.
-The thresholds can be tuned via the `mp_int_traits` class template parameter.
+The thresholds can be tuned via the `unbounded_int_traits` class template parameter.
* Small numbers: Comba algorithm O(N^2).
* Midsize numbers: Karatsuba algorithm O(N^log2(3)) ~ O(N^1.585).
* Large numbers: Toom-Cook algorithm O(N^(log(5)/log(3))) ~ O(N^1.465).
@@ -824,7 +857,7 @@
* [*Exception safety:] strong.
- mp_int& operator /= (const mp_int& x);
+ unbounded_int& operator /= (const unbounded_int& x);
* [*Requires: ] `x != 0`.
* [*Effects:] Divides `*this` by `x`.
@@ -836,7 +869,7 @@
* [*Exception safety:] strong.
- mp_int& operator %= (const mp_int& x);
+ unbounded_int& operator %= (const unbounded_int& x);
* [*Requires: ] `x != 0`.
* [*Effects:] Modulus `*this` by `x`.
@@ -850,7 +883,7 @@
[heading Bitwise operators]
- mp_int& operator |= (const mp_int& x);
+ unbounded_int& operator |= (const unbounded_int& x);
* [*Effects: ] `*this` OR `x`.
* [*Returns: ] `*this`.
@@ -859,7 +892,7 @@
* [*Exception safety:] strong.
- mp_int& operator &= (const mp_int& x);
+ unbounded_int& operator &= (const unbounded_int& x);
* [*Effects: ] `*this` AND `x`.
* [*Returns: ] `*this`.
@@ -868,7 +901,7 @@
* [*Exception safety:] strong.
- mp_int& operator ^= (const mp_int& x);
+ unbounded_int& operator ^= (const unbounded_int& x);
* [*Effects: ] `*this` XOR `x`.
* [*Returns: ] `*this`.
@@ -879,7 +912,7 @@
[heading Operators involving integral types]
- template<typename IntegralT> mp_int& operator += (IntegralT x);
+ template<typename IntegralT> unbounded_int& operator += (IntegralT x);
* [*Effects:] Adds `x` to `*this`.
* [*Returns: ] `*this`.
@@ -887,7 +920,7 @@
* [*Exception safety:] strong.
- template<typename IntegralT> mp_int& operator -= (IntegralT x);
+ template<typename IntegralT> unbounded_int& operator -= (IntegralT x);
* [*Effects:] Subtracts `x` to `*this`.
* [*Returns: ] `*this`.
@@ -895,7 +928,7 @@
* [*Exception safety:] strong.
- template<typename IntegralT> mp_int& operator *= (IntegralT x);
+ template<typename IntegralT> unbounded_int& operator *= (IntegralT x);
* [*Effects:] Multiplies `*this` by `x`.
* [*Returns: ] `*this`.
@@ -903,7 +936,7 @@
* [*Exception safety:] strong.
- template<typename IntegralT> mp_int& operator /= (IntegralT x);
+ template<typename IntegralT> unbounded_int& operator /= (IntegralT x);
* [*Effects:] Divides `*this` by `x`.
* [*Returns: ] `*this`.
@@ -911,7 +944,7 @@
* [*Exception safety:] strong.
- template<typename IntegralT> mp_int& operator %= (IntegralT x);
+ template<typename IntegralT> unbounded_int& operator %= (IntegralT x);
* [*Effects: ] `*this` modulo `x`.
* [*Returns: ] `*this`.
@@ -919,7 +952,7 @@
* [*Exception safety:] strong.
- template<typename IntegralT> mp_int& operator |= (IntegralT x);
+ template<typename IntegralT> unbounded_int& operator |= (IntegralT x);
* [*Effects:] Applies the bitwise or operation on `*this` and the absolute of `x`.
* [*Returns: ] `*this`.
@@ -927,7 +960,7 @@
* [*Exception safety:] strong.
- template<typename IntegralT> mp_int& operator &= (IntegralT x);
+ template<typename IntegralT> unbounded_int& operator &= (IntegralT x);
* [*Effects:] Applies the bitwise and operation on `*this` and the absolute of `x`.
* [*Returns: ] `*this`.
@@ -935,7 +968,7 @@
* [*Exception safety:] strong.
- template<typename IntegralT> mp_int& operator ^= (IntegralT x);
+ template<typename IntegralT> unbounded_int& operator ^= (IntegralT x);
* [*Effects:] Applies the bitwise xor operation on `*this` and the absolute of `x`.
* [*Returns: ] `*this`.
@@ -945,33 +978,33 @@
[heading Operators involving charT strings]
- template<typename charT> mp_int& operator += (const charT* s);
- template<typename charT> mp_int& operator -= (const charT* s);
- template<typename charT> mp_int& operator *= (const charT* s);
- template<typename charT> mp_int& operator /= (const charT* s);
- template<typename charT> mp_int& operator %= (const charT* s);
- template<typename charT> mp_int& operator |= (const charT* s);
- template<typename charT> mp_int& operator &= (const charT* s);
- template<typename charT> mp_int& operator ^= (const charT* s);
+ template<typename charT> unbounded_int& operator += (const charT* s);
+ template<typename charT> unbounded_int& operator -= (const charT* s);
+ template<typename charT> unbounded_int& operator *= (const charT* s);
+ template<typename charT> unbounded_int& operator /= (const charT* s);
+ template<typename charT> unbounded_int& operator %= (const charT* s);
+ template<typename charT> unbounded_int& operator |= (const charT* s);
+ template<typename charT> unbounded_int& operator &= (const charT* s);
+ template<typename charT> unbounded_int& operator ^= (const charT* s);
[heading Operators involving std::basic_string]
template<typename charT, class traits, class Alloc>
- mp_int& operator += (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator += (const std::basic_string<charT,traits,Alloc>& s);
template<typename charT, class traits, class Alloc>
- mp_int& operator -= (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator -= (const std::basic_string<charT,traits,Alloc>& s);
template<typename charT, class traits, class Alloc>
- mp_int& operator *= (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator *= (const std::basic_string<charT,traits,Alloc>& s);
template<typename charT, class traits, class Alloc>
- mp_int& operator /= (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator /= (const std::basic_string<charT,traits,Alloc>& s);
template<typename charT, class traits, class Alloc>
- mp_int& operator %= (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator %= (const std::basic_string<charT,traits,Alloc>& s);
template<typename charT, class traits, class Alloc>
- mp_int& operator |= (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator |= (const std::basic_string<charT,traits,Alloc>& s);
template<typename charT, class traits, class Alloc>
- mp_int& operator &= (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator &= (const std::basic_string<charT,traits,Alloc>& s);
template<typename charT, class traits, class Alloc>
- mp_int& operator ^= (const std::basic_string<charT,traits,Alloc>& s);
+ unbounded_int& operator ^= (const std::basic_string<charT,traits,Alloc>& s);
[heading Observers]
@@ -1051,64 +1084,64 @@
[heading Non-member functions]
template<class A, class T>
- void swap(mp_int<A,T>&&, mp_int<A,T>&&);
+ void swap(unbounded_int<A,T>&&, unbounded_int<A,T>&&);
template<class A, class T>
- mp_int<A,T> operator << (const mp_int<A,T>&, typename mp_int<A,T>::size_type);
+ unbounded_int<A,T> operator << (const unbounded_int<A,T>&, typename unbounded_int<A,T>::size_type);
template<class A, class T>
- mp_int<A,T> operator >> (const mp_int<A,T>&, typename mp_int<A,T>::size_type);
+ unbounded_int<A,T> operator >> (const unbounded_int<A,T>&, typename unbounded_int<A,T>::size_type);
template<class A, class T>
- mp_int<A,T> operator - (const mp_int<A,T>&);
+ unbounded_int<A,T> operator - (const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator + (const mp_int<A,T>&, const mp_int<A,T>&);
+ unbounded_int<A,T> operator + (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator - (const mp_int<A,T>&, const mp_int<A,T>&);
+ unbounded_int<A,T> operator - (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator * (const mp_int<A,T>&, const mp_int<A,T>&);
+ unbounded_int<A,T> operator * (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator / (const mp_int<A,T>&, const mp_int<A,T>&);
+ unbounded_int<A,T> operator / (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator % (const mp_int<A,T>&, const mp_int<A,T>&);
+ unbounded_int<A,T> operator % (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator | (const mp_int<A,T>&, const mp_int<A,T>&);
+ unbounded_int<A,T> operator | (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator & (const mp_int<A,T>&, const mp_int<A,T>&);
+ unbounded_int<A,T> operator & (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- mp_int<A,T> operator ^ (const mp_int<A,T>&, const mp_int<A,T>&);
+ unbounded_int<A,T> operator ^ (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T, typename IntegralT>
- mp_int<A,T> operator + (const mp_int<A,T>&, IntegralT);
+ unbounded_int<A,T> operator + (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- mp_int<A,T> operator - (const mp_int<A,T>&, IntegralT);
+ unbounded_int<A,T> operator - (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- mp_int<A,T> operator * (const mp_int<A,T>&, IntegralT);
+ unbounded_int<A,T> operator * (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- mp_int<A,T> operator / (const mp_int<A,T>&, IntegralT);
+ unbounded_int<A,T> operator / (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- mp_int<A,T> operator % (const mp_int<A,T>&, IntegralT);
+ unbounded_int<A,T> operator % (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- mp_int<A,T> operator | (const mp_int<A,T>&, IntegralT);
+ unbounded_int<A,T> operator | (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- mp_int<A,T> operator & (const mp_int<A,T>&, IntegralT);
+ unbounded_int<A,T> operator & (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- mp_int<A,T> operator ^ (const mp_int<A,T>&, IntegralT);
+ unbounded_int<A,T> operator ^ (const unbounded_int<A,T>&, IntegralT);
These functions are implemented in terms of their respective member functions.
@@ -1116,22 +1149,22 @@
[heading Comparison operators]
template<class A, class T>
- bool operator == (const mp_int<A,T>&, const mp_int<A,T>&);
+ bool operator == (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- bool operator != (const mp_int<A,T>&, const mp_int<A,T>&);
+ bool operator != (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- bool operator < (const mp_int<A,T>&, const mp_int<A,T>&);
+ bool operator < (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- bool operator > (const mp_int<A,T>&, const mp_int<A,T>&);
+ bool operator > (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- bool operator <= (const mp_int<A,T>&, const mp_int<A,T>&);
+ bool operator <= (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
template<class A, class T>
- bool operator >= (const mp_int<A,T>&, const mp_int<A,T>&);
+ bool operator >= (const unbounded_int<A,T>&, const unbounded_int<A,T>&);
* [*Effects:] These operators compare the numeric value of their arguments and
return a truth value based on that evaluation.
@@ -1139,24 +1172,24 @@
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator == (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
+ bool operator == (const unbounded_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator != (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
+ bool operator != (const unbounded_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator < (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
+ bool operator < (const unbounded_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator > (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
+ bool operator > (const unbounded_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator <= (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
+ bool operator <= (const unbounded_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator >= (const mp_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
+ bool operator >= (const unbounded_int<A,T>&, const std::basic_string<charT,Traits,Alloc>&);
-* [*Effects:] Converts the string argument to an `mp_int` object and compares it
+* [*Effects:] Converts the string argument to an `unbounded_int` object and compares it
to the object on the left side of the expression.
* [*Throws:]
* `std::bad_alloc`
@@ -1164,24 +1197,24 @@
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator == (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
+ bool operator == (const std::basic_string<charT,Traits,Alloc>&, const unbounded_int<A,T>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator != (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
+ bool operator != (const std::basic_string<charT,Traits,Alloc>&, const unbounded_int<A,T>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator < (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
+ bool operator < (const std::basic_string<charT,Traits,Alloc>&, const unbounded_int<A,T>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator > (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
+ bool operator > (const std::basic_string<charT,Traits,Alloc>&, const unbounded_int<A,T>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator <= (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
+ bool operator <= (const std::basic_string<charT,Traits,Alloc>&, const unbounded_int<A,T>&);
template<class A, class T, class charT, class Traits, class Alloc>
- bool operator >= (const std::basic_string<charT,Traits,Alloc>&, const mp_int<A,T>&);
+ bool operator >= (const std::basic_string<charT,Traits,Alloc>&, const unbounded_int<A,T>&);
-* [*Effects:] Converts the string argument to an `mp_int` object and compares it
+* [*Effects:] Converts the string argument to an `unbounded_int` object and compares it
to the object on the right side of the expression.
* [*Throws:]
* `std::bad_alloc`
@@ -1189,24 +1222,24 @@
template<class A, class T, typename charT>
- bool operator == (const mp_int<A,T>&, const charT*);
+ bool operator == (const unbounded_int<A,T>&, const charT*);
template<class A, class T, typename charT>
- bool operator != (const mp_int<A,T>&, const charT*);
+ bool operator != (const unbounded_int<A,T>&, const charT*);
template<class A, class T, typename charT>
- bool operator < (const mp_int<A,T>&, const charT*);
+ bool operator < (const unbounded_int<A,T>&, const charT*);
template<class A, class T, typename charT>
- bool operator > (const mp_int<A,T>&, const charT*);
+ bool operator > (const unbounded_int<A,T>&, const charT*);
template<class A, class T, typename charT>
- bool operator <= (const mp_int<A,T>&, const charT*);
+ bool operator <= (const unbounded_int<A,T>&, const charT*);
template<class A, class T, typename charT>
- bool operator >= (const mp_int<A,T>&, const charT*);
+ bool operator >= (const unbounded_int<A,T>&, const charT*);
-* [*Effects:] Converts the string argument to an `mp_int` object and compares it
+* [*Effects:] Converts the string argument to an `unbounded_int` object and compares it
to the object on the left side of the expression.
* [*Throws:]
* `std::bad_alloc`
@@ -1214,24 +1247,24 @@
template<class A, class T, typename charT>
- bool operator == (const charT*, const mp_int<A,T>&);
+ bool operator == (const charT*, const unbounded_int<A,T>&);
template<class A, class T, typename charT>
- bool operator != (const charT*, const mp_int<A,T>&);
+ bool operator != (const charT*, const unbounded_int<A,T>&);
template<class A, class T, typename charT>
- bool operator < (const charT*, const mp_int<A,T>&);
+ bool operator < (const charT*, const unbounded_int<A,T>&);
template<class A, class T, typename charT>
- bool operator > (const charT*, const mp_int<A,T>&);
+ bool operator > (const charT*, const unbounded_int<A,T>&);
template<class A, class T, typename charT>
- bool operator <= (const charT*, const mp_int<A,T>&);
+ bool operator <= (const charT*, const unbounded_int<A,T>&);
template<class A, class T, typename charT>
- bool operator >= (const charT*, const mp_int<A,T>&);
+ bool operator >= (const charT*, const unbounded_int<A,T>&);
-* [*Effects:] Converts the string argument to an `mp_int` object and compares it
+* [*Effects:] Converts the string argument to an `unbounded_int` object and compares it
to the object on the right side of the expression.
* [*Throws:]
* `std::bad_alloc`
@@ -1239,47 +1272,47 @@
template<class A, class T, typename IntegralT>
- bool operator == (const mp_int<A,T>&, IntegralT);
+ bool operator == (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- bool operator != (const mp_int<A,T>&, IntegralT);
+ bool operator != (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- bool operator < (const mp_int<A,T>&, IntegralT);
+ bool operator < (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- bool operator > (const mp_int<A,T>&, IntegralT);
+ bool operator > (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- bool operator <= (const mp_int<A,T>&, IntegralT);
+ bool operator <= (const unbounded_int<A,T>&, IntegralT);
template<class A, class T, typename IntegralT>
- bool operator >= (const mp_int<A,T>&, IntegralT);
+ bool operator >= (const unbounded_int<A,T>&, IntegralT);
-* [*Effects:] Converts the integral argument to an `mp_int` object and compares it
+* [*Effects:] Converts the integral argument to an `unbounded_int` object and compares it
to the object on the left side of the expression.
* [*Throws: ] `std::bad_alloc`.
template<class A, class T, typename IntegralT>
- bool operator == (IntegralT, const mp_int<A,T>&);
+ bool operator == (IntegralT, const unbounded_int<A,T>&);
template<class A, class T, typename IntegralT>
- bool operator != (IntegralT, const mp_int<A,T>&);
+ bool operator != (IntegralT, const unbounded_int<A,T>&);
template<class A, class T, typename IntegralT>
- bool operator < (IntegralT, const mp_int<A,T>&);
+ bool operator < (IntegralT, const unbounded_int<A,T>&);
template<class A, class T, typename IntegralT>
- bool operator > (IntegralT, const mp_int<A,T>&);
+ bool operator > (IntegralT, const unbounded_int<A,T>&);
template<class A, class T, typename IntegralT>
- bool operator <= (IntegralT, const mp_int<A,T>&);
+ bool operator <= (IntegralT, const unbounded_int<A,T>&);
template<class A, class T, typename IntegralT>
- bool operator >= (IntegralT, const mp_int<A,T>&);
+ bool operator >= (IntegralT, const unbounded_int<A,T>&);
-* [*Effects:] Converts the integral argument to an `mp_int` object and compares it
+* [*Effects:] Converts the integral argument to an `unbounded_int` object and compares it
to the object on the right side of the expression.
* [*Throws: ] `std::bad_alloc`.
@@ -1288,17 +1321,17 @@
template<class A, class T, typename charT, class traits>
std::basic_istream<charT, traits>&
- operator >> (std::basic_istream<charT, traits>& is, mp_int<A,T>& x);
+ operator >> (std::basic_istream<charT, traits>& is, unbounded_int<A,T>& x);
template<class A, class T, typename charT, class traits>
std::basic_ostream<charT, traits>&
- operator << (std::basic_ostream<charT, traits>& os, const mp_int<A,T>& x);
+ operator << (std::basic_ostream<charT, traits>& os, const unbounded_int<A,T>& x);
[heading Special functions]
template<class A, class T>
- mp_int<A,T> abs(const mp_int<A,T>& x);
+ unbounded_int<A,T> abs(const unbounded_int<A,T>& x);
* [*Returns:] The positive value of `x`.
* [*Complexity:] O(1).
@@ -1306,7 +1339,7 @@
template<class A, class T>
- mp_int<A,T> gcd(const mp_int<A,T>& a, const mp_int<A,T>& b);
+ unbounded_int<A,T> gcd(const unbounded_int<A,T>& a, const unbounded_int<A,T>& b);
* [*Returns:] The greatest common divisor of `a` and `b`.
* [*Complexity:] O((log2(AB))^2).
@@ -1314,7 +1347,7 @@
template<class A, class T>
- mp_int<A,T> lcm(const mp_int<A,T>& a, const mp_int<A,T>& b);
+ unbounded_int<A,T> lcm(const unbounded_int<A,T>& a, const unbounded_int<A,T>& b);
* [*Returns:] The least common multiple of `a` and `b`.
* [*Complexity:] O((log2(AB))^2).
@@ -1322,7 +1355,7 @@
template<class A, class T>
- int jacobi(const mp_int<A,T>& a, const mp_int<A,T>& p);
+ int jacobi(const unbounded_int<A,T>& a, const unbounded_int<A,T>& p);
* [*Returns:] The Jacobi symbol of integer `a` and positive odd integer `p`.
* [*Throws:]
@@ -1331,19 +1364,19 @@
template<class A, class T>
- mp_int<A,T> pow(const mp_int<A,T>& x, typename mp_int<A,T>::digit_type n);
+ unbounded_int<A,T> pow(const unbounded_int<A,T>& x, typename unbounded_int<A,T>::digit_type n);
template<class A, class T>
- mp_int<A,T> pow(const mp_int<A,T>& x, const mp_int<A,T>& n);
+ unbounded_int<A,T> pow(const unbounded_int<A,T>& x, const unbounded_int<A,T>& n);
* [*Returns:] The `n`th power of `x`.
* [*Throws: ] `std::bad_alloc`.
template<class A, class T>
- mp_int<A,T> modpow(const mp_int<A,T>& base,
- const mp_int<A,T>& exp,
- const mp_int<A,T>& mod);
+ unbounded_int<A,T> modpow(const unbounded_int<A,T>& base,
+ const unbounded_int<A,T>& exp,
+ const unbounded_int<A,T>& mod);
* [*Returns: ] `(base ^ exp) % mod`.
@@ -1351,7 +1384,7 @@
template<class A, class T>
- mp_int<A,T> sqrt(const mp_int<A,T>& x);
+ unbounded_int<A,T> sqrt(const unbounded_int<A,T>& x);
* [*Returns:] The square root of `x`.
* [*Throws:]
@@ -1360,10 +1393,10 @@
template<class A, class T>
- mp_int<A,T> nth_root(const mp_int<A,T>& x, typename mp_int<A,T>::digit_type n);
+ unbounded_int<A,T> nth_root(const unbounded_int<A,T>& x, typename unbounded_int<A,T>::digit_type n);
template<class A, class T>
- mp_int<A,T> nth_root(const mp_int<A,T>& x, const mp_int<A,T>& n);
+ unbounded_int<A,T> nth_root(const unbounded_int<A,T>& x, const unbounded_int<A,T>& n);
* [*Returns:] The `n`th root of `x`.
* [*Complexity:] O(log(N)).
@@ -1372,5 +1405,5 @@
* `std::domain_error` if `x` is negative and `n` is odd.
-[endsect][/mp_int reference]
+[endsect][/unbounded_int reference]
Copied: sandbox/mp_math/libs/mp_math/doc/unbounded_traits_reference.qbk (from r54215, /sandbox/mp_math/libs/mp_math/doc/mp_int_traits_reference.qbk)
==============================================================================
--- /sandbox/mp_math/libs/mp_math/doc/mp_int_traits_reference.qbk (original)
+++ sandbox/mp_math/libs/mp_math/doc/unbounded_traits_reference.qbk 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -1,16 +1,16 @@
-[/ Copyright Kevin Sopp 2008.
+[/ Copyright Kevin Sopp 2008 - 2009.
/ Distributed under the Boost Software License, Version 1.0.
/ (See accompanying file LICENSE_1_0.txt or copy at
/ http://www.boost.org/LICENSE_1_0.txt)]
-[section mp_int_traits reference]
+[section unbounded_traits reference]
The second template parameter to mp_int is a type which allows to customize some
of mp_int's internal workings.
[heading Synopsis]
``
-// <boost/mp_math/mp_int/traits.hpp>
+// <boost/mp_math/integer/unbounded_traits.hpp>
namespace boost {
namespace mp_math {
@@ -18,7 +18,7 @@
typename Digit = implementation defined,
typename Word = implementation defined
>
-struct mp_int_traits
+struct unbounded_traits
{
typedef std::size_t size_type;
typedef Digit digit_type;
@@ -33,5 +33,5 @@
} // namespace mp_math
} // namespace boost
``
-[endsect][/mp_int_traits reference]
+[endsect][/unbounded_traits reference]
Copied: sandbox/mp_math/libs/mp_math/doc/uniform_integer_bits_reference.qbk (from r54215, /sandbox/mp_math/libs/mp_math/doc/uniform_mp_int_bits_reference.qbk)
==============================================================================
--- /sandbox/mp_math/libs/mp_math/doc/uniform_mp_int_bits_reference.qbk (original)
+++ sandbox/mp_math/libs/mp_math/doc/uniform_integer_bits_reference.qbk 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -1,28 +1,28 @@
-[/ Copyright Kevin Sopp 2008.
+[/ Copyright Kevin Sopp 2008 - 2009.
/ Distributed under the Boost Software License, Version 1.0.
/ (See accompanying file LICENSE_1_0.txt or copy at
/ http://www.boost.org/LICENSE_1_0.txt)]
-[section uniform_mp_int_bits reference]
+[section uniform_integer_bits reference]
[heading Synopsis]
- // <boost/mp_math/mp_int.hpp>
- template<class MpInt = mp_int<> >
- struct uniform_mp_int_bits
+ // <boost/mp_math/integer.hpp>
+ template<class MpInt = integer<> >
+ struct uniform_integer_bits
{
typedef MpInt input_type;
typedef MpInt result_type;
static const bool has_fixed_range = false;
- uniform_mp_int_bits(typename MpInt::size_type bits);
+ uniform_integer_bits(typename MpInt::size_type bits);
result_type min() const;
result_type max() const;
void reset();
-
+
template<class UniformRandomNumberGenerator>
result_type operator()(UniformRandomNumberGenerator& urng);
};
@@ -30,9 +30,9 @@
[h3 Members]
- uniform_mp_int_bits(typename MpInt::size_type x);
+ uniform_integer_bits(typename MpInt::size_type x);
-* [*Effects:] Constructs a `uniform_mp_int_bits` object. All numbers generated
+* [*Effects:] Constructs a `uniform_integer_bits` object. All numbers generated
by this object will be `x` bits in size.
@@ -45,7 +45,7 @@
* [*Returns:] The greatest value of the distribution.
-
+
void reset();
* [*Effects:] Resets the state of the distribution function.
@@ -55,6 +55,6 @@
result_type operator()(UniformRandomNumberGenerator& urng);
* [*Returns:] A uniform random number `x` in the range `min <= x <= max`.
-
-[endsect][/uniform_mp_int_bits reference]
+
+[endsect][/uniform_integer_bits reference]
Copied: sandbox/mp_math/libs/mp_math/doc/uniform_integer_reference.qbk (from r54215, /sandbox/mp_math/libs/mp_math/doc/uniform_mp_int_reference.qbk)
==============================================================================
--- /sandbox/mp_math/libs/mp_math/doc/uniform_mp_int_reference.qbk (original)
+++ sandbox/mp_math/libs/mp_math/doc/uniform_integer_reference.qbk 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -1,28 +1,28 @@
-[/ Copyright Kevin Sopp 2008.
+[/ Copyright Kevin Sopp 2008 - 2009.
/ Distributed under the Boost Software License, Version 1.0.
/ (See accompanying file LICENSE_1_0.txt or copy at
/ http://www.boost.org/LICENSE_1_0.txt)]
-[section uniform_mp_int reference]
+[section uniform_integer reference]
[heading Synopsis]
- // <boost/mp_math/mp_int.hpp>
- template<class MpInt = mp_int<> >
- struct uniform_mp_int
+ // <boost/mp_math/integer.hpp>
+ template<class MpInt = integer<> >
+ struct uniform_integer
{
typedef MpInt input_type;
typedef MpInt result_type;
static const bool has_fixed_range = false;
- uniform_mp_int(const MpInt& min, const MpInt& max);
+ uniform_integer(const MpInt& min, const MpInt& max);
result_type min() const;
result_type max() const;
void reset();
-
+
template<class UniformRandomNumberGenerator>
result_type operator()(UniformRandomNumberGenerator& urng);
};
@@ -30,10 +30,10 @@
[h3 Members]
- uniform_mp_int(const MpInt& min, const MpInt& max);
+ uniform_integer(const MpInt& min, const MpInt& max);
* [*Requires: ] `min <= max`
-* [*Effects:] Constructs a `uniform_mp_int` object. `min` and `max` are the
+* [*Effects:] Constructs a `uniform_integer` object. `min` and `max` are the
parameters of the distribution.
@@ -46,7 +46,7 @@
* [*Returns:] The `max` parameter of the distribution.
-
+
void reset();
* [*Effects:] Resets the state of the distribution function.
@@ -56,6 +56,6 @@
result_type operator()(UniformRandomNumberGenerator& urng);
* [*Returns:] A uniform random number `x` in the range `min <= x <= max`.
-
-[endsect][/uniform_mp_int reference]
+
+[endsect][/uniform_integer reference]
Deleted: sandbox/mp_math/libs/mp_math/doc/uniform_mp_int_bits_reference.qbk
==============================================================================
--- sandbox/mp_math/libs/mp_math/doc/uniform_mp_int_bits_reference.qbk 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
+++ (empty file)
@@ -1,60 +0,0 @@
-[/ Copyright Kevin Sopp 2008.
- / Distributed under the Boost Software License, Version 1.0.
- / (See accompanying file LICENSE_1_0.txt or copy at
- / http://www.boost.org/LICENSE_1_0.txt)]
-
-[section uniform_mp_int_bits reference]
-
-[heading Synopsis]
-
- // <boost/mp_math/mp_int.hpp>
- template<class MpInt = mp_int<> >
- struct uniform_mp_int_bits
- {
- typedef MpInt input_type;
- typedef MpInt result_type;
-
- static const bool has_fixed_range = false;
-
- uniform_mp_int_bits(typename MpInt::size_type bits);
-
- result_type min() const;
- result_type max() const;
-
- void reset();
-
- template<class UniformRandomNumberGenerator>
- result_type operator()(UniformRandomNumberGenerator& urng);
- };
-
-
-[h3 Members]
-
- uniform_mp_int_bits(typename MpInt::size_type x);
-
-* [*Effects:] Constructs a `uniform_mp_int_bits` object. All numbers generated
-by this object will be `x` bits in size.
-
-
- result_type min() const;
-
-* [*Returns:] The least value of the distribution.
-
-
- result_type max() const;
-
-* [*Returns:] The greatest value of the distribution.
-
-
- void reset();
-
-* [*Effects:] Resets the state of the distribution function.
-
-
- template<class UniformRandomNumberGenerator>
- result_type operator()(UniformRandomNumberGenerator& urng);
-
-* [*Returns:] A uniform random number `x` in the range `min <= x <= max`.
-
-
-[endsect][/uniform_mp_int_bits reference]
Deleted: sandbox/mp_math/libs/mp_math/doc/uniform_mp_int_reference.qbk
==============================================================================
--- sandbox/mp_math/libs/mp_math/doc/uniform_mp_int_reference.qbk 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
+++ (empty file)
@@ -1,61 +0,0 @@
-[/ Copyright Kevin Sopp 2008.
- / Distributed under the Boost Software License, Version 1.0.
- / (See accompanying file LICENSE_1_0.txt or copy at
- / http://www.boost.org/LICENSE_1_0.txt)]
-
-[section uniform_mp_int reference]
-
-[heading Synopsis]
-
- // <boost/mp_math/mp_int.hpp>
- template<class MpInt = mp_int<> >
- struct uniform_mp_int
- {
- typedef MpInt input_type;
- typedef MpInt result_type;
-
- static const bool has_fixed_range = false;
-
- uniform_mp_int(const MpInt& min, const MpInt& max);
-
- result_type min() const;
- result_type max() const;
-
- void reset();
-
- template<class UniformRandomNumberGenerator>
- result_type operator()(UniformRandomNumberGenerator& urng);
- };
-
-
-[h3 Members]
-
- uniform_mp_int(const MpInt& min, const MpInt& max);
-
-* [*Requires: ] `min <= max`
-* [*Effects:] Constructs a `uniform_mp_int` object. `min` and `max` are the
-parameters of the distribution.
-
-
- result_type min() const;
-
-* [*Returns:] The `min` parameter of the distribution.
-
-
- result_type max() const;
-
-* [*Returns:] The `max` parameter of the distribution.
-
-
- void reset();
-
-* [*Effects:] Resets the state of the distribution function.
-
-
- template<class UniformRandomNumberGenerator>
- result_type operator()(UniformRandomNumberGenerator& urng);
-
-* [*Returns:] A uniform random number `x` in the range `min <= x <= max`.
-
-
-[endsect][/uniform_mp_int reference]
Added: sandbox/mp_math/libs/mp_math/test/gmp_integer/integral_ops.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/gmp_integer/integral_ops.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,425 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(construct_from_zero, int_type, IntTypes)
+{
+ const int_type x(0);
+ BOOST_CHECK_EQUAL(!x, true);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(equal_signed_char_min, int_type, IntTypes)
+{
+ const signed char x = std::numeric_limits<signed char>::min();
+ const int_type y(x);
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(equal_signed_char_max, int_type, IntTypes)
+{
+ const signed char x = std::numeric_limits<signed char>::max();
+ const int_type y(x);
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(equal_unsigned_char_min, int_type, IntTypes)
+{
+ const unsigned char x = std::numeric_limits<unsigned char>::min();
+ const int_type y(x);
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(equal_unsigned_char_max, int_type, IntTypes)
+{
+ const unsigned char x = std::numeric_limits<unsigned char>::max();
+ const int_type y(x);
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(equal_int_min, int_type, IntTypes)
+{
+ const int x = std::numeric_limits<int>::min();
+ const int_type y(x);
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(equal_int_max, int_type, IntTypes)
+{
+ const int x = std::numeric_limits<int>::max();
+ const int_type y(x);
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(equal_unsigned_int_min, int_type, IntTypes)
+{
+ const unsigned int x = std::numeric_limits<unsigned int>::min();
+ const int_type y(x);
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(equal_unsigned_int_max, int_type, IntTypes)
+{
+ const unsigned int x = std::numeric_limits<unsigned int>::max();
+ const int_type y(x);
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+#ifdef BOOST_HAS_LONG_LONG
+BOOST_AUTO_TEST_CASE_TEMPLATE(equal_long_long_int_min, int_type, IntTypes)
+{
+ const long long int x = std::numeric_limits<long long int>::min();
+ const int_type y(x);
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(equal_long_long_int_max, int_type, IntTypes)
+{
+ const long long int x = std::numeric_limits<long long int>::max();
+ const int_type y(x);
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(equal_unsigned_long_long_int_min, int_type, IntTypes)
+{
+ const unsigned long long int x = std::numeric_limits<unsigned long long int>::min();
+ const int_type y(x);
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(equal_unsigned_long_long_int_max, int_type, IntTypes)
+{
+ const unsigned long long int x = std::numeric_limits<unsigned long long int>::max();
+ const int_type y(x);
+ BOOST_CHECK_EQUAL(x, y);
+}
+#endif
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_signed_integral1, int_type, IntTypes)
+{
+ const int_type x("987777");
+ const int_type z = x + 1;
+ BOOST_CHECK_EQUAL(z, "987778");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_signed_integral2, int_type, IntTypes)
+{
+ const int_type x("987777");
+ const int_type z = x + (-1);
+ BOOST_CHECK_EQUAL(z, "987776");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_signed_integral3, int_type, IntTypes)
+{
+ const int_type x("9");
+ const int_type z = x + (-10);
+ BOOST_CHECK_EQUAL(z, "-1");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_signed_integral4, int_type, IntTypes)
+{
+ const int_type x("-1");
+ const int_type z = x + 5;
+ BOOST_CHECK_EQUAL(z, "4");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_unsigned_integral1, int_type, IntTypes)
+{
+ const int_type x("9999999");
+ const int_type z = x + 1U;
+ BOOST_CHECK_EQUAL(z, "10000000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_signed_char_min, int_type, IntTypes)
+{
+ const int_type x("0");
+ const int_type z = x + std::numeric_limits<signed char>::min();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<signed char>::min());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_signed_char_max, int_type, IntTypes)
+{
+ const int_type x("0");
+ const int_type z = x + std::numeric_limits<signed char>::max();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<signed char>::max());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_int_min, int_type, IntTypes)
+{
+ const int_type x("0");
+ const int_type z = x + std::numeric_limits<int>::min();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<int>::min());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_int_max, int_type, IntTypes)
+{
+ const int_type x("0");
+ const int_type z = x + std::numeric_limits<int>::max();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<int>::max());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(subtract_signed_integral1, int_type, IntTypes)
+{
+ const int_type x("987777");
+ const int_type z = x - 12345;
+ BOOST_CHECK_EQUAL(z, "975432");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(subtract_signed_integral2, int_type, IntTypes)
+{
+ const int_type x("98000");
+ const int_type z = x - (-1);
+ BOOST_CHECK_EQUAL(z, "98001");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(subtract_signed_integral3, int_type, IntTypes)
+{
+ const int_type x("125642682070");
+ const long y = 2147483647;
+ const int_type z = x - y;
+ BOOST_CHECK_EQUAL(z, "123495198423");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(subtract_signed_integral4, int_type, IntTypes)
+{
+ const int_type x("1");
+ const int_type z = x - 2;
+ BOOST_CHECK_EQUAL(z, "-1");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(subtract_signed_integral5, int_type, IntTypes)
+{
+ const int_type x("-0x23489328938ababba000909909");
+ const int_type z = x - (-2);
+ BOOST_CHECK_EQUAL(z, "-0x23489328938ababba000909907");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(subtract_signed_integral6, int_type, IntTypes)
+{
+ const int_type x("-0x23489328938ababba000909909");
+ const int_type z = x - 0x200;
+ BOOST_CHECK_EQUAL(z, "-0x23489328938ababba000909b09");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(subtract_unsigned_char1, int_type, IntTypes)
+{
+ const unsigned char y = 14;
+ const int_type x("987777");
+ const int_type z = x - y;
+ BOOST_CHECK_EQUAL(z, "987763");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(multiply1, int_type, IntTypes)
+{
+ const int_type x("-14");
+ const signed char y = 100;
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "-1400");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(multiply2, int_type, IntTypes)
+{
+ const int_type x("-14");
+ const int y = 10000;
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "-140000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(multiply3, int_type, IntTypes)
+{
+ const int_type x("-14");
+ const signed char y = -100;
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "1400");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(multiply4, int_type, IntTypes)
+{
+ const int_type x("-14");
+ const int y = -10000;
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "140000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(multiply5, int_type, IntTypes)
+{
+ const int_type x("-14");
+ const unsigned char y = 100;
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "-1400");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(multiply6, int_type, IntTypes)
+{
+ const int_type x("-14");
+ const unsigned int y = 10000;
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "-140000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(multiply7, int_type, IntTypes)
+{
+ const int_type x("-987777");
+ const signed char y = 123;
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "-121496571");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(multiply8, int_type, IntTypes)
+{
+ const int_type x("-987777");
+ const int y = 12345;
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "-12194107065");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(multiply9, int_type, IntTypes)
+{
+ const int_type x("987777");
+ const int_type z = x * -12345;
+ BOOST_CHECK_EQUAL(z, "-12194107065");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(multiply10, int_type, IntTypes)
+{
+ const int_type x("-987777");
+ const int_type z = x * -12345;
+ BOOST_CHECK_EQUAL(z, "12194107065");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(multiply11, int_type, IntTypes)
+{
+ const int_type x("1256");
+ const int_type z = x * 100U;
+ int_type w("125600");
+ BOOST_CHECK_EQUAL(z, "125600");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(multiply12, int_type, IntTypes)
+{
+ const int_type x("-0x500001f0000000");
+ const unsigned long y = 0x413000;
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "-0x145f007e4d0000000000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(multiply_by_zero1, int_type, IntTypes)
+{
+ const int_type x("-1");
+ const int y = 0;
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(multiply_by_zero2, int_type, IntTypes)
+{
+ const int_type x("-9877234234252377");
+ const int y = 0;
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(multiply_by_zero3, int_type, IntTypes)
+{
+ const int_type x("-9877234234252377");
+ const unsigned int y = 0;
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(multiply_by_negative_zero1, int_type, IntTypes)
+{
+ const int_type x("-9877234234252377");
+ const int_type z = x * -0;
+ BOOST_CHECK_EQUAL(z, "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(divide_by_unsigned_char1, int_type, IntTypes)
+{
+ const unsigned char y = 16;
+ const int_type x("10000001");
+ const int_type z = x / y;
+ BOOST_CHECK_EQUAL(z, "625000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(divide_by_unsigned_char2, int_type, IntTypes)
+{
+ const unsigned char y = 128;
+ const int_type x("14222200");
+ const int_type z = x / y;
+ BOOST_CHECK_EQUAL(z, "111110");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(divide_by_signed_integral1, int_type, IntTypes)
+{
+ const int_type x("786432");
+ const int_type z = x / 12;
+ BOOST_CHECK_EQUAL(z, "65536");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modulo_signed_integral1, int_type, IntTypes)
+{
+ const int_type x("786432");
+ const int_type z = x % 12;
+ BOOST_CHECK_EQUAL(z, "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modulo_signed_integral2, int_type, IntTypes)
+{
+ const int_type x("-987777");
+ const int_type z = x % 123456;
+ BOOST_CHECK_EQUAL(z, "-129");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modulo_signed_integral3, int_type, IntTypes)
+{
+ const int_type x("987777");
+ const int_type z = x % -123456;
+ BOOST_CHECK_EQUAL(z, "129");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modulo_signed_integral4, int_type, IntTypes)
+{
+ const int_type x("-987777");
+ const int_type z = x % -123456;
+ BOOST_CHECK_EQUAL(z, "-129");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modulo_unsigned_integral1, int_type, IntTypes)
+{
+ const int_type x("987771");
+ const int_type z = x % 16U;
+ BOOST_CHECK_EQUAL(z, "11");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modulo_unsigned_integral2, int_type, IntTypes)
+{
+ const int_type x("-987771");
+ const int_type z = x % 16U;
+ BOOST_CHECK_EQUAL(z, "-11");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(bitwise_or_signed_integral1, int_type, IntTypes)
+{
+ const int_type x("786432");
+ const int_type z = x | 1;
+ BOOST_CHECK_EQUAL(z, "786433");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(bitwise_or_signed_integral2, int_type, IntTypes)
+{
+ const int_type x("786432");
+ const int_type z = x | -1;
+ BOOST_CHECK_EQUAL(z, "-786433");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(bitwise_or_unsigned_integral1, int_type, IntTypes)
+{
+ const int_type x("786432");
+ const int_type z = x | 1U;
+ BOOST_CHECK_EQUAL(z, "786433");
+}
+
Modified: sandbox/mp_math/libs/mp_math/test/gmp_integer/modpow.cpp
==============================================================================
--- sandbox/mp_math/libs/mp_math/test/gmp_integer/modpow.cpp (original)
+++ sandbox/mp_math/libs/mp_math/test/gmp_integer/modpow.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -101,3 +101,12 @@
"8379f3024e4");
}
+BOOST_AUTO_TEST_CASE_TEMPLATE(modpow10, int_type, IntTypes)
+{
+ const int_type x("85219208314462076924446303193527165430");
+ const int_type exp("99459745544104451690992478817018793139");
+ const int_type m("198919491088208903381984957634037586279");
+ const int_type z = boost::mp_math::modpow(x, exp, m);
+ BOOST_CHECK_EQUAL(z, "1");
+}
+
Added: sandbox/mp_math/libs/mp_math/test/gmp_integer/prerequisite.hpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/gmp_integer/prerequisite.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,19 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/mp_math/gmp.hpp>
+#include <boost/mp_math/integer.hpp>
+#include <boost/mpl/vector.hpp>
+
+struct IntTypes
+:
+ boost::mpl::vector<
+ boost::mp_math::integer<
+ boost::mp_math::gmp_integer<>
+ >,
+ boost::mp_math::gmp_integer<>
+ >
+{};
+
Added: sandbox/mp_math/libs/mp_math/test/gmp_integer/serialization.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/gmp_integer/serialization.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,36 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <sstream>
+#include <boost/archive/text_oarchive.hpp>
+#include <boost/archive/text_iarchive.hpp>
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+#include <boost/mp_math/integer_serialization.hpp>
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_serialization1, int_type, IntTypes)
+{
+ int_type x("-0x123456789abcdef25700000000003a");
+ int_type y;
+
+ std::stringstream s;
+
+ // Wrap this in a block so that the text_oarchive dtor writes a terminating
+ // null character to the stream before opening an input archive on it.
+ // See the note on the stream_error exception in the Boost.Serialization
+ // documentation.
+ {
+ boost::archive::text_oarchive oa(s);
+ oa << x;
+ }
+
+ {
+ boost::archive::text_iarchive ia(s);
+ ia >> y;
+ }
+
+ BOOST_CHECK_EQUAL(x, y);
+}
+
Modified: sandbox/mp_math/libs/mp_math/test/gmp_integer/swap.cpp
==============================================================================
--- sandbox/mp_math/libs/mp_math/test/gmp_integer/swap.cpp (original)
+++ sandbox/mp_math/libs/mp_math/test/gmp_integer/swap.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -29,20 +29,6 @@
BOOST_CHECK_EQUAL(y, "-0xabff23742384bf892734029323819048039");
}
-#ifdef BOOST_HAS_RVALUE_REFS
-BOOST_AUTO_TEST_CASE_TEMPLATE(swap3, int_type, IntTypes)
-{
- int_type x;
- int_type y;
-
- boost::mp_math::swap(int_type("-0x1fee55d048039"), x);
- boost::mp_math::swap(y, int_type("-0x1fee55d048039"));
-
- BOOST_CHECK_EQUAL(x, "-0x1fee55d048039");
- BOOST_CHECK_EQUAL(y, "-0x1fee55d048039");
-}
-#endif
-
#include <algorithm>
BOOST_AUTO_TEST_CASE_TEMPLATE(swap4, int_type, IntTypes)
Added: sandbox/mp_math/libs/mp_math/test/gmp_integer/to_integral.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/gmp_integer/to_integral.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,138 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_char1, int_type, IntTypes)
+{
+ const int_type x("123");
+ const char z = x.template to_integral<char>();
+ BOOST_CHECK_EQUAL(z, 123);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_char2, int_type, IntTypes)
+{
+ const int_type x("-123");
+ const char z = x.template to_integral<char>();
+ BOOST_CHECK_EQUAL(z, -123);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_char_min, int_type, IntTypes)
+{
+ const int_type x(std::numeric_limits<char>::min());
+ const char z = x.template to_integral<char>();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<char>::min());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_char_max, int_type, IntTypes)
+{
+ const int_type x(std::numeric_limits<char>::max());
+ const int z = x.template to_integral<char>();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<char>::max());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_unsigned_char_min, int_type, IntTypes)
+{
+ int_type x(std::numeric_limits<unsigned char>::min());
+ const unsigned char z = x.template to_integral<unsigned char>();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<unsigned char>::min());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_unsigned_char_max, int_type, IntTypes)
+{
+ int_type x(std::numeric_limits<unsigned char>::max());
+ const unsigned char z = x.template to_integral<unsigned char>();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<unsigned char>::max());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_int_min, int_type, IntTypes)
+{
+ int_type x(std::numeric_limits<int>::min());
+ const int z = x.template to_integral<int>();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<int>::min());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_int_max, int_type, IntTypes)
+{
+ int_type x(std::numeric_limits<int>::max());
+ const int z = x.template to_integral<int>();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<int>::max());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_unsigned_int_min, int_type, IntTypes)
+{
+ int_type x(std::numeric_limits<unsigned int>::min());
+ const unsigned int z = x.template to_integral<unsigned int>();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<unsigned int>::min());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_unsigned_int_max, int_type, IntTypes)
+{
+ int_type x(std::numeric_limits<unsigned int>::max());
+ const unsigned int z = x.template to_integral<unsigned int>();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<unsigned int>::max());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_long_int_min, int_type, IntTypes)
+{
+ int_type x(std::numeric_limits<long int>::min());
+ const long int z = x.template to_integral<long int>();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<long int>::min());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_long_int_max, int_type, IntTypes)
+{
+ int_type x(std::numeric_limits<long int>::max());
+ const long int z = x.template to_integral<long int>();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<long int>::max());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_unsigned_long_int_min, int_type, IntTypes)
+{
+ int_type x(std::numeric_limits<unsigned long int>::min());
+ const unsigned long int z = x.template to_integral<unsigned long int>();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<unsigned long int>::min());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_unsigned_long_int_max, int_type, IntTypes)
+{
+ int_type x(std::numeric_limits<unsigned long int>::max());
+ const unsigned long int z = x.template to_integral<unsigned long int>();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<unsigned long int>::max());
+}
+
+#ifdef BOOST_HAS_LONG_LONG
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_long_long_int_min, int_type, IntTypes)
+{
+ int_type x(std::numeric_limits<long long int>::min());
+ const long long int z = x.template to_integral<long long int>();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<long long int>::min());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_long_long_int_max, int_type, IntTypes)
+{
+ int_type x(std::numeric_limits<long long int>::max());
+ const long long int z = x.template to_integral<long long int>();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<long long int>::max());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_unsigned_long_long_int_min, int_type, IntTypes)
+{
+ int_type x(std::numeric_limits<unsigned long long int>::min());
+ const unsigned long long int z =
+ x.template to_integral<unsigned long long int>();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<unsigned long long int>::min());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(to_unsigned_long_long_int_max, int_type, IntTypes)
+{
+ int_type x(std::numeric_limits<unsigned long long int>::max());
+ const unsigned long long int z =
+ x.template to_integral<unsigned long long int>();
+ BOOST_CHECK_EQUAL(z, std::numeric_limits<unsigned long long int>::max());
+}
+#endif
+
Added: sandbox/mp_math/libs/mp_math/test/gmp_integer/to_string.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/gmp_integer/to_string.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,112 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string1, int_type, IntTypes)
+{
+ const int_type x("0xabcdef123456789");
+ const std::string s =
+ x.template to_string<std::string>(std::ios::hex | std::ios::showbase);
+ BOOST_CHECK_EQUAL(s, "0xabcdef123456789");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string2, int_type, IntTypes)
+{
+ const int_type x("12345678901234567890");
+ const std::string s = x.template to_string<std::string>();
+ BOOST_CHECK_EQUAL(s, "12345678901234567890");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string3, int_type, IntTypes)
+{
+ const int_type x("0xabcdef123456789");
+ const std::string s = x.template to_string<std::string>(
+ std::ios::hex | std::ios::showbase | std::ios::uppercase);
+ BOOST_CHECK_EQUAL(s, "0XABCDEF123456789");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string4, int_type, IntTypes)
+{
+ const int_type x("76484675");
+ const std::string s = x.template to_string<std::string>(std::ios::oct);
+ BOOST_CHECK_EQUAL(s, "443610103");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string5, int_type, IntTypes)
+{
+ const int_type x("1024");
+ const std::string s = x.template to_string<std::string>(std::ios::oct);
+ BOOST_CHECK_EQUAL(s, "2000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string6, int_type, IntTypes)
+{
+ const int_type x("0");
+ const std::string s =
+ x.template to_string<std::string>(
+ std::ios_base::dec | std::ios_base::showbase | std::ios_base::showpos);
+ BOOST_CHECK_EQUAL(s, "+0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string7, int_type, IntTypes)
+{
+ const int_type x("0");
+ const std::string s =
+ x.template to_string<std::string>(
+ std::ios_base::oct | std::ios_base::showbase | std::ios_base::showpos);
+ BOOST_CHECK_EQUAL(s, "+0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string8, int_type, IntTypes)
+{
+ const int_type x("-0");
+ const std::string s =
+ x.template to_string<std::string>(
+ std::ios_base::oct | std::ios_base::showbase | std::ios_base::showpos);
+ BOOST_CHECK_EQUAL(s, "+0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string9, int_type, IntTypes)
+{
+ const int_type x("-1");
+ const std::string s =
+ x.template to_string<std::string>(
+ std::ios_base::hex | std::ios_base::showbase | std::ios_base::showpos);
+ BOOST_CHECK_EQUAL(s, "-0x1");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string10, int_type, IntTypes)
+{
+ const int_type x("0x95a6801ce5292b9a8410e1a59dd29967");
+ const std::string s =
+ x.template to_string<std::string>(std::ios_base::hex);
+ BOOST_CHECK_EQUAL(s, "95a6801ce5292b9a8410e1a59dd29967");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string11, int_type, IntTypes)
+{
+ const int_type x("0x12471fa56d6");
+ const std::string s = x.template to_string<std::string>();
+ BOOST_CHECK_EQUAL(s, "1256042682070");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string12, int_type, IntTypes)
+{
+ const int_type x("0x123456789abcdef");
+ const std::string s = x.template to_string<std::string>(
+ std::ios_base::hex | std::ios_base::showbase);
+ BOOST_CHECK_EQUAL(s, "0x123456789abcdef");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string13, int_type, IntTypes)
+{
+ const int_type x("0x123456789ABCDEF");
+ const std::string s = x.template to_string<std::string>(
+ std::ios_base::hex | std::ios_base::showbase | std::ios_base::uppercase);
+ BOOST_CHECK_EQUAL(s, "0X123456789ABCDEF");
+}
+
Modified: sandbox/mp_math/libs/mp_math/test/jamfile.v2
==============================================================================
--- sandbox/mp_math/libs/mp_math/test/jamfile.v2 (original)
+++ sandbox/mp_math/libs/mp_math/test/jamfile.v2 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -12,3 +12,13 @@
<define>BOOST_MP_MATH_MP_INT_USE_ASM
;
+alias boost_test
+: $(BOOST_ROOT)/libs/test/build//boost_unit_test_framework/<link>shared ;
+
+alias boost_serialization
+: $(BOOST_ROOT)/libs/serialization/build//boost_serialization/<link>shared ;
+
+lib gmp : : <name>gmp ;
+lib tommath : : <name>tommath ;
+
+unit-test type_conversion : type_conversion.cpp boost_test gmp ;
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/abs.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/abs.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,15 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(abs1, int_type, IntTypes)
+{
+ const int_type x("-0x123abdddfe4983");
+ const int_type y = boost::mp_math::abs(x);
+ BOOST_CHECK_EQUAL(y, "0x123abdddfe4983");
+}
+
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/add.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/add.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,245 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_assign1, int_type, IntTypes)
+{
+ int_type x("0xffffffff");
+ const int_type y("0xffffffffffffffff");
+ x += y;
+ BOOST_CHECK_EQUAL(x, "0x100000000fffffffe");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_positive_numbers1, int_type, IntTypes)
+{
+ const int_type x("123456");
+ const int_type y("987777");
+ const int_type z = x + y;
+ BOOST_CHECK_EQUAL(z, "1111233");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_positive_numbers2, int_type, IntTypes)
+{
+ const int_type x("999");
+ const int_type y("123456");
+ const int_type z = x + y;
+ BOOST_CHECK_EQUAL(z, "124455");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_positive_numbers3, int_type, IntTypes)
+{
+ const int_type x("21474836470");
+ const int_type y("1234567845600");
+ const int_type z = x + y;
+ BOOST_CHECK_EQUAL(z, "1256042682070");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_positive_numbers4, int_type, IntTypes)
+{
+ const int_type x("0xffffffffffffffff");
+ const int_type y("0xffffffffffffffff");
+ const int_type z = x + y;
+ BOOST_CHECK_EQUAL(z, "0x1fffffffffffffffe");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_positive_numbers5, int_type, IntTypes)
+{
+ const int_type x("0xffffffffffffffff");
+ const int_type y("0xffffffff");
+ const int_type z = x + y;
+ BOOST_CHECK_EQUAL(z, "0x100000000fffffffe");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_negative_numbers1, int_type, IntTypes)
+{
+ const int_type x("-123456");
+ const int_type y("-987777");
+ const int_type z = x + y;
+ BOOST_CHECK_EQUAL(z, "-1111233");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_negative_numbers2, int_type, IntTypes)
+{
+ const int_type x("-12345678900000000");
+ const int_type y("-987777");
+ const int_type z = x + y;
+ BOOST_CHECK_EQUAL(z, "-12345678900987777");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_negative_numbers3, int_type, IntTypes)
+{
+ const int_type x("-987777");
+ const int_type y("-12345678900000000");
+ const int_type z = x + y;
+ BOOST_CHECK_EQUAL(z, "-12345678900987777");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_mixed_numbers1, int_type, IntTypes)
+{
+ const int_type x("-123456");
+ const int_type y("987777");
+ const int_type z = x + y;
+ BOOST_CHECK_EQUAL(z, "864321");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_mixed_numbers2, int_type, IntTypes)
+{
+ const int_type x("123456");
+ const int_type y("-987777");
+ const int_type z = x + y;
+ BOOST_CHECK_EQUAL(z, "-864321");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_mixed_numbers3, int_type, IntTypes)
+{
+ const int_type x("-123456");
+ const int_type y("123456");
+ const int_type z = x + y;
+ BOOST_CHECK_EQUAL(z, "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_mixed_numbers4, int_type, IntTypes)
+{
+ const int_type x("123456");
+ const int_type y("-123456");
+ const int_type z = x + y;
+ BOOST_CHECK_EQUAL(z, "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_mixed_numbers5, int_type, IntTypes)
+{
+ const int_type x("1000");
+ const int_type y("-12345678901000");
+ const int_type z = x + y;
+ BOOST_CHECK_EQUAL(z, "-12345678900000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_mixed_numbers6, int_type, IntTypes)
+{
+ const int_type x("-12345678901000");
+ const int_type y("1000");
+ const int_type z = x + y;
+ BOOST_CHECK_EQUAL(z, "-12345678900000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_large_and_small, int_type, IntTypes)
+{
+ int_type x("123456789");
+ int_type y("123");
+ int_type z = x + y;
+ BOOST_CHECK_EQUAL(z, "123456912");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_small_and_large, int_type, IntTypes)
+{
+ int_type x("123");
+ int_type y("123456789");
+ int_type z = x + y;
+ BOOST_CHECK_EQUAL(z, "123456912");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_large_and_large, int_type, IntTypes)
+{
+ int_type x(
+ "76563204409879018101322737668344063995824904757312285775560614771886933079"
+ "77822556905976720912850551355328340715074887289899094852653102687850101285"
+ "85715275531977696497398396067715769512450915961775500023723324150851793075"
+ "51871751151095323159497918186624088118225730504044262785072662119470825604"
+ "40835072257208973943520251201155002832786969323087571220195329601804141972"
+ "71293425859967733061169954398382700046379970842289727254846347411792122453"
+ "98890529530611217475343335863666953662801553948341581412563112340543629531"
+ "01094529771464590172847457807673685591148055046712881378811934516545088775"
+ "38198087116656466935095055228728162461388333618793883566996616940381738437"
+ "03453867953392241443573580380271627517797446062394044787118140775664622031"
+ "49144609407766890328547643707523663509662747376486271392344480900673178645"
+ "33198519112197059826509662943577383543858946941049753393431035706592040680"
+ "43848484065292542884106550381079282660840705126574766636237650938379223350"
+ "073087806800887586256085275775217219429527000017403144");
+
+ int_type y(
+ "29156720459736055974643337783563754269574952607968485689453462316428566668"
+ "95504701770860331979649536167161534866285341319360225416010322271645564229"
+ "97610536562445338176729838019564690253931232562709745122032537539983616770"
+ "01864876491464203683664927984801289460556480278145114367860332493722569194"
+ "34026051618152579992400234314328079213866348120156368725488604236521299603"
+ "05243915357553896356662519397274629471920043679673543282319268893065423613"
+ "03777840501083119668898860689222271939900089123195611475211708096094521743"
+ "23436842195705603262202927396682954198215622617086455718070601797199587530"
+ "86110222151397352239086193648500251298495752840008363650931395221675337916"
+ "21665907282124706187656074325458499695895652068822763794228458103499408841"
+ "68233732651102406546734395563663969020820490032431359396293047454261598159"
+ "68165818673838448637209074584819780088546111644065538550490486693301185614"
+ "61602638472505490238203390055056474763248195271964604045005807592301719483"
+ "66411676459481184297663915491569500245585996483678005964410842919747216111"
+ "69086269285356198998091850661544255466466926579668887000118948737207396398"
+ "39189399212362197497646493143022100680619252808094160907526003969639965485"
+ "31238493375062268758735445211914107215235958346264702774326161208396163240"
+ "36339482493382189215697343908873498104516190541170342091008828518924813674"
+ "46253090923280613514725437269574928515018666111820866090440006060807129643"
+ "38626199608899966829344884873038261232122027815715568990196536130996880104"
+ "97887027262726591236620461428328000537452828616386217063092509908555188454"
+ "27278763741671312528892659532960085933913140197210561287118971031419725940"
+ "702202830556069344716729071140147820999566475298895832");
+ int_type z = x + y;
+ BOOST_CHECK_EQUAL(z,
+ "29156720459736055974643337783563754269574952607968485689453462316428566668"
+ "95504701770860331979649536167161534866285341319360225416010322271645564229"
+ "97610536562445338176729838019564690253931232562709745122032537539983616770"
+ "01864876491464203683664927984801289460556480278145114367860332493722569194"
+ "34026051618152579992400234314328079213866348120156368725488604236521299603"
+ "05243915357553896356662519397274629471920043679673543282319268893065423613"
+ "03777840501083119668898860689222271939900089123195611475211708096094521743"
+ "23436842195705603262202927396682954198215622617086455718070601797199587530"
+ "86110222151397352239086193648500251298495752840008363650931395221675337916"
+ "98229111692003724288978811993802563691720556826135049569789072875386341921"
+ "46056289557079127459584946918992309735895377322330454248946150142111699445"
+ "53881094205816145134607470652535549600997027605841038574213810844152978690"
+ "13474389623600813397701308241680562881473925776008866830078469711772545088"
+ "07246748716690158241184166692724503078372965806765577184606172521551358084"
+ "40379695145323932059261805059926955512846897421958614254965296148999518852"
+ "38079928742973414972989829006689054343420806756435742320089116310183595016"
+ "32333023146526858931582903019587792806384013392977584153138095724941252015"
+ "74537569610038656150792399137601660565904524159964225658005445459306552111"
+ "49706958876672854958299017649846556032816112174214910877558146836471751674"
+ "87770809016666857157892528580561924741784775192201840382541017031670058750"
+ "31085546374923651063130124371905384081311775557435970456523545615147229134"
+ "71127247806963855412999209914039368594753845323785327923356621969798949290"
+ "775290637356956930972814346915365040429093475316298976");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(increment1, int_type, IntTypes)
+{
+ int_type x("0");
+ for (int i = 0; i < 10; ++i)
+ ++x;
+ BOOST_CHECK_EQUAL(x, "10");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(increment2, int_type, IntTypes)
+{
+ int_type x("-4");
+ for (int i = 0; i < 10; ++i)
+ ++x;
+ BOOST_CHECK_EQUAL(x, "6");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(increment3, int_type, IntTypes)
+{
+ int_type x("-130");
+ for (int i = 0; i < 10; ++i)
+ ++x;
+ BOOST_CHECK_EQUAL(x, "-120");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(increment4, int_type, IntTypes)
+{
+ int_type x("120");
+ for (int i = 0; i < 10; ++i)
+ ++x;
+ BOOST_CHECK_EQUAL(x, "130");
+}
+
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/assign.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/assign.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,120 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_assign_zero, int_type, IntTypes)
+{
+ int_type x;
+ x = "0";
+ BOOST_CHECK_EQUAL(!x, true);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_assign_dec1, int_type, IntTypes)
+{
+ int_type x;
+ x = "269513460000009900000000";
+ BOOST_CHECK_EQUAL(x, "269513460000009900000000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_assign_dec2, int_type, IntTypes)
+{
+ int_type x;
+ x = "-269513460000009900000000";
+ BOOST_CHECK_EQUAL(x, "-269513460000009900000000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_assign_oct1, int_type, IntTypes)
+{
+ int_type x;
+ x = "012345676543210000001";
+ BOOST_CHECK_EQUAL(x, "012345676543210000001");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_assign_oct2, int_type, IntTypes)
+{
+ int_type x;
+ x = "-012345676543210000001";
+ BOOST_CHECK_EQUAL(x, "-012345676543210000001");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_assign_hex1, int_type, IntTypes)
+{
+ int_type x;
+ x = "0xabcdef123456789000000000005000000000000007ffffff";
+ BOOST_CHECK_EQUAL(x, "0xabcdef123456789000000000005000000000000007ffffff");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_assign_hex2, int_type, IntTypes)
+{
+ int_type x;
+ x = "-0xabcdef123456789000000000005000000000000007ffffff";
+ BOOST_CHECK_EQUAL(x, "-0xabcdef123456789000000000005000000000000007ffffff");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_assign_hex3, int_type, IntTypes)
+{
+ int_type x;
+ x = "-0xABCDEF00000123456798EEEEEEEEEE";
+ BOOST_CHECK_EQUAL(x, "-0xABCDEF00000123456798EEEEEEEEEE");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_assign_hex4, int_type, IntTypes)
+{
+ int_type x;
+ x = "-0Xabcdef00000123456798eeeeeeeeee";
+ BOOST_CHECK_EQUAL(x, "-0Xabcdef00000123456798eeeeeeeeee");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_assign1, int_type, IntTypes)
+{
+ int_type x("-0x1");
+ x = "0123456765432100000000000000000000001";
+ BOOST_CHECK_EQUAL(x, "0123456765432100000000000000000000001");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_assign2, int_type, IntTypes)
+{
+ int_type x("-0xabcedf0303030300000000000000");
+ x = "01";
+ BOOST_CHECK_EQUAL(x, "01");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_assign3, int_type, IntTypes)
+{
+ int_type x("0xabcedf0303030300000000000000");
+ x = "-500";
+ BOOST_CHECK_EQUAL(x, "-500");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_assign4, int_type, IntTypes)
+{
+ int_type x("0x0");
+ x = "-0x500aaaaaaaaaaaa000000";
+ BOOST_CHECK_EQUAL(x, "-0x500aaaaaaaaaaaa000000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(assign1, int_type, IntTypes)
+{
+ int_type x;
+ x.assign("123456789876543210000001", std::ios::dec);
+ BOOST_CHECK_EQUAL(x, "123456789876543210000001");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(assign2, int_type, IntTypes)
+{
+ int_type x;
+ x.assign("abcdefabcdef1234567890", std::ios::hex);
+ BOOST_CHECK_EQUAL(x, "0xabcdefabcdef1234567890");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(assign3, int_type, IntTypes)
+{
+ int_type x("-564897123123456456789789789897");
+ x.assign("1234567000000000000000000000000077", std::ios::oct);
+ BOOST_CHECK_EQUAL(x, "01234567000000000000000000000000077");
+}
+
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/bitwise_ops.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/bitwise_ops.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,100 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(and_op1, int_type, IntTypes)
+{
+ const int_type x("0x00ff0000000f");
+ const int_type y("-0xffffffffffff");
+ const int_type z = x & y;
+ BOOST_CHECK_EQUAL(z, x);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(and_op2, int_type, IntTypes)
+{
+ const int_type x("0x00ff0000000ffffffffff");
+ const int_type y( "0xffffffffffff");
+ const int_type z = x & y;
+ BOOST_CHECK_EQUAL(z, "0xffffffffff");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(or_op1, int_type, IntTypes)
+{
+ const int_type x("0x00ff0000000f");
+ const int_type y("-0xffffffffffff");
+ const int_type z = x | y;
+ BOOST_CHECK_EQUAL(z, y);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(or_op2, int_type, IntTypes)
+{
+ const int_type x("0x00ff0000000ffffffffff");
+ const int_type y( "0xaaffffffffff");
+ const int_type z = x | y;
+ BOOST_CHECK_EQUAL(z, "0x00ff00000aaffffffffff");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(xor_op1, int_type, IntTypes)
+{
+ const int_type x("0x00ff0000000f");
+ const int_type y("0xffffffffffff");
+ const int_type z = x ^ y;
+ BOOST_CHECK_EQUAL(z, "0xff00fffffff0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(xor_op2, int_type, IntTypes)
+{
+ const int_type x("0x00ff0000000ffffffffff");
+ const int_type y( "0x33aaffffffff");
+ const int_type z = x ^ y;
+ BOOST_CHECK_EQUAL(z,"0x00ff00000335500000000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(xor_op3, int_type, IntTypes)
+{
+ const int_type x("-0x00ff0000000f");
+ const int_type y("-0xffffffffffff");
+ const int_type z = x ^ y;
+ BOOST_CHECK_EQUAL(z, "0xff00fffffff0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(xor_op4, int_type, IntTypes)
+{
+ const int_type x("0x00ff0000000f");
+ const int_type y("-0xffffffffffff");
+ const int_type z = x ^ y;
+ BOOST_CHECK_EQUAL(z, "-0xff00fffffff0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(compl1, int_type, IntTypes)
+{
+ int_type x("-0x6f0000000000000fabab");
+ x = ~x;
+ BOOST_CHECK_EQUAL(x, "0x10fffffffffffff05454");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(compl2, int_type, IntTypes)
+{
+ int_type x("0");
+ x = ~x;
+ BOOST_CHECK_EQUAL(x, "-1");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(compl3, int_type, IntTypes)
+{
+ int_type x("1");
+ x = ~x;
+ BOOST_CHECK_EQUAL(x, "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(compl4, int_type, IntTypes)
+{
+ int_type x("18446744073709551616"); // 2^65
+ x = ~x;
+ BOOST_CHECK_EQUAL(x, "-0xFFFFFFFFFFFFFFFF");
+}
+
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/bool_conversion.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/bool_conversion.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,57 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(bool1, int_type, IntTypes)
+{
+ // this just tests operator == (const int_type&, bool)
+ const int_type x("1");
+ const int_type y("0");
+ BOOST_CHECK_EQUAL(x, true);
+ BOOST_CHECK_EQUAL(y, false);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(bool_or, int_type, IntTypes)
+{
+ const int_type x("1");
+ const int_type y("0");
+ const bool z = x || y;
+ BOOST_CHECK_EQUAL(z, true);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(bool_and1, int_type, IntTypes)
+{
+ const int_type x("1");
+ const int_type y("0");
+ const bool z = x && y;
+ BOOST_CHECK_EQUAL(z, false);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(bool_and2, int_type, IntTypes)
+{
+ const int_type x("-1");
+ const int_type y("-1");
+ const bool z = x && y;
+ BOOST_CHECK_EQUAL(z, true);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(bool_loop_condition1, int_type, IntTypes)
+{
+ int_type x("5");
+ while (x)
+ --x;
+ BOOST_CHECK_EQUAL(x, false);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(bool_loop_condition2, int_type, IntTypes)
+{
+ int_type x("-5");
+ while (x)
+ ++x;
+ BOOST_CHECK_EQUAL(x, false);
+}
+
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/ctors.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/ctors.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,234 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+// We mostly test from/to string conversions here since most other test cases
+// depend on these. If they are broken and senseless data gets into an integer
+// or we have wrong output then we need to fix this quickly.
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(default_ctor, int_type, IntTypes)
+{
+ const int_type x;
+ BOOST_CHECK_EQUAL(x.size(), 0U);
+// BOOST_CHECK_EQUAL(x.is_initialized(), false);
+// BOOST_CHECK_EQUAL(x.is_uninitialized(), true);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_empty_string1, int_type, IntTypes)
+{
+ const int_type x("");
+// BOOST_CHECK_EQUAL(x.size(), 0U);
+// BOOST_CHECK_EQUAL(x.is_initialized(), false);
+// BOOST_CHECK_EQUAL(x.is_uninitialized(), true);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_decimal_string1, int_type, IntTypes)
+{
+ const int_type x("0");
+ BOOST_CHECK(x.is_positive());
+// BOOST_CHECK_EQUAL(x.is_initialized(), true);
+// BOOST_CHECK_EQUAL(x.is_uninitialized(), false);
+// BOOST_REQUIRE_EQUAL(x.size(), 1U);
+// BOOST_CHECK_EQUAL(x[0], 0U);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_decimal_string2, int_type, IntTypes)
+{
+ const int_type x("12");
+ BOOST_CHECK_EQUAL(x.template to_string<std::string>(), "12");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_decimal_string3, int_type, IntTypes)
+{
+ const int_type x("123456789");
+ BOOST_CHECK_EQUAL(x.template to_string<std::string>(), "123456789");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_decimal_string4, int_type, IntTypes)
+{
+ const int_type x("1000000000");
+ BOOST_CHECK_EQUAL(x.template to_string<std::string>(), "1000000000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_decimal_string5, int_type, IntTypes)
+{
+ const int_type x("+1");
+ BOOST_CHECK_EQUAL(x.template to_string<std::string>(), "1");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_decimal_string6, int_type, IntTypes)
+{
+ const int_type x("-1");
+ BOOST_CHECK(x.is_negative());
+ BOOST_CHECK_EQUAL(x.template to_string<std::string>(), "-1");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_decimal_string7, int_type, IntTypes)
+{
+ const int_type x("8888000000009", std::ios_base::dec |
+ std::ios_base::showbase);
+ BOOST_CHECK_EQUAL(x.template to_string<std::string>(), "8888000000009");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_decimal_string8, int_type, IntTypes)
+{
+ BOOST_CHECK_THROW(int_type("1234567890a456456"), std::invalid_argument);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_decimal_string9, int_type, IntTypes)
+{
+ BOOST_CHECK_THROW(
+ int_type("1230", std::ios_base::showpos),
+ std::invalid_argument);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_octal_string1, int_type, IntTypes)
+{
+ const int_type x("0", std::ios_base::oct);
+ //BOOST_REQUIRE_EQUAL(x.size(), 1U);
+ //BOOST_CHECK_EQUAL(x[0], 0U);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_octal_string2, int_type, IntTypes)
+{
+ const int_type x("0", std::ios_base::oct | std::ios_base::showbase);
+ //BOOST_REQUIRE_EQUAL(x.size(), 1U);
+ //BOOST_CHECK_EQUAL(x[0], 0U);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_octal_string3, int_type, IntTypes)
+{
+ const int_type x("012");
+ BOOST_CHECK_EQUAL(x.template to_string<std::string>(), "10");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_octal_string4, int_type, IntTypes)
+{
+ const int_type x("000000000000000000000000000000000");
+ //BOOST_REQUIRE_EQUAL(x.size(), 1U);
+ //BOOST_CHECK_EQUAL(x[0], 0U);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_octal_string5, int_type, IntTypes)
+{
+ const int_type x("0123456777");
+ BOOST_CHECK_EQUAL(x.template to_string<std::string>(), "21913087");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_octal_string6, int_type, IntTypes)
+{
+ BOOST_CHECK_THROW(int_type("012345678"), std::invalid_argument);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_octal_string7, int_type, IntTypes)
+{
+ BOOST_CHECK_THROW(
+ int_type("1234567", std::ios_base::oct | std::ios_base::showbase),
+ std::invalid_argument);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string1, int_type, IntTypes)
+{
+ const int_type x("0x0");
+ BOOST_CHECK_EQUAL(x.template to_string<std::string>(), "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string2, int_type, IntTypes)
+{
+ const int_type x("0X0");
+ BOOST_CHECK_EQUAL(x.template to_string<std::string>(), "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string3, int_type, IntTypes)
+{
+ const int_type x("0", std::ios_base::hex);
+ BOOST_CHECK_EQUAL(x.template to_string<std::string>(), "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string4, int_type, IntTypes)
+{
+ const int_type x("0xF");
+ BOOST_CHECK_EQUAL(x.template to_string<std::string>(), "15");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string5, int_type, IntTypes)
+{
+ const int_type x("0xa0");
+ BOOST_CHECK_EQUAL(x.template to_string<std::string>(), "160");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string8, int_type, IntTypes)
+{
+ const int_type x("0xA0000000");
+ BOOST_CHECK_EQUAL(x.template to_string<std::string>(), "2684354560");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string11, int_type, IntTypes)
+{
+ BOOST_CHECK_THROW(int_type("0x15656abg56"), std::invalid_argument);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string12, int_type, IntTypes)
+{
+ BOOST_CHECK_THROW(
+ int_type("156afc56", std::ios_base::hex | std::ios_base::showbase),
+ std::invalid_argument);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string13, int_type, IntTypes)
+{
+ BOOST_CHECK_THROW(
+ int_type("015656ABDEE0", std::ios_base::hex | std::ios_base::showbase |
+ std::ios_base::uppercase),
+ std::invalid_argument);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_long_string, int_type, IntTypes)
+{
+ const int_type x(
+ "875004025190050300612679044488093050295124399425061612342608525876458563"
+ "36946409871074842737283625535525153833045575858681216");
+ BOOST_CHECK_EQUAL(x.template to_string<std::string>(),
+ "875004025190050300612679044488093050295124399425061612342608525876458563"
+ "36946409871074842737283625535525153833045575858681216");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(cctor1, int_type, IntTypes)
+{
+ const int_type x("0xabddd00012134f");
+ const int_type y(x);
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(cctor2, int_type, IntTypes)
+{
+ const int_type x("-0xabddd00012134f");
+ const int_type y(x);
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+
+/*
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_unsigned_integral_type1, int_type, IntTypes)
+{
+ const int_type x(9999999U);
+ BOOST_CHECK_EQUAL(x, "9999999");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_unsigned_integral_type2, int_type, IntTypes)
+{
+ const int_type x(123456U);
+ BOOST_CHECK_EQUAL(x, "123456");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_integral_type_unsigned_char, int_type, IntTypes)
+{
+ unsigned char c = 42;
+ const int_type x(c);
+ BOOST_CHECK_EQUAL(x, "42");
+}
+*/
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/gcd.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/gcd.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,62 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(gcd1, int_type, IntTypes)
+{
+ const int_type x("10");
+ const int_type y("2");
+ const int_type z = boost::mp_math::gcd(x,y);
+ BOOST_CHECK_EQUAL(z, "2");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(gcd2, int_type, IntTypes)
+{
+ const int_type x("456489798");
+ const int_type y("987");
+ const int_type z = boost::mp_math::gcd(x,y);
+ BOOST_CHECK_EQUAL(z, "3");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(gcd3, int_type, IntTypes)
+{
+ const int_type x("-16384");
+ const int_type y("16384");
+ const int_type z = boost::mp_math::gcd(x,y);
+ BOOST_CHECK_EQUAL(z, "16384");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(gcd4, int_type, IntTypes)
+{
+ const int_type x("0");
+ const int_type y("0");
+ const int_type z = boost::mp_math::gcd(x,y);
+ BOOST_CHECK_EQUAL(z, "0");
+}
+
+#ifdef BOOST_HAS_VARIADIC_TMPL
+BOOST_AUTO_TEST_CASE_TEMPLATE(variadic_gcd1, int_type, IntTypes)
+{
+ const int_type a("42");
+ const int_type b("56");
+ const int_type c("140");
+ const int_type z = boost::mp_math::gcd(a,b,c);
+ BOOST_CHECK_EQUAL(z, "14");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(variadic_gcd2, int_type, IntTypes)
+{
+ const int_type a("1200000000");
+ const int_type b("2400000000");
+ const int_type c("3600000000");
+ const int_type d("600000000000000");
+ const int_type z = boost::mp_math::gcd(a,b,c,d);
+ BOOST_CHECK_EQUAL(z, "1200000000");
+}
+#endif
+
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/jacobi.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/jacobi.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,32 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(jacobi1, int_type, IntTypes)
+{
+ const int_type x("1236");
+ const int_type y("20003");
+ const int z = boost::mp_math::jacobi(x,y);
+ BOOST_CHECK_EQUAL(z, 1);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(jacobi2, int_type, IntTypes)
+{
+ const int_type x("987897");
+ const int_type y("987");
+ const int z = boost::mp_math::jacobi(x,y);
+ BOOST_CHECK_EQUAL(z, 0);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(jacobi3, int_type, IntTypes)
+{
+ const int_type x("610");
+ const int_type y("987");
+ const int z = boost::mp_math::jacobi(x,y);
+ BOOST_CHECK_EQUAL(z, -1);
+}
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/lcm.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/lcm.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,78 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(lcm1, int_type, IntTypes)
+{
+ const int_type x("0");
+ const int_type y("0");
+ const int_type z = boost::mp_math::lcm(x,y);
+ BOOST_CHECK_EQUAL(z, "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(lcm2, int_type, IntTypes)
+{
+ const int_type x("51111");
+ const int_type y("0");
+ const int_type z = boost::mp_math::lcm(x,y);
+ BOOST_CHECK_EQUAL(z, "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(lcm3, int_type, IntTypes)
+{
+ const int_type x("4");
+ const int_type y("6");
+ const int_type z = boost::mp_math::lcm(x,y);
+ BOOST_CHECK_EQUAL(z, "12");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(lcm4, int_type, IntTypes)
+{
+ const int_type x("-4");
+ const int_type y("6");
+ const int_type z = boost::mp_math::lcm(x,y);
+ BOOST_CHECK_EQUAL(z, "12");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(lcm5, int_type, IntTypes)
+{
+ const int_type x("4");
+ const int_type y("-6");
+ const int_type z = boost::mp_math::lcm(x,y);
+ BOOST_CHECK_EQUAL(z, "12");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(lcm6, int_type, IntTypes)
+{
+ const int_type x("-4");
+ const int_type y("-6");
+ const int_type z = boost::mp_math::lcm(x,y);
+ BOOST_CHECK_EQUAL(z, "12");
+}
+
+#ifdef BOOST_HAS_VARIADIC_TMPL
+BOOST_AUTO_TEST_CASE_TEMPLATE(variadic_lcm1, int_type, IntTypes)
+{
+ const int_type a("120");
+ const int_type b("204");
+ const int_type c("136");
+ const int_type z = boost::mp_math::lcm(a,b,c);
+ BOOST_CHECK_EQUAL(z, "2040");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(variadic_lcm2, int_type, IntTypes)
+{
+ const int_type a("12010");
+ const int_type b("3299");
+ const int_type c("84780");
+ const int_type d("15");
+ const int_type z = boost::mp_math::lcm(a,b,c,d);
+ BOOST_CHECK_EQUAL(z, "335906753220");
+}
+#endif
+
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/modinv.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/modinv.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,33 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modinv1, int_type, IntTypes)
+{
+ const int_type a("35");
+ const int_type m("33");
+ const int_type i = boost::mp_math::modinv(a, m);
+ BOOST_CHECK_EQUAL(i, "17");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modinv2, int_type, IntTypes)
+{
+ const int_type a("17");
+ const int_type m("26");
+ const int_type i = boost::mp_math::modinv(a, m);
+ BOOST_CHECK_EQUAL(i, "23");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modinv3, int_type, IntTypes)
+{
+ const int_type a("982451111"); // is a prime
+ const int_type m("982451653"); // is a prime
+ const int_type i = boost::mp_math::modinv(a, m);
+ BOOST_CHECK_EQUAL(i, "871880526");
+}
+
+
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/modpow.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/modpow.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,112 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modpow1, int_type, IntTypes)
+{
+ const int_type x("2");
+ const int_type exp("14");
+ const int_type m("8");
+ const int_type z = boost::mp_math::modpow(x, exp, m);
+ BOOST_CHECK_EQUAL(z, "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modpow2, int_type, IntTypes)
+{
+ const int_type x("4");
+ const int_type exp("13");
+ const int_type m("497");
+ const int_type z = boost::mp_math::modpow(x, exp, m);
+ BOOST_CHECK_EQUAL(z, "445");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modpow3, int_type, IntTypes)
+{
+ const int_type x("2395422");
+ const int_type exp("2424832");
+ const int_type m("2424833");
+ const int_type z = boost::mp_math::modpow(x, exp, m);
+ BOOST_CHECK_EQUAL(z, "1");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modpow4, int_type, IntTypes)
+{
+ const int_type x("184");
+ const int_type exp("560");
+ const int_type m("561");
+ const int_type z = boost::mp_math::modpow(x, exp, m);
+ BOOST_CHECK_EQUAL(z, "1");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modpow5, int_type, IntTypes)
+{
+ const int_type x("997028168093060821869770104094480850560519901475");
+ const int_type exp("7455602825647884208337395736200454918783366342656");
+ const int_type m("7455602825647884208337395736200454918783366342657");
+ const int_type z = boost::mp_math::modpow(x, exp, m);
+ BOOST_CHECK_EQUAL(z, "1");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modpow6, int_type, IntTypes)
+{
+ const int_type x("184");
+ const int_type exp("5600");
+ const int_type m("2668");
+ const int_type z = boost::mp_math::modpow(x, exp, m);
+ BOOST_CHECK_EQUAL(z, "552");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modpow7, int_type, IntTypes)
+{
+ const int_type x("0x201abcff00aaffffffffffffffffffffffffffffffffffffffffff"
+ "ffffffffd6d7");
+ const int_type exp("0x123456789abcdef01");
+ // a modulus of type unrestricted diminished radix (2^253 - 41);
+ const int_type m("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ "ffffffffd7");
+ const int_type z = boost::mp_math::modpow(x, exp, m);
+ BOOST_CHECK_EQUAL(z, "0x8f112a89871984cde410bb05621d5a6073557d2da0444b6681699"
+ "80b5ef825a");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modpow8, int_type, IntTypes)
+{
+ const int_type x("0x201abcff00aaffffffffffffffffffffffffffffffffffffffffff"
+ "ffffffffd6d7123456789abcdef01123456789abcdef01ffffffff");
+ const int_type exp("0x123456789abcdef018978979899");
+ // a modulus of type unrestricted diminished radix slow (2^503 - exp)
+ const int_type m("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ "fffffffffffffffffffffffffffffffffffffffffffffedcba987654"
+ "3210fe7687686767");
+ const int_type z = boost::mp_math::modpow(x, exp, m);
+ BOOST_CHECK_EQUAL(z, "0x1ada35751ae1f5fec7ab0e60f6c924d5f4a4a5d8f6786cdd78838"
+ "5ab16ebd994ee9aaea5faef3f490822ef443fd3e169caa3b608162e"
+ "01d40a593e775c9fa5");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modpow9, int_type, IntTypes)
+{
+ const int_type x("0x201abcff00aaffffffffffffffffffffffffffffffffffffffffff"
+ "ffffffffd6d7123456789abcdef01123456789abcdef01ffffffff");
+ const int_type exp("0x123456789abcdef018978979899");
+ // a modulus of type restricted diminished radix (2^256 - 53)
+ const int_type m("0xffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ "ffffffffcb");
+ const int_type z = boost::mp_math::modpow(x, exp, m);
+ BOOST_CHECK_EQUAL(z, "0x777b5d9b290fbb5f99e4668cf1b0f723d3228fc252da492c54b75"
+ "8379f3024e4");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(modpow10, int_type, IntTypes)
+{
+ const int_type x("85219208314462076924446303193527165430");
+ const int_type exp("99459745544104451690992478817018793139");
+ const int_type m("198919491088208903381984957634037586279");
+ const int_type z = boost::mp_math::modpow(x, exp, m);
+ BOOST_CHECK_EQUAL(z, "1");
+}
+
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/mul.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/mul.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,373 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(mul_assign1, int_type, IntTypes)
+{
+ int_type x("12");
+ const int_type y("22459455");
+ x *= y;
+ BOOST_CHECK_EQUAL(x, "269513460");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(mul1, int_type, IntTypes)
+{
+ const int_type x("12");
+ const int_type y("22459455");
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "269513460");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(mul2, int_type, IntTypes)
+{
+ const int_type x("280708");
+ const int_type y("2245945");
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "630454729060");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(mul3, int_type, IntTypes)
+{
+ const int_type x("-65536");
+ const int_type y("65536");
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "-4294967296");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(mul4, int_type, IntTypes)
+{
+ const int_type x("-1234567890123456789");
+ const int_type y("-9877771234567890123");
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "12194779192182653090000267987090395047");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(mul5, int_type, IntTypes)
+{
+ const int_type x("789456120556882111687894651457623561325656871513");
+ const int_type y("54564563128978513215");
+ const int_type z = x * y;
+ BOOST_CHECK_EQUAL(z, "43076328327684465744675616648356768900793087398990591539995027544295");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(mul6, int_type, IntTypes)
+{
+ // this tests karatsuba multiplication for 8, 16 and 32 bit digit_type
+ const int_type x(
+ "87500402519005030061267904448809305029512439942506161234260852587645856336"
+ "94640987107484273728362553552515383304557585868121651546490330517814007487"
+ "34682745159208158750835203309620570274592666481348052963762094268695162425"
+ "18850320172906096781969070339129822281355221058882087466637338881223511228"
+ "63144016884857141834687376804878770495858121023810198067988560350169566260"
+ "59441070673981642057711662497893572913873133654626566743289483229067287310"
+ "16863866837882738076436342057320810154710294295605465397209378421688020320"
+ "35702406032061642794728883255642074744145228324022219347019013411158803532"
+ "45994041206565648683544493690427219798945006072652042753387791345064784511"
+ "50227920502852884378111055250850357557404795594025600468996407045934090727"
+ "08041078777870387730504");
+ const int_type y(
+ "87500402519005030061267904448809305029512439942506161234260852587645856336"
+ "94640987107484273728362553552515383304557585868121651546490330517814007487"
+ "34682745159208158750835203309620570274592666481348052963762094268695162425"
+ "18850320172906096781969070339129822281355221058882087466637338881223511228"
+ "63144016884857141834687376804878770495858121023810198067988560350169566260"
+ "59441070673981642057711662497893572913873133654626566743289483229067287310"
+ "16863866837882738076436342057320810154710294295605465397209378421688020320"
+ "35702406032061642794728883255642074744145228324022219347019013411158803532"
+ "45994041206565648683544493690427219798945006072652042753387791345064784511"
+ "50227920502852884378111055250850357557404795594025600468996407045934090727"
+ "08041078777870387730504938308922524767076619493071600607096868205642593777"
+ "83064672064693123083586511497969514956199763260628691421422356349215807298"
+ "53893432372651287096347803705731068491268031212879821570628466049198139563"
+ "07225373203247341492567070512742515269237115281940442618925655326204507165"
+ "43018685973456180521304052296263372550548657267007681462726186588489921154"
+ "03738735312309811855295260282588410141887442245474311543699839300870263148"
+ "89969642893224272388306131900850182843780525186002406202200057400419364041"
+ "12480917884571681605871307558328122948240801747503773233227317344565943160"
+ "78184811118761000119446172201197213166958413376441353073591860771242469526"
+ "34162171790217465073689788174652534961638870987430329380376975097234424950"
+ "28626203467171261194438985008578074151902043501430333019202385199270557942"
+ "82069487032265791643884311563532673152911052140807076806223793474752085674"
+ "51690168224265201474031350018449280412602665727006489664736651532321662145"
+ "22395731894311806382965185156526606660906262290677223798531105431808835740"
+ "80068277468617762211054331907328141344243411630209274782352265433366236954"
+ "62340796945506470082986574244652633468578747126384423018749343237426427830"
+ "62597495610006322516869046617226177792891514414040880511098169575819779926"
+ "53267511946096311413217967853431922008343789549408902117132966444741997352"
+ "58418657379544687590177580275674377304583931111620683151992749560156615440"
+ "09956001573216294273550652829235006290995819615078227235050765818475452342"
+ "95118077784320900839083926375344280915278665450149678774001364483022411118"
+ "86989210613864536835695555040115554865868694788922281253334356037168116291"
+ "99227045413249316876243936449829162763370534672670641521910718921661373160"
+ "93948899172794003245737017747952580428164207428777214495975431645589773283"
+ "12391742034637254884903040666536846003583703264118132242307521988982264762"
+ "13953490712153270721924306359669195669881431604926261623147833800912453474"
+ "06542388952383807976431616628717886593805647129190060659586374949333503420"
+ "5241703455510726935");
+
+ const int_type z = x * y;
+
+ const int_type w(
+ "76563204409879018101322737668344063995824904757312285775560614771886933079"
+ "77822556905976720912850551355328340715074887289899094852653102687850101285"
+ "85715275531977696497398396067715769512450915961775500023723324150851793075"
+ "51871751151095323159497918186624088118225730504044262785072662119470825604"
+ "40835072257208973943520251201155002832786969323087571220195329601804141972"
+ "71293425859967733061169954398382700046379970842289727254846347411792122453"
+ "98890529530611217475343335863666953662801553948341581412563112340543629531"
+ "01094529771464590172847457807673685591148055046712881378811934516545088775"
+ "38198087116656466935095055228728162461388333618793883566996616940381738437"
+ "03453867953392241443573580380271627517797446062394044787118140775664622031"
+ "49144609407766890328547643707523663509662747376486271392344480900673178645"
+ "33198519112197059826509662943577383543858946941049753393431035706592040680"
+ "43848484065292542884106550381079282660840705126574766636237650938379223350"
+ "07308780680088758625608527577521721942952700001740314426688555136034651920"
+ "92948869415921251533176579828351648585255631612516166131530519177426817087"
+ "53127165191235539369253485175856164884318259457319518574027800748530624722"
+ "30999853784133144744590149844870058500033133557974954747400058296439058233"
+ "59080109028703731380219724583279605028258137468666258706566102379192203551"
+ "90274426910716106736469216457355540125186992654301008720830993368763363204"
+ "11036960264301276622450044075944548104639523605502445335712149154791061273"
+ "09156720459736055974643337783563754269574952607968485689453462316428566668"
+ "95504701770860331979649536167161534866285341319360225416010322271645564229"
+ "97610536562445338176729838019564690253931232562709745122032537539983616770"
+ "01864876491464203683664927984801289460556480278145114367860332493722569194"
+ "34026051618152579992400234314328079213866348120156368725488604236521299603"
+ "05243915357553896356662519397274629471920043679673543282319268893065423613"
+ "03777840501083119668898860689222271939900089123195611475211708096094521743"
+ "23436842195705603262202927396682954198215622617086455718070601797199587530"
+ "86110222151397352239086193648500251298495752840008363650931395221675337916"
+ "21665907282124706187656074325458499695895652068822763794228458103499408841"
+ "68233732651102406546734395563663969020820490032431359396293047454261598159"
+ "68165818673838448637209074584819780088546111644065538550490486693301185614"
+ "61602638472505490238203390055056474763248195271964604045005807592301719483"
+ "66411676459481184297663915491569500245585996483678005964410842919747216111"
+ "69086269285356198998091850661544255466466926579668887000118948737207396398"
+ "39189399212362197497646493143022100680619252808094160907526003969639965485"
+ "31238493375062268758735445211914107215235958346264702774326161208396163240"
+ "36339482493382189215697343908873498104516190541170342091008828518924813674"
+ "46253090923280613514725437269574928515018666111820866090440006060807129643"
+ "38626199608899966829344884873038261232122027815715568990196536130996880104"
+ "97887027262726591236620461428328000537452828616386217063092509908555188454"
+ "27278763741671312528892659532960085933913140197210561287118971031419725940"
+ "70220283055606934471672907114014782099956647529889583250740029484462218658"
+ "62960901244568848989478467720707250809806379509214397878558772543587967635"
+ "96161034019645060913914198361071023036142203589230741296078930717247341831"
+ "26204308310630181474853421564903407641109879794777661716811159608177803322"
+ "61170286373919980640839261570604290919653466216587527613203517128403418424"
+ "791614399508711582164287714644181913925240");
+
+ BOOST_CHECK_EQUAL(z, w);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(mul7, int_type, IntTypes)
+{
+ // this tests toom cook multiplication for 8, 16 and 32 bit digit_type
+ const int_type x(
+ "0x5004a2519b00503006126bb044af8930502951243994250616123426085258764a856336"
+ "35702406cff061642794728883255642074744145228324022219347019013411158803532"
+ "4599404120656564868354acc9369a42721979894500607265f042a53387791b3dd4784511"
+ "50227920502852884378111055ccff50357557404795594025600468996407045934090727"
+ "08041078777870387730504addbc23489bdbd45615ca892497b8b93428a2f9871374491b5c"
+ "0fbcfe9b5dba53956c25b59f111f1923f82a4ab1c5ed5d807aa9812835b01243185be550c7"
+ "dc372be5d7480deb1fe9bdc06a7c19bf174e49b69c1efbe47860fc19dc6240ca1cc2de92c6"
+ "f4a7484aa5cb0a9dc76f988da983e5152a831c66db00327c8bf597fc7c6e00bf3d5a791470"
+ "6ca63511429296727b70a852e1b21384d2c6dfc53380d13650a7354766a0abb81c2c92e927"
+ "22c85a2bfe8a1a81a664bc24b8b70c76c51a3d192e819d6990624f40e3585106aa07019a4c"
+ "1161e376c082748774c34b0bcb5391c0cb34ed8aa4a5b9cca4f682e6ff3748f82ee78a5636"
+ "08041078777870387730504addbc23489bdbd45615ca892497b8b93428a2f9871374491b5c"
+ "9464098710748f27372836255355251ae330455ffaa58681216515eeff0330517814dd7487"
+ "34682745159208158750835203309620570274592666481348052963762094268695162425"
+ "18850320172906096781969070339129822281355221058882087466637338881223511228"
+ "63144016884857141834687376804878770495858121023810198067988560350169566260"
+ "5944107067ac5771a1662497b8b93cfe57291387313365462656674328aaaaaf9067287310"
+ "ea6863ec68378827380764363420573208101547102942bf05465397209378421688020320"
+ "35702406cff061642794728883255642074744145228324022219347019013411158803532"
+ "4599404120656564868354acc9369a42721979894500607265f042a53387791b3dd4784511"
+ "50227920502852884378111055ccff50357557404795594025600468996407045934090727"
+ "08041078777870387730504addbc23489bdbd45615ca892497b8b93428a2f9871374491b5c"
+ "0fbcfe9b5dba53956c25b59f111f1923f82a4ab1c5ed5d807aa9812835b01243185be550c7"
+ "dc372be5d7480deb1fe9bdc06a7c19bf174e49b69c1efbe47860fc19dc6240ca1cc2de92c6"
+ "f4a7484aa5cb0a9dc76f988da983e5152a831c66db00327c8bf597fc7c6e00bf3d5a791470"
+ "6ca63511429296727b70a852e1b21384d2c6dfc53380d13650a7354766a0abb81c2c92e927"
+ "22c85a2bfe8a1a81a664bc24b8b70c76c51a3d192e819d6990624f40e3585106aa07019a4c"
+ "1161e376c082748774c34b0bcb5391c0cb34ed8aa4a5b9cca4f682e6ff3748f82ee78a5636"
+ "08041078777870387730504addbc23489bdbd45615ca892497b8b93428a2f9871374491b5c"
+ "18850320172906096781969070339129822281355221058882087466637338881223511228"
+ "63144016884857141834687376804878770495858121023810198067988560350169566260"
+ "59441070673981642057711662497893572913873133654626566743289483229067287310"
+ "35702406cff061642794728883255642074744145228324022219347019013411158803532"
+ "4599404120656564868354acc9369a42721979894500607265f042a53387791b3dd4784511"
+ "50227920502852884378111055ccff50357557404795594025600468996407045934090727"
+ "08041078777870387730504addbc23489bdbd45615ca892497b8b93428a2f9871374491b5c"
+ "0fbcfe9b5dba53956c25b59f111f1923f82a4ab1c5ed5d807aa9812835b01243185be550c7"
+ "dc372be5d7480deb1fe9bdc06a7c19bf174e49b69c1efbe47860fc19dc6240ca1cc2de92c6"
+ "f4a7484aa5cb0a9dc76f988da983e5152a831c66db00327c8bf597fc7c6e00bf3d5a791470"
+ "6ca63511429296727b70a852e1b21384d2c6dfc53380d13650a7354766a0abb81c2c92e927"
+ "22c85a2bfe8a1a81a664bc24b8b70c76c51a3d192e819d6990624f40e3585106aa07019a4c"
+ "1161e376c082748774c34b0bcb5391c0cb34ed8aa4a5b9cca4f682e6ff3748f82ee78a5636"
+ "08041078777870387730504addbc23489bdbd45615ca892497b8b93428a2f9871374491b5c"
+ "16863866837882738076436342057320810154710294295605465397209378421688020320"
+ "0fbcfe9b5dba53956c25b59f111f1923f82a4ab1c5ed5d807aa9812835b01243185be550c7"
+ "dc372be5d7480deb1fe9bdc06a7c19bf174e49b69c1efbe47860fc19dc6240ca1cc2de92c6"
+ "f4a7484aa5cb0a9dc76f988da983e5152a831c66db00327c8bf597fc7c6e00bf3d5a791470"
+ "f84c878148cc7020890befffaa4506cebbef9a3f7c67178f2");
+ const int_type y(
+ "0x875aa402519005030061267904ccc8809d0502243994250616123426085258764585633a"
+ "94640987107484273728362553552515383304557585868121651546490330517814007487"
+ "34682745159208158750835203309620570274592666481348052963762094268695162425"
+ "18850320172906096781969070339129822281355221058882087466637338881223511228"
+ "63144016884857141834687376804878770495858121023810198067988560350169566260"
+ "59441070673981642057711662497893572913873133654626566743289483229067287310"
+ "16863866837882738076436342057320810154710294295605465397209378421688020320"
+ "357024060320616427947288832ff6420747dd145228324022219347019013411158803532"
+ "45994041206565648683544493690427219798945006072652042753387791345064784511"
+ "50227920502852884378111055250850357557404795594025600468996407045934090727"
+ "08041078777870387730504938308922524767076619493071600607096868205642593777"
+ "35702406cff061642794728883255642074744145228324022219347019013411158803532"
+ "4599404120656564868354acc9369a42721979894500607265f042a53387791b3dd4784511"
+ "50227920502852884378111055ccff50357557404795594025600468996407045934090727"
+ "08041078777870387730504addbc23489bdbd45615ca892497b8b93428a2f9871374491b5c"
+ "0fbcfe9b5dba53956c25b59f111f1923f82a4ab1c5ed5d807aa9812835b01243185be550c7"
+ "dc372be5d7480deb1fe9bdc06a7c19bf174e49b69c1efbe47860fc19dc6240ca1cc2de92c6"
+ "f4a7484aa5cb0a9dc76f988da983e5152a831c66db00327c8bf597fc7c6e00bf3d5a791470"
+ "6ca63511429296727b70a852e1b21384d2c6dfc53380d13650a7354766a0abb81c2c92e927"
+ "22c85a2bfe8a1a81a664bc24b8b70c76c51a3d192e819d6990624f40e3585106aa07019a4c"
+ "1161e376c082748774c34b0bcb5391c0cb34ed8aa4a5b9cca4f682e6ff3748f82ee78a5636"
+ "08041078777870387730504addbc23489bdbd45615ca892497b8b93428a2f9871374491b5c"
+ "83064672064693123083586511497969514956199763260628691421422356349215807298"
+ "53893432372651287096347803705731068491268031212879821570628466049198139563"
+ "07225373203247341492562497b8b93568861230addd281940442618925655326204507165"
+ "43018685973456180521304052296263372550548657267007681462726186588489921154"
+ "03738735312309811855295260282588410141887442245474311543699839300870263148"
+ "cdd69642893224272388306131f0a850182843780525186002406202200057400419364041"
+ "12480917884571681605871307558328122948240801747503773233227317344565943160"
+ "78184811118761000119446172201197213166958413376441353073591860771242469526"
+ "34162171790217465073689788174652534961638870987430329380376975097234424950"
+ "286262034671712611944389850085780a4151902043501430333019202385199270557942"
+ "82069487032265791643884311563532673152911052140807076806223793474752085674"
+ "51690168224265201474031350018449280412602665727006489664736651532321662145"
+ "22395731894311806382965185156526606660906262290677223798531105431808835740"
+ "80068277468617762211054331907328141344243411630209274782352265433366236954"
+ "62340796945506470082986574244652633468578747126384423018749343237426427830"
+ "62597495610006322516869046617226177792891514414040880511098169575819779926"
+ "53267511946096311413217967853431922008343789549408902117132966444741997352"
+ "5841865737954468759a177580275674377304583931111620683151992749560156615440"
+ "09956001573216294273550652829235006290995819615078227235050765818475452342"
+ "95118077784320900839083926375344280915278665450149678774001364483022411118"
+ "86989210613864536835695555040115554865868694788922281253334356037168116291"
+ "99227045413249316876243936449829162763370534672670641521910718921661373160"
+ "93948899172794003245737017747952580428164207428777214495975431645589773283"
+ "12391742034637254884903040666536846003583703264118132242307521988982264762"
+ "13953490712153270721924306359669195669881431604926261623147833800912453474"
+ "06542388952383807976431616628717886593805647129190060659586374949333503420"
+ "ffab023789d7d78f78a45a45fee789001a1a");
+
+ const int_type z = x * y;
+
+ const int_type w(
+ "0x2a4ec67dcaf1afdd14bf63d7cd883f269ca00be2cae5c539545352050e33af7bb008713c"
+ "63587bc02911b0cb1fb807d94cd4a937f6e19801a28500f45ba1dc90a548e8e15e0c31536b"
+ "39f3940191a76b6fd96fda83c7aa9aa675f536633917587fbdb4990f73dc4650e19af67392"
+ "712b0a94aeec78f21523bd2ae92cee0b5d42ce2ead649060ff8134dbca0790f051b132b8fd"
+ "2f0bbe66f3226f7fe7a80c0be18fcd0238ff0100e4353f4973c1cb72c40e83804192fbd008"
+ "1e3d4dfe03e1d4c8d1ed4ba8ffe7cf5d00237598de949ab89cd6f95cbc3545a4d797e425f9"
+ "041fbe52955af28221505ce3e53cb5bc12d8d9a13f39704463db4db21aaea4fc29643a2746"
+ "2e6d3b40f9eb621106bda6223bf2aaa4f027e037acb45406cd39b242c90df3b4fae1bf788a"
+ "1529dac1ce1b77f4d1557e2aa8a4adf9c6b3b0c364ce68300b5f65efc8166dae1b2e0f8443"
+ "76975b12b72c36f2dfc4a533adca3db43955265d91d15232bcfd712e46dd4cd4f63981317b"
+ "31be8e9fc0a56275da498e8a4c13419eb8560fa05d73373ff238787b77c0b45c0b44b6b042"
+ "365bfb3b3a4d96cdb3ad7cb9b9248498a02b43a16206db5cc3f52c4cdf2c58807a68a6d1b0"
+ "f24bf8daa4eaf6ffdd3e781fd52b5fe609678d045944d7ea6a6689954b82a737b136a86d32"
+ "e8de0c6b88e66300487b83deb53038fc298c2b1d1ffe64ab7ebf0e7682b285bb567c3ad4bc"
+ "69c0e0216f5c8df2681a3e84435b39dbd4a3cd5dcdf0b776bc0b5281f8806155318e70d237"
+ "4267ca699ebdc5df58e282f7a6d2a7401a3544193741e9597df7fb92c7a0c87128b53ae873"
+ "14aacf233fc20cba4ac4835579bd82b6efcadd591dbf826d470795d64bb698202e3fc5bbd3"
+ "9ca2249167520764d448a95c7a7ed00f43d2f36f4158fccacf2f5738878099da8a323e7d2c"
+ "57579da5e348b45aabe59366085532c73c2388b3a2672b08758bdaae3746364b49d0217b27"
+ "5d22b2b4916628afd5009e103803f4ba5241413200d85e119ceb4dc876c1521047a8be7650"
+ "767b0d83fcbf991c6b04a51213692867fe4c9e452b2800fe5fc57df9d8f75cab72609a49af"
+ "92b1e2407b64ea424344a626b2e86eacdf18af6a000af8c5607019df1d670307a65df3e4bf"
+ "51e9809212a3288001e1df69a6070558e24f686ff34b50e7b2daf5f3f7abc7be88fff8fb5d"
+ "f0aab1f952f91eec5c5ff7e25d2babb61db263e7381fbe40ad81b3494c323a35d3333fcadd"
+ "d6b057c88fe2f43ec1bf754de9fdbc768457d7fc44c90c2e44f79c32849f56d7d2152b96d1"
+ "4b7735e8eae29d8e9ccdd61be1f73f7d1d2e16732505448a33145a5b1d5c342f0990a0a731"
+ "a5e034cb3c0f5658e20b8ac7f4e93c249ec9badb93c4e064b59c34b11e4327d0dacb0951ac"
+ "1c13831520a06deee884613bce16fe5b92e1e0776caf6aa1a7aadccad11a741e7c08512816"
+ "e1c4a0f8910c35450a7448c180528decdc54a9af2cf5b5244c03d088be6d8b6978f2e90baa"
+ "3ce9f85456b51768f7b2d2261785f7680e62cdc420d0e62e41aba012a391c250d3579665ec"
+ "06a0e137c8d3da6ec07be1c2f0599dcbd1f6a801a06a062734ec34889edcd57ca99bc35d5b"
+ "9686b7fc073aa06d9d052ae7d762a7dbc5740e73ef730b478acdb54455d4db80e80b03bc61"
+ "aa013ab9c0b9ece6a00e4e46c16068a2771d0c9c42432f4ef1279481886c6cf890d656a8fa"
+ "e248c9c17bedb151ea802c3b8d7918296dc38a71f173c0b6fceb72611bc817429271ff1d1f"
+ "9fc29780727dbab824eb6ff07e552c8a6679c667bbb20925b7920c7307e3f553c64e1f8962"
+ "e556168cef58af8f406f9f6847719addd6083d19e351b2281bb6f8f64789cdab8f29915f71"
+ "128cd2152ba95124b935770dda3231973037cb7c1e8d22ee4bd10331c91d4db53c291cb16c"
+ "f498366646a27bc18df39aeb5790ba6e02c9904b0fe7e6127dd412daaafdc9b1548727eb05"
+ "57e191893e391f038797139cdf054dab4a208b00dbea79313c3952bcaf8384882456dace78"
+ "117550a133acd3cc883c036e2ecb133eaca4f6df4c002589436f529f3975fde6c779ab3038"
+ "85b1decf3f9b625dd31d634e98410486ba3e3dfff5e90da22c1734fbf9b52b92db6b44af70"
+ "da57859ca38220d8a24dca3251f9f65a1abfcbd2386732f3919c88af189efeb31ee6da9deb"
+ "f70e85bbaa928abb1d2ba86d3b038c1eea98c1a36d0e783a79e578cbc3b98d9a9f4a9c0392"
+ "bf51fcb31325c1b9131f762cd31583c231d786190dc92752781192a72ff75c3c8c297706a0"
+ "4d14571575e076dc13c8bf2c3202bb468ef6f20f6ae27ba91a0182af2c73a40477a9e1d23d"
+ "60fc5f57e9f3a86315b11ea7dc922ba70d38a24c18e1552e15239b2a29d6fc7517f5aabdd5"
+ "e0c800178beeac9b582c44af59f7c2cee341813eb13220d4bee3ef07e9ab8d35ccc0f684e9"
+ "902affb65f87cee827e6bd42fbc433df0070dc210d078fdc92fb7f559b577150e28f21f64a"
+ "c0edc61da523858e62cca0c85b8c16b8bd784f7ed8efb96314e75b3b9bd26ea93bdfc45565"
+ "85ea59cda0c92be16321ed27d93b9a05980574fc99dcb079e6145a0b0ab0c4cbebdc0e51af"
+ "2825278224922511ab721f412589b8a160fa95c3bc9038a3af4a330f5e796d30bf60017921"
+ "bc01a0200e87c26a0afedc292ff05a3e9d564323d0e0c738bcbf24f226d9aa59944abc109a"
+ "9916f57dad39fd1c928da18c32184a230be2eef814c47cea0baea02241c34fae2c8d025a02"
+ "0ab4faf8409cbc467333b807af12473f5dc3be988bb9ef61a60ff1672e07de7f5f6bf99583"
+ "f876305337ca3bbc6b2cc1f562d9f4b90cd9e54d85e04b8aa47dcb4dd5efb271f2a1d61922"
+ "cefdabcad5c3565f3f65a3e421e688b53c15a568c368eeed28d546e47dd53afc3944bfce69"
+ "94841555ac1a1968412a5504d68ae69b2067aaf3c8516a993ffb0657f82cfcb4950e6da431"
+ "de09b4a1d104e3190af9518bd2d10921ee2a3cbba8c25e1ef98606121d60cb48dbe91994f6"
+ "afceb6ea5187fdbd6d943b24c6a2584516d014ca5549828b1c5dcb80016f5dbe91667d03c0"
+ "ed9db277261ff9a7fe77886bb1c9c7d3e95e8a4204b984115323b3a8895ae102921e807294"
+ "131b5554246e6004541e11d1e449f017f1590b18c695ab79b098683f4693e0c6d87836feae"
+ "3db0bceca8b11f9b2190b8f61d77fdad0687ce678c31059af3771bc54170fad3171efa5eaa"
+ "39a4dc3d3fa837e868d1cd704de7c1877e4b77cd9fa44d500b74d0a52cf1b9c5ca6f031005"
+ "c6362066e930694a5d8063a2f27c899a78dd4f79f89e47c46e24c454efcb034105824c009f"
+ "9ce5f9b0eb6998ee1a61a2b83ed878ac81e50ffa48f6c5eaf225a56c9cbca51312808c0c51"
+ "7f49f131c12ecb7094f389228b77db2a305a01f69975138aa67dce71b80285fa1f21993189"
+ "b38898d0e2c5e6fddb644101107f610ac20ab744140addc41021fbf68b041b80fa3c1a3851"
+ "65038651ac3a07ef76368658c5a984d28e149981a7ab931e6fa1d87aa8756331927c54443a"
+ "54177cb8617bd8f54aba47a06af8f41f28cc47d71bd153d821c0c45adbad135170cfe68429"
+ "683a0bc06e4e7a06bd060a87fb8309e4f14c31a3732eada80079072e55fc26cb02ac710791"
+ "0a95d32111198ac6c07625c117acf23fefbbff59fb4c84bc6ac1a3fde905cf1d75693caaf7"
+ "7d2728e7c66d6005a236176e85cb3b282fb7a577e5e4c617c23b2af879810b560882c93552"
+ "27ee9670073d5288c4af9e57a0c81c7af0142670dbb0a18a2f79fe3ae3791739e732784600"
+ "fe9a9a4475ad985499e81ce7a06a04368fbdd007ddb2a222a0268c086252e73f18ef9b165a"
+ "c044c5f42af698b80eba1c1b4423c3b8d010d31ea85831fae7bbb74efe9a22283c1e238d09"
+ "6ae5d00ded7ae17744925d316b3d1c92861c58e1e6668dd52f4932c1e891ed5441f29786fd"
+ "d41a78b75730b8cc193ed85ac5a667a86ba4bbc1ad45aeddc56d32e16f410ad06f5cd2e6b8"
+ "2a31feb6585cfe987b8db1dc8dfdd3a4a8b09518f341fac8f8c7aeb8052cec62bf23eab8a1"
+ "b35cab3e3ed3acc3b64e29c1cc4d7cdeaefcd61f06c61b8a48b90a838ee0aac2cc76a2e56f"
+ "d8dda42e2ff863f75132ff39dd4241ac3ac1aa21845a66bdd02b77b4c38dd5ada02e3863e0"
+ "12b5bf5ad2eae7f6b1b85b4fdf960b915c257dc2be810ce92bb82c58bc478994a71332502c"
+ "ea5e5cf5bfc2ba0480d53dd2dec046f718001eba5088463e6598488dbca8cf07024102458c"
+ "abac35a14188323195f0bcc8a4d7b006467ad4ee46e6cc61f91243e311e0a775582ca3be74"
+ "9193f6044b573435eb7185c437ce3abb6b232f7d85d5beb68ebe859b9af9d6216a5c1a236c"
+ "499c661d705e9df96466429370c573b7c02d6b66c9725f39550e9bd8f63b69dd1d91ae3b7d"
+ "daf6e53f36111e43f185b2a19e6969c95441159ab96ba7928d9a8c66a81d8cb2967d90f5b8"
+ "65bf2b0986e7e10275476faf729ff6ff275347c3afb647cfaf80b76a7d51c1530e5e305241"
+ "e46f992416baa5e204ed1ccc29ab615e71ee06a21d29fabf1c114bcb0262a5031bbb8bf5d5"
+ "a4fcf004f0276eb27cb4007eb0cfc99fc515e858170e135707b07b5f0839f602d1f1ce9eb7"
+ "a41e02aea4c95a499f9ade35d8f1de41791d62ee88fac1e74828aa5025efa0444425f58edc"
+ "1158f0c1afa86f9cf062ef973eb852fe203a48a8cc6f9ef89bbd76e5602aa93c3af0cab8e0"
+ "0433b8beaf63024c36d652dfc1065c483ce480e6b36250d8bf4c3e8500ca1ab6457fa02206"
+ "6592d25f38e376a4e9d7b1dec77b378b6daf4a3e33e5aac75ff2a93808b163e738b62d6f32"
+ "c8526d92795fa623217fcb8c4450bd0ed300742327457928fb0ac0d9a1a47c490db6d3eb56"
+ "900e091c8e047e6f618acac52dea702c4ca72acd001f2c056291d71e8e7e49ea13afae0d3f"
+ "66a7d7dd8d6a264ca4be9eb02549bf40e61f1e2e4f01fe4ceafd7855686747eb1b1acd2c96"
+ "92fcedc94");
+
+ BOOST_CHECK_EQUAL(z, w);
+}
+
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/pow.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/pow.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,460 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+/*BOOST_AUTO_TEST_CASE_TEMPLATE(pow2_1, int_type, IntTypes)
+{
+ int_type x;
+ x.pow2(0);
+ BOOST_CHECK_EQUAL(x, "1");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(pow2_2, int_type, IntTypes)
+{
+ int_type x;
+ x.pow2(1);
+ BOOST_CHECK_EQUAL(x, "2");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(pow2_3, int_type, IntTypes)
+{
+ int_type x;
+ x.pow2(64);
+ BOOST_CHECK_EQUAL(x, "18446744073709551616");
+}
+*/
+BOOST_AUTO_TEST_CASE_TEMPLATE(pow1, int_type, IntTypes)
+{
+ const int_type x("2");
+ const int_type z = pow(x, 0);
+ BOOST_CHECK_EQUAL(z, "1");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(pow2, int_type, IntTypes)
+{
+ const int_type x("2");
+ const int_type z = pow(x, 1);
+ BOOST_CHECK_EQUAL(z, "2");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(pow3, int_type, IntTypes)
+{
+ const int_type x("2");
+ const int_type z = pow(x, 64);
+ BOOST_CHECK_EQUAL(z, "18446744073709551616");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(pow4, int_type, IntTypes)
+{
+ const int_type x("-2");
+ const int_type z = pow(x, 64);
+ BOOST_CHECK_EQUAL(z, "18446744073709551616");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(pow5, int_type, IntTypes)
+{
+ const int_type x("-2");
+ const int_type z = pow(x, 63);
+ BOOST_CHECK_EQUAL(z, "-0x8000000000000000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(pow6, int_type, IntTypes)
+{
+ const int_type x("-0x5abbdf3478aa00");
+ const int_type z = pow(x, 4);
+ BOOST_CHECK_EQUAL(z,
+ "0x40a2f27784f54fc480bce13f80a50a2ed92396abc2b4b1000000000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(pow7, int_type, IntTypes)
+{
+ const int_type x("-0x5abbdf3478aa00");
+ const int_type z = pow(x, 5);
+ BOOST_CHECK_EQUAL(z,
+ "-0x16e8b8a052d3083215ce1982a007171c266ccb004649d9f8cf36f2f58a00000000000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(pow8, int_type, IntTypes)
+{
+ const int_type x = pow(int_type("301"), int_type("259"));
+ const int_type z(
+ "0x16becbb1b891cbbbab4825ed1335f0f4ef5250f620023061045e87ca80d80ea7daf0cda8"
+ "023aed1a969864de781297ae556f2bba6d951ae294805dc888f6de01dac2b7dd3ab47db207"
+ "b0f980f26a54f1c7dbb3ebc6cd5b952cccc67569487fd2aea057d4326cc56aad90ecd89b3c"
+ "74c1f30f6ac637a64b706087f2fe16c3bf2be3692106717387813a8a2c9da65b657a8a2a61"
+ "abdfdc6698a6f6543d8f5ae88b192293e2a76ed402d3c914ca0c40e21fb1508cb2c5a7dfe5"
+ "1a357fa58bf9e2f1d1fdd2c3e72b600a8e7390ac0ec65cda8b0636595a83dfeed163a0e161"
+ "b17acc476db2cc246bb3b14a1b33cdfd659d43437b2c4a203e07a8f297ad3a716b53d8ce28"
+ "e84f1b3ad36ba0d2f5");
+ BOOST_CHECK_EQUAL(x, z);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(pow9, int_type, IntTypes)
+{
+ const int_type x = pow(int_type("3"), int_type("66666"));
+ const int_type z(
+ "0x8a25f1339bf63db8e5881f75e7f89ad860d393776362040a47448cfbcb4a9402558acf60"
+ "7a590c1fa521b672329cc18a63eca1cadf87465bf8b44ef05fce12fb020ebf2c2b246d9a36"
+ "af527f947f3d238d3e2504dd5a0f3a071dc98784d1084cbfc4554fc21d72f72ae65766600a"
+ "007b364d2c182ba9b9b16011c2853a28fa2455bce4ac2af57f6c8337b85a8e01fd4086f128"
+ "bedf51902d90fb9e9a7e859e65219b46ee14d5a1660f37884801c65d2f580577f7644014a7"
+ "f26f648308b7e7852fcd1702740aeddf1c63d2e41e3a70f13347c1236f8dda54db58b1df1c"
+ "0849b96ec08286e3160db6c7c71b7488d8516af84eb08e8188a4bfbf045f3ed85ad3d63a16"
+ "79a4dab46fd15caf25543e21751c164b9e7bf0c3ca98ce518e95dc7dc9c949b114aac50935"
+ "f3744f4cea72d9f857c2aed3a1b9e682dd00d6c470365b2af4f95733c16cebdd56ca2d0f23"
+ "846be5f1b6bbf0f5fa7ce974bd310e07fe23502def57e53d495364f5b6db3b11ca05582a36"
+ "d17ffb5a409044e2352bfcb4fb721e39a530c8d9d8373c50ec0063aabacff9781e9cc6df7d"
+ "aaa44256e70ec2e3e0db73b4bdcdbc62d86406dd63dcb24551bb1719232ae07381129299c1"
+ "81c17e69b45391e668c5711112e00f90d492a428c15d93e331fc50faa7f0bf3e3de80050ae"
+ "b198df940c84501f2b419b19b03b339b86b5eaed0647808fe1094601bb6d948f2865194f8f"
+ "b661e26e60ce3a0850258ae914b6c35acf512b4ff6b8adad70eb32e649757368216a02fcfb"
+ "dbc887e9003a2edc863c23c878cb9cb84e7bf478258d0c5c297bddf56dc30b87f693efdf7c"
+ "b1c6c42d867ff7c1d953749905e90c74eb8db7c83ba48a69d4c7b5a4d49bda733fb7e18ad3"
+ "df329e4bedb322678ba5b1884509ce90db795dae188978bd1308796f6d34fb4b9b8e95ca7a"
+ "af4599dcff213ace57690345ee9cca65f870fed4d59072a9de2a9d8d523b34881c78e79f6a"
+ "1666e7f01a987d6052fc995f38c92b3412ecff1a009d4c55636afa1e11dd375f909026ad7a"
+ "caf6a593e6df0a607c5f2b231de83bf86d7817dc7f927d05dea16e3752ab18ff6fcac9031b"
+ "390036a0b3c6e89f5d880a3c31755bc9bbe3b74b7cb0ff521f0c61f4b772c1dfc7fdc834e4"
+ "aedb0b257490b0b6f926648617463aceb4b6b6f16e8145cedac27bb671f4a38986c15302e5"
+ "51e1f0e5d38b767990c944b3f2a652d71eb3d3065d2872c0816a9a59bf57b760eae8748254"
+ "54e8c3623b0515c83387318a2c9c0a8c99e497f4684fd8ec03505b4b1eb7f5f3ecb8505c2e"
+ "96c0e9d8b44af13a9197d415766f38e9dcf11c4cde6232f1d43f63765d45212535a628aa1e"
+ "354bc23e810f71058e38dbeab9e2ff3f335abcb58293f4e594d643f10be1a7669b667ab735"
+ "1899f7664015a4d5b4051ac01129710f03df6dc71146123e7d443f307341cab65f197bfe87"
+ "5313d66c8dc0338e87c52773ae8f3bdba84dbf8a1a3f4f73b3e0ef9452981521d5a30c01d6"
+ "a6827882790ed81f599371c5ae2a266167cf96d9d01431a6358a669d63f21034e998b47c32"
+ "4ddd505f27253dcef488b1c203ae3f46206769669dd1122ab00dfbf36f89c557d75a6bf7be"
+ "a889f32493efb3bd63a1432c7d7130b7502d2dcc55c85a80ec915370c90f0719328d1a87e0"
+ "2652c515b710488f3509faf0792e6d853ad1fbd5322fcc5c78bf2da284fb8ebe79304db8a2"
+ "ebb0a14e5eae45a5627b8f81714821ce0e83f742fc79804e27d8bbc38eca3994243a8f5f48"
+ "ae202e7575835c760eb05742dbd11b31111450148dbfafb29ffd28718dada8f6ae40d498fc"
+ "e7d6a24ed98e1aff5e453f70def935430a795b4daddbe4945710f5553d903f95e60b731f41"
+ "8a6e570492b52e0c8b7fb00bec64703e8f62262f32d70686a9cc9244491b8e5ef606a40787"
+ "e6b41bd08c24499abf57227b142baae204fc0b4d55a81011d9252c3f4fc5543fa0fd912d13"
+ "44da807f30d314669ef47d9cef9f7e316bd3e5b706b87237b0aa86365452116f0229d3e35c"
+ "5684db8b6ae7076d6decc75822d7ef0ff94f7ed3db1f7296cdc2465faf0ea31e4e11bfe5e9"
+ "a7a65493ea438ddedf92036914a54a20f03f3d65a91fb138714b74d6e6fdea549719e3613b"
+ "2840e277dac23aa4d466b7f895801e6ad95532e1f2c3183c8f3c2adfe96fd0c0c47e23c172"
+ "bd993fe30ac299e12941a8a60ebd499b31fed0ef7c2981a862aa5ad6486eabaf38bdd838d3"
+ "8ed62fb21fc76fdc50935c3003c02fe61000218e8507511602b29969ce1648371f8fed081e"
+ "395726af42734f3cb8910f52180d01178242dcd9093dfb7abfd3bfcbcc543f495820dcb1ee"
+ "60a1b69ff7f080fc21e39f22e4aa9643558bbe37d2e92563938e3f4a8958ff7d5becc6246c"
+ "bf2e0f24481e1593122000897d171e2cf9b18bcac4951305f0ce9e74837a4cad004b5b91c3"
+ "ecc8507758143e4df2c8d5901b8e9185241a6bada332682e764e3b9d55e06132205b257c3c"
+ "8ada391d6b6a82fa493eddfdfb141371480e04a0ba6f7ffac004aef32247e99463319aeb6b"
+ "93577df50cdd3c4189478f04cdb9861c416e6a0a05ee0d60073d7f1473b06d4cc1d064b8fc"
+ "6b14d12e414f7f532d70bb953405a04c34c0edc0a6f2dc67fcbe7643bbe0cdb8275b41074b"
+ "a5a7c332fac3947f8dda001177147e8e8f1e509aa1b602c781614977c3cc06fd48115f9382"
+ "8e60f4d57f76b1a5b2fd9bfc03616eb0fba9339e4d59f2e0556c792f6ee3afd5b1369aecf6"
+ "2fab5eb9ecd6641b710a39753edc0d8c535f95c4fbbb0d44f51e8fc63dbd3bdfc48688446e"
+ "f255f4452f68b8bb0b0cba01bb0ba41ef33ddaa2c929841b9013b201424aafca3d1a98f19d"
+ "8dfe28eff5ba2f1645252ae27d3a8378d2c50b498f449291e85ebb65a82cdca952a47c77c7"
+ "680cafb603a202998d5c422d475ebc42eeba9d26a962feb579ea01509d5e47b1cf3da3a862"
+ "7527369ed4828eb893fb07fa6fcdb5c4c4fddef59dd2b04f63c09038351d7a6b12d2eefff2"
+ "b6b98af2650d7ce99c075b4bd45fd95bb07c79398341a754701b3e3d843b757c4389226fda"
+ "645adf339cb0d7a5a9966be122e103d5ea66ba6b7e17f8537139ba7a96bcf52d04f7349861"
+ "ca52e78fa5b3dbed6fac6cfcc2b254b9f5f9997d4b874e86c54b4ba4b3291b81afa23b6028"
+ "5c63cb8a59a4d52d774371e519df25cdc6099a571c668353721f34c55c2fd9e5aed9dd3526"
+ "1fba8e180f2e179101f894849c3deb5a19636442e405f48fe2bd7d984fb036a5cb933f2ac2"
+ "e350df4235d0d1219b47c0866911864fa88f83a67970cc4b051bf6214c55afcfd8501966c0"
+ "afe34612e2edbcd6e309d8486436e7ff0515fcd9a3541ee7d7a4462e21784d8e6876240afd"
+ "b74f14cf6a1ce0cdf99c7c511e3c92bc546586615e26dd8b02cc53c24d8070122b1fe63cc2"
+ "068a8b53f9f12023057bbd30a809b880bc33cbbff07b598e1190702ad8ff32044f0d3a714e"
+ "d7d86eb0e13bcf68af313453151bdb9a0ed8c550dcb9cbe28dc78a1d267f3ef25180ab3cdd"
+ "11390ce243bb2bde0ed3b1191b0f492a258d2dc73482fbedd891af36cf1f224ad7ac1b8de4"
+ "f36606294f1a228ad7eb390043b71916e9d0409a4ef0ee0f3a50f250e633008062ff6df9db"
+ "4ed7f69b396493ba0dc5a39d6804c4b93c962b3d70d25188e3a5d5e1f5487708e8dc3d7d80"
+ "989e76b69d7405b31bf12a2d043e523804b2d7ff95ad87e84bbd27cf2ac09a8c5d9762ccf3"
+ "dea56a320ec763ff4c25f2c4d4edf89c8b7512baa662548a6848411ac486af95c2987ef5f8"
+ "16ec5ffb476e560d8fd69c8ff9870b549d6da5f262abc1e07293178d5bec9a0520fbdb5a75"
+ "1663efcfb39ac505725e4e64d63841e7431fef657e0b293d8e6b6d4f8b9c81c7022ab701eb"
+ "f671896bcf9d05aa68b3c67bea8f464a000fcea3e231298c198e511654a0af214fea046f5a"
+ "cd6f204ffef81d67d17b7e0c81fd9e9e7eb88990bb39069ba164139bb2be2c816201f59c79"
+ "957cec370f81f7350614b2b6c94bcbf5f275e301db6a5b335df9b21a6898618be21e34d7c6"
+ "8a5474610d680726661ba18b39f432b257eaa2e2fb157dd4d5f1936ea1e6edc2b92088760f"
+ "74121b8335de082c7684a151ae853e3f5156b7577444b6c8e90d772fbf18259e3ea59ad4e8"
+ "177ac10728a506be1621d0064342bbb3c5ec7553dd03efa6466b9dc9740757b5e890444540"
+ "f60e9e6f32b5d770e76e321a950aeb32aafae3857aa3265dc16c1487989a5d84b598bf45d9"
+ "faf181a6130343e87f664ddc1b844302c2311515258c6e1b9a2d09b1eccccee59c2d69d2b5"
+ "1dadfa6e28db845fb8371184e72cc1ed9ad3d8b6db5eafa84895c8ae26fa99bf69787792b6"
+ "052eb6f1178de7d0a691a249aaa2545437fe89533c8c6aaaeff32d49cad1b6d41cf45a3b04"
+ "96fe7d1b177ba3ee3cd0415a3d1b81ce355fe18f9113a8628d9c057daaa0d1ec9f2c838589"
+ "a5b90774e5d55b7bb166806ae3ff2ee4027d8c8cb4d9c00b1b03d63add86212b87c3302cc4"
+ "9c9577c77a4f55b8f2c82189c6d3b63df882b473c2a17253add07ea88be17293429827d0dc"
+ "65071cf01c3ec3bb87df788f95ef3f5472c6e595c7629b1b7d7a27efc79b91ea8b348179af"
+ "e210ddfa00d7673beb345f13f39e455cba990056355f8634576f3f49e5937a90a8dabed519"
+ "dd045e95f471185c8bde7a27fe344b25ac6d97eed9a3ffc033900e025a38b72da43747dd06"
+ "c7f4ea8639b931f2852d8a3f60be3cdd74dea49e9fc303146e26e0af20cc7897e2a0bdacee"
+ "61187eb389d77060260502d276f541b71b98ffc04abf8e199aa53d831ba348e9820c2fbcf4"
+ "b07cc37008fae656db21ce91281ea5b389c75ed7c167c133e0bed82b40ba19e1f98be20b74"
+ "9266d185b8373b451768f8f1179950056086561c47fe3cb2e8b647f0fa5d511e3291cab566"
+ "b1ec0ffbccb7940e40c5b44a28c2fa9b7d100a05d4f59158b5dacc3cad1d6f054cb648ab7d"
+ "26db6126b26d011d1d982a63bc69804381b6ce05192b4996679962027e41c453fecfc41217"
+ "fd9e83c76cf1ff4151d9d32f209dc826c511a35dab3cf7252eb80ad9ce02290edc8de51c25"
+ "0ec5d874866b6389926dcdfd953ffafe8126a6b0582df5d5cf836002e41c04a9d6ee986ca5"
+ "a68fed99a57256d1401cd4b8ab19cc6fff65b328986dd30015e4c9f609510d6b93669aa2cc"
+ "13b9d457aa6c994007bbf00907935621f576c77ae91e8fe5b3f3f3040010e1921cb2087568"
+ "fe8fc74ba65295649bc97456be30b41b8f6576d5e9aa9bfa997ac307912bf074d70efa36df"
+ "5dc309d05625778f1ec83490f8524eb6f82de3f16363321d9e335a705cc4cd6e7f83d1428f"
+ "8b52e4d7998ac1de3a6956de0cde32b7231a5a96051a4de052263f5c14332f7f2cf585adeb"
+ "1ef6d4db6f963621da8e5baa50bc911b09264ba9c05e56976eaf1f749eed3380773797b8d2"
+ "d29d6bf9ea5ed0183e883d9815f0799b984207b893ebf438ef5226db72e1e74a56a83b5be7"
+ "ec28a8efbc18ccefe0f790dd9cbe6fd4e4576ddde67442e4da0a16245e973ee8c3c6b0cbb0"
+ "ccfb445be3eaf40c2e6c748af0496857ba0aebfd7c4abdcb7faf2d511c23ef6e33e63be6bd"
+ "db711b5fbadd579be403d06776fc5f9028bfe6c0adac730b0d728380434e80a2f85b01ff68"
+ "092f5780b701217866abcde23955d4513d76eb738e4e746a32862d5bf4a7e576dc5e0733a4"
+ "ea9ddf0080a5098d7f86af82ff52a14f9b8eeb85d03bf5a4856844b6a49db23403eb36647f"
+ "2123f86fe89f240be30e47207a74e509804d3201eb06c0a33746f4efd275a358a709777b8a"
+ "d85cde65a481cf7d52d3a48137d0e3f464e5b7083bb4d56639d0e5ca5ef91265e32e1d76c2"
+ "c318505f735762d33f8da0a5a0b2ff9a0538654fd7dae9d4795f0ce2cef620933972a90637"
+ "219764fa6dc342e69059dfc73dc29a7da6cc5f0466272cb4f42d46013be2dfe8bdac4d795a"
+ "89368f473eb7335a2101f64a5a07a5cf8fd7f66245b68a7e49c57d1a1e146aaa7f33859dfd"
+ "d1762846044e5f38e246716d51321c1040540259b41d9daad868cae75580c50e3810d20228"
+ "e7cedd1097b8f91104c20d057b821ee97fc9aacd7cc225fb62e86490d3a0ce7ea1554769f2"
+ "508673b27f7195a1b5cb4d2396cb008043c54edbf03c7033fe46f2e04ab4c9d9a33cd4941a"
+ "826169216b96af7ffe43b1b00433ce8e5d0892d518eef9b1315486661abddb7224bbc7e020"
+ "0d73aa1c677a66ed5e4e9e9c24083e9d6f1729c2544679cbcca14f99709d2cd4f92d79ec53"
+ "043f2194b21378971d4109df46c34cd662edd8f783ce05bfe634b3e6ebb2b6ea4fd93b3ed4"
+ "9011b00fda3661f7447185e3cbfe18a74eb6fc0d27cf52dd5b40106d458542b3fdb16debf4"
+ "b746549226b22b1d657c7d0ace25cd4ceee9cd91f868e7abcedfe12942c069e287f64679ab"
+ "9ae9018a2c1d39a1a67f6c9fa74fb52aba56f25b49528490a97f320cdc4f723d92d5d641f2"
+ "0d9d9809661707ef09e6fae3d855dd6d944fb9f596008426cde5b74176f94504adb0b99811"
+ "cfd49f7317d712656db9034bc03ceeb18bb5d84fb03c6c9843b2e0de64db7f0d170818a7d4"
+ "009226270e52f2148b827b3874054d014072b2d6fea3bf8d3391a212b87f729b14fb5cb2b2"
+ "af51c5a1198c68836d802c77df67eee5c03a1ef3ae76d1f362377a9497603439408ffd2ff8"
+ "bb14ba82fe9127ee636856bef4f15dd93a508cba2fa17b3edd83550f4f4b726dc5bd1d3c6a"
+ "c3116b13a32464b833463468a1290c2e80b2ddc8fc0259d71e16444a7949aa35ad482fc068"
+ "d5014dfee33075c27e9a8061dc76b142aae617ac05bed9ee847e26f41014336ed24e480e08"
+ "3544df22e5dca68e081d1ff2b3732208858d9f782fedabff8d3bc83242733169d3222403a3"
+ "72d9335146a6af07d7f75aff8b1d73f4a8423a517b5d0b4c390a780e10722965b9f74d5721"
+ "17d2986b54ddc54a6b58b7e7189c4d1293446d5325912a19672d68b7237db891cf59d0b6b8"
+ "9092161991eca1563df8b2e0f1881f4900d7a41d34ba55d55bc170e9069dcb73f61a6cacad"
+ "e21b4f20a7c25eb7d0fac2033f9a372805c755f99f6b838e556a45018d7a2bcd3d60dd583d"
+ "46f35d2553beac5928f5bf4f695c0b4d328854791c0b99bfbb9f9dba732eef4275e1f6a553"
+ "182ac6471650967ff83367ecdcb61f6bf67a77e617526c67dad885413738b00f3242948c5e"
+ "3a70ec4ef77db5867a0ca673eff3602b2f242f97e98ee946ef8f8b7684991b5c14a9d31011"
+ "b9aa4d3915d84ddd798c304776f4cb50f375f46459e4d637bf3b30258ea21a7e0fb6689ad2"
+ "5f814ddae78fdd88cc59824723b063175b9ead2f2612da72e7c458049e4b68ee04a409d5b2"
+ "6e7696a4f700a1c64fdb3164cec26fa673fbbf60f72c2bc717690bdfc575d595648468c5ad"
+ "848c627130d6ebb468159536ce59f9b6d62c772e9fa23ae4413c26e8d2f0a50c95f736c246"
+ "80cc0d8fe94b8674702a92929f464504aa2404f66e76331c0b08d2e31ee04ac9e99b695a0d"
+ "8799e52fac2e21c1928cfef8c08acc7c5959a9d42c7e038177f5d7f0f64ccd5b890498ff51"
+ "549be791874928b7f43d2982db3ad1bab48ecb757b51e12a9c6626871ff177abe783a94296"
+ "e5e37baecf5a376a5212556475262172c6afcddb3d8ca8041f7fe80868c846230ec31ab5db"
+ "78f2a92b39fca377fd0000631c95c512b090e87b2291ed912593259aae0198f2895f8ae769"
+ "04c103a79aaf777d96e7c999a6a2ee92dd17f3c06021545b5801c6c0a2e5788e285cca6380"
+ "5bdbf51a4c81a290cf1796c36c9e2f5944b227c6521f681d376670488931b89f24f79357a4"
+ "7bf4af9e2303659a5c623edbe472b7a4d1ad85ee60c3adfdd1a30f7f14c455d43510a15f21"
+ "20c0fe148707cf3e777ad2102c3381013d482e2dd2b68ced555ef58955f6293ac891ea6cc1"
+ "6607b6b51c16e54671960a3c1c00b1285696bd85c458a663dd9d638814ee65e71b77fa783f"
+ "78e175e2a880ee3093aba5bfc3ff0e5b6e1b6ab7ea4f184ecf11c6621e2187f0ba112d6036"
+ "4d95e2acebc75b9255d1e681476b55d5cb9d682519212dd03521c5d00b84b97a934877b574"
+ "ff4a180d777bc446e7584cbf5f0e8ba20f04a899f0c684dedbd7c87cb33642d1828e3bbaeb"
+ "8b4c077fca8fd08e460740daa26b2a924181db0e2103f08c3862e1fd23795eb530ca6589dc"
+ "90a1f2fb893743a495a4140bff2e7b49330e5ef5584ca5b395679f479ee3802632add5b660"
+ "3e14729ed8d13666ba6ecff0f10dcf30cb820143c8e3e07c96031bc42c81c9b63842e9fdb4"
+ "c248e246c758abb4e07ecd5c89b4376e371ee862a1a8f66ee5a2a464d9366bf1b381558079"
+ "59b8705e1890a9fa46c1cc54f7310a240c88b2c36f5b9db8e710b38510d1645ee8a4a4e0e8"
+ "b14c05892371a200dad579e14af518de70f0120fdafa14f5cd62f74467c4544660b094da9e"
+ "9e00a0cb1d7a7c382d30e75cc8c5517f5e02a68e67398e505a88998593152af5a96e09e718"
+ "b6e719b4631a4cb2f8d1f64a3c673ef01e640628383004da91f1045cf47c7e0d34b437d571"
+ "a68f40e2f6b4af1a00a2c83592b11c9a736ec23ff83479d9503a562571f3dfd9f2398bbedf"
+ "825af5bcf88bda170d915b11dbb2a3749ce6908cffc0ce7819b4f6ef60f6fb5b0210a29863"
+ "998aab74607a6fd818e4cf3a0143b61570186a98864ab65c288268817201431ab2637ccfe2"
+ "a977a725cb5fffebe5b481f531f0a6857c763c226f7fba39ec939580dd28965801d68eb8c3"
+ "1605341e85d22e68bd661652b0c8a3e64a0f469a7a16debb45dbd0edf47ff7d761f99255e7"
+ "ed9e3fdea5328e26bf5fcfa789b1c7f2cd3c9234c99c030b1db4071779bd2ebd7ad8d20023"
+ "00d94cde83293dc1fa698821f7c8792397835a599fe7d359e88906df7440a3edb4b9d6b285"
+ "7b0e6fdd0f1485862e2ff3244d7821719e72899eb5f5a0bcc413f634ebf4e5ea7798e09536"
+ "be917c6d6b97646873cd30bed56972fc3abdc042463a6a606be95b9d96b4484a53ef5d5b9a"
+ "11a52fa31e268df46551789f5b7f09dc2fa09e4a958fbb76c4503a48a8e0faa4ec422aa3e3"
+ "6776327726786e18bcc17a2ff0b58979b41e7f8da369a21927bba63dab179ce341073034e3"
+ "c50ae3bf27b25dc791479904d3dbb5c3a42f00da0b0f16a89578fad646c9f8c8f93776ecdf"
+ "eb71acb61a9a7cd3be74c0a3492c529ad76c9003fa781e57f8513d92cc5b2ed1cf69880e3e"
+ "45bd298e94aa174191f294cadcddd954c431d0dd7f045032005873d943ab7172a4bf64f382"
+ "c789f6a8ac0e5a3caebbf8fbf26cbbcd9d58970ca1b22157e7929c8517bf633d28946cec27"
+ "6aebdb0a638720a1e1cb382826e4cfaa5cce5a68572904567d0a1ac7cc6be9211126de62ff"
+ "49a2164b5e7a74d49ac1c385fd8d6f7880c4fcd5e173c5d215be1a3785d8025edb7a31c0f0"
+ "9b528918a48a083133e181df412777ecc9fef1693c7c19cb79d6943b4d58617cdc6e9cf83b"
+ "7562bf4b93a8b8fd865bacc383d552450fd1571e2eca6557a27270fe21975cedcccdab20a4"
+ "ff6a754b9a0502194aafbbbd738afd2fc3ed3ff5c6190ac6ffdffd494fe5f25e7cb4ff44a0"
+ "445bcaad32d9cfc2b58de9d1d53bcc6007617f0fc713eb5b5acbd6858c999b96dfb1b46da1"
+ "6a0fe11accde3b4e011614980cca78325599de8f93a6f8e4af4126993b1f940fac19f649fe"
+ "721474cac4d32227e92a2adab1b9ff9d1e5935f806d8721d09be737ac1b024eb67750c154e"
+ "61e6bdf8cabc98755fa16d3640e80b94e4e23deb3a36a2172da28dc9eeea3675be759de36b"
+ "ee0e951fd77d7aa68ae4caee0fc80175045595957fd00ea3ec4536e666a691efba0380d05c"
+ "0c88154b4ab67f34ea6c201b600da60ff8b46ceb971a663bcdf2ba0eef26095f3783b42c60"
+ "10dd3959df46c4d631e7a89e62f5391d6857b79f9e4502cb3862586a80a7f33576820f9985"
+ "eccea22b4534a5e121db3ed2e21a2d7a9dd80a624479bbb061b91c38ae5714ecc996e4b1ee"
+ "ea6498f1b5b7aa11d0475b591b8769dc10bcb405ca2a6c5de880c7c533272dd6e3bc9b13b9"
+ "e8705b549bb50e72da1e943a0c98d313e43eb847f4e8b79a549b5cc8992a59677a473f694a"
+ "3e94f4048e0fd7164772aae1056149dc9f747be8f59f365702f24222fe0f6f320de6345a3a"
+ "00677bcdcf1a99592c45076b049616db7b447c4fe3a7937febeb392c4baed841c4e96c7cb2"
+ "a63ea3322adbc2e88078b6d0f10c7b373cca2fe3ab24cf2bfb4c0bf253222ab49011cad073"
+ "23bfb8b554b513025e4f04a61fa2218b7f2e341fdf86633cf90fcef924f8175e30f3290cc7"
+ "bab09b7cf8bc574f7dcdac67d5c59436f6762ef35d4b1327fefaac7d575314acec5af01cd7"
+ "477e13de5ba16c9798a8868767fbb2633eb152cfd1c946b500090a43abbc4c322f5639f0a1"
+ "5e8d99573860a14960e36ea8cebd1eae0a15da0494a29f80cd4912b18dd6305a093409c7ac"
+ "796a3e6a8b5e15ac469cbd8e6f60d0549e4a31713bc639dc3754d857d2a97790b7487efbf2"
+ "99ad8259a31c45e64e0cbb464b1fe0b74c4a24fd1317363103252144820b45bc0702a756fa"
+ "6e89ab4166385106051713cb6ba5cc5b4dc92819cef9c33d27b9550eda8300e3583af8b10e"
+ "7f18501c59ec2f4563792e8cce5a68b261a9b961de92edee5e5a78c4e7bad2a2484e5bb46c"
+ "ef8b1ff7c0d111e012e5d295065398f99d85a9511f3dcff5fb2a7549b0934a3af06294e43c"
+ "d8d4d6c65fcce4dd86a673bdb9f3be3fe177215187d3514f10a387b7aa22d1368d0735b200"
+ "8ac19612fe39cd0ebaee1adba3c94cbebdb21855f0fc5d9484ef26bf7c85b7c92fd1b67531"
+ "3ec37086b7bd647c0cff49f39ec2f64838e0605fc5d423b0934a6a3ba1a5de2b32d8234269"
+ "f282f2abbdb546d1186d9986cccca90a4cc781a634d797d8c89efa7af57d8584ba8d6f9a32"
+ "f7d158a940b9c7bf74e232173a573cf42a38cc3ef85b5b838846aa8de09484df405c21fb1f"
+ "492a5e30376925e49cbac45feabe81d7c5451ed3d97a458866aaeb241cc3f1257903aa854d"
+ "ec01bbefaf65338bddb7af026b3afc91b38e09775676075d343935e6f04a3a7e11f4e1fc3a"
+ "1dcd064aad3adb7ed5ce42c0905d0be146601683b2a8ac6670fb05f4ae73c18460d3f17506"
+ "4de1ed3d61cc1378edb7b0d20b7ff8d14c228c9c597b8df4cb96c37e38561bfcebcade33a8"
+ "5c1ed148b69e5362427f86b020468fc72432d2f50e5bcd73c5bea6b4f44c2a09aa7bd2c2f9"
+ "adc85be963e0770cf2f5aa38e7f5de6bfc4fcc8498b09c815abb3d90aba39b849d1dc5e2b0"
+ "906481b888ec4b50d7169caf274f22848e35a405273aa58bd4de8b92db57914bd4d88644fa"
+ "e5a2673ba8b7ce95d0d798d88ab08a5dc53b78c0be8d8f4f8804195cb2b816258ec66bde39"
+ "e22a66ad5e14931ce4de9deb8aab0237cbec2abcca45a2feed085541982eaf663316c9710f"
+ "66ced3b0f8ba1bf69106967d013323b2656de0b93ca15f4895c8ff15a339315e25ba5fb252"
+ "14a503bb688fda76a5551ef529235c5ffa09611aa59598a47b4c8ce22aa49df7217950a74b"
+ "03a0e8a0ebd9424eb170d5277b573b223289cc520b467c834b4c53f1d4e5b574380ded24bb"
+ "59cd70ed0f905f15c798952d29f9ce3c8b4a04678a58842b6b3bfb7669e5a0f2a153e02001"
+ "a7b012548050699dda11fc95f026466062bde597fd61be5c32ebaa19075636f212ceb0ff46"
+ "122e4ab88be9439d4ec653f7599dcb0caa86f26469da9f9d537793f1b890d682a84464b4f2"
+ "6a5481bc12802684c1d73dba5f7acfc4451a213645c39e0b3c7c6681623ecf255bc6c75d59"
+ "4726ce1a7318bb3ddb80cddb77806cdde22b90fb1a998d931d596bc833dcd0764993ce42bf"
+ "b40befaa469aae29b2758d584fa4804551046fe36452cce20e26e9454c9bb20e7dd9b5f63e"
+ "e35bbf7c43f772f38cb3baa2bea11e9881a8c94cd5385b75611abe8dcd17b33a5dd1c9b928"
+ "41cc08cd032c91408b475a0ae8866d4b7eb005d5f2bb227f2298444db54e8af8ff5b6e08af"
+ "5e609429ecba4c4ab5faa9669378be9308c900d0f04e2c65f0327c3e41c574dae5f96dfd66"
+ "41b96cb8923ff9ed42060e2d089ebf0dceec2d386da7f98c2726a142e0527f47be4559e0c9"
+ "f555bc6d87737f93cc82b6dbf2ab73921c57c28c0340273e8daf79a9a1db2ca7c88fa4531b"
+ "4e4b89c27f5cc4f59255d5a92656c984e2041a2eaac1cbff11e1720fa3425f9c97ce2789c0"
+ "0c6eee26e07639f47a3f0798708b4f5e3feda3b35e45504f42ddb10ab545175d82060c5eba"
+ "b9ff97fe51e33860f3edfea8c38ec927ec15398f811a0995ba948a790278c0bd2c6a398fb8"
+ "43a2646a11e0600560f729e412859cd21e1325ed505f2d06b1f77f69306e689d1b0b91b7df"
+ "1b7d97d96609bbfec187bb7a93288b37cc96fb22ec72b0493f0a60f1e00858d056970e535c"
+ "e4803c135e97c999df22c34d2524913c7a70313bf3601b07e3fcf5a257b46a87f48d58e73f"
+ "ce9447a8d10353a55e8ddbd99178e8c93e3681b16543cbf12dae84c93083111b0dc89a4f19"
+ "dba14e0b5ecb7b9793336a1768da49f72befd65bf67e13255c703bb4b7f6c9c8304d0de149"
+ "01fac221603a39941f57d9201c506e8440dad927d1e9a1f0e28d986949bdc4dc700c1998f7"
+ "1641f7d7a335f4295abedafdbb71e1ac829402443b4953386c9302d141bb6cd9d218c66d26"
+ "6c460aca44a0c49f3fcd3347fb7bd0ff8858f2bd37efa64c73ca85b4830f0181079619aaeb"
+ "675bea0e15aa2afaa62d25a5a1b3d45573705986c1a8a67ca5be85b062e77685f69313d87b"
+ "a16bfa2cc2810fc3882313f640a1f1eb0ee759b8f52f89a2a9d5853bd24e7d09c150e4b294"
+ "d65ec1d246aceb217d5a0cba04673d3c70bb2630d914e513f4f6cf30ef82e6b8f43aa4e168"
+ "6c259c76f593a3dab623ca0440d90fd99e84ea49ff376f2e300f8628ea27a9dd57b4e44219"
+ "67d7d55945be9e75c06f2be4c96fbf1b2f379cfed2c7e28cc66b205fb87f3ecc6f81081253"
+ "65ba7443907fa9129be3abf3147b9be54f7c8dea7df51330078877a0974843eb6f0667969f"
+ "73b5a64b406459f6ba6b266ec8a0032be573ff5ae53637d9d343d41af68346d974681f4cb8"
+ "922b3cd1ebbf695ed46dab551a245675f82a8f53e178684ea4da62fd817d0a9fbadfc12df5"
+ "9d18f6373fb111f0d3f9712b98ff16611f8eabc59997d0f975b67c47daaedf03521eea6beb"
+ "3dd569be0e9d14af9a6eda4650fe712789a6d59b8388997e9e0a8f1b215b5bb327ac5b4984"
+ "e1513baf6053ad05bd4eec0162ba25b5a3f37a2219230b9f940f7337a047dc2b6f71267fcc"
+ "64e2fec49cba93405125b185987f3f96276067a51b71b0668aab901ed1957c9c752c628825"
+ "04c2c2a8f81551161a1b015e36db1fdcf9520c2c5fe02c8bde49e1e422dcc7d04ba746e3f3"
+ "442a2b9a2443579058eb91bf39575f7f03fdf8d8cfdbfa22095834356ca28eddd87e174ceb"
+ "958d21d3f6af03175334f2ac43c7385701e08da369bd8d73899874a06759fdd4d747250d65"
+ "9f1a4fdf9f82ae6615cb5bc093266b5f3629d066a9094923249199fb816dc6d4f9bcf84384"
+ "569fb6ce070ae60811af0e8d88ec983b9b00d492b3a28ac0c64aff11bb9054406b7eb464ab"
+ "9f29e0947329de4811aba7546aca0f35f24d93f701ce9b58fe6c0379ed182149913a599adb"
+ "ef2f7c57a40a7654503a520e07b29a8a9e398b34ac99b4d29a5c4aa2a61abe583489c304c2"
+ "a3b708d3beea806720a179a7fd20de94c24e87fe3dd3856ce5381cb4d1ccd33d1b5323bd48"
+ "f364f8c995a3f8ab098118f66f5f111c4efa9739b69be6f8a09ea4a88c6d24d5d9ab3bb595"
+ "0ecb7fc5f3f9c3c1aac7c89c95ca75931c64651f081181f182d3235dd726329f9ec43c8c2a"
+ "fa9d8ec5058b22ef627105d6dcad48158ec6e8ad202a6c2f034d37c022342fcaec10fc9800"
+ "51c3c3d5d014e58a2be79061a78811860bf2137ee1a1510d4e72f7029252ec8e1f691ddcb0"
+ "8cfa7ab971d1f7b6e20d7c012177eb0f3f6e4a1cab589ee85e09f4c27579f3ff52c09a416b"
+ "5c585b7e6a1b7424779734820eb93e66be93044d09ee8ca34126b47358244b5bc25299b69c"
+ "5d39ed2826de5cfb285981e2ea043cbfbc603ebf6c6a885f68edcff2f0cf4addf628ad5992"
+ "84a798f3ad659f36fae28cb16fcd439ffa5a69c516dff3dad3760f663fb7ba084bc3dc66d4"
+ "6b31f3120c57bf46f7a20c6b225e867977245b3acf75e2136c39fe744999b76dbf44152043"
+ "b7af96a3a0ed4463f6b1b61d5f07a1e0c395c0051656959767e654eb163f53b80026dd5b49"
+ "b90cdbf2ab50306a23287665afc61d7e4bf0d6d5ff4c6416c07d1ca8d6390c1a69084d408e"
+ "1cb35a3afa0bca0c9fe58344d7e992c23b05c22c6cf57349b90f523e7227becdb320f39255"
+ "c3ffbf8e43b20fbd1e898cd181c6abcef5456807bf2914766bc70fb406228ae3c7c23a64ae"
+ "42b3293e17bb4dd622052f433a65fa781c221187aedcfefa816cb040ba11647c785f64ba3a"
+ "1e2eadd17bc6f8eb7e2ba480da06b6606e6f4ede7f9fdaf26fe89cc7cdb0ec08f1c53ea273"
+ "6a83a53824d1f9d05022aba64e65a59f19e6713d60e7c64f5270befed0570ac245490c77ea"
+ "af2baa4165a8cd1b268458b634df1f38c20e79b20d1fa6453e9ceb74c447c53705fab82e7f"
+ "a23251e425215c1fd55818ddcf4449f58ec238ffb1a3cb24b53caaa8430f8b01a1cfd515d9"
+ "91c6547c165b34d3608bc117207480396338645097f84499296425333bb68bf39349c59d04"
+ "dca85341a816fabed09c2d42c601c1966ad4e2baf3eea257f75524e96798b9af773169cf95"
+ "0186968f5aec8fd5906e55c9486a70f44f5435b112a47a33b782f01b5a0dd26ebb6ebb95fa"
+ "0a83d02b444416e2a340f5bade3c76a9217f993d508d48d013737da2c6ed9af245a0877ea1"
+ "b50719b77d26eb1085cd2a418f7c04b9fc413629923aea6b7ecc795958b0ecfec3b820d5b5"
+ "ea6bd1f7cb1b555c2820165f01aa85c49343f7b7005b28a28bcad9bc77999207559b60295a"
+ "e2ed8b11702e14b98c0026712400ec219ff867dd78aa2637927c9921238165292ab08409be"
+ "a2bc683b00e771510fa0db6c956603313a985e2dd1f13d0aaa1f7331aac6b8a5d5b195e8a9"
+ "3f5d5a07e4ce064258e2049f6c4eb1efcd3a7d890d881dfb080e990927d93bea148b5e7645"
+ "7c1bdf2a73d364cc30b81345edf3dcb375c5cc5bcf34536ad0481f3669ed32cb1e9c0895a5"
+ "0d2542bdb135878a8fa4fec38d46f0e3c8f9b14738ff36865d29c94b31faf6119b479b8e2f"
+ "dc9e1c838b82605809c66b08576b97b7b5d90d4865c77201c678cdcf770a7db91f2070c17c"
+ "67d4327e4d7ced8e2a73285993b1a19fe3eab29154035e4cac04d0cfada92aa5963e785f8c"
+ "a20d77e9f7e65169db4d9196abfc76c70f520b41017313d7ff8c43d129134a0f265ff6f10f"
+ "ad88054ddf128680ac133315bdd91b00d92d026a0d692f80069bb45aede03f09622237bae8"
+ "ef09462a0bfc4bbdda430833702a8481d6eb028f111b7305d33f30c8558a7d270a3aa5610c"
+ "aa8bcb39867efce7a44b0595c556c0befe0899908b82af48c07106e30c667ecd75df0df03f"
+ "9a606f680afff7c1b12625177d3f829adc2e304a5b1bb6c8788b712ebb6759629857d243d9"
+ "57b8aa44369fe3eda0474827c60ba9a042879c9e5896b71b35aa19f8d6e5ef5e0f713ed302"
+ "b8f50bc1d9083b7fd28765c8206e774ff62a522949c56dbe738b99d9e9b2eee7fce9029a92"
+ "b7c21f31cb36fdb974d237c7641060105e77a6a6a0e61d3a60aa4f792622e897e89bf6809c"
+ "d9f72674ee4aab58e636200e0de7d08efabbcbba05e408b16d9b472f8b993e0d3b5b74c105"
+ "e171ed02150e3a9c4a95a8b5cee3d35788a45bf328e2018501b86e973300221be59787fb68"
+ "1064a6f2bbaa44aa4be578bb8fa3c24e0dfcd16f8da1bcf72b9ee98c86ab8fea3913f5f3fa"
+ "c6840cf705fc1e1b945047e7301efa976135fc0bdbdc2188d9911cbb2ca2cc99f0d62b1888"
+ "cfbdff94ebd6b1583ebc07ad468ff5ca600e28438cc89e5a7ba3fa97742e51c45eddee2c21"
+ "46c29f0fd3f8ef8e2e3be6ca727e1d35ccfc5539f372103ea30803779089fb811aaf517213"
+ "ea35fb33c0d4a2464f37f286be1804030d59bf53be9bbc11fbdfa9b2fee8deb60f6ac7d6b4"
+ "070f4d666235ee4dc314b85869f339333a1b3cff2eaec781ea6a07a2440bb035b75a00ee0a"
+ "7d42672f160604a2e372c3ced65d4a556412837c8038f6a93e4eecfbcb4408a42159e76625"
+ "3b2e0f443edfb3e6f098021eb7b030f6d0d4b20243222604ea84d81e03a0f7e63a447f9bd1"
+ "a3f26485bf69912e16dcfb0222c8c5d74e7166e1f899101c74abcf4fc0558b4ae26a2c0e08"
+ "e2dc20c91d2c9fbe835d44ff15a26c6b976fcece277e4ff9fe80c0a28d5bf40bc40af5f782"
+ "13476c0b6873fe734a066fda3eb350302d7206168dd61ee4de813c8ac65a3a48cb40ccc821"
+ "c8efa14ce9320e6f0de35b5e68735bab8d03ef1185799151bb5f8a3f4d956752aec525cc73"
+ "d187665a0027189cd895f01422e59abed3bba5b655828d4aff00d77c846ea690c18a5a3f2b"
+ "86fd9da63f095da01f3778107b640a2813197a3f7023d652b2865ea8e2f93398fafa2f9af9"
+ "0ee81a8d6eba0d6671951ae831f85bb510605caf3ef2550ed0ded1fb90061857dd26eded72"
+ "5fe4399711fb2d0178a386046db054259a44896fcb795961e283fcda0d13be9b390fdc71a3"
+ "e3aadbac44dc71b9086e4b204cae1b0fa06268bd73b746807fd4c0ece38fdf877c490cdc7f"
+ "b622c8ec94b374a3b739c013476ba680edf46739c981ab095c175acc045c445ae15b208637"
+ "b13b841eae64b9b571630dc82119547ceefbab3288fa224d73b572ab1ac600258dbb7711c3"
+ "2801723744a2f80902b46286d52665d368892de15e283f30a5e3fe1d36284ad42afeb58a7f"
+ "a9850d6afd277ce4709c716160521dfabc755803932fdac96c096606be2690af795f418ba1"
+ "a3fd1e5758f570d702be4855c76c8ffeb3cf31056b47ca5d7aa498fd83302e490c61b32c8d"
+ "3586f43ea5772ad98b724cc51e2337d4674f086f915556b69ecfb837e4586c84b147cfbea8"
+ "a6427fd5cef19750866fb59dbc669de92972052b651c8d4c2f7cad2db4e2690b23db7830c1"
+ "c20658fce756d74db87eb7b93020dfbc49b86fb1ca81291f337d4642a0b330665aa8f4087f"
+ "ee34d22b190639bd02cf126ad96a34f21957e92549e0d96f54d0b1aeb904c33ea8e6733f0f"
+ "42abc821451471293415c18d4e01c044a3b96f85850c73a26aa01a382e424350f85eb5007c"
+ "d23878fd90f21c0413eeca6337a0a1b7bebf8042fbb10c6b6f6469dcd61ac494bd3efb2d5f"
+ "fbfd5e5398920d5a13e84da91a1636ae862c95b2a4d99e8e62eb43a7ce89a543db8c942926"
+ "e48b08d33b89afb9582bf56e50c5cd9d64e9e733e9a47404217b51d8854872800edcfd5426"
+ "39385e1f66242e01f97fd3a97e201eb95d16305956e57a8f9adede23791b8ee2fa3b81db49"
+ "f56cd02fa900439c2bb8b9fa7c65ee662d415164f5930a7c65769156080b3cce889e103330"
+ "a9a7934962d5ef10e8577438524c484aeccf8f556975a2006cc4e7d7143165f2f771d77a64"
+ "06d2251b8dd659c8a42aebac5d8e5513bd0527f9b6f709714bd82cceda33a18a572d7b1f28"
+ "e998a96d4fb596f021f68215356439f40ad42282bf784b954bc4900860bc07f4452ccae599"
+ "5a27afc8535b5854c5305ff02af7b876879512071f6d7aa7eb5ed7d37c0e657c00962f3441"
+ "2b23a694e75a52a60fc7a861deec2f27ce4f323dce313b98dcd9c4d419985ad696c5f58361"
+ "392563e2b0a0f72ca286e9a5a044a32685a01e4ade75983f3e53f74f4e1022b82479269ef5"
+ "279ec1765955642c27aa83847e0b9c029b63da839835575820699af9a038b587a468e556d4"
+ "26601282fbe9be24e1b33d0e1bcab5c5398f3ac6b67889f4c99b40cfa906fc2cf002868c2f"
+ "3d6f3bc73b683bf210ee4a5f5281c416898ae4cd14ced66f51e1c48a08420d275c90c3d3c7"
+ "7ca4eb22fdc5df97ff81eb1adf987118b7fc6b501b8a2c7a9be1933ab3b6f651ae93141ff9"
+ "7de2fe9ad3fc3852df6c89b2959a0fbfca0b63a7cec988e7eddc256962d58c2916f17b4981"
+ "0fe5543a37b5d74b52fa3bbb5385b7a08ad38b99b80b4744d48aaab4075c7672a45736e3d3"
+ "8c58f827472ba8550dff056e919f439796ba9c905a5a1df24e93d40958e215c59edba0886f"
+ "5c9f8c8b05dba2f2c9d4e568555ea29018cef66b10ebbbf76cfbf6d72c1795402a70bed95a"
+ "c819b0f05431b2203355e77827c72fb5b0270b1817df07cd9c99a4df89f8cbec7a87ab59e6"
+ "3cfc554d19d1f38a29206d3e5e590de1e6e329c2585d215945e9397d6762d60e23992a450b"
+ "e389e03eccdc0901808be8ebc45051b32956a1189649f25c37a09287762f5f4a5c69c54867"
+ "d63159662c6d83cfdaa0a9ffd19b356ef4aaeae58d6c481b84ede83decbbc44717f6e0be29"
+ );
+ BOOST_CHECK_EQUAL(x, z);
+}
+
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/shift.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/shift.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,57 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(left_shift1, int_type, IntTypes)
+{
+ int_type x("12");
+ x <<= 3;
+ const int_type y("96");
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(left_shift2, int_type, IntTypes)
+{
+ int_type x("246556567891512374789511237456594795648912323213860000007849");
+ x <<= 2;
+ const int_type y(
+ "986226271566049499158044949826379182595649292855440000031396");
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(left_shift3, int_type, IntTypes)
+{
+ int_type x("246556567891512374789511237456594795648912323213860000007849");
+ x <<= 99;
+ const int_type y(
+ "156273790638943927367154966864556037925514287264587565911690950563681284"
+ "261029491729498112");
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(right_shift1, int_type, IntTypes)
+{
+ int_type x("246556567891512374789511237456594795648912323213860000007849");
+ x >>= 17;
+ int_type y(
+ "1881077330715273855510797404911764493171022973738555908");
+ BOOST_CHECK_EQUAL(x, y);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(right_shift2, int_type, IntTypes)
+{
+ int_type x("0");
+ x >>= 17;
+ BOOST_CHECK_EQUAL(x, "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(right_shift3, int_type, IntTypes)
+{
+ int_type x("14222200");
+ x >>= 8;
+ BOOST_CHECK_EQUAL(x, "55555");
+}
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/sqr.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/sqr.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,234 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sqr1, int_type, IntTypes)
+{
+ int_type x("-123456789");
+ x *= x;
+ BOOST_CHECK_EQUAL(x, "15241578750190521");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sqr2, int_type, IntTypes)
+{
+ const int_type x("-123456789");
+ const int_type y = x * x;
+ BOOST_CHECK_EQUAL(y, "15241578750190521");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sqr3, int_type, IntTypes)
+{
+ const int_type x("-25");
+ const int_type y = x * x;
+ BOOST_CHECK_EQUAL(y, "625");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sqr4, int_type, IntTypes)
+{
+ const int_type x("300");
+ const int_type y = x * x;
+ const int_type z("90000");
+ BOOST_CHECK_EQUAL(y, z);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sqr5, int_type, IntTypes)
+{
+ const int_type x("2228218");
+ const int_type y = x * x;
+ BOOST_CHECK_EQUAL(y, "4964955455524");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sqr6, int_type, IntTypes)
+{
+ const int_type x("-999998000001");
+ const int_type y = x * x;
+ const int_type z("999996000005999996000001");
+ BOOST_CHECK_EQUAL(y, z);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sqr7, int_type, IntTypes)
+{
+ // this tests toom squaring and karatsuba squaring for 8, 16 and 32 bit
+ // digit_type
+ const int_type x(
+ "0x5004a2519b00503006126bb044af8930502951243994250616123426085258764a856336"
+ "35702406cff061642794728883255642074744145228324022219347019013411158803532"
+ "4599404120656564868354acc9369a42721979894500607265f042a53387791b3dd4784511"
+ "50227920502852884378111055ccff50357557404795594025600468996407045934090727"
+ "08041078777870387730504addbc23489bdbd45615ca892497b8b93428a2f9871374491b5c"
+ "0fbcfe9b5dba53956c25b59f111f1923f82a4ab1c5ed5d807aa9812835b01243185be550c7"
+ "dc372be5d7480deb1fe9bdc06a7c19bf174e49b69c1efbe47860fc19dc6240ca1cc2de92c6"
+ "f4a7484aa5cb0a9dc76f988da983e5152a831c66db00327c8bf597fc7c6e00bf3d5a791470"
+ "6ca63511429296727b70a852e1b21384d2c6dfc53380d13650a7354766a0abb81c2c92e927"
+ "22c85a2bfe8a1a81a664bc24b8b70c76c51a3d192e819d6990624f40e3585106aa07019a4c"
+ "1161e376c082748774c34b0bcb5391c0cb34ed8aa4a5b9cca4f682e6ff3748f82ee78a5636"
+ "08041078777870387730504addbc23489bdbd45615ca892497b8b93428a2f9871374491b5c"
+ "9464098710748f27372836255355251ae330455ffaa58681216515eeff0330517814dd7487"
+ "34682745159208158750835203309620570274592666481348052963762094268695162425"
+ "18850320172906096781969070339129822281355221058882087466637338881223511228"
+ "63144016884857141834687376804878770495858121023810198067988560350169566260"
+ "5944107067ac5771a1662497b8b93cfe57291387313365462656674328aaaaaf9067287310"
+ "ea6863ec68378827380764363420573208101547102942bf05465397209378421688020320"
+ "35702406cff061642794728883255642074744145228324022219347019013411158803532"
+ "4599404120656564868354acc9369a42721979894500607265f042a53387791b3dd4784511"
+ "50227920502852884378111055ccff50357557404795594025600468996407045934090727"
+ "08041078777870387730504addbc23489bdbd45615ca892497b8b93428a2f9871374491b5c"
+ "0fbcfe9b5dba53956c25b59f111f1923f82a4ab1c5ed5d807aa9812835b01243185be550c7"
+ "dc372be5d7480deb1fe9bdc06a7c19bf174e49b69c1efbe47860fc19dc6240ca1cc2de92c6"
+ "f4a7484aa5cb0a9dc76f988da983e5152a831c66db00327c8bf597fc7c6e00bf3d5a791470"
+ "6ca63511429296727b70a852e1b21384d2c6dfc53380d13650a7354766a0abb81c2c92e927"
+ "22c85a2bfe8a1a81a664bc24b8b70c76c51a3d192e819d6990624f40e3585106aa07019a4c"
+ "1161e376c082748774c34b0bcb5391c0cb34ed8aa4a5b9cca4f682e6ff3748f82ee78a5636"
+ "08041078777870387730504addbc23489bdbd45615ca892497b8b93428a2f9871374491b5c"
+ "18850320172906096781969070339129822281355221058882087466637338881223511228"
+ "63144016884857141834687376804878770495858121023810198067988560350169566260"
+ "59441070673981642057711662497893572913873133654626566743289483229067287310"
+ "35702406cff061642794728883255642074744145228324022219347019013411158803532"
+ "4599404120656564868354acc9369a42721979894500607265f042a53387791b3dd4784511"
+ "50227920502852884378111055ccff50357557404795594025600468996407045934090727"
+ "08041078777870387730504addbc23489bdbd45615ca892497b8b93428a2f9871374491b5c"
+ "0fbcfe9b5dba53956c25b59f111f1923f82a4ab1c5ed5d807aa9812835b01243185be550c7"
+ "dc372be5d7480deb1fe9bdc06a7c19bf174e49b69c1efbe47860fc19dc6240ca1cc2de92c6"
+ "f4a7484aa5cb0a9dc76f988da983e5152a831c66db00327c8bf597fc7c6e00bf3d5a791470"
+ "6ca63511429296727b70a852e1b21384d2c6dfc53380d13650a7354766a0abb81c2c92e927"
+ "22c85a2bfe8a1a81a664bc24b8b70c76c51a3d192e819d6990624f40e3585106aa07019a4c"
+ "1161e376c082748774c34b0bcb5391c0cb34ed8aa4a5b9cca4f682e6ff3748f82ee78a5636"
+ "08041078777870387730504addbc23489bdbd45615ca892497b8b93428a2f9871374491b5c"
+ "16863866837882738076436342057320810154710294295605465397209378421688020320"
+ "0fbcfe9b5dba53956c25b59f111f1923f82a4ab1c5ed5d807aa9812835b01243185be550c7"
+ "dc372be5d7480deb1fe9bdc06a7c19bf174e49b69c1efbe47860fc19dc6240ca1cc2de92c6"
+ "f4a7484aa5cb0a9dc76f988da983e5152a831c66db00327c8bf597fc7c6e00bf3d5a791470"
+ "f84c878148cc7020890befffaa4506cebbef9a3f7c67178f2");
+
+ const int_type y = x * x;
+
+ const int_type z(
+ "0x1902e5887a586c505ed49b0ef0db72e959da458fbfe7f7f1738b9da657ebc6b4f3eeda8f3"
+ "45f86a9439fb0a314af8a6d54e9002f6b9778bc217f31e1c2af869b890e50b105f2a6c8f6d4"
+ "d9f7ce008697c1ef9f6b1b3d58089517db9a209f0951f3843c9f5dd81da8082a4e79771c9fe"
+ "c7a967defed9c1d7229a9e6a78226389976caba3a3419a68d1376d7b67eb20136d1c47b480f"
+ "446428ec425ddeb779492e6e40c2318633e6783066d046486a419676066b0fcacf9c9da24ef"
+ "bb6ae2a639af668b9c732ed3ba74f4e73f28cffbc415d3a086decd149e1dd1f4265ede8666c"
+ "2963f2ef61b190fb094730110586e73afc7656f6e8e3188767ee075b98cceff2de2959b3c51"
+ "eb0cd03b5d277846536a3d5fa2baaff03d2ff90785581d170ad264d845d6e3522921afae94f"
+ "13eda75f99694a961beff0495830b53f1b282d4fc5fa665a402cc253d71aa411a16c7cf3825"
+ "6ff351d8e7f6c476d01ca3d39947a71703488cc0c85f7ce9ae7521e22ce4cb99e14dcaaaa69"
+ "d8f1390f8c8275c899e8ec14b2fb9100bd8c4e44bc2d531f049a31583e11d73070a815efad7"
+ "0e28caa18cd89a7e4bb1a17a961ae011511fe3ef495ae1c8e44653a73c6434ee77b242f7d9a"
+ "462613b92a5809da93c6d687222abf79b09a718fdf7787c7aff48b1e529da53898273abab56"
+ "00d67781a15c06e3741c79948cecbd3cd24414d40b0087844c9271bae8d470571a4e87309f9"
+ "ba510ef32c2def3e29f0f342f9a6f50fb00ee16159d0de74dfc85baf97c861a1ae63aca48b7"
+ "b2c3830ae11aa818f6da2a3cc74b5c2d0c635c9dd6d9fc5b9d35e46f8a53b93724e112a140e"
+ "cdee10eeaefa830d4678d06e1f3426abba1c9f76415ed479bee5160a8a5fcf9d5803552ca5a"
+ "810ea290fab7df557d9687af8782413fd04bf41454eae63c470ab231186c7aaf88b7e8de2ef"
+ "5e04cc8f9738f42ab5c8f993d13f8051765d4369709e54d24ec5e14138d1fe7ac81b311eb42"
+ "b0c35deebd10a3f5a60535870eeebd8662d11844ae4b39507232787d04e3c214e5b73b7b280"
+ "3395fd5a5c0c373cf2dbe76a2972e3bbaf6ff166c8134ad831ed000a4c4d5e615b74d697f8c"
+ "2be9fd8326e1aa352bcdb5ba460a0d34f750de03701e98ea43969c5b3b9de3e7bb562a320de"
+ "b10d1c8671b523611ffe7c2da353a1d3b86cf1c4d34d3347d02337e0656b9b39c8fe1f961f3"
+ "b5919df4469e895d3869590c042d6f881d9781c413613f6c5a22fd9cd24c906582e143b04b7"
+ "a09aefeed701bbf92687e995cc56578784b96c5a7a648d5c166c3b7c9a0c2df9c0166bf00b8"
+ "55c1f6e236ac96484638733eb9e84ccc4ccb33a49399e5057bd2d96ca51133496d5283a2085"
+ "56aa7f2b3264678f99f7cf5380bd61180230870ae35c00d272ec73d960ead550b29730a42a1"
+ "051e825890ec2283cf0de984af072a2125fd4ff692e47ef620b24a952c37ea379444061869c"
+ "aec75d2836afff972e54255daa9069f4c51f5bdb8ada41d3907fb5581dc7289d50577663616"
+ "464fc8b3f99676dd67bb93358a897feadd7a92336a0f4af44c9325fc53ba1d87f7b914e4847"
+ "462109cba84ad8498cd717c503d4c363b8ff405df44fa84bc9c8bed141c7f91954098b2ecb8"
+ "b59fc457ec86022bf6c395bb382f6a193e3387d52f3e1978af4576153fa7fb60d5b896cef43"
+ "e628045ec0577971b78e7ab1b3a9fa9ea6cc8e4a04f141e744f70fe0c800ce5dd3c748729c6"
+ "efa085877a7d9296ad489883ee966117e5db61bafbcd55284dc8d470646473761ec606357bb"
+ "fed899cd7c69e027656ef30b12e8a9e63868048bae95c7b67d26a843c94cec551ed5093542b"
+ "ff7437316a830e3c48f19491a81fb37aef5d89ee08b507b881e65fbf8dd3343e58b63ea3a2b"
+ "d465e02c5cb673e5c8cced17f5d3f9fad8307cd6c3abf9111e063fb197df4db52eac6092229"
+ "64e157a1b172004c1817162e688b55245c598cbdc5fd9f74db4911484feb5a390c27d0efeb3"
+ "a8bc21ff9dec02808fad5f882580facb5324a4f3a21b75c23cc311be7afe003895351fd07fa"
+ "c037d67718cc11aa5942837ee9048882e2564b625689ee3bd9487c4ec43f562508bbcd0671c"
+ "18434ca6ae92725d905210060d80e2524eb38ed600aeaf486d7b2b690a9f567d86444c35fd9"
+ "8bdf6b665dbf7e43557b281a792400274ca21fec996e5e6142780f8a7adcddbae4a2e9474a1"
+ "38931c19f96368bb2bc40aace10616bef5c975feca3c7f3e1122b41a39df9202a7a6405c647"
+ "d032f8c692e1e89838fc1dacb291d9e2d8ee90d88b6f598947d085289f9c4247548628a9e3f"
+ "6ea8ac5980e290749e39a9417b20f39dbbbed20209584a741747771020b2287007b37d17779"
+ "21303e3b7a9ee49db7b14dda965d9241548387e610758507c946eee0c49b67efaeedbe64e6b"
+ "114e3b4ddff5edd2050322d8298ae66388b1fb64435fa064364f41f129ce83a0cc563f8796e"
+ "1dd09be1a03bc5567caed9326df5714f6cf88ca247826ce93add7d17332d6870b1d0613a4fd"
+ "fd4c7d8185db385687d735d0bf22e87a045ad2a397db9c4ee0908a047f087a0fb49a27f65d0"
+ "e6e6ef0ef506d1411788ac027c29be3e93253e61ee76f951d3ce721c825bf5b883471f91f68"
+ "a37ca36d198adf93063e220a16b94e9aaca5c4691590ff2a696c1663b5ca69e3f3a11409cf9"
+ "727cf409a1f87a0a5e4805008c7488b7c9e23c42e33bfb0fab7e4f59e482ec50aa1b4d64996"
+ "4e7232c26acb75217ef1b200ebde38169d6ce7aeb2746aa29249d61af1e168a256e1848cb33"
+ "873c5457afd48194f77c786bcd8ce842605117c66b003abc05fb9b74869cc832c88df506e0e"
+ "79ebb0436443fb467269e42840a0486b3f35acca04b000876b9bf2c6a7f09ec6ff7ce198f8f"
+ "584e3e22b4a2e8279c1a043899fe0d2e5180ec1738b1cb23032374069b33a471fdd8e5f5be2"
+ "a4ff945697d9dc540878bc6a6704cb8b866914fbce94021bc2e6743dc7e160a8780912a90ff"
+ "732a81b060d97f777713881e9214474e1196ff13f07361385e19e5c5ffa24aa6b00f473cfd3"
+ "e71c42ed1c31eb9b5ec91635bf8c77e7aff696009da2163c7e1621bea9b30479a8e10906d3e"
+ "1ba06f3e64e776a62164238d18cebaf9684427fe8e5930fbd8892851c8cfa4e2c729558b909"
+ "a665f57919565d834fbebb0d64ba1721b083ca6fe55dab07546df6c1e60ab41f4836f64c27c"
+ "4f715764a472f01d947cbf8d3cd8e011129edecca4334b095edf3d37e27b7c30900eac3702c"
+ "3e09179a53462cda8dece1ecdda223d6cc32c9363f5123982b071367609b01bcfccfd4a0120"
+ "23b4dfacb5993d04434aac5a95e0192770206b4a3bdcb3a75013daedf68ed40cfca0e4bd802"
+ "4906ff8cc816d7bf556898545965b846f2b1dda3216d17d236e4ba5d2427ee799696c60297a"
+ "c720adacd63da47e2e3aeeb99c136e1b5de50cfe523823a87f94b1b4b8f6be2162ea40441dc"
+ "2f9af466c7642d0ef34429a986ae96e962e4a2cd9c12a41d71398ac03c990a15364c38a3bd9"
+ "af6605d1c9b807babd942bd66d2f6e4ccfaa2131354cf78aa09ffcec32258c9c3b53fbcc755"
+ "5bfeb11152332bef6420b08528d43f6865c5d53ade958d3b58dfe2f34391ea8d2d8fb35c32e"
+ "6a8f569d6cc9d456ff5b78fae829cc171f95f5389373a0dee3565a428237ec4e68b6e6efc3c"
+ "a5bd220699eb80bd498d2ea90d43b901881567e9c18898caea36334008b4a08e3e6cbda4e17"
+ "db7f5187d6f3284eca8c1a03faa28a2a23b27d560690642db0ea485e4be8c1c8b4441234f39"
+ "f31a6c9fe5cc7e50c777acd0746bbfb7399ee262a36a54a8ee25c334e503dcd6e00f7e9ac3a"
+ "80495156af9f9aaac62fe02c4c2373cc03d32c4be1b077d97f6167413661403a38b0df999d0"
+ "24701c5f17e5e5701cf9b9eccd9417af7637139473aab760b7ecafa863e7f049a6b98be603b"
+ "6bf0132b211b80123246c657cfdbb4b5dff7be43c364be943b5cdf03db86a6cd56a96187cb4"
+ "5b6acbf37383ca3fe7c9cc3b65a57c9ea6f4d686222801ce6d1463bb92ff5f2599619388660"
+ "99365474bbcba180f940ede8a02777bcf55d3549cfcd819aca8f055074d81af6472c3c9beaa"
+ "67b8f89066f1e02d1502aa13a4c872b9b1dc4e2a2b6d58eaa869c9e62a9f7e01efc2c87eb6a"
+ "9bc80d29c9c48a10edec1e5a799aeff2a580736525357ae40d677aa4fb6533c15b4afed1fde"
+ "f6e0e4c0a548c5be8751da42ffd8b409dcd77487437a16d769e232c95d0b780a46395ea0023"
+ "6cf19b1fafbda1c8c75aee09e06bcf0383816d0f9c364baa95a09fe2e2894693fc66166a16a"
+ "e152a24dfc5ca3646ce2cafe40a7ffbeb561ae4db74dc7ff045e85a9126a25152f0342d1f87"
+ "3ecb21bc411771eb7589f3df1be59fa97156ca5d3c93a7df10b90c525e25df36e7947614770"
+ "1f9ab2a368b179428ad005c7af2fb500fac032f0f1ff3f9694412d3c164fcc444075135fd9d"
+ "a58e2fab3ebf7b5fcaaf20256052e64b59c92db1cd3c2e0c2df41b06a540a754d349a284fa1"
+ "45a13795674240616f433d174fc67dda102db9e9e3bf23d4a8816ad130bca720ef707606206"
+ "7ab36f2061261981528dfdcaa3e21787f164e6ba318bb018f3974540ae8559790284852d31a"
+ "d8c77066f8620345f099606eced7f93e465b3a31a7b196b24e76a44d7ec6f597fb4a3a9a1a8"
+ "ba5611156e20c294b90cdde30166ee59c0c80936e992e5f3185c6396756194a7c8f1971a0b8"
+ "27477b2060dfe721fd0c2e725e25cc99d1227c6db9d5452dd70dbb0c2db67187a4e93c9bcfa"
+ "0049fad1289773ea6ffdcf6e6680a44cd577223b8f86eae3568ee5cd0b2f45a17f7b6d7531c"
+ "925e2c22b4004fd8e12ab70e2392e190dab556c0227b660cc226f5db558668bcb426a8153bc"
+ "32af18b8c7dbe3c2ad210300582f823fc5fd7aadc653c2c0b59b3e5362b158793485e56c7c4"
+ "c4");
+
+ BOOST_CHECK_EQUAL(y, z);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sqr8, int_type, IntTypes)
+{
+ const int_type x(
+ "-0x10ef8a70456e96e5d20ac502fce83ab3218dff7522c2d02088a667bc00eb467c18c5c91"
+ "17bedaf7d79b09357862f8a8eac280a29cfee813f0721484ca7b8010000000000000000000"
+ "00000000000000000000000000000000000000000000000000000000000000000000000000"
+ "00000000000000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000");
+
+ const int_type y = x * x;
+
+ const int_type z(
+ "0x11ed171d12cb37289a825658ab14c26a6870e9895c9beff0e5a8c415c68d5bb7991c061e"
+ "99888c8c93d69f4a8aa8b2b4c81d63a1bba5e0191de7511edb701f7e0f4c337c5dbf8e57b6"
+ "54eaacb22f542e3ef3d3ca3d255a8bf76604ad5e4b32164949c50c4144377417897fdcad19"
+ "602dc396ac9c2ed00c9c5b22d8f70010000000000000000000000000000000000000000000"
+ "00000000000000000000000000000000000000000000000000000000000000000000000000"
+ "00000000000000000000000000000000000000000000000000000000000000000000000000"
+ "00000000000000000000000000000000000000000000000000000000000000000000000000"
+ "00000000000000000000000000000000000000000000000000000000000000000000000000"
+ "000000000000000000000000000000000000000000000");
+
+ BOOST_CHECK_EQUAL(y, z);
+}
+
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/sub.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/sub.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,139 @@
+// Copyright Kevin Sopp 2008 - 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sub_assign1, int_type, IntTypes)
+{
+ int_type x("0xf2378eeec78234932222111000000f");
+ x -= x;
+ BOOST_CHECK_EQUAL(x, "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sub1, int_type, IntTypes)
+{
+ const int_type x("123456");
+ const int_type y("987777");
+ const int_type z = x - y;
+ BOOST_CHECK_EQUAL(z, "-864321");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sub2, int_type, IntTypes)
+{
+ const int_type x("955588990000001");
+ const int_type y("9801");
+ const int_type z = x - y;
+ BOOST_CHECK_EQUAL(z, "955588989990200");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sub3, int_type, IntTypes)
+{
+ const int_type x("99999991");
+ const int_type y("987654321000123456789");
+ const int_type z = x - y;
+ BOOST_CHECK_EQUAL(z, "-987654321000023456798");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sub4, int_type, IntTypes)
+{
+ const int_type x(
+ "49144609407766890328547643707523663509662747376486271392344480900673178645"
+ "33198519112197059826509662943577383543858946941049753393431035706592040680"
+ "43848484065292542884106550381079282660840705126574766636237650938379223350"
+ "073087806800887586256085275775217219429527000017403144");
+ const int_type y(
+ "49144609407766890328547643707523663509662747376486271392344480900673178645"
+ "33198519112197059826509662943577383543858946941049753393431035706592040680"
+ "43848484065292542884106550381079282660840705126574766636237650938379223350"
+ "073087806800887586256085275775217219429527000017403144");
+ const int_type z = x - y;
+ BOOST_CHECK_EQUAL(z, "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sub5, int_type, IntTypes)
+{
+ const int_type x(
+ "21665907282124706187656074325458499695895652068822763794228458103499408841");
+ const int_type y(
+ "173087806800887586256085275775299999999889978789789");
+ const int_type z = x - y;
+ const int_type w(
+ "21665907282124706187655901237651698808309395983546988494228458213520619052");
+ BOOST_CHECK_EQUAL(z, w);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sub6, int_type, IntTypes)
+{
+ const int_type x("0xff");
+ const int_type y("0x1000ff0000000");
+ const int_type z = x - y;
+ BOOST_CHECK_EQUAL(z, "-0x1000fefffff01");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sub7, int_type, IntTypes)
+{
+ const int_type x("1000000");
+ const int_type y("-1000000");
+ const int_type z = x - y;
+ BOOST_CHECK_EQUAL(z, "2000000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sub8, int_type, IntTypes)
+{
+ const int_type x("-1000000");
+ const int_type y("1000000");
+ const int_type z = x - y;
+ BOOST_CHECK_EQUAL(z, "-2000000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sub9, int_type, IntTypes)
+{
+ const int_type x("-123456789");
+ const int_type y("-123456789");
+ const int_type z = x - y;
+ BOOST_CHECK_EQUAL(z, "0");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(sub10, int_type, IntTypes)
+{
+ const int_type x("-1000000");
+ const int_type y("-2500000");
+ const int_type z = x - y;
+ BOOST_CHECK_EQUAL(z, "1500000");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(decrement1, int_type, IntTypes)
+{
+ int_type x("0");
+ for (int i = 0; i < 10; ++i)
+ --x;
+ BOOST_CHECK_EQUAL(x, "-10");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(decrement2, int_type, IntTypes)
+{
+ int_type x("4");
+ for (int i = 0; i < 10; ++i)
+ --x;
+ BOOST_CHECK_EQUAL(x, "-6");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(decrement3, int_type, IntTypes)
+{
+ int_type x("-120");
+ for (int i = 0; i < 10; ++i)
+ --x;
+ BOOST_CHECK_EQUAL(x, "-130");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(decrement4, int_type, IntTypes)
+{
+ int_type x("130");
+ for (int i = 0; i < 10; ++i)
+ --x;
+ BOOST_CHECK_EQUAL(x, "120");
+}
+
Added: sandbox/mp_math/libs/mp_math/test/libtom_integer/swap.cpp
==============================================================================
--- (empty file)
+++ sandbox/mp_math/libs/mp_math/test/libtom_integer/swap.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -0,0 +1,44 @@
+// Copyright Kevin Sopp 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/test/unit_test.hpp>
+#include "prerequisite.hpp"
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(swap1, int_type, IntTypes)
+{
+ int_type x("-0xabff23742384bf892734029323819048039");
+ int_type y("0x1fee55d048039");
+
+ boost::mp_math::swap(x, y);
+
+ BOOST_CHECK_EQUAL(x, "0x1fee55d048039");
+ BOOST_CHECK_EQUAL(y, "-0xabff23742384bf892734029323819048039");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(swap2, int_type, IntTypes)
+{
+ int_type x("-0xabff23742384bf892734029323819048039");
+ int_type y("-0x1fee55d048039");
+
+ x.swap(y);
+
+ BOOST_CHECK_EQUAL(x, "-0x1fee55d048039");
+ BOOST_CHECK_EQUAL(y, "-0xabff23742384bf892734029323819048039");
+}
+
+#include <algorithm>
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(swap4, int_type, IntTypes)
+{
+ int_type x("-0xabff23742384bf892734029323819048039");
+ int_type y("0x1fee55d048039");
+
+ std::swap(x, y);
+
+ BOOST_CHECK_EQUAL(x, "0x1fee55d048039");
+ BOOST_CHECK_EQUAL(y, "-0xabff23742384bf892734029323819048039");
+}
+
Modified: sandbox/mp_math/libs/mp_math/test/unbounded/signed/ctors.cpp
==============================================================================
--- sandbox/mp_math/libs/mp_math/test/unbounded/signed/ctors.cpp (original)
+++ sandbox/mp_math/libs/mp_math/test/unbounded/signed/ctors.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -166,52 +166,35 @@
BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string6, int_type, IntTypes)
{
- const int_type x("0x123456789abcdef");
- BOOST_CHECK_EQUAL(x.template to_string<std::string>(std::ios_base::hex |
- std::ios_base::showbase),
- "0x123456789abcdef");
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string7, int_type, IntTypes)
-{
- const int_type x("0x123456789ABCDEF");
- BOOST_CHECK_EQUAL(x.template to_string<std::string>(std::ios_base::hex |
- std::ios_base::showbase |
- std::ios_base::uppercase),
- "0X123456789ABCDEF");
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string8, int_type, IntTypes)
-{
const int_type x("0xA0000000");
BOOST_CHECK_EQUAL(x.template to_string<std::string>(), "2684354560");
}
-BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string9, int_type, IntTypes)
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string7, int_type, IntTypes)
{
const int_type x("0x");
BOOST_CHECK_EQUAL(x.is_uninitialized(), true);
}
-BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string10, int_type, IntTypes)
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string8, int_type, IntTypes)
{
const int_type x("-0x");
BOOST_CHECK_EQUAL(x.is_uninitialized(), true);
}
-BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string11, int_type, IntTypes)
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string9, int_type, IntTypes)
{
BOOST_CHECK_THROW(int_type("0x15656abg56"), std::invalid_argument);
}
-BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string12, int_type, IntTypes)
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string10, int_type, IntTypes)
{
BOOST_CHECK_THROW(
int_type("156afc56", std::ios_base::hex | std::ios_base::showbase),
std::invalid_argument);
}
-BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string13, int_type, IntTypes)
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string11, int_type, IntTypes)
{
BOOST_CHECK_THROW(
int_type("015656ABDEE0", std::ios_base::hex | std::ios_base::showbase |
@@ -258,6 +241,12 @@
BOOST_CHECK_EQUAL(x, y);
}
+BOOST_AUTO_TEST_CASE_TEMPLATE(cctor2, int_type, IntTypes)
+{
+ const int_type x("-0xabddd00012134f");
+ const int_type y(x);
+ BOOST_CHECK_EQUAL(x, y);
+}
/*
BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_unsigned_integral_type1, int_type, IntTypes)
Modified: sandbox/mp_math/libs/mp_math/test/unbounded/signed/integral_ops.cpp
==============================================================================
--- sandbox/mp_math/libs/mp_math/test/unbounded/signed/integral_ops.cpp (original)
+++ sandbox/mp_math/libs/mp_math/test/unbounded/signed/integral_ops.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -84,6 +84,13 @@
BOOST_AUTO_TEST_CASE_TEMPLATE(add_signed_integral3, int_type, IntTypes)
{
+ const int_type x("9");
+ const int_type z = x + (-10);
+ BOOST_CHECK_EQUAL(z, "-1");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(add_signed_integral4, int_type, IntTypes)
+{
const int_type x("-1");
const int_type z = x + 5;
BOOST_CHECK_EQUAL(z, "4");
@@ -153,6 +160,27 @@
BOOST_CHECK_EQUAL(z, "-1");
}
+BOOST_AUTO_TEST_CASE_TEMPLATE(subtract_signed_integral5, int_type, IntTypes)
+{
+ const int_type x("-1");
+ const int_type z = x - (-5);
+ BOOST_CHECK_EQUAL(z, "4");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(subtract_signed_integral6, int_type, IntTypes)
+{
+ const int_type x("-0x23489328938ababba000909909");
+ const int_type z = x - (-2);
+ BOOST_CHECK_EQUAL(z, "-0x23489328938ababba000909907");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(subtract_signed_integral7, int_type, IntTypes)
+{
+ const int_type x("-0x23489328938ababba000909909");
+ const int_type z = x - 0x200;
+ BOOST_CHECK_EQUAL(z, "-0x23489328938ababba000909b09");
+}
+
BOOST_AUTO_TEST_CASE_TEMPLATE(subtract_unsigned_char1, int_type, IntTypes)
{
const unsigned char y = 14;
@@ -302,14 +330,6 @@
BOOST_CHECK_EQUAL(z, "111110");
}
-BOOST_AUTO_TEST_CASE_TEMPLATE(divide_by_unsigned_int1, int_type, IntTypes)
-{
- const unsigned int y = 140;
- const int_type x("51065");
- const int_type z = x / y;
- BOOST_CHECK_EQUAL(z, "364");
-}
-
BOOST_AUTO_TEST_CASE_TEMPLATE(divide_by_signed_integral1, int_type, IntTypes)
{
const int_type x("786432");
Modified: sandbox/mp_math/libs/mp_math/test/unbounded/signed/jamfile.v2
==============================================================================
--- sandbox/mp_math/libs/mp_math/test/unbounded/signed/jamfile.v2 (original)
+++ sandbox/mp_math/libs/mp_math/test/unbounded/signed/jamfile.v2 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -35,7 +35,7 @@
unit-test sqr : sqr.cpp boost_test ;
unit-test sub : sub.cpp boost_test ;
unit-test stream_io : stream_io.cpp boost_test ;
-unit-test string_ops : string_ops.cpp boost_test ;
unit-test swap : swap.cpp boost_test ;
unit-test to_integral : to_integral.cpp boost_test ;
+unit-test to_string : to_string.cpp boost_test ;
Modified: sandbox/mp_math/libs/mp_math/test/unbounded/signed/modpow.cpp
==============================================================================
--- sandbox/mp_math/libs/mp_math/test/unbounded/signed/modpow.cpp (original)
+++ sandbox/mp_math/libs/mp_math/test/unbounded/signed/modpow.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -101,3 +101,12 @@
"8379f3024e4");
}
+BOOST_AUTO_TEST_CASE_TEMPLATE(modpow10, int_type, IntTypes)
+{
+ const int_type x("85219208314462076924446303193527165430");
+ const int_type exp("99459745544104451690992478817018793139");
+ const int_type m("198919491088208903381984957634037586279");
+ const int_type z = boost::mp_math::modpow(x, exp, m);
+ BOOST_CHECK_EQUAL(z, "1");
+}
+
Modified: sandbox/mp_math/libs/mp_math/test/unbounded/signed/prerequisite.hpp
==============================================================================
--- sandbox/mp_math/libs/mp_math/test/unbounded/signed/prerequisite.hpp (original)
+++ sandbox/mp_math/libs/mp_math/test/unbounded/signed/prerequisite.hpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -17,7 +17,7 @@
true,
std::allocator<void>,
boost::mp_math::unbounded_traits<
- boost::uint8_t, boost::uint16_t, std::size_t, use_debug_mode
+ boost::uint8_t, std::size_t, use_debug_mode
>
>
>,
@@ -26,7 +26,16 @@
true,
std::allocator<void>,
boost::mp_math::unbounded_traits<
- boost::uint16_t, boost::uint32_t, std::size_t, use_debug_mode
+ boost::uint16_t, std::size_t, use_debug_mode
+ >
+ >
+ >,
+ boost::mp_math::integer<
+ boost::mp_math::unbounded<
+ true,
+ std::allocator<void>,
+ boost::mp_math::unbounded_traits<
+ boost::uint32_t, std::size_t, use_debug_mode
>
>
>,
@@ -36,7 +45,7 @@
true,
std::allocator<void>,
boost::mp_math::unbounded_traits<
- boost::uint32_t, boost::uint64_t, std::size_t, use_debug_mode
+ boost::uint64_t, std::size_t, use_debug_mode
>
>
>,
Modified: sandbox/mp_math/libs/mp_math/test/unbounded/signed/prime.cpp
==============================================================================
--- sandbox/mp_math/libs/mp_math/test/unbounded/signed/prime.cpp (original)
+++ sandbox/mp_math/libs/mp_math/test/unbounded/signed/prime.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -1,4 +1,4 @@
-// Copyright Kevin Sopp 2008.
+// Copyright Kevin Sopp 2008 - 2009.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -225,7 +225,9 @@
template<class ApInt>
bool operator()(const ApInt& p)
{
- return test1(p) && test2(rng, p);
+ const bool a = test1(p);
+ const bool b = test2(rng, p);
+ return a && b;
}
};
Deleted: sandbox/mp_math/libs/mp_math/test/unbounded/signed/string_ops.cpp
==============================================================================
--- sandbox/mp_math/libs/mp_math/test/unbounded/signed/string_ops.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
+++ (empty file)
@@ -1,96 +0,0 @@
-// Copyright Kevin Sopp 2008 - 2009.
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/test/unit_test.hpp>
-#include "prerequisite.hpp"
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string1, int_type, IntTypes)
-{
- const int_type x("0xabcdef123456789");
- const std::string s =
- x.template to_string<std::string>(std::ios::hex | std::ios::showbase);
- BOOST_CHECK_EQUAL(s, "0xabcdef123456789");
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string2, int_type, IntTypes)
-{
- const int_type x("12345678901234567890");
- const std::string s = x.template to_string<std::string>();
- BOOST_CHECK_EQUAL(s, "12345678901234567890");
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string3, int_type, IntTypes)
-{
- const int_type x("0xabcdef123456789");
- const std::string s = x.template to_string<std::string>(
- std::ios::hex | std::ios::showbase | std::ios::uppercase);
- BOOST_CHECK_EQUAL(s, "0XABCDEF123456789");
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string4, int_type, IntTypes)
-{
- const int_type x("76484675");
- const std::string s = x.template to_string<std::string>(std::ios::oct);
- BOOST_CHECK_EQUAL(s, "443610103");
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string5, int_type, IntTypes)
-{
- const int_type x("1024");
- const std::string s = x.template to_string<std::string>(std::ios::oct);
- BOOST_CHECK_EQUAL(s, "2000");
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string6, int_type, IntTypes)
-{
- const int_type x("0");
- const std::string s =
- x.template to_string<std::string>(
- std::ios_base::dec | std::ios_base::showbase | std::ios_base::showpos);
- BOOST_CHECK_EQUAL(s, "+0");
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string7, int_type, IntTypes)
-{
- const int_type x("0");
- const std::string s =
- x.template to_string<std::string>(
- std::ios_base::oct | std::ios_base::showbase | std::ios_base::showpos);
- BOOST_CHECK_EQUAL(s, "+0");
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string8, int_type, IntTypes)
-{
- const int_type x("-0");
- const std::string s =
- x.template to_string<std::string>(
- std::ios_base::oct | std::ios_base::showbase | std::ios_base::showpos);
- BOOST_CHECK_EQUAL(s, "+0");
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string9, int_type, IntTypes)
-{
- const int_type x("-1");
- const std::string s =
- x.template to_string<std::string>(
- std::ios_base::hex | std::ios_base::showbase | std::ios_base::showpos);
- BOOST_CHECK_EQUAL(s, "-0x1");
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string10, int_type, IntTypes)
-{
- const int_type x("0x95a6801ce5292b9a8410e1a59dd29967");
- const std::string s =
- x.template to_string<std::string>(std::ios_base::hex);
- BOOST_CHECK_EQUAL(s, "95a6801ce5292b9a8410e1a59dd29967");
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string11, int_type, IntTypes)
-{
- const int_type x("0x12471fa56d6");
- const std::string s = x.template to_string<std::string>();
- BOOST_CHECK_EQUAL(s, "1256042682070");
-}
-
Modified: sandbox/mp_math/libs/mp_math/test/unbounded/signed/swap.cpp
==============================================================================
--- sandbox/mp_math/libs/mp_math/test/unbounded/signed/swap.cpp (original)
+++ sandbox/mp_math/libs/mp_math/test/unbounded/signed/swap.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -29,20 +29,6 @@
BOOST_CHECK_EQUAL(y, "-0xabff23742384bf892734029323819048039");
}
-#ifdef BOOST_HAS_RVALUE_REFS
-BOOST_AUTO_TEST_CASE_TEMPLATE(swap3, int_type, IntTypes)
-{
- int_type x;
- int_type y;
-
- boost::mp_math::swap(int_type("-0x1fee55d048039"), x);
- boost::mp_math::swap(y, int_type("-0x1fee55d048039"));
-
- BOOST_CHECK_EQUAL(x, "-0x1fee55d048039");
- BOOST_CHECK_EQUAL(y, "-0x1fee55d048039");
-}
-#endif
-
#include <algorithm>
BOOST_AUTO_TEST_CASE_TEMPLATE(swap4, int_type, IntTypes)
Copied: sandbox/mp_math/libs/mp_math/test/unbounded/signed/to_string.cpp (from r54215, /sandbox/mp_math/libs/mp_math/test/unbounded/signed/string_ops.cpp)
==============================================================================
--- /sandbox/mp_math/libs/mp_math/test/unbounded/signed/string_ops.cpp (original)
+++ sandbox/mp_math/libs/mp_math/test/unbounded/signed/to_string.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -94,3 +94,19 @@
BOOST_CHECK_EQUAL(s, "1256042682070");
}
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string12, int_type, IntTypes)
+{
+ const int_type x("0x123456789abcdef");
+ const std::string s = x.template to_string<std::string>(
+ std::ios_base::hex | std::ios_base::showbase);
+ BOOST_CHECK_EQUAL(s, "0x123456789abcdef");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string13, int_type, IntTypes)
+{
+ const int_type x("0x123456789ABCDEF");
+ const std::string s = x.template to_string<std::string>(
+ std::ios_base::hex | std::ios_base::showbase | std::ios_base::uppercase);
+ BOOST_CHECK_EQUAL(s, "0X123456789ABCDEF");
+}
+
Modified: sandbox/mp_math/libs/mp_math/test/unbounded/unsigned/ctors.cpp
==============================================================================
--- sandbox/mp_math/libs/mp_math/test/unbounded/unsigned/ctors.cpp (original)
+++ sandbox/mp_math/libs/mp_math/test/unbounded/unsigned/ctors.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -144,28 +144,11 @@
BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string6, uint_type, UIntTypes)
{
- const uint_type x("0x123456789abcdef");
- BOOST_CHECK_EQUAL(x.template to_string<std::string>(std::ios_base::hex |
- std::ios_base::showbase),
- "0x123456789abcdef");
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string7, uint_type, UIntTypes)
-{
- const uint_type x("0x123456789ABCDEF");
- BOOST_CHECK_EQUAL(x.template to_string<std::string>(std::ios_base::hex |
- std::ios_base::showbase |
- std::ios_base::uppercase),
- "0X123456789ABCDEF");
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string8, uint_type, UIntTypes)
-{
const uint_type x("0xA0000000");
BOOST_CHECK_EQUAL(x.template to_string<std::string>(), "2684354560");
}
-BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string9, uint_type, UIntTypes)
+BOOST_AUTO_TEST_CASE_TEMPLATE(ctor_from_hexadecimal_string7, uint_type, UIntTypes)
{
BOOST_CHECK_THROW(uint_type("0x15656abg56"), std::invalid_argument);
}
Modified: sandbox/mp_math/libs/mp_math/test/unbounded/unsigned/string_ops.cpp
==============================================================================
--- sandbox/mp_math/libs/mp_math/test/unbounded/unsigned/string_ops.cpp (original)
+++ sandbox/mp_math/libs/mp_math/test/unbounded/unsigned/string_ops.cpp 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -85,6 +85,22 @@
BOOST_CHECK_EQUAL(s, "1256042682070");
}
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string12, int_type, IntTypes)
+{
+ const int_type x("0x123456789abcdef");
+ const std::string s = x.template to_string<std::string>(
+ std::ios_base::hex | std::ios_base::showbase);
+ BOOST_CHECK_EQUAL(s, "0x123456789abcdef");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(op_to_string13, int_type, IntTypes)
+{
+ const int_type x("0x123456789ABCDEF");
+ const std::string s = x.template to_string<std::string>(
+ std::ios_base::hex | std::ios_base::showbase | std::ios_base::uppercase);
+ BOOST_CHECK_EQUAL(s, "0X123456789ABCDEF");
+}
+
BOOST_AUTO_TEST_CASE_TEMPLATE(op_assign1, uint_type, UIntTypes)
{
uint_type x;
Modified: sandbox/mp_math/libs/mp_math/tools/benchmark/jamfile.v2
==============================================================================
--- sandbox/mp_math/libs/mp_math/tools/benchmark/jamfile.v2 (original)
+++ sandbox/mp_math/libs/mp_math/tools/benchmark/jamfile.v2 2009-07-13 16:23:18 EDT (Mon, 13 Jul 2009)
@@ -19,7 +19,7 @@
# be installed for the benchmark to work
lib gmp : : <name>gmp ;
-lib tommath : tommath.cpp : <variant>release ;
+lib tommath : : <name>tommath ;
exe benchmark
:
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