Skip to content

Commit

Permalink
gh-35335: Make FLINT polynomial factor() interruptible
Browse files Browse the repository at this point in the history
    
### πŸ“š Description

This is useful for large degree polynomials.
Currently FLINT factorization of `Zmod(n)` polynomials for small `n`
cannot be interrupted using Ctrl-C.

### πŸ“ Checklist

- [x] I have made sure that the title is self-explanatory and the
description concisely explains the PR.
- [ ] I have linked an issue or discussion.
- [x] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### βŒ› Dependencies

None
    
URL: #35335
Reported by: RΓ©my Oudompheng
Reviewer(s): Travis Scrimshaw, Vincent Delecroix
  • Loading branch information
Release Manager committed Apr 4, 2023
2 parents de75f8f + 21d1151 commit 1910013
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/sage/libs/flint/nmod_poly_linkage.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,12 @@ cdef factor_helper(Polynomial_zmod_flint poly, bint squarefree=False):
cdef nmod_poly_factor_t factors_c
nmod_poly_factor_init(factors_c)

sig_on()
if squarefree:
nmod_poly_factor_squarefree(factors_c, &poly.x)
else:
nmod_poly_factor(factors_c, &poly.x)
sig_off()

factor_list = []
cdef Polynomial_zmod_flint t
Expand Down
10 changes: 10 additions & 0 deletions src/sage/rings/polynomial/polynomial_zmod_flint.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,16 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
Traceback (most recent call last):
...
NotImplementedError: factorization of polynomials over rings with composite characteristic is not implemented
Test that factorization can be interrupted::
sage: R.<x> = PolynomialRing(GF(65537), implementation="FLINT")
sage: f = R.random_element(9973) * R.random_element(10007)
sage: alarm(0.5); f.factor()
Traceback (most recent call last):
...
AlarmInterrupt
"""
R = self.base_ring()

Expand Down

0 comments on commit 1910013

Please sign in to comment.