Skip to content
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

change sorting for WeierstrassIsomorphism #34728

Closed
yyyyx4 opened this issue Nov 7, 2022 · 12 comments
Closed

change sorting for WeierstrassIsomorphism #34728

yyyyx4 opened this issue Nov 7, 2022 · 12 comments

Comments

@yyyyx4
Copy link
Member

yyyyx4 commented Nov 7, 2022

Currently, EllipticCurve_generic.automorphisms() returns the automorphisms in a more or less arbitrary (albeit deterministic) order.

It is much more natural to users to receive a list with the identity and negation first, since they exist for any curve, then any other automorphisms that may exist. (I have personally seen code making this incorrect assumption.)

In this patch, we change ._comparison_impl() for WeierstrassIsomorphism in such a way that [1] and [-1] will appear first in a sorted list of automorphisms.

Diff without the dependencies: sagemath/sagetrac-mirror@d92c9f4...c9e9646

Depends on #34727
Depends on #34722

CC: @JohnCremona

Component: elliptic curves

Author: Lorenz Panny

Branch/Commit: c9e9646

Reviewer: John Cremona

Issue created by migration from https://trac.sagemath.org/ticket/34728

@yyyyx4 yyyyx4 added this to the sage-9.8 milestone Nov 7, 2022
@yyyyx4

This comment has been minimized.

@JohnCremona
Copy link
Member

Reviewer: John Cremona

@JohnCremona
Copy link
Member

comment:2

All looks good, and I agree with the sorting strategy. Two questions: (1) when p=2 in the random test is it still the case that the second auto in the list is multiplcation by -1? (2) In the test for the length of the autos, for the last two cases you don't really need to put both 0 and 1728 in the list since they are equal :) But I will not insist.

As long as the answer to (1) is yes, you can take a positive review from me.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 8, 2022

Changed commit from 6eaaf7e to c9e9646

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 8, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

4c4ce930 == 1728 in characteristics 2 and 3
c9e9646compare entire (u,r,s,t) tuple

@yyyyx4

This comment has been minimized.

@yyyyx4
Copy link
Member Author

yyyyx4 commented Nov 8, 2022

comment:4

Thank you for the feedback!

(2) Done.

(1) The answer used to be no (I had incorrectly assumed that u uniquely identifies the isomorphism, which is manifestly untrue in characteristics 2 and 3), but it should be handled correctly now. This did require moving the comparison up from baseWI to WeierstrassIsomorphism, as the former knows nothing about the domain curve.

Since the new changes are not totally trivial, I'll let you have another look rather than setting it to positive review right away.

Another question: Did you check all modifications in this branch or just the ones in "diff without the dependencies"?

@JohnCremona
Copy link
Member

comment:5

I checked all. Can't check again right now as travelling.

@JohnCremona
Copy link
Member

comment:6

Thanks for the two extra changes. I like that the new sorting key code ends up several lines shorter!

@yyyyx4
Copy link
Member Author

yyyyx4 commented Nov 10, 2022

comment:7

Thank you! I'll also boldly go ahead and set #34722 to positive review, since the changes there are contained in this branch — which you've reviewed.

@JohnCremona
Copy link
Member

comment:8

Replying to Lorenz Panny:

Thank you! I'll also boldly go ahead and set #34722 to positive review, since the changes there are contained in this branch — which you've reviewed.

OK fine

@vbraun
Copy link
Member

vbraun commented Dec 3, 2022

Changed branch from public/sort_elliptic_curve_isomorphisms to c9e9646

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants