mirror of
https://github.com/boostorg/integer.git
synced 2025-07-30 04:37:13 +02:00
Replace math with integer, untabify.
This commit is contained in:
@ -7,10 +7,10 @@
|
|||||||
|
|
||||||
// See http://www.boost.org for updates, documentation, and revision history.
|
// See http://www.boost.org for updates, documentation, and revision history.
|
||||||
|
|
||||||
#ifndef BOOST_MATH_COMMON_FACTOR_HPP
|
#ifndef BOOST_INTEGER_COMMON_FACTOR_HPP
|
||||||
#define BOOST_MATH_COMMON_FACTOR_HPP
|
#define BOOST_INTEGER_COMMON_FACTOR_HPP
|
||||||
|
|
||||||
#include <boost/math/common_factor_ct.hpp>
|
#include <boost/integer/common_factor_ct.hpp>
|
||||||
#include <boost/math/common_factor_rt.hpp>
|
#include <boost/integer/common_factor_rt.hpp>
|
||||||
|
|
||||||
#endif // BOOST_MATH_COMMON_FACTOR_HPP
|
#endif // BOOST_INTEGER_COMMON_FACTOR_HPP
|
||||||
|
@ -7,16 +7,15 @@
|
|||||||
|
|
||||||
// See http://www.boost.org for updates, documentation, and revision history.
|
// See http://www.boost.org for updates, documentation, and revision history.
|
||||||
|
|
||||||
#ifndef BOOST_MATH_COMMON_FACTOR_CT_HPP
|
#ifndef BOOST_INTEGER_COMMON_FACTOR_CT_HPP
|
||||||
#define BOOST_MATH_COMMON_FACTOR_CT_HPP
|
#define BOOST_INTEGER_COMMON_FACTOR_CT_HPP
|
||||||
|
|
||||||
#include <boost/math_fwd.hpp> // self include
|
#include <boost/integer_fwd.hpp> // self include
|
||||||
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT, etc.
|
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT, etc.
|
||||||
#include <boost/mpl/integral_c.hpp>
|
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace math
|
namespace integer
|
||||||
{
|
{
|
||||||
|
|
||||||
// Implementation details --------------------------------------------------//
|
// Implementation details --------------------------------------------------//
|
||||||
@ -76,22 +75,28 @@ namespace detail
|
|||||||
|
|
||||||
// Compile-time greatest common divisor evaluator class declaration --------//
|
// Compile-time greatest common divisor evaluator class declaration --------//
|
||||||
|
|
||||||
template < static_gcd_type Value1, static_gcd_type Value2 >
|
template < static_gcd_type Value1, static_gcd_type Value2 > struct static_gcd
|
||||||
struct static_gcd : public mpl::integral_c<static_gcd_type, (detail::static_gcd_helper_t<Value1, Value2>::value) >
|
|
||||||
{
|
{
|
||||||
}; // boost::math::static_gcd
|
BOOST_STATIC_CONSTANT( static_gcd_type, value = (detail::static_gcd_helper_t<Value1, Value2>::value) );
|
||||||
|
}; // boost::integer::static_gcd
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
|
||||||
|
template< static_gcd_type Value1, static_gcd_type Value2 > static_gcd_type const static_gcd< Value1, Value2 >::value;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Compile-time least common multiple evaluator class declaration ----------//
|
// Compile-time least common multiple evaluator class declaration ----------//
|
||||||
|
|
||||||
template < static_gcd_type Value1, static_gcd_type Value2 >
|
template < static_gcd_type Value1, static_gcd_type Value2 > struct static_lcm
|
||||||
struct static_lcm : public mpl::integral_c<static_gcd_type, (detail::static_lcm_helper_t<Value1, Value2>::value) >
|
|
||||||
{
|
{
|
||||||
}; // boost::math::static_lcm
|
BOOST_STATIC_CONSTANT( static_gcd_type, value = (detail::static_lcm_helper_t<Value1, Value2>::value) );
|
||||||
|
}; // boost::integer::static_lcm
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
|
||||||
|
template< static_gcd_type Value1, static_gcd_type Value2 > static_gcd_type const static_lcm< Value1, Value2 >::value;
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace math
|
} // namespace integer
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
|
||||||
#endif // BOOST_MATH_COMMON_FACTOR_CT_HPP
|
#endif // BOOST_INTEGER_COMMON_FACTOR_CT_HPP
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
|
|
||||||
// See http://www.boost.org for updates, documentation, and revision history.
|
// See http://www.boost.org for updates, documentation, and revision history.
|
||||||
|
|
||||||
#ifndef BOOST_MATH_COMMON_FACTOR_RT_HPP
|
#ifndef BOOST_INTEGER_COMMON_FACTOR_RT_HPP
|
||||||
#define BOOST_MATH_COMMON_FACTOR_RT_HPP
|
#define BOOST_INTEGER_COMMON_FACTOR_RT_HPP
|
||||||
|
|
||||||
#include <boost/math_fwd.hpp> // self include
|
#include <boost/integer_fwd.hpp> // self include
|
||||||
|
|
||||||
#include <boost/config.hpp> // for BOOST_NESTED_TEMPLATE, etc.
|
#include <boost/config.hpp> // for BOOST_NESTED_TEMPLATE, etc.
|
||||||
#include <boost/limits.hpp> // for std::numeric_limits
|
#include <boost/limits.hpp> // for std::numeric_limits
|
||||||
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace math
|
namespace integer
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ public:
|
|||||||
result_type operator ()( first_argument_type const &a,
|
result_type operator ()( first_argument_type const &a,
|
||||||
second_argument_type const &b ) const;
|
second_argument_type const &b ) const;
|
||||||
|
|
||||||
}; // boost::math::gcd_evaluator
|
}; // boost::integer::gcd_evaluator
|
||||||
|
|
||||||
|
|
||||||
// Least common multiple evaluator class declaration -----------------------//
|
// Least common multiple evaluator class declaration -----------------------//
|
||||||
@ -71,7 +71,7 @@ public:
|
|||||||
result_type operator ()( first_argument_type const &a,
|
result_type operator ()( first_argument_type const &a,
|
||||||
second_argument_type const &b ) const;
|
second_argument_type const &b ) const;
|
||||||
|
|
||||||
}; // boost::math::lcm_evaluator
|
}; // boost::integer::lcm_evaluator
|
||||||
|
|
||||||
|
|
||||||
// Implementation details --------------------------------------------------//
|
// Implementation details --------------------------------------------------//
|
||||||
@ -450,11 +450,11 @@ lcm
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace math
|
} // namespace integer
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // BOOST_MATH_COMMON_FACTOR_RT_HPP
|
#endif // BOOST_INTEGER_COMMON_FACTOR_RT_HPP
|
||||||
|
@ -158,6 +158,29 @@ template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Valu
|
|||||||
template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
|
template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
|
||||||
struct static_unsigned_max;
|
struct static_unsigned_max;
|
||||||
|
|
||||||
|
|
||||||
|
// From <boost/integer/common_factor_ct.hpp>
|
||||||
|
|
||||||
|
#ifdef BOOST_NO_INTEGRAL_INT64_T
|
||||||
|
typedef unsigned long static_gcd_type;
|
||||||
|
#else
|
||||||
|
typedef boost::uintmax_t static_gcd_type;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template < static_gcd_type Value1, static_gcd_type Value2 >
|
||||||
|
struct static_gcd;
|
||||||
|
template < static_gcd_type Value1, static_gcd_type Value2 >
|
||||||
|
struct static_lcm;
|
||||||
|
|
||||||
|
|
||||||
|
// From <boost/integer/common_factor_rt.hpp>
|
||||||
|
|
||||||
|
template < typename IntegerType >
|
||||||
|
class gcd_evaluator;
|
||||||
|
template < typename IntegerType >
|
||||||
|
class lcm_evaluator;
|
||||||
|
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ inline ostream& operator<<(ostream& os, unsigned __int64 i)
|
|||||||
// GCD on signed integer types
|
// GCD on signed integer types
|
||||||
template< class T > void gcd_int_test() // signed_test_types
|
template< class T > void gcd_int_test() // signed_test_types
|
||||||
{
|
{
|
||||||
using boost::math::gcd;
|
using boost::integer::gcd;
|
||||||
|
|
||||||
// Originally from Boost.Rational tests
|
// Originally from Boost.Rational tests
|
||||||
BOOST_TEST_EQ( gcd<T>( 1, -1), static_cast<T>( 1) );
|
BOOST_TEST_EQ( gcd<T>( 1, -1), static_cast<T>( 1) );
|
||||||
@ -270,7 +270,7 @@ template< class T > void gcd_int_test() // signed_test_types
|
|||||||
// GCD on unmarked signed integer type
|
// GCD on unmarked signed integer type
|
||||||
void gcd_unmarked_int_test()
|
void gcd_unmarked_int_test()
|
||||||
{
|
{
|
||||||
using boost::math::gcd;
|
using boost::integer::gcd;
|
||||||
|
|
||||||
// The regular signed-integer GCD function performs the unsigned version,
|
// The regular signed-integer GCD function performs the unsigned version,
|
||||||
// then does an absolute-value on the result. Signed types that are not
|
// then does an absolute-value on the result. Signed types that are not
|
||||||
@ -297,7 +297,7 @@ void gcd_unmarked_int_test()
|
|||||||
// GCD on unsigned integer types
|
// GCD on unsigned integer types
|
||||||
template< class T > void gcd_unsigned_test() // unsigned_test_types
|
template< class T > void gcd_unsigned_test() // unsigned_test_types
|
||||||
{
|
{
|
||||||
using boost::math::gcd;
|
using boost::integer::gcd;
|
||||||
|
|
||||||
// Note that unmarked types (i.e. have no std::numeric_limits
|
// Note that unmarked types (i.e. have no std::numeric_limits
|
||||||
// specialization) are treated like non/unsigned types
|
// specialization) are treated like non/unsigned types
|
||||||
@ -314,7 +314,7 @@ template< class T > void gcd_unsigned_test() // unsigned_test_types
|
|||||||
// GCD at compile-time
|
// GCD at compile-time
|
||||||
void gcd_static_test()
|
void gcd_static_test()
|
||||||
{
|
{
|
||||||
using boost::math::static_gcd;
|
using boost::integer::static_gcd;
|
||||||
|
|
||||||
BOOST_TEST_EQ( (static_gcd< 1, 1>::value), 1 );
|
BOOST_TEST_EQ( (static_gcd< 1, 1>::value), 1 );
|
||||||
BOOST_TEST_EQ( (static_gcd< 0, 0>::value), 0 );
|
BOOST_TEST_EQ( (static_gcd< 0, 0>::value), 0 );
|
||||||
@ -336,7 +336,7 @@ void gcd_static_test()
|
|||||||
// LCM on signed integer types
|
// LCM on signed integer types
|
||||||
template< class T > void lcm_int_test() // signed_test_types
|
template< class T > void lcm_int_test() // signed_test_types
|
||||||
{
|
{
|
||||||
using boost::math::lcm;
|
using boost::integer::lcm;
|
||||||
|
|
||||||
// Originally from Boost.Rational tests
|
// Originally from Boost.Rational tests
|
||||||
BOOST_TEST_EQ( lcm<T>( 1, -1), static_cast<T>( 1) );
|
BOOST_TEST_EQ( lcm<T>( 1, -1), static_cast<T>( 1) );
|
||||||
@ -360,7 +360,7 @@ template< class T > void lcm_int_test() // signed_test_types
|
|||||||
// LCM on unmarked signed integer type
|
// LCM on unmarked signed integer type
|
||||||
void lcm_unmarked_int_test()
|
void lcm_unmarked_int_test()
|
||||||
{
|
{
|
||||||
using boost::math::lcm;
|
using boost::integer::lcm;
|
||||||
|
|
||||||
// The regular signed-integer LCM function performs the unsigned version,
|
// The regular signed-integer LCM function performs the unsigned version,
|
||||||
// then does an absolute-value on the result. Signed types that are not
|
// then does an absolute-value on the result. Signed types that are not
|
||||||
@ -387,7 +387,7 @@ void lcm_unmarked_int_test()
|
|||||||
// LCM on unsigned integer types
|
// LCM on unsigned integer types
|
||||||
template< class T > void lcm_unsigned_test() // unsigned_test_types
|
template< class T > void lcm_unsigned_test() // unsigned_test_types
|
||||||
{
|
{
|
||||||
using boost::math::lcm;
|
using boost::integer::lcm;
|
||||||
|
|
||||||
// Note that unmarked types (i.e. have no std::numeric_limits
|
// Note that unmarked types (i.e. have no std::numeric_limits
|
||||||
// specialization) are treated like non/unsigned types
|
// specialization) are treated like non/unsigned types
|
||||||
@ -404,7 +404,7 @@ template< class T > void lcm_unsigned_test() // unsigned_test_types
|
|||||||
// LCM at compile-time
|
// LCM at compile-time
|
||||||
void lcm_static_test()
|
void lcm_static_test()
|
||||||
{
|
{
|
||||||
using boost::math::static_lcm;
|
using boost::integer::static_lcm;
|
||||||
|
|
||||||
BOOST_TEST_EQ( (static_lcm< 1, 1>::value), 1 );
|
BOOST_TEST_EQ( (static_lcm< 1, 1>::value), 1 );
|
||||||
BOOST_TEST_EQ( (static_lcm< 0, 0>::value), 0 );
|
BOOST_TEST_EQ( (static_lcm< 0, 0>::value), 0 );
|
||||||
@ -423,51 +423,51 @@ void lcm_static_test()
|
|||||||
// Various types to test with each GCD/LCM
|
// Various types to test with each GCD/LCM
|
||||||
|
|
||||||
#define TEST_SIGNED_( test ) \
|
#define TEST_SIGNED_( test ) \
|
||||||
test<signed char>(); \
|
test<signed char>(); \
|
||||||
test<short>(); \
|
test<short>(); \
|
||||||
test<int>(); \
|
test<int>(); \
|
||||||
test<long>(); \
|
test<long>(); \
|
||||||
test<MyInt1>();
|
test<MyInt1>();
|
||||||
|
|
||||||
#ifdef BOOST_HAS_LONG_LONG
|
#ifdef BOOST_HAS_LONG_LONG
|
||||||
# define TEST_SIGNED( test ) \
|
# define TEST_SIGNED( test ) \
|
||||||
TEST_SIGNED_( test ) \
|
TEST_SIGNED_( test ) \
|
||||||
test<boost::long_long_type>();
|
test<boost::long_long_type>();
|
||||||
#elif defined(BOOST_HAS_MS_INT64)
|
#elif defined(BOOST_HAS_MS_INT64)
|
||||||
# define TEST_SIGNED( test ) \
|
# define TEST_SIGNED( test ) \
|
||||||
TEST_SIGNED_( test ) \
|
TEST_SIGNED_( test ) \
|
||||||
test<__int64>();
|
test<__int64>();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TEST_UNSIGNED_( test ) \
|
#define TEST_UNSIGNED_( test ) \
|
||||||
test<unsigned char>(); \
|
test<unsigned char>(); \
|
||||||
test<unsigned short>(); \
|
test<unsigned short>(); \
|
||||||
test<unsigned>(); \
|
test<unsigned>(); \
|
||||||
test<unsigned long>(); \
|
test<unsigned long>(); \
|
||||||
test<MyUnsigned1>(); \
|
test<MyUnsigned1>(); \
|
||||||
test<MyUnsigned2>();
|
test<MyUnsigned2>();
|
||||||
|
|
||||||
#ifdef BOOST_HAS_LONG_LONG
|
#ifdef BOOST_HAS_LONG_LONG
|
||||||
# define TEST_UNSIGNED( test ) \
|
# define TEST_UNSIGNED( test ) \
|
||||||
TEST_UNSIGNED_( test ) \
|
TEST_UNSIGNED_( test ) \
|
||||||
test<boost::ulong_long_type>();
|
test<boost::ulong_long_type>();
|
||||||
#elif defined(BOOST_HAS_MS_INT64)
|
#elif defined(BOOST_HAS_MS_INT64)
|
||||||
# define TEST_UNSIGNED( test ) \
|
# define TEST_UNSIGNED( test ) \
|
||||||
TEST_UNSIGNED_( test ) \
|
TEST_UNSIGNED_( test ) \
|
||||||
test<unsigned __int64>();
|
test<unsigned __int64>();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
TEST_SIGNED( gcd_int_test )
|
TEST_SIGNED( gcd_int_test )
|
||||||
gcd_unmarked_int_test();
|
gcd_unmarked_int_test();
|
||||||
TEST_UNSIGNED( gcd_unsigned_test )
|
TEST_UNSIGNED( gcd_unsigned_test )
|
||||||
gcd_static_test();
|
gcd_static_test();
|
||||||
|
|
||||||
TEST_SIGNED( lcm_int_test )
|
TEST_SIGNED( lcm_int_test )
|
||||||
lcm_unmarked_int_test();
|
lcm_unmarked_int_test();
|
||||||
TEST_UNSIGNED( lcm_unsigned_test )
|
TEST_UNSIGNED( lcm_unsigned_test )
|
||||||
lcm_static_test();
|
lcm_static_test();
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user