Skip to content

Commit 9de4730

Browse files
author
Release Manager
committed
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
2 parents 93619a4 + a297e3c commit 9de4730

File tree

1 file changed

+77
-77
lines changed

1 file changed

+77
-77
lines changed

0 commit comments

Comments
 (0)