-
-
Notifications
You must be signed in to change notification settings - Fork 660
add optional order= argument to .log() method for PARI finite-field elements #37329
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 optional order= argument to .log() method for PARI finite-field elements #37329
Conversation
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.
Thank you for adding this into Sage. It's been on my TODO list for a while and should have done it myself. This change looks good to me.
Is it worth doing some kind of naive check that the order supplied is the order of both self
and the base
? Maybe with a check=True
arg if nothing else? Just to catch when users accidentally send the wrong order as a param.
else:
base_order = _new_GEN_from_mpz_t((<Integer>order).value)
if check:
if not (base**base_order).is_one() and (self**base_order).is_one():
raise ValueError
5821c85
to
26c05b2
Compare
26c05b2
to
6bd17e5
Compare
Thanks! I added a |
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.
Looks good to me, should check be false by default? If we make it true the function will be a little slower but those who read the documentation can set it to be fast for speedier results?
Documentation preview for this PR (built with commit 6bd17e5; changes) is ready! 🎉 |
sagemathgh-37329: add optional order= argument to .log() method for PARI finite-field elements When the order of the base element of a finite-field logarithm is already known, factoring the unit-group order can be skipped. PARI's `fflog()` accepts the order of the base element as an optional input, but that argument is currently not exposed in Sage. This patch takes care of it. An example of the speedup is given in the new doctests. URL: sagemath#37329 Reported by: Lorenz Panny Reviewer(s): Giacomo Pope
sagemathgh-37329: add optional order= argument to .log() method for PARI finite-field elements When the order of the base element of a finite-field logarithm is already known, factoring the unit-group order can be skipped. PARI's `fflog()` accepts the order of the base element as an optional input, but that argument is currently not exposed in Sage. This patch takes care of it. An example of the speedup is given in the new doctests. URL: sagemath#37329 Reported by: Lorenz Panny Reviewer(s): Giacomo Pope
…ements Mimick Lorenz Panny's code from sagemath#37329
sagemathgh-38359: Homogenise `.log()` api across implementations of finite field elements <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Fixes sagemath#38350 by adding `order=` and `check=` arguments to the `.log()` method of finite field elements, under all implementations. - `element_pari_ffelt.pyx`: done by @yyyyx4 in sagemath#37329. - `element_ntl_gf2e.pyx`: if provided, does not compute `base_order`. - `element_givaro.pyx`: if provided, passes `order` to the underlying `discrete_log` call. - `integer_mod.pyx`: the argument is discarded (unless `check=True`, in which case the order is checked). ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#38359 Reported by: Justin Carel Reviewer(s): Lorenz Panny
When the order of the base element of a finite-field logarithm is already known, factoring the unit-group order can be skipped. PARI's
fflog()
accepts the order of the base element as an optional input, but that argument is currently not exposed in Sage. This patch takes care of it. An example of the speedup is given in the new doctests.