-
-
Notifications
You must be signed in to change notification settings - Fork 673
speed up construction of kernel polynomial for Vélu isogeny using product tree #40948
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
base: develop
Are you sure you want to change the base?
speed up construction of kernel polynomial for Vélu isogeny using product tree #40948
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.
Good change, it does make me wonder if it would be good to make a polynomial from roots method. I know flint has methods for this and maybe NTL does too?
for xQ in self.__kernel_mod_sign.keys(): | ||
psi *= x - invX(xQ) | ||
from sage.misc.misc_c import prod | ||
psi = prod([x - invX(xQ) for xQ in self.__kernel_mod_sign.keys()]) # building the list is not redundant; this is slightly faster |
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.
really? prod
delegates to iterator_prod
if the input is a generator. Where does the overhead come from?
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.
actually the overhead might be because Python can inline the list comprehension, but not the generator expression.
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.
doesnt prod use a binary tree for the product when given a list?
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.
Last time I checked, the difference was that passing an iterator makes it use a different (suboptimal) tree structure since the total length is not a priori known.
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.
Looking at it again, I'm not sure if that is the reason: iterator_prod()
does promise that the tree will be balanced... So you might be right, @user202729.
Documentation preview for this PR (built with commit c9545c8; changes) is ready! 🎉 |
Nice suggestion. Should we add the |
I had a look (albeit quickly) for the function in NTL and couldn't see it. So maybe it's just flint that supports it? I dunno what's best. Maybe just a generic python implementation and then a call to library specific functions if they exist. This feels like a good place to introduce the patch but also it could be in a new PR to avoid this taking up more of your time. |
sagemathgh-40948: speed up construction of kernel polynomial for Vélu isogeny using product tree Computing a product of a collection of linear polynomials is best done using a balanced product tree. Example: ```sage sage: E = EllipticCurve(GF(16411), [1,0]) sage: P = E.lift_x(25) sage: phi = E.isogeny(P) sage: assert phi._EllipticCurveIsogeny__algorithm == 'velu' sage: %time _ = phi.kernel_polynomial() ``` Current `develop`: ``` CPU times: user 25.6 ms, sys: 0 ns, total: 25.6 ms Wall time: 25.7 ms ``` This branch: ``` CPU times: user 13.7 ms, sys: 0 ns, total: 13.7 ms Wall time: 13.8 ms ``` URL: sagemath#40948 Reported by: Lorenz Panny Reviewer(s): Giacomo Pope, Lorenz Panny, user202729
sagemathgh-40948: speed up construction of kernel polynomial for Vélu isogeny using product tree Computing a product of a collection of linear polynomials is best done using a balanced product tree. Example: ```sage sage: E = EllipticCurve(GF(16411), [1,0]) sage: P = E.lift_x(25) sage: phi = E.isogeny(P) sage: assert phi._EllipticCurveIsogeny__algorithm == 'velu' sage: %time _ = phi.kernel_polynomial() ``` Current `develop`: ``` CPU times: user 25.6 ms, sys: 0 ns, total: 25.6 ms Wall time: 25.7 ms ``` This branch: ``` CPU times: user 13.7 ms, sys: 0 ns, total: 13.7 ms Wall time: 13.8 ms ``` URL: sagemath#40948 Reported by: Lorenz Panny Reviewer(s): Giacomo Pope, Lorenz Panny, user202729
Computing a product of a collection of linear polynomials is best done using a balanced product tree.
Example:
Current
develop
:This branch: