]> www.ginac.de Git - ginac.git/commitdiff
Optimize some use of CLN's expt_pos() function in factor().
authorRichard Kreckel <kreckel@ginac.de>
Wed, 12 Oct 2022 22:12:07 +0000 (00:12 +0200)
committerRichard Kreckel <kreckel@ginac.de>
Wed, 12 Oct 2022 22:12:07 +0000 (00:12 +0200)
(Not that it's slow or mattered much, but why waste cycles?)

ginac/factor.cpp

index d30cf956200b6408ee96b9de9bcdb6b8af8c6a20..fde15b32841e16547815a552f69099bce690dac7 100644 (file)
@@ -1206,7 +1206,7 @@ static inline cl_I calc_bound(const ex& a, const ex& x, int maxdeg)
                coeff = coeff + square(aa);
        }
        cl_I coeffnorm = ceiling1(the<cl_R>(cln::sqrt(coeff)));
-       cl_I B = coeffnorm * expt_pos(cl_I(2), cl_I(maxdeg));
+       cl_I B = coeffnorm * ash(cl_I(1), maxdeg);  // coeffnorm * 2^maxdeg
        return ( B > maxcoeff ) ? B : maxcoeff;
 }
 
@@ -1223,7 +1223,7 @@ static inline cl_I calc_bound(const upoly& a, int maxdeg)
                coeff = coeff + square(aa);
        }
        cl_I coeffnorm = ceiling1(the<cl_R>(cln::sqrt(coeff)));
-       cl_I B = coeffnorm * expt_pos(cl_I(2), cl_I(maxdeg));
+       cl_I B = coeffnorm * ash(cl_I(1), maxdeg);  // coeffnorm * 2^maxdeg
        return ( B > maxcoeff ) ? B : maxcoeff;
 }
 
@@ -2409,7 +2409,7 @@ static ex factor_multivariate(const ex& poly, const exset& syms)
                }
                
                // set up modular factors (mod p^l)
-               cl_modint_ring R = find_modint_ring(expt_pos(cl_I(prime),l));
+               cl_modint_ring R = find_modint_ring(pl);
                upvec modfactors(ufaclst.nops()-1);
                for ( size_t i=1; i<ufaclst.nops(); ++i ) {
                        umodpoly_from_ex(modfactors[i-1], ufaclst.op(i), x, R);