Skip to content

Commit 202a17c

Browse files
ZeroDivisionError in gcd of sparse polynomials
1 parent 2f1a76d commit 202a17c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/sage/rings/polynomial/polynomial_element_generic.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,17 @@ def gcd(self,other,algorithm=None):
953953
1
954954
sage: (6*x).gcd(9)
955955
3
956+
957+
Check that :trac:`36427` is fixed::
958+
959+
sage: P = PolynomialRing(ZZ, "q", sparse=True)
960+
sage: q = P.gen()
961+
sage: 2*q^-100
962+
2/q^100
963+
sage: gcd(1, q^100)
964+
1
965+
sage: gcd(q^0, q^100)
966+
1
956967
"""
957968

958969
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
@@ -969,8 +980,8 @@ def gcd(self,other,algorithm=None):
969980
# <https://groups.google.com/d/msg/sage-devel/6qhW90dgd1k/Hoq3N7fWe4QJ>
970981
sd = self.degree()
971982
od = other.degree()
972-
if max(sd,od) < 100 or \
973-
min(len(self.__coeffs)/sd, len(other.__coeffs)/od) > .06:
983+
if ((sd < 100 or len(self.__coeffs)/sd > .06)
984+
and (od < 100 or len(other.__coeffs)/od > .06)):
974985
implementation = "FLINT"
975986
else:
976987
implementation = "NTL"

0 commit comments

Comments
 (0)