-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
is_prime for ideals uses factorization, can be VERY slow #34980
Conversation
The single test failure is unrelated and will be fixed by #35017. |
Codecov ReportBase: 88.59% // Head: 88.58% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## develop #34980 +/- ##
===========================================
- Coverage 88.59% 88.58% -0.02%
===========================================
Files 2140 2140
Lines 396998 396963 -35
===========================================
- Hits 351740 351651 -89
- Misses 45258 45312 +54
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
I'm thinking something simple like this: diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
index 1a9d11aec68..8ca1f958039 100644
--- a/src/sage/rings/number_field/number_field_ideal.py
+++ b/src/sage/rings/number_field/number_field_ideal.py
@@ -1017,13 +1017,15 @@ class NumberFieldIdeal(Ideal_generic):
K = self.number_field().pari_nf()
I = self.pari_hnf()
- self._pari_prime = K.idealismaximal(I) or None
+ candidate = K.idealismaximal(I) or None
# PARI uses probabilistic primality testing inside idealismaximal().
- if self._pari_prime \
- and get_flag(None, 'arithmetic') \
- and not self._pari_prime[0].isprime():
- self._pari_prime = None
+ if get_flag(None, 'arithmetic'):
+ # proof required, check using isprime()
+ if candidate and not candidate[0].isprime():
+ candidate = None
+
+ self._pari_prime = candidate
return self._pari_prime is not None
What do you think? You are probably right that there is no way to trigger anything bad here, but it still smells to me. It also feels easier to read if the condition In any case, do you think it's better to squash everything into a single commit? The final diff is much simpler than 5-6 commits. |
In the added TEST, the ideal norm is product of two primes but factoring this product takes about half an hour, so factoring the ideal is slow. To fix the issue, we use PARI's idealismaximal() function instead. Co-authored-by: Gonzalo Tornaría <tornaria@cmat.edu.uy> Co-authored-by: Lorenz Panny <lorenz@yx7.cc>
Okay, all done, including squashing. |
Documentation preview for this PR is ready! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #33360.