From 45a99a8843497a8d2ff9b688f6436e8b3d7f1503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Fri, 13 Jun 2025 23:00:19 +0200 Subject: [PATCH 1/2] Add ordering for a vector of variables --- src/comparison.jl | 4 ++++ 1 file changed, 4 insertions(+) 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) From eb34d9fd36c7bb6f2c47a6becb0438c56f762015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 27 Aug 2025 14:55:53 +0200 Subject: [PATCH 2/2] Add tests --- test/commutative/comparison.jl | 4 ++++ 1 file changed, 4 insertions(+) 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