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

add generic has_order() function #36806

Merged
merged 6 commits into from
Jan 14, 2024

Conversation

yyyyx4
Copy link
Member

@yyyyx4 yyyyx4 commented Dec 3, 2023

Currently there is order_from_multiple() for generic groups, but sometimes we really only want to know if the order equals a particular value (e.g., when sampling random elements to find a generating set of a group with known structure). This means the computation can be aborted earlier than when finding the exact order is required.

In this patch we add such an optimized has_order() function as well as a convenience wrapper for elliptic-curve points. An example of the speedup can be found in one of the new doctests.

n = n.factor()

G = P.parent()
if operation == '+':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to use operator.add and operator.mul than string comparisons. Although strings seem to be used elsewhere...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the long run, all of these ad-hoc interfaces should be replaced by a proper wrapper class (which is work in progress). For now, I'd stick to doing it the same way as the existing functions in this file...

@yyyyx4 yyyyx4 force-pushed the public/generic_has_order_function branch from ebaa89c to be14d9f Compare December 26, 2023 20:41
Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, fair enough. Then just a few more little things.

Copy link

github-actions bot commented Jan 2, 2024

Documentation preview for this PR (built with commit 3e61e7d; changes) is ready! 🎉

Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. LGTM now.

@yyyyx4
Copy link
Member Author

yyyyx4 commented Jan 3, 2024

Thank you!

vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 5, 2024
sagemathgh-36806: add generic has_order() function
    
Currently there is `order_from_multiple()` for generic groups, but
sometimes we really only want to know if the order equals a particular
value (e.g., when sampling random elements to find a generating set of a
group with known structure). This means the computation can be aborted
earlier than when finding the exact order is required.

In this patch we add such an optimized `has_order()` function as well as
a convenience wrapper for elliptic-curve points.  An example of the
speedup can be found in one of the new doctests.
    
URL: sagemath#36806
Reported by: Lorenz Panny
Reviewer(s): Lorenz Panny, Travis Scrimshaw
@vbraun vbraun merged commit cecd9a2 into sagemath:develop Jan 14, 2024
@mkoeppe mkoeppe added this to the sage-10.3 milestone Jan 14, 2024
@yyyyx4 yyyyx4 deleted the public/generic_has_order_function branch January 19, 2024 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants