diff --git a/doc/html/boost_integer/cstdint.html b/doc/html/boost_integer/cstdint.html deleted file mode 100644 index 5d2c1ba..0000000 --- a/doc/html/boost_integer/cstdint.html +++ /dev/null @@ -1,49 +0,0 @@ - - - -Removed from library: Standard Integer Types - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHome -
-
-

-Removed from library: Standard Integer - Types -

-

- The Boost.Config - module provides the typedefs useful for writing portable code that requires - certain integer widths. -

-
- - - -
-
-
-PrevUpHome -
- - diff --git a/doc/html/boost_integer/extended_euclidean.html b/doc/html/boost_integer/extended_euclidean.html deleted file mode 100644 index e132901..0000000 --- a/doc/html/boost_integer/extended_euclidean.html +++ /dev/null @@ -1,109 +0,0 @@ - - - -Extended Euclidean Algorithm - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
-

-Extended Euclidean Algorithm -

-
-
Introduction
-
Synopsis
-
Usage
-
References
-
-
- -

- The extended Euclidean algorithm solves the integer relation mx - + ny = gcd(m, n) for - x and y. -

-
-
- -
#include <boost/integer/extended_euclidean.hpp>
-
-namespace boost { namespace integer {
-
-template<class Z>
-struct euclidean_result_t {
-  Z gcd;
-  Z x;
-  Z y;
-};
-
-
-template<class Z>
-euclidean_result_t<Z> extended_euclidean(Z m, Z n);
-
-}}
-
-
-
-

-Usage -

-
int m = 12;
-int n = 15;
-auto res = extended_euclidean(m, n);
-
-int gcd = res.gcd;
-int x = res.x;
-int y = res.y;
-// mx + ny = gcd(m,n) should now hold
-
-

- Unlike most of the library, the extended Euclidean algorithm requires C++11 - features. -

-
-
- -

- Wagstaff, Samuel S., The Joy of Factoring, Vol. 68. - American Mathematical Soc., 2013. -

-
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/boost_integer/gcd_lcm.html b/doc/html/boost_integer/gcd_lcm.html deleted file mode 100644 index 588b98f..0000000 --- a/doc/html/boost_integer/gcd_lcm.html +++ /dev/null @@ -1,400 +0,0 @@ - - - -Greatest Common Divisor and Least Common Multiple - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
-

-Greatest Common Divisor and Least - Common Multiple -

-
-
Introduction
-
Synopsis
-
GCD Function - Object
-
LCM Function - Object
-
Run-time GCD & LCM - Determination
-
Compile time GCD - and LCM determination
-
Header <boost/integer/common_factor.hpp>
-
Demonstration Program
-
Rationale
-
History
-
Credits
-
-
- -

- The class and function templates in <boost/math/common_factor.hpp> - provide run-time and compile-time evaluation of the greatest common divisor - (GCD) or least common multiple (LCM) of two integers. These facilities are - useful for many numeric-oriented generic programming problems. -

-
-
- -
namespace boost
-{
-namespace integer
-{
-
-template < typename IntegerType >
-   class gcd_evaluator;
-template < typename IntegerType >
-   class lcm_evaluator;
-
-template < typename IntegerType >
-   constexpr IntegerType  gcd( IntegerType const &a, IntegerType const &b );
-template < typename IntegerType >
-   constexpr IntegerType  lcm( IntegerType const &a, IntegerType const &b );
-template < typename IntegerType, typename... Args >
-   constexpr IntegerType  gcd( IntegerType const &a, IntegerType const &b, Args const&... );
-template < typename IntegerType, typename... Args >
-   constexpr IntegerType  lcm( IntegerType const &a, IntegerType const &b, Args const&... );
-
-template <typename I>
-std::pair<typename std::iterator_traits<I>::value_type, I>
-   gcd_range(I first, I last);
-template <typename I>
-std::pair<typename std::iterator_traits<I>::value_type, I>
-   lcm_range(I first, I last);
-
-typedef see-below static_gcd_type;
-
-template < static_gcd_type Value1, static_gcd_type Value2 >
-   struct static_gcd;
-template < static_gcd_type Value1, static_gcd_type Value2 >
-   struct static_lcm;
-
-}
-}
-
-
-
- -

- Header: <boost/integer/common_factor_rt.hpp> -

-
template < typename IntegerType >
-class boost::integer::gcd_evaluator
-{
-public:
-   // Types
-   typedef IntegerType  result_type;
-   typedef IntegerType  first_argument_type;
-   typedef IntegerType  second_argument_type;
-
-   // Function object interface
-   constexpr result_type  operator ()(
-      first_argument_type const &a,
-      second_argument_type const &b ) const;
-};
-
-

- The boost::integer::gcd_evaluator class template defines a function object - class to return the greatest common divisor of two integers. The template - is parameterized by a single type, called IntegerType here. This type should - be a numeric type that represents integers. The result of the function object - is always nonnegative, even if either of the operator arguments is negative. -

-

- This function object class template is used in the corresponding version - of the GCD function template. If a numeric type wants to customize evaluations - of its greatest common divisors, then the type should specialize on the gcd_evaluator - class template. -

-

- Note that these function objects are constexpr - in C++14 and later only. They are also declared noexcept - when appropriate. -

-
-
- -

- Header: <boost/integer/common_factor_rt.hpp> -

-
template < typename IntegerType >
-class boost::integer::lcm_evaluator
-{
-public:
-   // Types
-   typedef IntegerType  result_type;
-   typedef IntegerType  first_argument_type;
-   typedef IntegerType  second_argument_type;
-
-   // Function object interface
-   constexpr result_type  operator ()(
-     first_argument_type const &a,
-     second_argument_type const &b ) const;
-};
-
-

- The boost::integer::lcm_evaluator class template defines a function object - class to return the least common multiple of two integers. The template is - parameterized by a single type, called IntegerType here. This type should - be a numeric type that represents integers. The result of the function object - is always nonnegative, even if either of the operator arguments is negative. - If the least common multiple is beyond the range of the integer type, the - results are undefined. -

-

- This function object class template is used in the corresponding version - of the LCM function template. If a numeric type wants to customize evaluations - of its least common multiples, then the type should specialize on the lcm_evaluator - class template. -

-

- Note that these function objects are constexpr in C++14 and later only. They - are also declared noexcept when - appropriate. -

-
-
- -

- Header: <boost/integer/common_factor_rt.hpp> -

-
template < typename IntegerType >
-constexpr IntegerType  boost::integer::gcd( IntegerType const &a, IntegerType const &b );
-
-template < typename IntegerType >
-constexpr IntegerType  boost::integer::lcm( IntegerType const &a, IntegerType const &b );
-
-template < typename IntegerType, typename... Args >
-   constexpr IntegerType  gcd( IntegerType const &a, IntegerType const &b, Args const&... );
-
-template < typename IntegerType, typename... Args >
-   constexpr IntegerType  lcm( IntegerType const &a, IntegerType const &b, Args const&... );
-
-template <typename I>
-std::pair<typename std::iterator_traits<I>::value_type, I>
-   gcd_range(I first, I last);
-
-template <typename I>
-std::pair<typename std::iterator_traits<I>::value_type, I>
-   lcm_range(I first, I last);
-
-

- The boost::integer::gcd function template returns the greatest common (nonnegative) - divisor of the two integers passed to it. boost::integer::gcd_range - is the iteration of the above gcd algorithm over a range, returning the greatest - common divisor of all the elements. The algorithm terminates when the gcd - reaches unity or the end of the range. Thus it also returns the iterator - after the last element inspected because this may not be equal to the end - of the range. The variadic version of gcd - behaves similarly but does not indicate which input value caused the gcd - to reach unity. -

-

- The boost::integer::lcm function template returns the least common (nonnegative) - multiple of the two integers passed to it. As with gcd, there are range and - variadic versions of the function for more than 2 arguments. -

-

- Note that these functions are constexpr in C++14 and later only. They are - also declared noexcept when - appropriate. -

-
-
- -
- - - - - -
[Note]Note

- These functions are deprecated in favor of constexpr gcd - and lcm on C++14 capable - compilers. -

-

- Header: <boost/integer/common_factor_ct.hpp> -

-
typedef unspecified static_gcd_type;
-
-template < static_gcd_type Value1, static_gcd_type Value2 >
-struct boost::integer::static_gcd : public mpl::integral_c<static_gcd_type, implementation_defined>
-{
-};
-
-template < static_gcd_type Value1, static_gcd_type Value2 >
-struct boost::integer::static_lcm : public mpl::integral_c<static_gcd_type, implementation_defined>
-{
-};
-
-

- The type static_gcd_type - is the widest unsigned-integer-type that is supported for use in integral-constant-expressions - by the compiler. Usually this the same type as boost::uintmax_t, - but may fall back to being unsigned - long for some older compilers. -

-

- The boost::integer::static_gcd and boost::integer::static_lcm class templates - take two value-based template parameters of the static_gcd_type - type and inherit from the type boost::mpl::integral_c. Inherited from the base class, - they have a member value that is the greatest common - factor or least common multiple, respectively, of the template arguments. - A compile-time error will occur if the least common multiple is beyond the - range of static_gcd_type. -

-

- - Example -

-
#include <boost/integer/common_factor.hpp>
-#include <algorithm>
-#include <iterator>
-#include <iostream>
-
-int main()
-{
-   using std::cout;
-   using std::endl;
-
-   cout << "The GCD and LCM of 6 and 15 are "
-   << boost::integer::gcd(6, 15) << " and "
-   << boost::integer::lcm(6, 15) << ", respectively."
-   << endl;
-
-   cout << "The GCD and LCM of 8 and 9 are "
-   << boost::integer::static_gcd<8, 9>::value
-   << " and "
-   << boost::integer::static_lcm<8, 9>::value
-   << ", respectively." << endl;
-
-   int  a[] = { 4, 5, 6 }, b[] = { 7, 8, 9 }, c[3];
-   std::transform( a, a + 3, b, c, boost::integer::gcd_evaluator<int>() );
-   std::copy( c, c + 3, std::ostream_iterator<int>(cout, " ") );
-}
-
-
-
- -

- This header simply includes the headers <boost/integer/common_factor_ct.hpp> - and <boost/integer/common_factor_rt.hpp>. -

-

- Note this is a legacy header: it used to contain the actual implementation, - but the compile-time and run-time facilities were moved to separate headers - (since they were independent of each other). -

-
-
- -

- The program common_factor_test.cpp - is a demonstration of the results from instantiating various examples of - the run-time GCD and LCM function templates and the compile-time GCD and - LCM class templates. (The run-time GCD and LCM class templates are tested - indirectly through the run-time function templates.) -

-
-
- -

- The greatest common divisor and least common multiple functions are greatly - used in some numeric contexts, including some of the other Boost libraries. - Centralizing these functions to one header improves code factoring and eases - maintenance. -

-
-
- -
    -
  • - 24th April 2017 Moved to Jeremy Murphy's improved algorithms, added constexpr - and noexcept support, added compiler intrinsic support, added variadic - and range based versions of the algorithms. -
  • -
  • - 13 May 2013 Moved into main Boost.Math Quickbook documentation. -
  • -
  • - 17 Dec 2005: Converted documentation to Quickbook Format. -
  • -
  • - 2 Jul 2002: Compile-time and run-time items separated to new headers. -
  • -
  • - 7 Nov 2001: Initial version -
  • -
