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

Commit

Permalink
implement polynomial factorization modulo prime powers (by calling th…
Browse files Browse the repository at this point in the history
…e implementation for p-adics)
  • Loading branch information
yyyyx4 committed Aug 15, 2022
1 parent 7f71494 commit 19018bb
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/sage/rings/polynomial/polynomial_zmod_flint.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -736,19 +736,36 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
sage: (x^2 + 1).factor()
(x + 2) * (x + 3)
It also works for prime-power moduli::
sage: R.<x> = Zmod(23^5)[]
sage: (x^3 + 1).factor()
(x + 1) * (x^2 + 6436342*x + 1)
TESTS::
sage: R.<x> = GF(5)[]
sage: (2*x^2 + 2).factor()
(2) * (x + 2) * (x + 3)
sage: P.<x> = Zmod(10)[]
sage: (x^2).factor()
Traceback (most recent call last):
...
NotImplementedError: factorization of polynomials over rings with composite characteristic is not implemented
"""
if not self.base_ring().is_field():
raise NotImplementedError("factorization of polynomials over rings with composite characteristic is not implemented")
R = self.base_ring()

if not R.is_field():
p,e = R.characteristic().is_prime_power(get_data=True)
if not e:
raise NotImplementedError("factorization of polynomials over rings with composite characteristic is not implemented")

# Factoring is well-defined for prime-power moduli.
# For simplicity we reuse the implementation for p-adics;
# presumably this can be done faster.
from sage.rings.padics.factory import Zp
f = self.change_ring(Zp(p, prec=e))
return f.factor().base_change(self.parent())

return factor_helper(self)

Expand Down

0 comments on commit 19018bb

Please sign in to comment.