forked from sagemath/sage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sagemathgh-39018: Fix Singular polynomial comparison
Fixes sagemath#35681 Basically, I think this change makes the comparison makes more sense (apart from that, it should speed up the comparison a bit because it only calls `cfGreater` when `cfEqual` returns `False`, and get rid of the `cfSub`) After this change, **as long as `cfGreater` defines a total order, you get a total order on the polynomials**. For example now `Integers(10)[]` has a total order. For unordered fields however, `cfGreater` may not define a total order anyway; but in newer Singular, `cfGreater` now defines a total order. It's not always consistent with `cfGreaterZero` though. Singular/Singular#1253 (comment) There's a lot of test breakage because now we change which polynomial compares greater than `0`, and that is used to determine whether the sign to display is `+` or `-` in several places. -------- More detail: ```python TESTS:: sage: R.<x, y> = ZZ[] sage: x^2+x > x^2 True sage: x^2 > x^2-x # NEW True sage: x^2 > x^2-x # OLD False sage: x^2+x > x^2-x True sage: x^2 > 0 True sage: -x^2 > 0 # NEW False sage: -x^2 > 0 # OLD True sage: x^2 > -x^2 True :: sage: R.<x, y> = GF(7)[] sage: x^2+x > x^2 True sage: x^2 > x^2-x # NEW True sage: x^2 > x^2-x # OLD False sage: x^2+x > x^2-x # NEW False sage: x^2+x > x^2-x # OLD True sage: x^2 > 0 True sage: -x^2 > 0 # NEW False sage: -x^2 > 0 # OLD True sage: x^2 > -x^2 # NEW False sage: x^2 > -x^2 # OLD True :: sage: R.<x, y> = Integers(8)[] sage: x^2+x > x^2 True sage: x^2 > x^2-x # NEW True sage: x^2 > x^2-x # OLD False sage: x^2+x > x^2-x True sage: x^2 > 0 True sage: -x^2 > 0 # NEW False sage: -x^2 > 0 # OLD True sage: x^2 > -x^2 True :: sage: R.<x, y> = Integers(10)[] sage: x^2+x > x^2 True sage: x^2 > x^2-x False sage: x^2+x > x^2-x # NEW False sage: x^2+x > x^2-x # OLD True sage: x^2 > 0 True sage: -x^2 > 0 True sage: x^2 > -x^2 # NEW False sage: x^2 > -x^2 # OLD True :: sage: R.<x, y> = ZZ[] sage: l = [i*x+j*x^2 for i in range(-5, 5) for j in range(-5, 5)] sage: l.sort() sage: for i in range(len(l)): ....: for b in l[:i]: ....: assert b < l[i], (b, l[i]) :: sage: R.<x, y> = Integers(10)[] sage: l = [i*x+j*y for i in range(7) for j in range(7)] sage: l.sort() sage: for i in range(len(l)): # NEW ....: for b in l[:i]: ....: assert b < l[i], (b, l[i]) sage: for i in range(len(l)): # OLD ....: for b in l[:i]: ....: assert b < l[i], (b, l[i]) Traceback (most recent call last): ... AssertionError: (y, 2*y) ``` The comparison function was added all the way back in 2007 without explanation e22dc86 ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39018 Reported by: user202729 Reviewer(s): Kwankyu Lee, user202729
- Loading branch information
Showing
34 changed files
with
518 additions
and
472 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.