-
-
- -

- The author of the Boost compilation of GCD and LCM computations is Daryle - Walker. The code was prompted by existing code hiding in the implementations - of Paul Moore's rational library and Steve Cleary's pool library. The code - had updates by Helmut Zeisel. -

-
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/boost_integer/history.html b/doc/html/boost_integer/history.html deleted file mode 100644 index 544e5d7..0000000 --- a/doc/html/boost_integer/history.html +++ /dev/null @@ -1,90 +0,0 @@ - - - -History - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
-

-History -

-
- - 1.56.0 -
-
-
- - 1.42.0 -
-
-
- - 1.32.0 -
-
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/boost_integer/integer.html b/doc/html/boost_integer/integer.html deleted file mode 100644 index 65f2558..0000000 --- a/doc/html/boost_integer/integer.html +++ /dev/null @@ -1,432 +0,0 @@ - - - -Integer Type Selection - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
-

-Integer Type Selection -

-
-
Synopsis
-
Easiest-to-Manipulate - Types
-
Sized Types
-
Example
-
Demonstration - Program
-
Rationale
-
Alternative
-
Credits
-
-

- The <boost/integer.hpp> - type selection templates allow integer types to be selected based on desired - characteristics such as number of bits or maximum value. This facility is particularly - useful for solving generic programming problems. -

-
- -
namespace boost
-{
-  //  fast integers from least integers
-  template<typename LeastInt>
-  struct int_fast_t
-  {
-      typedef implementation-defined-type  type;
-  };
-
-  //  signed
-  template<int Bits>
-  struct int_t
-  {
-      /* Member exact may or may not be defined depending upon Bits */
-      typedef implementation-defined-type  exact;
-      typedef implementation-defined-type  least;
-      typedef int_fast_t<least>::fast      fast;
-  };
-
-  //  unsigned
-  template<int Bits>
-  struct uint_t
-  {
-      /* Member exact may or may not be defined depending upon Bits */
-      typedef implementation-defined-type  exact;
-      typedef implementation-defined-type  least;
-      typedef int_fast_t<least>::fast      fast;
-  };
-
-  //  signed
-  template<long long MaxValue>
-  struct int_max_value_t
-  {
-      typedef implementation-defined-type  least;
-      typedef int_fast_t<least>::fast      fast;
-  };
-
-  template<long long MinValue>
-  struct int_min_value_t
-  {
-      typedef implementation-defined-type  least;
-      typedef int_fast_t<least>::fast      fast;
-  };
-
-  //  unsigned
-  template<unsigned long long Value>
-  struct uint_value_t
-  {
-      typedef implementation-defined-type  least;
-      typedef int_fast_t<least>::fast      fast;
-  };
-} // namespace boost
-
-
-
- -

- The int_fast_t class template maps its input type to the - next-largest type that the processor can manipulate the easiest, or to itself - if the input type is already an easy-to-manipulate type. For instance, processing - a bunch of char objects may go faster if they were converted - to int objects before processing. The input type, passed - as the only template parameter, must be a built-in integral type, except - bool. Unsigned integral types can be used, as well as - signed integral types. The output type is given as the nested type fast. -

-

- Implementation Notes: By default, the output - type is identical to the input type. Eventually, this code's implementation - should be customized for each platform to give accurate mappings between - the built-in types and the easiest-to-manipulate built-in types. Also, there - is no guarantee that the output type actually is easier to manipulate than - the input type. -

-
-
- -

- The int_t, uint_t, int_max_value_t, - int_min_value_t, and uint_value_t class - templates find the most appropiate built-in integral type for the given template - parameter. This type is given by the nested type least. - The easiest-to-manipulate version of that type is given by the nested type - fast. The following table describes each template's criteria. -

-
-

Table 1. Criteria for the Sized Type Class Templates

-
---- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

- Class Template -

-
-

- Template Parameter Mapping -

-
-

- boost::int_t<N>::least -

-
-

- The smallest, built-in, signed integral type with at least N - bits, including the sign bit. The parameter should be a positive - number. A compile-time error results if the parameter is larger - than the number of bits in the largest integer type. -

-
-

- boost::int_t<N>::fast -

-
-

- The easiest-to-manipulate, built-in, signed integral type with - at least N bits, including the sign bit. The - parameter should be a positive number. A compile-time error results - if the parameter is larger than the number of bits in the largest - integer type. -

-
-

- boost::int_t<N>::exact -

-
-

- A built-in, signed integral type with exactly N - bits, including the sign bit. The parameter should be a positive - number. Note that the member exact is defined - only if there exists a type with - exactly N bits. -

-
-

- boost::uint_t<N>::least -

-
-

- The smallest, built-in, unsigned integral type with at least N - bits. The parameter should be a positive number. A compile-time - error results if the parameter is larger than the number of bits - in the largest integer type. -

-
-

- boost::uint_t<N>::fast -

-
-

- The easiest-to-manipulate, built-in, unsigned integral type with - at least N bits. The parameter should be a - positive number. A compile-time error results if the parameter - is larger than the number of bits in the largest integer type. -

-
-

- boost::uint_t<N>::exact -

-
-

- A built-in, unsigned integral type with exactly N - bits. The parameter should be a positive number. A compile-time - error results if the parameter is larger than the number of bits - in the largest integer type. Note that the member exact - is defined only if there exists - a type with exactly N bits. -

-
-

- boost::int_max_value_t<V>::last -

-
-

- The smallest, built-in, signed integral type that can hold all - the values in the inclusive range 0 - V. The - parameter should be a positive number. -

-
-

