Skip to content

Commit 4bd74ad

Browse files
authored
Fix Lex comparison (#153)
* Fix Lex comparison * fix
1 parent 5e0a70c commit 4bd74ad

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/comp.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ function MP.compare(
9999
j += 1
100100
end
101101
end
102+
@inbounds while i <= nvariables(x)
103+
if x.z[i] > 0
104+
return 1
105+
end
106+
i += 1
107+
end
108+
@inbounds while j <= nvariables(y)
109+
if y.z[j] > 0
110+
return -1
111+
end
112+
j += 1
113+
end
102114
return 0
103115
end
104116

test/comp.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ import DynamicPolynomials: Commutative, CreationOrder # to test hygiene
1010
@polyvar x variable_order = order
1111
@test z != x
1212
end
13+
function _less(a, b)
14+
@test a < b
15+
@test b > a
16+
@test compare(monomial(a), b) < 0
17+
@test compare(b, monomial(a)) > 0
18+
end
19+
@testset "Issue 152" begin
20+
@polyvar x y monomial_order=LexOrder
21+
_less(x, x * y)
22+
_less(x * y^2, x^2)
23+
end
1324
@testset "README example" begin
1425
function p(x, y, z)
1526
return sprint(

0 commit comments

Comments
 (0)