#15426: Performance of casting ZZ[x] to Qp[x]
-------------------------+-------------------------------------------------
Reporter: afiori | Owner:
Type: | Status: new
enhancement | Milestone: sage-5.13
Priority: minor | Keywords: performance padic polynomial
Component: | casting
performance | Authors: Andrew Fiori
Merged in: | Report Upstream: N/A
Reviewers: | Branch:
Work issues: | Dependencies:
Commit: |
Stopgaps: |
-------------------------+-------------------------------------------------
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
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/15426>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.