- boost::int_max_value_t<V>::fast -

-
-

- The easiest-to-manipulate, built-in, signed integral type that - can hold all the values in the inclusive range 0 - V. - The parameter should be a positive number. -

-
-

- boost::int_min_value_t<V>::least -

-
-

- The smallest, built-in, signed integral type that can hold all - the values in the inclusive range V - 0. The - parameter should be a negative number. -

-
-

- boost::int_min_value_t<V>::fast -

-
-

- The easiest-to-manipulate, built-in, signed integral type that - can hold all the values in the inclusive range V - 0. - The parameter should be a negative number. -

-
-

- boost::uint_value_t<V>::least -

-
-

- The smallest, built-in, unsigned integral type that can hold all - positive values up to and including V. The - parameter should be a positive number. -

-
-

- boost::uint_value_t<V>::fast -

-
-

- The easiest-to-manipulate, built-in, unsigned integral type that - can hold all positive values up to and including V. - The parameter should be a positive number. -

-
-
-
-
-
- -
#include <boost/integer.hpp>
-
-//...
-
-int main()
-{
-    boost::int_t<24>::least my_var;  // my_var has at least 24-bits
-    //...
-    // This one is guaranteed not to be truncated:
-    boost::int_max_value_t<1000>::least my1000 = 1000;
-    //...
-    // This one is guaranteed not to be truncated, and as fast
-    // to manipulate as possible, its size may be greater than
-    // that of my1000:
-    boost::int_max_value_t<1000>::fast my_fast1000 = 1000;
-}
-
-
-
- -

- The program integer_test.cpp - is a simplistic demonstration of the results from instantiating various examples - of the sized type class templates. -

-
-
- -

- The rationale for the design of the templates in this header includes: -

-
    -
  • - Avoid recursion because of concern about C++'s limited guaranteed recursion - depth (17). -
  • -
  • - Avoid macros on general principles. -
  • -
  • - Try to keep the design as simple as possible. -
  • -
-
-
- -

- If the number of bits required is known beforehand, it may be more appropriate - to use the types supplied in <boost/cstdint.hpp>. -

-
-
- -

- The author of most of the Boost integer type choosing templates is Beman Dawes. He - gives thanks to Valentin Bonnard and Kevlin - Henney for sharing their designs for similar templates. Daryle - Walker designed the value-based sized templates. -

-
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/boost_integer/log2.html b/doc/html/boost_integer/log2.html deleted file mode 100644 index 685969c..0000000 --- a/doc/html/boost_integer/log2.html +++ /dev/null @@ -1,151 +0,0 @@ - - - -Compile Time log2 Calculation - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
-

-Compile Time log2 Calculation -

-
-
Synopsis
-
Usage
-
Demonstration - Program
-
Rationale
-
Credits
-
-

- The class template in <boost/integer/static_log2.hpp> - determines the position of the highest bit in a given value. This facility - is useful for solving generic programming problems. -

-
- -
namespace boost
-{
-
-  typedef implementation-defined static_log2_argument_type;
-  typedef implementation-defined static_log2_result_type;
-
-  template <static_log2_argument_type arg>
-  struct static_log2
-  {
-    static const static_log2_result_type value = implementation-defined;
-  };
-
-
-  template < >
-  struct static_log2< 0 >
-  {
-    // The logarithm of zero is undefined.
-  };
-
-
-}  // namespace boost
-
-
-
-

-Usage -

-

- The boost::static_log2 class template takes one template - parameter, a value of type static_log2_argument_type. - The template only defines one member, value, which gives - the truncated, base-two logarithm of the template argument. -

-

- Since the logarithm of zero, for any base, is undefined, there is a specialization - of static_log2 for a template argument of zero. This specialization - has no members, so an attempt to use the base-two logarithm of zero results - in a compile-time error. -

-

- Note: -

-
    -
  • - static_log2_argument_type is an unsigned - integer type (C++ standard, 3.9.1p3). -
  • -
  • - static_log2_result_type is an integer type - (C++ standard, 3.9.1p7). -
  • -
-
-
- -

- The program static_log2_test.cpp - is a simplistic demonstration of the results from instantiating various examples - of the binary logarithm class template. -

-
-
- -

- The base-two (binary) logarithm, abbreviated lb, function is occasionally - used to give order-estimates of computer algorithms. The truncated logarithm - can be considered the highest power-of-two in a value, which corresponds - to the value's highest set bit (for binary integers). Sometimes the highest-bit - position could be used in generic programming, which requires the position - to be available statically (i.e. at compile-time). -

-
-
- -

- The original version of the Boost binary logarithm class template was written - by Daryle Walker - and then enhanced by Giovanni Bajo with support for compilers without partial - template specialization. The current version was suggested, together with - a reference implementation, by Vesa Karvonen. Gennaro Prota wrote the actual - source file. -

-
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/boost_integer/mask.html b/doc/html/boost_integer/mask.html deleted file mode 100644 index 030ace0..0000000 --- a/doc/html/boost_integer/mask.html +++ /dev/null @@ -1,380 +0,0 @@ - - - -Integer Masks - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
-

-Integer Masks -

-
-
Overview
-
Synopsis
-
Single - Bit-Mask Class Template
-
Group - Bit-Mask Class Template
-
Implementation - Notes
-
Example
-
Demonstration - Program
-
Rationale
-
Credits
-
-
- -

- The class templates in <boost/integer/integer_mask.hpp> - provide bit masks for a certain bit position or a contiguous-bit pack of - a certain size. The types of the masking constants come from the integer - type selection templates header. -

