Skip to content

Commit a8d720e

Browse files
committed
faster roots when multiplicities=False for polynomials over finite fields
1 parent 85c8f1e commit a8d720e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/sage/rings/finite_rings/integer_mod_ring.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1935,7 +1935,12 @@ def _roots_univariate_polynomial(self, f, ring=None, multiplicities=True, algori
19351935

19361936
# Finite fields are a base case
19371937
if self.is_field():
1938-
return f._roots_from_factorization(f.factor(), False)
1938+
R = f.parent()
1939+
x = R.gen()
1940+
p = R.modulus()
1941+
g = pow(x, p, f) - x
1942+
g = f.gcd(g)
1943+
return g._roots_from_factorization(g.factor(), False)
19391944

19401945
# Otherwise, find roots modulo each prime power
19411946
fac = self.factored_order()

0 commit comments

Comments
 (0)