Skip to content

Commit d0fe6f3

Browse files
committed
add check for zero monomial
1 parent 1be0a58 commit d0fe6f3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/sage/rings/polynomial/multi_polynomial_libsingular.pyx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,6 +2985,15 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
29852985
-1
29862986
sage: f.monomial_coefficient(x^10)
29872987
0
2988+
2989+
TESTS::
2990+
2991+
sage: R.<x,y> = PolynomialRing(ZZ)
2992+
sage: f = x + y
2993+
sage: f.monomial_coefficient(x - x)
2994+
Traceback (most recent call last):
2995+
...
2996+
ValueError: mon must not be equal to 0.
29882997
"""
29892998
cdef poly *p = self._poly
29902999
cdef poly *m = mon._poly
@@ -2993,6 +3002,9 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
29933002
if mon._parent is not self._parent:
29943003
raise TypeError("mon must have same parent as self.")
29953004

3005+
if mon._poly == NULL:
3006+
raise ValueError("mon must not be equal to 0.")
3007+
29963008
while p:
29973009
if p_ExpVectorEqual(p, m, r) == 1:
29983010
return si2sa(p_GetCoeff(p, r), r, self._parent._base)

0 commit comments

Comments
 (0)