mirror of https://github.com/CGAL/cgal
use f==g before computing the gcd(f,g)
This commit is contained in:
parent
f65c305dd0
commit
f7731fc15e
|
|
@ -388,7 +388,7 @@ public:
|
||||||
// we have ]low(), high()[ == ]y.low(),y.high()[ == ]L,R[
|
// we have ]low(), high()[ == ]y.low(),y.high()[ == ]L,R[
|
||||||
// and let both numbers decide for the gcd or its complement
|
// and let both numbers decide for the gcd or its complement
|
||||||
Poly F1,F2,G;
|
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);
|
F1 = integral_division_up_to_constant_factor(polynomial(),G);
|
||||||
CGAL_postcondition(CGAL::degree(F1)==
|
CGAL_postcondition(CGAL::degree(F1)==
|
||||||
CGAL::degree(polynomial())-CGAL::degree(G));
|
CGAL::degree(polynomial())-CGAL::degree(G));
|
||||||
|
|
@ -495,7 +495,7 @@ public:
|
||||||
if (is_rational() ) return CGAL::ZERO == Q.sign_at(rational());
|
if (is_rational() ) return CGAL::ZERO == Q.sign_at(rational());
|
||||||
|
|
||||||
if ( may_have_common_factor(polynomial(), Q) ) {
|
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){
|
if(CGAL::degree(G)!=0){
|
||||||
Poly F1 = integral_division_up_to_constant_factor(
|
Poly F1 = integral_division_up_to_constant_factor(
|
||||||
polynomial(),G
|
polynomial(),G
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,7 @@ public:
|
||||||
// we have ]low(), high()[ == ]y.low(),y.high()[ == ]L,R[
|
// we have ]low(), high()[ == ]y.low(),y.high()[ == ]L,R[
|
||||||
// and let both numbers decide for the gcd or its complement
|
// and let both numbers decide for the gcd or its complement
|
||||||
Poly F1,F2,G;
|
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);
|
F1 = CGAL::integral_division_up_to_constant_factor(polynomial(),G);
|
||||||
CGAL_postcondition(CGAL::degree(F1)==
|
CGAL_postcondition(CGAL::degree(F1)==
|
||||||
CGAL::degree(polynomial())-CGAL::degree(G));
|
CGAL::degree(polynomial())-CGAL::degree(G));
|
||||||
|
|
|
||||||
|
|
@ -222,6 +222,8 @@ class Polynomial_algebraic_structure_traits_base< POLY, Unique_factorization_dom
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
POLY operator()( const POLY& x, const POLY& y ) const {
|
POLY operator()( const POLY& x, const POLY& y ) const {
|
||||||
|
if(x==y) return x;
|
||||||
|
|
||||||
typedef Algebraic_structure_traits<POLY> AST;
|
typedef Algebraic_structure_traits<POLY> AST;
|
||||||
typename AST::Integral_division idiv;
|
typename AST::Integral_division idiv;
|
||||||
typename AST::Unit_part upart;
|
typename AST::Unit_part upart;
|
||||||
|
|
|
||||||
|
|
@ -1150,6 +1150,7 @@ struct Construct_innermost_coefficient_const_iterator_range
|
||||||
:public std::binary_function<Polynomial_d, Polynomial_d, Polynomial_d> {
|
:public std::binary_function<Polynomial_d, Polynomial_d, Polynomial_d> {
|
||||||
Polynomial_d
|
Polynomial_d
|
||||||
operator()(const Polynomial_d& p, const Polynomial_d& q) const {
|
operator()(const Polynomial_d& p, const Polynomial_d& q) const {
|
||||||
|
if(p==q) return p;
|
||||||
if (CGAL::is_zero(p) && CGAL::is_zero(q)){
|
if (CGAL::is_zero(p) && CGAL::is_zero(q)){
|
||||||
return Polynomial_d(0);
|
return Polynomial_d(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue