You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trac #15426: Performance of casting ZZ[x] to Qp[x]
One probably expects that casting ZZ[x] to Qp[x] is at least as fast as
casting QQ[x] to Q[x].
This appeared not to be the case:
{{{
sage: prim=primes_first_n(1000)
sage: ZZX=ZZ['x']
sage: QQX=QQ['x']
sage: polysZZ = [ ZZX(prim[i:i+30]) for i in range(1,900)]
sage: polysQQ = [ QQX(prim[i:i+30]) for i in range(1,900)]
sage: QP=Qp(3,30);
sage: QPX=QP['x']
sage: def test1(PR,l):
return [PR(P) for P in l];
sage: %timeit test1(QPX,polysZZ)
1 loops, best of 3: 395 ms per loop
sage: %timeit test1(QPX,polysQQ)
1 loops, best of 3: 244 ms per loop
}}}
This appears to have been caused by unneccisary repeat virtual function
calls in polynomial_padic_capped_relative_dense::_comp_valaddeds. The
number of excess calls was proportional to the degree of the polynomial,
hence this likely does not cause noticeable performance issue for very
low degree polynomials.
The attached patch should correct this, I have new timings
{{{
sage: %timeit test1(QPX,polysZZ)
1 loops, best of 3: 171 ms per loop
sage: %timeit test1(QPX,polysQQ)
1 loops, best of 3: 256 ms per loop
}}}
URL: https://trac.sagemath.org/15426
Reported by: afiori
Ticket author(s): Andrew Fiori
Reviewer(s): Xavier Caruso
0 commit comments