diff --git a/src/comparison.jl b/src/comparison.jl index 9814b4bb..8d1eba87 100644 --- a/src/comparison.jl +++ b/src/comparison.jl @@ -328,6 +328,10 @@ function ordering end ordering(::Type{<:AbstractMonomial}) = Graded{LexOrder} ordering(::Type{P}) where {P} = ordering(monomial_type(P)) ordering(p::AbstractPolynomialLike) = ordering(typeof(p)) +# Useful for instance to ask ordering given the list +# of variables +ordering(::AbstractVector{T}) where {T} = ordering(T) +ordering(t::Tuple) = ordering(first(t)) # We reverse the order of comparisons here so that the result # of x < y is equal to the result of Monomial(x) < Monomial(y) diff --git a/test/commutative/comparison.jl b/test/commutative/comparison.jl index a13aa099..7d6d9aa3 100644 --- a/test/commutative/comparison.jl +++ b/test/commutative/comparison.jl @@ -1,6 +1,10 @@ @testset "Comparison" begin @testset "Graded Lex Order" begin Mod.@polyvar x y z + O = Graded{LexOrder} + @test ordering(x) == O + @test ordering(x * y) == O + @test ordering(variables(x * y)) == O @test x > y > z @test x^2 * y > y^3 > z @test y^2 >= x