mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Fix failures when used with an expression-template enabled number type such as the gmpxx clases.
Add additional concept check for integer code using gmp classes. Fixes #4139. [SVN r61837]
This commit is contained in:
@@ -13,10 +13,13 @@ obj has_long_double_support : has_long_double_support.cpp ;
|
|||||||
obj has_mpfr_class : has_mpfr_class.cpp :
|
obj has_mpfr_class : has_mpfr_class.cpp :
|
||||||
<include>$(gmp_path) <include>$(gmp_path)/mpfr <include>$(gmp_path)/gmpfrxx ;
|
<include>$(gmp_path) <include>$(gmp_path)/mpfr <include>$(gmp_path)/gmpfrxx ;
|
||||||
obj has_ntl_rr : has_ntl_rr.cpp : <include>$(ntl-path)/include ;
|
obj has_ntl_rr : has_ntl_rr.cpp : <include>$(ntl-path)/include ;
|
||||||
|
obj has_gmpxx : has_gmpxx.cpp :
|
||||||
|
<include>$(gmp_path) <include>$(gmp_path)/mpfr <include>$(gmp_path)/gmpfrxx ;
|
||||||
|
|
||||||
explicit has_long_double_support ;
|
explicit has_long_double_support ;
|
||||||
explicit has_mpfr_class ;
|
explicit has_mpfr_class ;
|
||||||
explicit has_ntl_rr ;
|
explicit has_ntl_rr ;
|
||||||
|
explicit has_gmpxx ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
7
config/has_gmpxx.cpp
Normal file
7
config/has_gmpxx.cpp
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// Copyright John Maddock 2008.
|
||||||
|
// Use, modification and distribution are 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)
|
||||||
|
|
||||||
|
#include <gmpxx.h>
|
||||||
|
|
||||||
@@ -78,8 +78,8 @@ namespace detail
|
|||||||
RingType
|
RingType
|
||||||
gcd_euclidean
|
gcd_euclidean
|
||||||
(
|
(
|
||||||
RingType a,
|
RingType a,
|
||||||
RingType b
|
RingType b
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Avoid repeated construction
|
// Avoid repeated construction
|
||||||
@@ -116,7 +116,7 @@ namespace detail
|
|||||||
IntegerType const zero = static_cast<IntegerType>( 0 );
|
IntegerType const zero = static_cast<IntegerType>( 0 );
|
||||||
IntegerType const result = gcd_euclidean( a, b );
|
IntegerType const result = gcd_euclidean( a, b );
|
||||||
|
|
||||||
return ( result < zero ) ? -result : result;
|
return ( result < zero ) ? static_cast<IntegerType>(-result) : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Greatest common divisor for unsigned binary integers
|
// Greatest common divisor for unsigned binary integers
|
||||||
@@ -212,7 +212,7 @@ namespace detail
|
|||||||
IntegerType const zero = static_cast<IntegerType>( 0 );
|
IntegerType const zero = static_cast<IntegerType>( 0 );
|
||||||
IntegerType const result = lcm_euclidean( a, b );
|
IntegerType const result = lcm_euclidean( a, b );
|
||||||
|
|
||||||
return ( result < zero ) ? -result : result;
|
return ( result < zero ) ? static_cast<IntegerType>(-result) : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function objects to find the best way of computing GCD or LCM
|
// Function objects to find the best way of computing GCD or LCM
|
||||||
|
|||||||
@@ -24,11 +24,16 @@ namespace boost{ namespace math{
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
|
struct big_int_type
|
||||||
|
{
|
||||||
|
operator boost::uintmax_t()const;
|
||||||
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct largest_cbrt_int_type
|
struct largest_cbrt_int_type
|
||||||
{
|
{
|
||||||
typedef typename mpl::if_<
|
typedef typename mpl::if_<
|
||||||
boost::is_convertible<boost::uintmax_t, T>,
|
boost::is_convertible<big_int_type, T>,
|
||||||
boost::uintmax_t,
|
boost::uintmax_t,
|
||||||
unsigned int
|
unsigned int
|
||||||
>::type type;
|
>::type type;
|
||||||
|
|||||||
@@ -752,6 +752,7 @@ run complex_test.cpp ../../test/build//boost_test_exec_monitor ;
|
|||||||
|
|
||||||
compile ntl_concept_check.cpp : [ check-target-builds ../config//has_ntl_rr : : <build>no ] ;
|
compile ntl_concept_check.cpp : [ check-target-builds ../config//has_ntl_rr : : <build>no ] ;
|
||||||
compile mpfr_concept_check.cpp : [ check-target-builds ../config//has_mpfr_class : : <build>no ] ;
|
compile mpfr_concept_check.cpp : [ check-target-builds ../config//has_mpfr_class : : <build>no ] ;
|
||||||
|
compile test_common_factor_gmpxx.cpp : [ check-target-builds ../config//has_gmpxx : : <build>no ] ;
|
||||||
|
|
||||||
build-project ../example ;
|
build-project ../example ;
|
||||||
|
|
||||||
|
|||||||
22
test/test_common_factor_gmpxx.cpp
Normal file
22
test/test_common_factor_gmpxx.cpp
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
// (C) Copyright John Maddock 2010.
|
||||||
|
// Use, modification and distribution are 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)
|
||||||
|
|
||||||
|
#include <gmpxx.h>
|
||||||
|
#include <boost/math/common_factor.hpp>
|
||||||
|
|
||||||
|
template class boost::math::gcd_evaluator<mpz_class>;
|
||||||
|
template class boost::math::lcm_evaluator<mpz_class>;
|
||||||
|
template mpz_class boost::math::gcd(const mpz_class&, const mpz_class&);
|
||||||
|
template mpz_class boost::math::lcm(const mpz_class&, const mpz_class&);
|
||||||
|
|
||||||
|
template mpz_class boost::math::detail::gcd_euclidean(const mpz_class, const mpz_class);
|
||||||
|
template mpz_class boost::math::detail::gcd_integer(const mpz_class&, const mpz_class&);
|
||||||
|
template mpz_class boost::math::detail::lcm_euclidean(const mpz_class&, const mpz_class&);
|
||||||
|
template mpz_class boost::math::detail::lcm_integer(const mpz_class&, const mpz_class&);
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user