New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add iterator method in QQ for Calkin-Wilf sequence #28282
Comments
Commit: |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Author: Bryan Gillespie |
comment:4
Ticket retargeted after milestone closed |
comment:5
Batch modifying tickets that will likely not be ready for 9.1, based on a review of the ticket title, branch/review status, and last modification date. |
comment:6
That would be a nice addition! The branch needs rebasing. In addition I suggest considering these minor changes: - p, q = ZZ(1), ZZ(1)
+ p = q = ZZ.one()
if all_rationals:
- yield self(0)
+ yield self.zero()
while True:
- yield self(p / q)
- yield -self(p / q)
+ yield self((p, q))
+ yield self((-p, q))
p, q = q, 2 * (p // q) * q - p + q
else:
while True:
- yield self(p / q)
+ yield self((p, q))
p, q = q, 2 * (p // q) * q - p + q |
Reviewer: Samuel Lelièvre |
comment:7
We've been there already: sagemath/sagetrac-mirror@45dc1b9/src/sage/rings/rational_field.py It's indeed a cute sequence. The generating formula is surprisingly simple, but most problems that require iterating over the rationals are better served by another order (indeed, it's since been replaced by iteration by height): https://github.com/sagemath/sagetrac-mirror/commits/55ad3590cb7d993f38c9104ea87da24b21567009 |
comment:8
Thanks @nbruin for pointing out the initial iterator for This ticket aims to provide a Calkin-Wilf iterator as distinct Would you advise against it? Would this Calkin-Wilf iterator |
comment:9
Replying to @slel:
I'd think so. The formula is exceedingly simple: see the original implementation that was essentially a one-liner. I was originally enthusiastic when I learned about the formula, but I don't think the sequence really has wider applications. Including it would be more of encyclopedic interest, and I think |
comment:11
Setting new milestone based on a cursory review of ticket status, priority, and last modification date. |
comment:12
Setting a new milestone for this ticket based on a cursory review. |
Add a method to the set of rational numbers to produce an iterator for the Calkin-Wilf sequence, an explicit ordering of the positive rationals with some interesting features. Background:
CC: @slel
Component: combinatorics
Keywords: sequence, iterator
Author: Bryan Gillespie
Branch/Commit: u/bgillespie/add_iterator_method_in_qq_for_calkin_wilf_sequence @
9b82dac
Reviewer: Samuel Lelièvre
Issue created by migration from https://trac.sagemath.org/ticket/28282
The text was updated successfully, but these errors were encountered: