Simplify computation of all points for curves over finite fields #37595
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.
This PR removes the call to
_points_fast_sqrt()
for computing the set of all points as it (seems) to always be slower than using_points_via_group_structure()
.While performing this change, I also attempted to clean up the code and simplify / clarify certain docstrings.
Justification
When a curve is defined over a prime order finite field with order larger than 50, the set of all points is computed using the group structure of the curve.
However, when a curve is implemented over a non-prime field or a field with order less than 50, the set of all points is instead computed by brute-force enumeration by checking all x-coordinates.
For all cases I have tested, this enumeration is slower.
Small characteristic, prime field
When
p < 50
:When
p > 50
Small characteristic, non-prime field
When the order is smaller than 50:
When the order is larger than 50:
Further comments
The commit which introduced
_points_fast_sqrt()
as a method implemented it for hyperelliptic curves over finite fields and then addedHyperellipticCurve_finite_field
as a parent toEllipticCurve_finite_field
to inherit this function. With the removal of the slower_points_fast_sqrt()
, this parent inheritance has been removed.ruff
noticed thatfrom sage.sets.set import Set
was unused, so I removed it📝 Checklist