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

Improve NotImplementedError for sqrt(Mod(a,n), all=True) #39856

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
15 changes: 14 additions & 1 deletion src/sage/rings/finite_rings/integer_mod.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,19 @@ cdef class IntegerMod_abstract(FiniteRingElement):
sage: Mod(1/25, next_prime(2^90)).sqrt()^(-2)
25

Error message as requested in :issue:`38802`::

sage: sqrt(Mod(2, 101010), all=True)
Traceback (most recent call last):
...
NotImplementedError: Finding all square roots in extensions is not implemented; try extend=False to find only roots in the base ring Zmod(n).

Using the suggested ``extend=False`` works and returns an empty list
as expected::

sage: sqrt(Mod(2, 101010), all=True, extend=False)
[]

::

sage: a = Mod(3, 5); a
Expand Down Expand Up @@ -1260,7 +1273,7 @@ cdef class IntegerMod_abstract(FiniteRingElement):
z = Q.gen()
if all:
# TODO
raise NotImplementedError
raise NotImplementedError("Finding all square roots in extensions is not implemented; try extend=False to find only roots in the base ring Zmod(n).")
return z
if all:
return []
Expand Down