Skip to content

Commit

Permalink
add check for zero monomial
Browse files Browse the repository at this point in the history
  • Loading branch information
keltecc committed Jan 3, 2025
1 parent c9dd1e8 commit 27f754a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2985,6 +2985,15 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
-1
sage: f.monomial_coefficient(x^10)
0
TESTS::
sage: R.<x,y> = PolynomialRing(ZZ)
sage: f = x + y
sage: f.monomial_coefficient(x - x)
Traceback (most recent call last):
...
ValueError: mon must not be equal to 0.
"""
cdef poly *p = self._poly
cdef poly *m = mon._poly
Expand All @@ -2993,6 +3002,9 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
if mon._parent is not self._parent:
raise TypeError("mon must have same parent as self.")

if mon._poly == NULL:
raise ValueError("mon must not be equal to 0.")

while p:
if p_ExpVectorEqual(p, m, r) == 1:
return si2sa(p_GetCoeff(p, r), r, self._parent._base)
Expand Down

0 comments on commit 27f754a

Please sign in to comment.