-
-
Notifications
You must be signed in to change notification settings - Fork 636
Fix: Correct divides() for LaurentPolynomialRing elements (closes #40… #40394
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
base: develop
Are you sure you want to change the base?
Fix: Correct divides() for LaurentPolynomialRing elements (closes #40… #40394
Conversation
r""" | ||
Return ``True`` if ``self`` divides ``other``. | ||
|
||
EXAMPLES:: | ||
|
||
sage: R.<x> = LaurentPolynomialRing(ZZ) | ||
sage: (2*x**-1 + 1).divides(4*x**-2 - 1) | ||
True | ||
sage: (2*x + 1).divides(4*x**2 + 1) | ||
False | ||
sage: (2*x + x**-1).divides(R(0)) | ||
True | ||
sage: R(0).divides(2*x ** -1 + 1) | ||
False | ||
sage: R(0).divides(R(0)) | ||
True | ||
sage: R.<x> = LaurentPolynomialRing(Zmod(6)) | ||
sage: p = 4*x + 3*x^-1 | ||
sage: q = 5*x^2 + x + 2*x^-2 | ||
sage: p.divides(q) | ||
False | ||
|
||
sage: R.<x,y> = GF(2)[] | ||
sage: S.<z> = LaurentPolynomialRing(R) | ||
sage: p = (x+y+1) * z**-1 + x*y | ||
sage: q = (y^2-x^2) * z**-2 + z + x-y | ||
sage: p.divides(q), p.divides(p*q) # needs sage.libs.singular | ||
(False, True) | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please do not move these tests.
As mentioned in the issue, the problem is with the |
…s for Zmod(4) and Zmod(8) (closes sagemath#40372)
|
did you forget to push your changes? |
I have now pushed my latest changes to this pull request. The most recent commit updates the divides() method in polynomial_element.pyx to use division with remainder for rings with zero divisors, as requested. |
No, they are not visible. Something went wrong. Please check again. |
Fix divides() for polynomials over rings with zero divisors (closes #40372)
This PR fixes the divides() method for LaurentPolynomialRing elements. The previous implementation incorrectly delegated to the underlying polynomial ring, which does not handle Laurent monomials or zero divisors correctly.
This PR fixes the divides() method for polynomials over rings with zero divisors (e.g., Zmod(4), Zmod(8)), as requested by reviewers and described by DaveWitteMorris in #40372.
Fixes #40372