]> www.ginac.de Git - ginac.git/commitdiff
Fixed bug in modular square-free factorization.
authorJens Vollinga <jensv@nikhef.nl>
Mon, 18 Aug 2008 19:10:48 +0000 (21:10 +0200)
committerJens Vollinga <jensv@nikhef.nl>
Mon, 18 Aug 2008 19:10:48 +0000 (21:10 +0200)
ginac/factor.cpp

index 3a012405ffc2934ae9d91358261a039101343e2e..18e7c04c78bc3ce86dab49e377f7a25de44d0aa3 100644 (file)
@@ -574,9 +574,10 @@ static void sqrfree_main(const UniPoly& a, UniFactorVec& fvec)
                        gcd(w, c, y);
                        div(w, y, z);
                        if ( !is_one(z) ) {
                        gcd(w, c, y);
                        div(w, y, z);
                        if ( !is_one(z) ) {
-                               UniFactor uf(z, i++);
+                               UniFactor uf(z, i);
                                fvec.factors.push_back(uf);
                        }
                                fvec.factors.push_back(uf);
                        }
+                       ++i;
                        w = y;
                        UniPoly cbuf(a.R);
                        div(c, y, cbuf);
                        w = y;
                        UniPoly cbuf(a.R);
                        div(c, y, cbuf);
@@ -1026,7 +1027,7 @@ static ex factor_univariate(const ex& poly, const ex& x)
                        UniPoly modpoly(R, prim, x);
                        UniFactorVec sqrfree_ufv;
                        squarefree(modpoly, sqrfree_ufv);
                        UniPoly modpoly(R, prim, x);
                        UniFactorVec sqrfree_ufv;
                        squarefree(modpoly, sqrfree_ufv);
-                       if ( sqrfree_ufv.factors.size() == 1 ) break;
+                       if ( sqrfree_ufv.factors.size() == 1 && sqrfree_ufv.factors.front().exp == 1 ) break;
                }
                p = next_prime(p);
                R = find_modint_ring(p);
                }
                p = next_prime(p);
                R = find_modint_ring(p);