-
-
- -
#include <cstddef>  // for std::size_t
-
-namespace boost
-{
-
-template <std::size_t Bit>
-struct high_bit_mask_t
-{
-    typedef implementation-defined-type  least;
-    typedef implementation-defined-type  fast;
-
-    static const least       high_bit       = implementation-defined;
-    static const fast        high_bit_fast  = implementation-defined;
-
-    static const std::size_t bit_position   = Bit;
-};
-
-template <std::size_t Bits>
-struct low_bits_mask_t
-{
-    typedef implementation-defined-type  least;
-    typedef implementation-defined-type  fast;
-
-    static const least       sig_bits       = implementation-defined;
-    static const fast        sig_bits_fast  = implementation-defined;
-
-    static const std::size_t bit_count      = Bits;
-};
-
-// Specializations for low_bits_mask_t exist for certain bit counts.
-
-}  // namespace boost
-
-
-
- -

- The boost::high_bit_mask_t class template provides constants - for bit masks representing the bit at a certain position. The masks are equivalent - to the value 2Bit, where Bit is the template parameter. - The bit position must be a nonnegative number from zero to Max, - where Max is one less than the number of bits supported by the largest unsigned - built-in integral type. The following table describes the members of an instantiation - of high_bit_mask_t. -

-
-

Table 2. Members of the boost::high_bit_mask_t - Class Template

-
---- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

- Member -

-
-

- Meaning -

-
-

- least -

-
-

- The smallest, unsigned, built-in type that supports the given bit - position. -

-
-

- fast -

-
-

- The easiest-to-manipulate analog of least. -

-
-

- high_bit -

-
-

- A least constant of the value 2Bit. -

-
-

- high_bit_fast -

-
-

- A fast analog of high_bit. -

-
-

- bit_position -

-
-

- The value of the template parameter, in case its needed from a - renamed instantiation of the class template. -

-
-
-
-
-
- -

- The boost::low_bits_mask_t class template provides constants - for bit masks equivalent to the value (2Bits - 1), where Bits - is the template parameter. The parameter Bits must be - a non-negative integer from zero to Max, where Max is - the number of bits supported by the largest, unsigned, built-in integral - type. The following table describes the members of low_bits_mask_t. -

-
-

Table 3. Members of the boost::low_bits_mask_t Class Template

-
---- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

- Member -

-
-

- Meaning -

-
-

- least -

-
-

- The smallest, unsigned built-in type that supports the given bit - count. -

-
-

- fast -

-
-

- The easiest-to-manipulate analog of least. -

-
-

- sig_bits -

-
-

- A least constant of the desired bit-masking - value. -

-
-

- sig_bits_fast -

-
-

- A fast analog of sig_bits. -

-
-

- bit_count -

-
-

- The value of the template parameter, in case its needed from a - renamed instantiation of the class template. -

-
-
-
-
-
- -

- When Bits is the exact size of a built-in unsigned type, - the implementation has to change to prevent undefined behavior. Therefore, - there are specializations of low_bits_mask_t at those - bit counts. -

-
-
- -
#include <boost/integer/integer_mask.hpp>
-
-//...
-
-int main()
-{
-    typedef boost::high_bit_mask_t<29>  mask1_type;
-    typedef boost::low_bits_mask_t<15>  mask2_type;
-
-    mask1_type::least  my_var1;
-    mask2_type::fast   my_var2;
-    //...
-
-    my_var1 |= mask1_type::high_bit;
-    my_var2 &= mask2_type::sig_bits_fast;
-
-    //...
-}
-
-
-
- -

- The program integer_mask_test.cpp - is a simplistic demonstration of the results from instantiating various examples - of the bit mask class templates. -

-
-
- -

- The class templates in this header are an extension of the integer - type selection class templates. The new class templates provide the - same sized types, but also convenient masks to use when extracting the highest - or all the significant bits when the containing built-in type contains more - bits. This prevents contamination of values by the higher, unused bits. -

-
-
- -

- The author of the Boost bit mask class templates is Daryle - Walker. -

-
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/boost_integer/minmax.html b/doc/html/boost_integer/minmax.html deleted file mode 100644 index d12ad1a..0000000 --- a/doc/html/boost_integer/minmax.html +++ /dev/null @@ -1,160 +0,0 @@ - - - -Compile time min/max calculation - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
-

-Compile time min/max calculation -

-
-
Synopsis
-
Usage
-
Example
-
Demonstration - Program
-
Rationale
-
Credits
-
-

- The class templates in <boost/integer/static_min_max.hpp> - provide a compile-time evaluation of the minimum or maximum of two integers. - These facilities are useful for generic programming problems. -

-
- -
namespace boost
-{
-
-typedef implementation-defined static_min_max_signed_type;
-typedef implementation-defined static_min_max_unsigned_type;
-
-template <static_min_max_signed_type Value1, static_min_max_signed_type Value2 >
-    struct static_signed_min;
-
-template <static_min_max_signed_type Value1, static_min_max_signed_type Value2>
-    struct static_signed_max;
-
-template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
-    struct static_unsigned_min;
-
-template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
-    struct static_unsigned_max;
-
-}
-
-
-
-

-Usage -

-

- The four class templates provide the combinations for finding the minimum - or maximum of two signed or unsigned - (long) parameters, Value1 and Value2, - at compile-time. Each template has a single static data member, value, - which is set to the respective minimum or maximum of the template's parameters. -

