From: Richard Kreckel Date: Thu, 22 Dec 2022 23:44:23 +0000 (+0100) Subject: Some more minor optimizations in factor.cpp. X-Git-Tag: release_1-8-5~3 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=commitdiff_plain;h=3dde1c1a46cda22f908c8005771550a51c5aec33;p=ginac.git Some more minor optimizations in factor.cpp. This isn't changing much, but once I've seen a missed opportunity, it keeps catching the eye and then it's hard to resist. :-) --- diff --git a/ginac/factor.cpp b/ginac/factor.cpp index 3b93cc6d..7d321b40 100644 --- a/ginac/factor.cpp +++ b/ginac/factor.cpp @@ -482,12 +482,12 @@ static umodpoly umodpoly_to_umodpoly(const umodpoly& a, const cl_modint_ring& R, return e; } -/** Divides all coefficients of the polynomial a by the integer x. +/** Divides all coefficients of the polynomial a by the positive integer x. * All coefficients are supposed to be divisible by x. If they are not, the - * the cast will raise an exception. + * division will raise an exception. * * @param[in,out] a polynomial of which the coefficients will be reduced by x - * @param[in] x integer that divides the coefficients + * @param[in] x positive integer that divides the coefficients */ static void reduce_coeff(umodpoly& a, const cl_I& x) { @@ -497,7 +497,7 @@ static void reduce_coeff(umodpoly& a, const cl_I& x) for (auto & i : a) { // cln cannot perform this division in the modular field cl_I c = R->retract(i); - i = cl_MI(R, the(c / x)); + i = cl_MI(R, exquopos(c, x)); } } @@ -2279,8 +2279,9 @@ struct factorization_ctx { numeric prefac = ex_to(ufaclst[i+1].lcoeff(x)); for ( int j=ftilde.size()-1; j>=0; --j ) { int count = 0; - while ( irem(prefac, ftilde[j]) == 0 ) { - prefac = iquo(prefac, ftilde[j]); + numeric q; + while ( irem(prefac, ftilde[j], q) == 0 ) { + prefac = q; ++count; } if ( count ) { @@ -2295,8 +2296,9 @@ struct factorization_ctx { numeric prefac = ex_to(ufaclst[i+1].lcoeff(x)); for ( int j=ftilde.size()-1; j>=0; --j ) { int count = 0; - while ( irem(prefac, ftilde[j]) == 0 ) { - prefac = iquo(prefac, ftilde[j]); + numeric q; + while ( irem(prefac, ftilde[j], q) == 0 ) { + prefac = q; ++count; } while ( irem(ex_to(delta)*prefac, ftilde[j]) == 0 ) { @@ -2335,13 +2337,10 @@ struct factorization_ctx { } // set up evaluation points - EvalPoint ep; vector epv; auto s = syms_wox.begin(); for ( size_t i=0; i