Avoid overflow in passing large exponents to singular #40455
+83
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #40442
I don't know what the output would be in 32-bit.
I think it's justified to change
singular_polynomial_pow
'sexp
parameter type fromunsigned long
toint
, because previously it didn't work forint
anyway (since singular'spPower
takesint
parameter). We could keep making it takeunsigned long
and do the divmodINT_MAX
at low level, but I find it easier to do that at high level (Python), where, as can be seen from this pull request, that takes only 3 lines of code.I think it's completely impractical to raise anything except monomials to power larger than 2^31 anyway. Except maybe
(x+y)^2^n mod 2
, but that can only be quickly calculated when internally repeated squaring is used.📝 Checklist
⌛ Dependencies