Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for zero monomial in monomial_coefficient #39256

Merged
merged 2 commits into from
Mar 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 is 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
Loading