Ticket #496 (closed defect: fixed)
In several places the generic powering and n*x code is stupid.
| Reported by: | was | Owned by: | boothby |
|---|---|---|---|
| Priority: | major | Milestone: | sage-2.8.4 |
| Component: | basic arithmetic | Keywords: | |
| Cc: | Work issues: | ||
| Report Upstream: | Reviewers: | ||
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description
- In rings/arith.py the code for generic powering does an extra multiply the last time through the loop.
This can take a huge amount of extra time on big powering.
- In structure/element.pyx the code for generic n*x (the function cdef ModuleElement? _lmul_c_impl(self, RingElement? right), around line 1125) does possibly an extra add.
To fix this either rewrite or refactor the above code to be more like the pow that is around line 1057 of element.pyx. Also, write *lots of doctests* to make sure you're really computing the right thing.
Attachments
Change History
comment:1 Changed 6 years ago by boothby
- Status changed from new to closed
- Resolution set to fixed
Attached patch fixes the problem.
comment:2 Changed 6 years ago by mabshoff
Hello,
I think that bugs should only be closed as fixed once the patch has made it into the Repo. While this might be the case at least to the outside world this changeset is not visible yet. So I would suggest adding in Action an option "fix attached" to the resolve option.
Cheers,
Michael
comment:3 Changed 6 years ago by boothby
- Status changed from closed to reopened
- Resolution fixed deleted
Attached file introduces bugs. Better fix is located at:
http://sage.math.washington.edu/home/boothby/my_patches/arith_2.8.3.hg
(patch re-opened due to Michael's suggestion)
comment:5 Changed 6 years ago by was
- Status changed from closed to reopened
- Resolution fixed deleted
comment:6 Changed 6 years ago by boothby
- Status changed from reopened to closed
- Resolution set to fixed
Everything seems to check out. Almost all element classes are now using the generic code, and all tests pass. The classes which do not use generic code are listed in #503, or have good reason not to use it (for example, integers call mpz library code).

