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

prevent crash in order_from_multiple() due to rounding error #38490

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/sage/groups/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,17 @@ def order_from_multiple(P, m, plist=None, factorization=None, check=True,
sage: K.<a> = GF(3^60)
sage: order_from_multiple(a, 3^60 - 1, operation='*', check=False)
42391158275216203514294433200
TESTS:
Check that :issue:`38489` is fixed::
sage: from sage.groups.generic import order_from_multiple
sage: plist = [43, 257, 547, 881]
sage: m = prod(plist[:-1])
sage: elt = Zmod(m)(plist[-1])
sage: order_from_multiple(elt, m, plist=plist)
6044897
"""
Z = integer_ring.ZZ

Expand Down Expand Up @@ -1325,6 +1336,8 @@ def _order_from_multiple_helper(Q, L, S):
if abs(sum_left + v - (S / 2)) > abs(sum_left - (S / 2)):
break
sum_left += v
if not 0 < k < l:
k = l // 2
L1 = L[:k]
L2 = L[k:]
# recursive calls
Expand Down
Loading