Skip to content

Commit

Permalink
Fix Lex comparison (#153)
Browse files Browse the repository at this point in the history
* Fix Lex comparison

* fix
  • Loading branch information
blegat authored Feb 15, 2024
1 parent 5e0a70c commit 4bd74ad
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/comp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ function MP.compare(
j += 1
end
end
@inbounds while i <= nvariables(x)
if x.z[i] > 0
return 1
end
i += 1
end
@inbounds while j <= nvariables(y)
if y.z[j] > 0
return -1
end
j += 1
end
return 0
end

Expand Down
11 changes: 11 additions & 0 deletions test/comp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ import DynamicPolynomials: Commutative, CreationOrder # to test hygiene
@polyvar x variable_order = order
@test z != x
end
function _less(a, b)
@test a < b
@test b > a
@test compare(monomial(a), b) < 0
@test compare(b, monomial(a)) > 0
end
@testset "Issue 152" begin
@polyvar x y monomial_order=LexOrder
_less(x, x * y)
_less(x * y^2, x^2)
end
@testset "README example" begin
function p(x, y, z)
return sprint(
Expand Down

0 comments on commit 4bd74ad

Please sign in to comment.