Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge branch 'u/tornaria/33360-ideal.is_prime' into public/33360
Browse files Browse the repository at this point in the history
  • Loading branch information
yyyyx4 committed Sep 28, 2022
2 parents 627b2bd + 6330cee commit 7f19cea
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/sage/rings/number_field/number_field_ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,10 +995,32 @@ def is_prime(self):
False
sage: K.ideal(17).is_prime() # ramified
False
TESTS::
Check that we do not factor the norm of the ideal, this used
to take half an hour, see :trac:`33360`
sage: K.<a,b,c> = NumberField([x^2-2,x^2-3,x^2-5])
sage: t = (((-2611940*c + 1925290/7653)*b - 1537130/7653*c
....: + 10130950)*a + (1343014/7653*c - 8349770)*b
....: + 6477058*c - 2801449990/4002519)
sage: t.is_prime()
False
"""
try:
return self._pari_prime is not None
except AttributeError:
K = self.number_field().pari_nf()
I = self.pari_hnf()
# This would be better, but it is broken in pari 2.13.3.
# self._pari_prime = K.idealismaximal(I) or None
# Instead we factor I, but only if the norm is a prime power
n = K.idealnorm(I)
if n.denominator() > 1 or not n.isprimepower():
self._pari_prime = None
return False
F = self.factor() # factorization with caching
if len(F) != 1 or F[0][1] != 1:
self._pari_prime = None
Expand Down

0 comments on commit 7f19cea

Please sign in to comment.