diff --git a/src/comp.jl b/src/comp.jl index b29a6e3..d9c0fbd 100644 --- a/src/comp.jl +++ b/src/comp.jl @@ -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 diff --git a/test/comp.jl b/test/comp.jl index 42e2f4a..2e72721 100644 --- a/test/comp.jl +++ b/test/comp.jl @@ -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(