-
-
- -
#include <boost/integer/static_min_max.hpp>
-
-template < unsigned long AddendSize1, unsigned long AddendSize2 >
-class adder
-{
-public:
-    static  unsigned long  const  addend1_size = AddendSize1;
-    static  unsigned long  const  addend2_size = AddendSize2;
-    static  unsigned long  const  sum_size = boost::static_unsigned_max<AddendSize1, AddendSize2>::value + 1;
-
-    typedef int  addend1_type[ addend1_size ];
-    typedef int  addend2_type[ addend2_size ];
-    typedef int  sum_type[ sum_size ];
-
-    void  operator ()( addend1_type const &a1, addend2_type const &a2, sum_type &s ) const;
-};
-
-//...
-
-int main()
-{
-    int const   a1[] = { 0, 4, 3 };  // 340
-    int const   a2[] = { 9, 8 };     //  89
-    int         s[ 4 ];
-    adder<3,2>  obj;
-
-    obj( a1, a2, s );  // 's' should be 429 or { 9, 2, 4, 0 }
-    //...
-}
-
-
-
- -

- The program static_min_max_test.cpp - is a simplistic demonstration of various comparisons using the compile-time - extrema class templates. -

-
-
- -

- Sometimes the minimum or maximum of several values needs to be found for - later compile-time processing, e.g. for a bound for - another class template. -

-
-
- -

- The author of the Boost compile-time extrema class templates is Daryle - Walker. -

-
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/boost_integer/mod_inverse.html b/doc/html/boost_integer/mod_inverse.html deleted file mode 100644 index abdffc9..0000000 --- a/doc/html/boost_integer/mod_inverse.html +++ /dev/null @@ -1,105 +0,0 @@ - - - -Modular Multiplicative Inverse - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
-

-Modular Multiplicative Inverse -

-
-
Introduction
-
Synopsis
-
Usage
-
References
-
-
- -

- The modular multiplicative inverse of a number a is - that number x which satisfies ax - = 1 mod p. A fast algorithm for computing modular multiplicative - inverses based on the extended Euclidean algorithm exists and is provided - by Boost. -

-
-
- -
#include <boost/integer/mod_inverse.hpp>
-
-namespace boost { namespace integer {
-
-template<class Z>
-boost::optional<Z> mod_inverse(Z a, Z m);
-
-}}
-
-
-
-

-Usage -

-

- Multiplicative modular inverses exist if and only if a - and m are coprime. So for example -

-
auto x = mod_inverse(2, 5);
-if (x)
-{
-    int should_be_three = x.value();
-}
-auto y = mod_inverse(2, 4);
-if (!y)
-{
-    std::cout << "There is no inverse of 2 mod 4\n";
-}
-
-
-
- -

- Wagstaff, Samuel S., The Joy of Factoring, Vol. 68. - American Mathematical Soc., 2013. -

-
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/boost_integer/traits.html b/doc/html/boost_integer/traits.html deleted file mode 100644 index 677eb23..0000000 --- a/doc/html/boost_integer/traits.html +++ /dev/null @@ -1,215 +0,0 @@ - - - -Integer Traits - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
-

-Integer Traits -

-
-
Motivation
-
Synopsis
-
Description
-
Test Program
-
Acknowledgements
-
-
- -

- The C++ Standard Library <limits> header supplies a class template - numeric_limits<> - with specializations for each fundamental type. -

-

- For integer types, the interesting members of std::numeric_limits<> are: -

-
static const bool is_specialized;      // Will be true for integer types.
-static T min() throw();                // Smallest representable value.
-static T max() throw();                // Largest representable value.
-static const int digits;               // For integers, the number of value bits.
-static const int digits10;             // The number of base 10 digits that can be represented.
-static const bool is_signed;           // True if the type is signed.
-static const bool is_integer;          // Will be true for all integer types.
-
-

- For many uses, these are sufficient. But min() and max() are problematical - because they are not constant expressions (std::5.19), yet some usages require - constant expressions. -

-

- The template class integer_traits addresses this problem. -

-
-
- -
namespace boost {
-  template<class T>
-  class integer_traits : public std::numeric_limits<T>
-  {
-  public:
-     static const bool is_integral = false;
-     //
-     // These members are defined only if T is a built-in
-     // integal type:
-     //
-     static const T const_min = implementation-defined;
-     static const T const_max = implementation-defined;
-  };
-}
-
-
-
- -

- Template class integer_traits is derived from std::numeric_limits. - The primary specialization adds the single bool member - is_integral with the compile-time constant value false. - However, for all integral types T (std::3.9.1/7 [basic.fundamental]), - there are specializations provided with the following compile-time constants - defined: -

-
----- - - - - - - - - - - - - - - - - - - - - - - -
-

- member -

-
-

- type -

-
-

- value -

-
-

- is_integral -

-
-

- bool -

-
-

- true -

-
-

- const_min -

-
-

- T -

-
-

- equivalent to std::numeric_limits<T>::min() -

-
-

- const_max -

-
-

- T -

-
-

- equivalent to std::numeric_limits<T>::max() -

-
-

- Note: The is_integral flag is provided, because a user-defined - integer class should specialize std::numeric_limits<>::is_integer - = true, while compile-time constants const_min - and const_max are not provided for that user-defined class, - unless boost::integer_traits is also specialized. -

-
-
- -

- The program integer_traits_test.cpp - exercises the integer_traits class. -

-
-
- -

- Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers discussed the integer - traits idea on the boost mailing list in August 1999. -

-
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/index.html b/doc/html/index.html deleted file mode 100644 index 5954497..0000000 --- a/doc/html/index.html +++ /dev/null @@ -1,291 +0,0 @@ - - - -Boost.Integer - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
Next
-
-
-
-

-Boost.Integer

-
-

-Beman Dawes -

-

-Daryle Walker -

-

-Gennaro Prota -

-

-John Maddock -

-
-
-
-

- Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -

-
-
-
-
-
-

Table of Contents

-
-
Overview
-
Integer Traits
-
Integer Type Selection
-
Greatest Common Divisor and Least - Common Multiple
-
Extended Euclidean Algorithm
-
Modular Multiplicative Inverse
-
Integer Masks
-
Compile Time log2 Calculation
-
Compile time min/max calculation
-
History
-
Removed from library: Standard Integer - Types
-
-
-
- -

