Conversation
Collaborator
|
CC @crockeea |
Collaborator
|
Fixes #644 (by computing roots quickly at runtime we avoid the need to hard-code any particular roots for particular primes) |
37e378e to
3ab95d4
Compare
crockeea
reviewed
Jan 28, 2026
| #include <cassert> | ||
| #include <cstdint> | ||
| #include <utility> | ||
| #include <vector> |
Collaborator
There was a problem hiding this comment.
Nit: Unless required by coding standards, is already included in the header.
crockeea
reviewed
Jan 28, 2026
| const APInt& modulus) { | ||
| APInt res(modulus.getBitWidth(), 1); | ||
| APInt b = base.urem(modulus); | ||
| APInt e = exponent; |
Collaborator
There was a problem hiding this comment.
The modulus can be reduced as well (AI claims e -> ((e mod totient(q)) + totient(q) for arbitrary base/exponent). I guess if this is for computing compile-time constants that may not matter so much?
crockeea
reviewed
Jan 28, 2026
|
|
||
| #include <cmath> | ||
| #include <cstdint> | ||
| #include <optional> |
crockeea
approved these changes
Jan 28, 2026
3ab95d4 to
070c94d
Compare
PiperOrigin-RevId: 862408126
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add primitive root calculator based on sympy
Reviewer beware: this implementation was generated entirely by Gemini. I have given it a light review, and verified the references are correct, but I am mainly relying on the robustness of the fuzz testing to ensure correctness.
Runtimes for the primitive root calculator are ~3us with optimizations and ~30us without