From: Jens Vollinga Date: Mon, 8 Sep 2008 17:17:56 +0000 (+0200) Subject: Fixed bug in unvariate factorization. Bound for lifting was using a ordinary X-Git-Tag: release_1-5-0~66 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=commitdiff_plain;h=bb6b3d82cdf9e7ff4ecac89c47e63024e39ec96b;p=ginac.git Fixed bug in unvariate factorization. Bound for lifting was using a ordinary int instead of a cl_I. --- diff --git a/check/exam_factor.cpp b/check/exam_factor.cpp index 7e156487..fa895c6d 100644 --- a/check/exam_factor.cpp +++ b/check/exam_factor.cpp @@ -94,6 +94,13 @@ static unsigned exam_factor1() e = x; result += check_factor(e); + // x^37 + 1 + e = ex("(1+x)*(1+x^2-x^29-x^11-x^25-x^9-x^35+x^20-x^3+x^16-x^15-x-x^13+x^28+x^24-x^33+x^8-x^19+x^36+x^12-x^27+x^10-x^23+x^18+x^14+x^34-x^31+x^32+x^30-x^5+x^26+x^4+x^22-x^21-x^7-x^17+x^6)", syms); + result += check_factor(e); + + e = ex("(1+4*x)*x^2*(1-4*x+16*x^2)*(3+5*x+92*x^3)", syms); + result += check_factor(e); + return result; } diff --git a/ginac/factor.cpp b/ginac/factor.cpp index 3afaec54..886819a3 100644 --- a/ginac/factor.cpp +++ b/ginac/factor.cpp @@ -1048,8 +1048,8 @@ static ex hensel_univar(const ex& a_, const ex& x, unsigned int p, const UniPoly maxcoeff += pow(abs(a.coeff(x, i)),2); } cl_I normmc = ceiling1(the(cln::sqrt(ex_to(maxcoeff).to_cl_N()))); - unsigned int maxdegree = (u1_.degree() > w1_.degree()) ? u1_.degree() : w1_.degree(); - unsigned int B = cl_I_to_uint(normmc * expt_pos(cl_I(2), maxdegree)); + cl_I maxdegree = (u1_.degree() > w1_.degree()) ? u1_.degree() : w1_.degree(); + cl_I B = normmc * expt_pos(cl_I(2), maxdegree); // step 1 ex alpha = a.lcoeff(x); @@ -1077,10 +1077,11 @@ static ex hensel_univar(const ex& a_, const ex& x, unsigned int p, const UniPoly ex u = replace_lc(u1.to_ex(x), x, gamma); ex w = replace_lc(w1.to_ex(x), x, alpha); ex e = expand(a - u * w); - unsigned int modulus = p; + numeric modulus = p; + const numeric maxmodulus(2*B*gamma_ui); // step 4 - while ( !e.is_zero() && modulus < 2*B*gamma_ui ) { + while ( !e.is_zero() && modulus < maxmodulus ) { ex c = e / modulus; phi = expand(s.to_ex(x)*c); UniPoly sigmatilde(R, phi, x);