-
-
Notifications
You must be signed in to change notification settings - Fork 510
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
Integer.{perfect_power,is_prime_power,is_irreducible}: Handle easy cases without PARI #35847
Integer.{perfect_power,is_prime_power,is_irreducible}: Handle easy cases without PARI #35847
Conversation
ef8f5b7
to
f01b0c2
Compare
…done without PARI
…done without PARI (fixup)
if n >= 4: | ||
if not (n & 1): | ||
if mpz_popcount(self.value) == 1: | ||
return smallInteger(2), smallInteger(mpz_sizeinbase(self.value, 2) - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer sanity tests for this.
It's so easy to get this wrong by +-1....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Added tests in d2c9c5e
…sts for powers of 2
LGTM. |
Thank you! |
Documentation preview for this PR (built with commit d2c9c5e; changes) is ready! 🎉 |
… imports <!-- Please provide a concise, informative and self-explanatory title. --> <!-- Don't put issue numbers in the title. Put it in the Description below. --> <!-- For example, instead of "Fixes #12345", use "Add a new method to multiply two integers" --> ### 📚 Description <!-- Describe your changes here in detail. --> - Many `# optional` are removed because small prime finite fields no longer need to be marked `# optional/needs sage.rings.finite_rings` since #35847 - Other `# optional` are replaced by codeblock-scoped `# needs` tags - Remaining `# optional` with standard features are replaced by `# needs` - Some import fixes needed for separate testing of **sagemath-modules** or **sagemath-graphs**[modules] from #35095 <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> This is: - done with the help of `sage -fixdoctests` from #35749 - Part of: #29705 - Cherry-picked from: #35095 <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x ]`. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35919 Reported by: Matthias Köppe Reviewer(s): David Coudert, Matthias Köppe
…eds` <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> - Many `# optional` are removed because small prime finite fields no longer need to be marked `# optional/needs sage.rings.finite_rings` since #35847 - Other `# optional` are replaced by codeblock-scoped `# needs` tags - Remaining `# optional` with standard features are replaced by `# needs` - Some import fixes needed for separate testing of **sagemath-graphs** from #35095 <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> This is: - done with the help of `sage -fixdoctests` from #35749 - Part of: #29705 - Cherry-picked from: #35095 <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35943 Reported by: Matthias Köppe Reviewer(s): David Coudert, Matthias Köppe
<!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> - Many `# optional` are removed because small prime finite fields no longer need to be marked `# optional/needs sage.rings.finite_rings` since #35847 - Other `# optional` are replaced by codeblock-scoped `# needs` tags - Remaining `# optional` with standard features are replaced by `# needs` - Some import fixes needed for separate testing of **sagemath-graphs** from #35095 <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> This is: - done with the help of `sage -fixdoctests` from #35749 - Part of: #29705 - Cherry-picked from: #35095 ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35957 Reported by: Matthias Köppe Reviewer(s): David Coudert, Matthias Köppe
📚 Description
Taking care of small primes and powers of two.
In particular, this allows us to set up
GF(2)
without pulling in PARI, and avoids many# optional
tags insage.combinat.designs
andsage.combinat.posets
.📝 Checklist
⌛ Dependencies