use f==g before computing the gcd(f,g)

This commit is contained in:
Michael Hemmer 2010-08-04 15:30:42 +00:00
parent f65c305dd0
commit f7731fc15e
4 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -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));

View File

@ -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<POLY> AST;
typename AST::Integral_division idiv;
typename AST::Unit_part upart;

View File

@ -1150,6 +1150,7 @@ struct Construct_innermost_coefficient_const_iterator_range
:public std::binary_function<Polynomial_d, Polynomial_d, Polynomial_d> {
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);
}