- Boost.Integer provides integer type support, particularly helpful in generic - programming. It provides the means to select an integer type based upon its - properties, like the number of bits or the maximum supported value, as well - as compile-time bit mask selection. There is a derivative of std::numeric_limits - that provides integral constant expressions for min - and max. Finally, it provides - two compile-time algorithms: determining the highest power of two in a compile-time - value; and computing min and max of constant expressions. -

-
----- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

- Component -

-
-

- Header -

-
-

- Purpose -

-
-

- Forward Declarations. -

-
-

- <boost/integer_fwd.hpp> -

-
-

- Forward declarations of classes and class templates - for use when - just the name of a class is needed. -

-
-

- Integer Traits. -

-
-

- <boost/integer_traits.hpp> -

-
-

- Class template boost::integer_traits, derives - from std::numeric_limits and adds const_min - and const_max members. -

-
-

- Integer Type Selection. -

-
-

- <boost/integer.hpp> -

-
-

- Templates for integer type selection based on properties such as - maximum value or number of bits: Use to select the type of an integer - when some property such as maximum value or number of bits is known. - Useful for generic programming. -

-
-

- Greatest Common Divisor and - Least Common Multiple. -

-
-

- <boost/integer/common_factor_rt.hpp> - and <boost/integer/common_factor_ct.hpp> -

-
-

- Functions gcd and - lcm plus function - objects and compile time versions. -

-
-

- Integer Masks. -

-
-

- <boost/integer/integer_mask.hpp> -

-
-

- Templates for the selection of integer masks, single or lowest group, - based on the number of bits: Use to select a particular mask when - the bit position(s) are based on a compile-time variable. Useful - for generic programming. -

-
-

- Compile time log2 Calculation. -

-
-

- <boost/integer/static_log2.hpp> -

-
-

- Template for finding the highest power of two in a number: Use to - find the bit-size/range based on a maximum value. Useful for generic - programming. -

-
-

- Compile time min/max calculation. -

-
-

- <boost/integer/static_min_max.hpp> -

-
-

- Templates for finding the extrema of two numbers: Use to find a bound - based on a minimum or maximum value. Useful for generic programming. -

-
-

- Extended Euclidean - algorithm. -

-
-

- <boost/integer/extended_euclidean.hpp> -

-
-

- Solves mx + ny = gcd(x,y) for x - and y. -

-
-

- Modular multiplicative - inverse. -

-
-

- <boost/integer/mod_inverse.hpp> -

-
-

- Given a and m, solves - ax = 1 mod m for x. -

-
-
-
- - - -

Last revised: November 02, 2018 at 19:38:28 GMT

