#13259: Correcting implementation of "negative" quantum integers
-----------------------------------+----------------------------------------
Reporter: andrew.mathas | Owner: andrew.mathas
Type: defect | Status: needs_review
Priority: minor | Milestone: sage-5.3
Component: combinatorics | Resolution:
Keywords: quantum integer | Work issues:
Report Upstream: N/A | Reviewers:
Authors: | Merged in:
Dependencies: | Stopgaps:
-----------------------------------+----------------------------------------
Comment (by andrew.mathas):
Thanks for this. I guess that the moral is that working with polynomials,
rather than Laurent polynomials, is more efficient. I'll upload a combined
patch.
Replying to [comment:8 arminstraub]:
> The updated patch just fixes a tiny latex issue.
>
> Replying to [comment:6 andrew.mathas]:
>
> You're right: I changed the return statement mostly because of "looks"
and to make it visibly agree with the documentation. However, it actually
turns out that the new statement is also **much** faster than both the
previous one or the one you suggested as an alternative:
>
> {{{
> sage: p = ZZ['q'].gens()[0]
> sage: n = -10
> sage: %timeit -sum(p**j for j in range(-1,n-1,-1))
> 625 loops, best of 3: 972 µs per loop
> sage: %timeit sum([-p**(n+i) for i in range(-n)])
> 625 loops, best of 3: 979 µs per loop
> sage: %timeit -p**n * sum([p**i for i in range(-n)])
> 625 loops, best of 3: 158 µs per loop
> sage: n = -100
> sage: %timeit -sum(p**j for j in range(-1,n-1,-1))
> 25 loops, best of 3: 22.7 ms per loop
> sage: %timeit sum([-p**(n+i) for i in range(-n)])
> 25 loops, best of 3: 27.6 ms per loop
> sage: %timeit -p**n * sum([p**i for i in range(-n)])
> 625 loops, best of 3: 716 µs per loop
> }}}
>
> I certainly didn't anticipate this.
>
> Thus, I would suggest leaving the two patches as they are. From my
(little) experience, I would say that there is no need to combine the two
patches into a single one. However, I just noted that your patch does not
contain the ticket number in the comment line (at the top). So when
changing this, you might as well combine the two patches.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13259#comment:9>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.