mirror of
https://github.com/boostorg/integer.git
synced 2025-07-30 04:37:13 +02:00
Added missing #include <iostream>
[SVN r81697]
This commit is contained in:
committed by
Peter Dimov
parent
e394f8fd86
commit
9677dbd035
@ -11,8 +11,8 @@
|
|||||||
[last-revision $Date: 2006-12-29 11:08:32 +0000 (Fri, 29 Dec 2006) $]
|
[last-revision $Date: 2006-12-29 11:08:32 +0000 (Fri, 29 Dec 2006) $]
|
||||||
]
|
]
|
||||||
|
|
||||||
This manual is also available in
|
This manual is also available in
|
||||||
[@http://sourceforge.net/projects/boost/files/boost-docs/
|
[@http://sourceforge.net/projects/boost/files/boost-docs/
|
||||||
printer friendly PDF format].
|
printer friendly PDF format].
|
||||||
|
|
||||||
|
|
||||||
@ -20,10 +20,10 @@ printer friendly PDF format].
|
|||||||
|
|
||||||
[section Introduction]
|
[section Introduction]
|
||||||
|
|
||||||
The class and function templates in <boost/math/common_factor.hpp>
|
The class and function templates in <boost/math/common_factor.hpp>
|
||||||
provide run-time and compile-time evaluation of the greatest common divisor
|
provide run-time and compile-time evaluation of the greatest common divisor
|
||||||
(GCD) or least common multiple (LCM) of two integers.
|
(GCD) or least common multiple (LCM) of two integers.
|
||||||
These facilities are useful for many numeric-oriented generic
|
These facilities are useful for many numeric-oriented generic
|
||||||
programming problems.
|
programming problems.
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
@ -44,7 +44,7 @@ programming problems.
|
|||||||
IntegerType gcd( IntegerType const &a, IntegerType const &b );
|
IntegerType gcd( IntegerType const &a, IntegerType const &b );
|
||||||
template < typename IntegerType >
|
template < typename IntegerType >
|
||||||
IntegerType lcm( IntegerType const &a, IntegerType const &b );
|
IntegerType lcm( IntegerType const &a, IntegerType const &b );
|
||||||
|
|
||||||
typedef ``['see-below]`` static_gcd_type;
|
typedef ``['see-below]`` static_gcd_type;
|
||||||
|
|
||||||
template < static_gcd_type Value1, static_gcd_type Value2 >
|
template < static_gcd_type Value1, static_gcd_type Value2 >
|
||||||
@ -54,7 +54,7 @@ programming problems.
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
[section GCD Function Object]
|
[section GCD Function Object]
|
||||||
@ -75,16 +75,16 @@ programming problems.
|
|||||||
second_argument_type const &b ) const;
|
second_argument_type const &b ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
The boost::math::gcd_evaluator class template defines a function object
|
The boost::math::gcd_evaluator class template defines a function object
|
||||||
class to return the greatest common divisor of two integers.
|
class to return the greatest common divisor of two integers.
|
||||||
The template is parameterized by a single type, called IntegerType here.
|
The template is parameterized by a single type, called IntegerType here.
|
||||||
This type should be a numeric type that represents integers.
|
This type should be a numeric type that represents integers.
|
||||||
The result of the function object is always nonnegative, even if either of
|
The result of the function object is always nonnegative, even if either of
|
||||||
the operator arguments is negative.
|
the operator arguments is negative.
|
||||||
|
|
||||||
This function object class template is used in the corresponding version of
|
This function object class template is used in the corresponding version of
|
||||||
the GCD function template. If a numeric type wants to customize evaluations
|
the GCD function template. If a numeric type wants to customize evaluations
|
||||||
of its greatest common divisors, then the type should specialize on the
|
of its greatest common divisors, then the type should specialize on the
|
||||||
gcd_evaluator class template.
|
gcd_evaluator class template.
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
@ -107,17 +107,17 @@ gcd_evaluator class template.
|
|||||||
second_argument_type const &b ) const;
|
second_argument_type const &b ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
The boost::math::lcm_evaluator class template defines a function object
|
The boost::math::lcm_evaluator class template defines a function object
|
||||||
class to return the least common multiple of two integers. The template
|
class to return the least common multiple of two integers. The template
|
||||||
is parameterized by a single type, called IntegerType here. This type
|
is parameterized by a single type, called IntegerType here. This type
|
||||||
should be a numeric type that represents integers. The result of the
|
should be a numeric type that represents integers. The result of the
|
||||||
function object is always nonnegative, even if either of the operator
|
function object is always nonnegative, even if either of the operator
|
||||||
arguments is negative. If the least common multiple is beyond the range
|
arguments is negative. If the least common multiple is beyond the range
|
||||||
of the integer type, the results are undefined.
|
of the integer type, the results are undefined.
|
||||||
|
|
||||||
This function object class template is used in the corresponding version
|
This function object class template is used in the corresponding version
|
||||||
of the LCM function template. If a numeric type wants to customize
|
of the LCM function template. If a numeric type wants to customize
|
||||||
evaluations of its least common multiples, then the type should
|
evaluations of its least common multiples, then the type should
|
||||||
specialize on the lcm_evaluator class template.
|
specialize on the lcm_evaluator class template.
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
@ -132,13 +132,13 @@ specialize on the lcm_evaluator class template.
|
|||||||
template < typename IntegerType >
|
template < typename IntegerType >
|
||||||
IntegerType boost::math::lcm( IntegerType const &a, IntegerType const &b );
|
IntegerType boost::math::lcm( IntegerType const &a, IntegerType const &b );
|
||||||
|
|
||||||
The boost::math::gcd function template returns the greatest common
|
The boost::math::gcd function template returns the greatest common
|
||||||
(nonnegative) divisor of the two integers passed to it.
|
(nonnegative) divisor of the two integers passed to it.
|
||||||
The boost::math::lcm function template returns the least common
|
The boost::math::lcm function template returns the least common
|
||||||
(nonnegative) multiple of the two integers passed to it.
|
(nonnegative) multiple of the two integers passed to it.
|
||||||
The function templates are parameterized on the function arguments'
|
The function templates are parameterized on the function arguments'
|
||||||
IntegerType, which is also the return type. Internally, these function
|
IntegerType, which is also the return type. Internally, these function
|
||||||
templates use an object of the corresponding version of the
|
templates use an object of the corresponding version of the
|
||||||
gcd_evaluator and lcm_evaluator class templates, respectively.
|
gcd_evaluator and lcm_evaluator class templates, respectively.
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
@ -158,19 +158,19 @@ gcd_evaluator and lcm_evaluator class templates, respectively.
|
|||||||
struct boost::math::static_lcm : public mpl::integral_c<static_gcd_type, implementation_defined>
|
struct boost::math::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
|
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
|
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`
|
the same type as `boost::uintmax_t`, but may fall back to being `unsigned long`
|
||||||
for some older compilers.
|
for some older compilers.
|
||||||
|
|
||||||
The boost::math::static_gcd and boost::math::static_lcm class templates
|
The boost::math::static_gcd and boost::math::static_lcm class templates
|
||||||
take two value-based template parameters of the ['static_gcd_type] type
|
take two value-based template parameters of the ['static_gcd_type] type
|
||||||
and inherit from the type `boost::mpl::integral_c`.
|
and inherit from the type `boost::mpl::integral_c`.
|
||||||
Inherited from the base class, they have a member /value/
|
Inherited from the base class, they have a member /value/
|
||||||
that is the greatest common factor or least
|
that is the greatest common factor or least
|
||||||
common multiple, respectively, of the template arguments.
|
common multiple, respectively, of the template arguments.
|
||||||
A compile-time error will occur if the least common multiple
|
A compile-time error will occur if the least common multiple
|
||||||
is beyond the range of `static_gcd_type`.
|
is beyond the range of `static_gcd_type`.
|
||||||
|
|
||||||
[h3 Example]
|
[h3 Example]
|
||||||
@ -178,7 +178,7 @@ is beyond the range of `static_gcd_type`.
|
|||||||
#include <boost/math/common_factor.hpp>
|
#include <boost/math/common_factor.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@ -205,31 +205,31 @@ is beyond the range of `static_gcd_type`.
|
|||||||
|
|
||||||
[section:header Header <boost/math/common_factor.hpp>]
|
[section:header Header <boost/math/common_factor.hpp>]
|
||||||
|
|
||||||
This header simply includes the headers
|
This header simply includes the headers
|
||||||
[@../../../../../boost/math/common_factor_ct.hpp <boost/math/common_factor_ct.hpp>]
|
[@../../../../../boost/math/common_factor_ct.hpp <boost/math/common_factor_ct.hpp>]
|
||||||
and [@../../../../../boost/math/common_factor_rt.hpp <boost/math/common_factor_rt.hpp>].
|
and [@../../../../../boost/math/common_factor_rt.hpp <boost/math/common_factor_rt.hpp>].
|
||||||
|
|
||||||
Note this is a legacy header: it used to contain the actual implementation,
|
Note this is a legacy header: it used to contain the actual implementation,
|
||||||
but the compile-time and run-time facilities
|
but the compile-time and run-time facilities
|
||||||
were moved to separate headers (since they were independent of each other).
|
were moved to separate headers (since they were independent of each other).
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
[section:demo Demonstration Program]
|
[section:demo Demonstration Program]
|
||||||
|
|
||||||
The program [@../../../../../libs/math/test/common_factor_test.cpp common_factor_test.cpp] is a demonstration of the results from
|
The program [@../../../../../libs/math/test/common_factor_test.cpp common_factor_test.cpp] is a demonstration of the results from
|
||||||
instantiating various examples of the run-time GCD and LCM function
|
instantiating various examples of the run-time GCD and LCM function
|
||||||
templates and the compile-time GCD and LCM class templates.
|
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 GCD and LCM class templates are tested indirectly through
|
||||||
the run-time function templates.)
|
the run-time function templates.)
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
[section Rationale]
|
[section Rationale]
|
||||||
|
|
||||||
The greatest common divisor and least common multiple functions are
|
The greatest common divisor and least common multiple functions are
|
||||||
greatly used in some numeric contexts, including some of the other
|
greatly used in some numeric contexts, including some of the other
|
||||||
Boost libraries. Centralizing these functions to one header improves
|
Boost libraries. Centralizing these functions to one header improves
|
||||||
code factoring and eases maintainence.
|
code factoring and eases maintainence.
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
@ -237,16 +237,16 @@ code factoring and eases maintainence.
|
|||||||
[section History]
|
[section History]
|
||||||
|
|
||||||
* 17 Dec 2005: Converted documentation to Quickbook Format.
|
* 17 Dec 2005: Converted documentation to Quickbook Format.
|
||||||
* 2 Jul 2002: Compile-time and run-time items separated to new headers.
|
* 2 Jul 2002: Compile-time and run-time items separated to new headers.
|
||||||
* 7 Nov 2001: Initial version
|
* 7 Nov 2001: Initial version
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
[section Credits]
|
[section Credits]
|
||||||
|
|
||||||
The author of the Boost compilation of GCD and LCM computations is
|
The author of the Boost compilation of GCD and LCM computations is
|
||||||
Daryle Walker. The code was prompted by existing code hiding in the
|
Daryle Walker. The code was prompted by existing code hiding in the
|
||||||
implementations of Paul Moore's rational library and Steve Cleary's
|
implementations of Paul Moore's rational library and Steve Cleary's
|
||||||
pool library. The code had updates by Helmut Zeisel.
|
pool library. The code had updates by Helmut Zeisel.
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
Reference in New Issue
Block a user