Ticket #8268 (closed enhancement: fixed)
Improve speed of Christoffel word construction
| Reported by: | slabbe | Owned by: | slabbe |
|---|---|---|---|
| Priority: | major | Milestone: | sage-4.3.4 |
| Component: | combinatorics | Keywords: | christoffel words |
| Cc: | abmasse | Work issues: | |
| Report Upstream: | N/A | Reviewers: | Alexandre Blondin Massé |
| Authors: | Sébastien Labbé | Merged in: | sage-4.3.4.alpha0 |
| Dependencies: | Stopgaps: |
Description
This patch adds a new implementation for construction of Christoffel words using continued fraction :
sage: %timeit words.ChristoffelWord(5, 9, algorithm='linear') 625 loops, best of 3: 67.7 µs per loop sage: %timeit words.ChristoffelWord(5, 9, algorithm='cf') 625 loops, best of 3: 309 µs per loop
For large words, it is much faster than the actual implementation.
sage: %timeit words.ChristoffelWord(500, 90001, algorithm='linear') 5 loops, best of 3: 111 ms per loop sage: %timeit words.ChristoffelWord(500, 90001, algorithm='cf') 125 loops, best of 3: 4 ms per loop
Attachments
Change History
comment:2 Changed 3 years ago by abmasse
I tested the improved function. It is indeed much faster, especially when the two prime numbers are big. The code makes sense, all tests passed, and I tried also other values with very big prime numbers: no problem. The doc builds fine too.
I made very minor changes (typos, punctuation, etc.). Positive review.
comment:3 Changed 3 years ago by abmasse
- Keywords christoffel words added
- Reviewers set to Alexandre Blondin Massé
- Status changed from needs_review to positive_review
- Authors set to Sébastien Labbé
comment:4 Changed 3 years ago by abmasse
- Status changed from positive_review to needs_work
Sorry, forgot two small things, uploading a new patch in a few minutes.
Changed 3 years ago by abmasse
-
attachment
trac_8268_review-abm.patch
added
Minor change -- apply on top
Note: See
TracTickets for help on using
tickets.
