From f7731fc15ef80e2573d396f31a297d1ddbda57cf Mon Sep 17 00:00:00 2001 From: Michael Hemmer Date: Wed, 4 Aug 2010 15:30:42 +0000 Subject: [PATCH] use f==g before computing the gcd(f,g) --- .../include/CGAL/Algebraic_kernel_d/Algebraic_real_rep.h | 4 ++-- .../include/CGAL/Algebraic_kernel_d/Algebraic_real_rep_bfi.h | 2 +- .../include/CGAL/Polynomial/Algebraic_structure_traits.h | 2 ++ Polynomial/include/CGAL/Polynomial_traits_d.h | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Algebraic_real_rep.h b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Algebraic_real_rep.h index 21c8cd7e3e6..5f5f2c6d976 100644 --- a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Algebraic_real_rep.h +++ b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Algebraic_real_rep.h @@ -388,7 +388,7 @@ public: // we have ]low(), high()[ == ]y.low(),y.high()[ == ]L,R[ // and let both numbers decide for the gcd or its complement Poly F1,F2,G; - G = gcd_utcf(polynomial(),y.polynomial()); + G = CGAL::gcd_up_to_constant_factor(polynomial(),y.polynomial()); F1 = integral_division_up_to_constant_factor(polynomial(),G); CGAL_postcondition(CGAL::degree(F1)== CGAL::degree(polynomial())-CGAL::degree(G)); @@ -495,7 +495,7 @@ public: if (is_rational() ) return CGAL::ZERO == Q.sign_at(rational()); if ( may_have_common_factor(polynomial(), Q) ) { - Poly G = gcd_utcf(polynomial(),Q); + Poly G = CGAL::gcd_up_to_constant_factor(polynomial(),Q); if(CGAL::degree(G)!=0){ Poly F1 = integral_division_up_to_constant_factor( polynomial(),G diff --git a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Algebraic_real_rep_bfi.h b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Algebraic_real_rep_bfi.h index ba24a2f65e7..b5265be6ab7 100644 --- a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Algebraic_real_rep_bfi.h +++ b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Algebraic_real_rep_bfi.h @@ -234,7 +234,7 @@ public: // we have ]low(), high()[ == ]y.low(),y.high()[ == ]L,R[ // and let both numbers decide for the gcd or its complement Poly F1,F2,G; - G = gcd_utcf(polynomial(),y.polynomial()); + G = CGAL::gcd_up_to_constant_factor(polynomial(),y.polynomial()); F1 = CGAL::integral_division_up_to_constant_factor(polynomial(),G); CGAL_postcondition(CGAL::degree(F1)== CGAL::degree(polynomial())-CGAL::degree(G)); diff --git a/Polynomial/include/CGAL/Polynomial/Algebraic_structure_traits.h b/Polynomial/include/CGAL/Polynomial/Algebraic_structure_traits.h index 53949cb3b4c..a6c4490c3a1 100644 --- a/Polynomial/include/CGAL/Polynomial/Algebraic_structure_traits.h +++ b/Polynomial/include/CGAL/Polynomial/Algebraic_structure_traits.h @@ -222,6 +222,8 @@ class Polynomial_algebraic_structure_traits_base< POLY, Unique_factorization_dom } public: POLY operator()( const POLY& x, const POLY& y ) const { + if(x==y) return x; + typedef Algebraic_structure_traits AST; typename AST::Integral_division idiv; typename AST::Unit_part upart; diff --git a/Polynomial/include/CGAL/Polynomial_traits_d.h b/Polynomial/include/CGAL/Polynomial_traits_d.h index 1d145809097..b1a92b57d94 100644 --- a/Polynomial/include/CGAL/Polynomial_traits_d.h +++ b/Polynomial/include/CGAL/Polynomial_traits_d.h @@ -1150,6 +1150,7 @@ struct Construct_innermost_coefficient_const_iterator_range :public std::binary_function { Polynomial_d operator()(const Polynomial_d& p, const Polynomial_d& q) const { + if(p==q) return p; if (CGAL::is_zero(p) && CGAL::is_zero(q)){ return Polynomial_d(0); }