-
-
Notifications
You must be signed in to change notification settings - Fork 401
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 additional bindings from NTL to Polynomial_ZZ_pEX
#36097
Conversation
Add reverse and inverse_series methods to extension polynomial classes using bindings to NTL
|
Tried to fix all the pycodestyle problems, which meant editing more of the file than just my additions, hopefully this is OK, but please let me know. I added doctests for the two functions I've included but noticed other functions in this file are missing doctests. |
Thanks. You are only responsible for the code that you want to add. |
cython files are not supposed to be fully compliant with pycodestyle. You should rather undo your pycodestyle changes, except the ones insise your new code. |
Thank you for your advice. I have reverted the changes against old code and tidied up my own to match (hopefully with linting remaining happy) |
Thanks. The first line of each traceback doctest result should rather be |
Before committing etc, I will check. For interactive sage I have: ValueError Traceback (most recent call last)
Cell In [6], line 1
----> 1 f.reverse(degree=-Integer(1))
File ~/sage/sage/src/sage/rings/polynomial/polynomial_zz_pex.pyx:537, in sage.rings.polynomial.polynomial_zz_pex.Polynomial_ZZ_pEX.reverse()
535 if degree is not None:
536 if degree <= 0:
--> 537 raise ValueError("degree argument must be a non-negative integer, got %s" % (degree))
538 try:
539 d = degree
ValueError: degree argument must be a non-negative integer, got -1 I should have only: Traceback (most recent call last):
...
ValueError: degree argument must be a non-negative integer, got -1 Do I need the ellipse, or can I do Traceback (most recent call last):
ValueError: degree argument must be a non-negative integer, got -1 |
you shoudl write with the ellipsis
You can use "git grep -A2 Traceback src/sage" to compare with existing doctests of this shape. |
there is a failing doctest in
|
ok, looks good. Still some little tweaks required in the doc : In the first new method, degree should be written with two backticks before and after, not only one In the second new method, separate the first line and the rest of the first paragraph by an empty line. |
The failing doctests are known and unrelated to the present changes |
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.
ok, good to go. Thanks
Documentation preview for this PR (built with commit 1308baa; changes) is ready! 🎉 |
Thanks for all your help in getting this ready. My next contribution should be much smoother as a result :) |
There are current cython bindings to NTL methods which are not made available to polynomial rings over extension fields.
For some of these bindings, their introduction does not offer much speed up, but there is a 50x improvement for using NTL reverse over that of the current implementation, and about a 20% speed up using the NTL
ZZ_pEX_InvTrunc
over what is currently implemented.Method names and functionalities have been preserved, so this simply improves performance for the
Polynomial_ZZ_pEX
type without effecting other polynomial ring classes.Before Patch
After Patch
📝 Checklist
⌛ Dependencies
The only additional import is
sig_on()
andsig_off()
into thePolynomial_ZZ_pEX.pyx
Warning!
This is my first attempt to contribute new functions to sagemath, and it's also my first few weeks of playing with cython. I have done my best to do what is needed, but maybe I have done something incorrect. Please let me know if there's more I can do.
In particular, I know an alternative edit to the one I proposed is to modify the child
Polynomial_template
class instead of thePolynomial_ZZ_pEX
class, but I know less about all the other parents of this class and I was concerned I may make breaking changes somewhere downstream.Currently, this just adds the NTL methods when I know they are avaialble and they simply do what is done currently, but faster.