-
-
Next
- - diff --git a/doc/modular_arithmetic/extended_euclidean.qbk b/doc/modular_arithmetic/extended_euclidean.qbk index fb3dc57..097dba2 100644 --- a/doc/modular_arithmetic/extended_euclidean.qbk +++ b/doc/modular_arithmetic/extended_euclidean.qbk @@ -38,8 +38,6 @@ The extended Euclidean algorithm solves the integer relation /mx + ny/ = gcd(/m/ int y = res.y; // mx + ny = gcd(m,n) should now hold -Unlike most of the library, the extended Euclidean algorithm requires C++11 features. - [endsect] [section References] diff --git a/include/boost/integer/extended_euclidean.hpp b/include/boost/integer/extended_euclidean.hpp index 83d9a71..6326a1f 100644 --- a/include/boost/integer/extended_euclidean.hpp +++ b/include/boost/integer/extended_euclidean.hpp @@ -9,6 +9,8 @@ #include #include #include +#include +#include namespace boost { namespace integer { @@ -16,27 +18,27 @@ namespace boost { namespace integer { // Solves mx + ny = gcd(m,n). Returns tuple with (gcd(m,n), x, y). template -struct euclidean_result_t { - Z gcd; - Z x; - Z y; +struct euclidean_result_t +{ + Z gcd; + Z x; + Z y; }; template -euclidean_result_t::is_signed, Z>::type> +typename boost::enable_if_c< std::numeric_limits< Z >::is_signed, euclidean_result_t< Z > >::type extended_euclidean(Z m, Z n) { if (m < 1 || n < 1) { - BOOST_THROW_EXCEPTION(std::domain_error("Arguments must be strictly positive.")); + BOOST_THROW_EXCEPTION(std::domain_error("extended_euclidean: arguments must be strictly positive")); } bool swapped = false; if (m < n) { - swapped = true; - using std::swap; - swap(m, n); + swapped = true; + boost::swap(m, n); } Z u0 = m; Z u1 = 1; @@ -49,23 +51,32 @@ extended_euclidean(Z m, Z n) Z w2; while(v0 > 0) { - Z q = u0/v0; - w0 = u0 - q*v0; - w1 = u1 - q*v1; - w2 = u2 - q*v2; - u0 = v0; - u1 = v1; - u2 = v2; - v0 = w0; - v1 = w1; - v2 = w2; + Z q = u0/v0; + w0 = u0 - q*v0; + w1 = u1 - q*v1; + w2 = u2 - q*v2; + u0 = v0; + u1 = v1; + u2 = v2; + v0 = w0; + v1 = w1; + v2 = w2; } - if (swapped) + euclidean_result_t< Z > result; + result.gcd = u0; + if (!swapped) { - return {u0, u2, u1}; + result.x = u1; + result.y = u2; } - return {u0, u1, u2}; + else + { + result.x = u2; + result.y = u1; + } + + return result; } }} diff --git a/include/boost/integer/mod_inverse.hpp b/include/boost/integer/mod_inverse.hpp index d57cbcc..1aad4a1 100644 --- a/include/boost/integer/mod_inverse.hpp +++ b/include/boost/integer/mod_inverse.hpp @@ -24,7 +24,7 @@ Z mod_inverse(Z a, Z modulus) { if (modulus < Z(2)) { - BOOST_THROW_EXCEPTION(std::domain_error("Modulus must be > 1.")); + BOOST_THROW_EXCEPTION(std::domain_error("mod_inverse: modulus must be > 1")); } // make sure a < modulus: a = a % modulus; @@ -33,7 +33,7 @@ Z mod_inverse(Z a, Z modulus) // a doesn't have a modular multiplicative inverse: return Z(0); } - euclidean_result_t u = extended_euclidean(a, modulus); + boost::integer::euclidean_result_t u = extended_euclidean(a, modulus); if (u.gcd > Z(1)) { return Z(0); diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index a0a8dd7..b1057d6 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -17,8 +17,8 @@ test-suite integer [ run integer_mask_test.cpp ] [ run static_log2_test.cpp ] [ run static_min_max_test.cpp ] - [ run extended_euclidean_test.cpp : : : [ requires cxx11_unified_initialization_syntax sfinae_expr ] ] - [ run mod_inverse_test.cpp : : : [ requires cxx11_unified_initialization_syntax sfinae_expr ] ] + [ run extended_euclidean_test.cpp ] + [ run mod_inverse_test.cpp ] [ compile integer_traits_include_test.cpp ] [ compile integer_include_test.cpp ] [ compile integer_mask_include_test.cpp ] diff --git a/test/common_factor_test.cpp b/test/common_factor_test.cpp index b54919e..682d55b 100644 --- a/test/common_factor_test.cpp +++ b/test/common_factor_test.cpp @@ -34,11 +34,7 @@ #include #endif -#if (defined(BOOST_MSVC) && (BOOST_MSVC < 1500)) || \ - (defined(__clang_major__) && (__clang_major__ == 3) && (__clang_minor__ < 2)) || \ - (defined(BOOST_GCC) && defined(BOOST_GCC_CXX11) && BOOST_GCC < 40800) -#define DISABLE_MP_TESTS -#endif +#include "multiprecision_config.hpp" #ifndef DISABLE_MP_TESTS #include diff --git a/test/extended_euclidean_test.cpp b/test/extended_euclidean_test.cpp index 2978083..8299a25 100644 --- a/test/extended_euclidean_test.cpp +++ b/test/extended_euclidean_test.cpp @@ -4,18 +4,15 @@ * 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 -#if (defined(BOOST_MSVC) && (BOOST_MSVC < 1500)) || \ - (defined(__clang_major__) && (__clang_major__ == 3) && (__clang_minor__ < 2)) || \ - (defined(BOOST_GCC) && defined(BOOST_GCC_CXX11) && BOOST_GCC < 40800) -#define DISABLE_MP_TESTS -#endif + +#include "multiprecision_config.hpp" #ifndef DISABLE_MP_TESTS +#include +#include #include #include #include -#include using boost::multiprecision::int128_t; using boost::multiprecision::int256_t; @@ -46,9 +43,9 @@ void test_extended_euclidean() int main() { - test_extended_euclidean(); - test_extended_euclidean(); - test_extended_euclidean(); + test_extended_euclidean(); + test_extended_euclidean(); + test_extended_euclidean(); test_extended_euclidean(); return boost::report_errors();; diff --git a/test/mod_inverse_test.cpp b/test/mod_inverse_test.cpp index 8c99b4d..729bbb3 100644 --- a/test/mod_inverse_test.cpp +++ b/test/mod_inverse_test.cpp @@ -4,18 +4,16 @@ * 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 -#if (defined(BOOST_MSVC) && (BOOST_MSVC < 1500)) || \ - (defined(__clang_major__) && (__clang_major__ == 3) && (__clang_minor__ < 2)) || \ - (defined(BOOST_GCC) && defined(BOOST_GCC_CXX11) && BOOST_GCC < 40800) -#define DISABLE_MP_TESTS -#endif + +#include "multiprecision_config.hpp" #ifndef DISABLE_MP_TESTS +#include +#include +#include #include #include #include -#include using boost::multiprecision::int128_t; using boost::multiprecision::int256_t; @@ -58,9 +56,9 @@ void test_mod_inverse() int main() { - test_mod_inverse(); - test_mod_inverse(); - test_mod_inverse(); + test_mod_inverse(); + test_mod_inverse(); + test_mod_inverse(); test_mod_inverse(); return boost::report_errors(); diff --git a/test/multiprecision_config.hpp b/test/multiprecision_config.hpp new file mode 100644 index 0000000..e423111 --- /dev/null +++ b/test/multiprecision_config.hpp @@ -0,0 +1,18 @@ +// Copyright (c) 2018 Andrey Semashev +// +// Use, modification, and distribution is subject to 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) + +#ifndef BOOST_INTEGER_TEST_MULTIPRECISION_CONFIG_HPP_INCLUDED_ +#define BOOST_INTEGER_TEST_MULTIPRECISION_CONFIG_HPP_INCLUDED_ + +#include + +#if (defined(BOOST_MSVC) && (BOOST_MSVC < 1500)) || \ + (defined(__clang_major__) && (__clang_major__ == 3) && (__clang_minor__ < 2)) || \ + (defined(BOOST_GCC) && defined(BOOST_GCC_CXX11) && BOOST_GCC < 40800) +#define DISABLE_MP_TESTS +#endif + +#endif // BOOST_INTEGER_TEST_MULTIPRECISION_CONFIG_HPP_INCLUDED_