Skip to content

Commit 985e962

Browse files
authored
Add ordering for a vector of variables (#327)
* Add ordering for a vector of variables * Add tests
1 parent 03d6b8b commit 985e962

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/comparison.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ function ordering end
328328
ordering(::Type{<:AbstractMonomial}) = Graded{LexOrder}
329329
ordering(::Type{P}) where {P} = ordering(monomial_type(P))
330330
ordering(p::AbstractPolynomialLike) = ordering(typeof(p))
331+
# Useful for instance to ask ordering given the list
332+
# of variables
333+
ordering(::AbstractVector{T}) where {T} = ordering(T)
334+
ordering(t::Tuple) = ordering(first(t))
331335

332336
# We reverse the order of comparisons here so that the result
333337
# of x < y is equal to the result of Monomial(x) < Monomial(y)

test/commutative/comparison.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
@testset "Comparison" begin
22
@testset "Graded Lex Order" begin
33
Mod.@polyvar x y z
4+
O = Graded{LexOrder}
5+
@test ordering(x) == O
6+
@test ordering(x * y) == O
7+
@test ordering(variables(x * y)) == O
48
@test x > y > z
59
@test x^2 * y > y^3 > z
610
@test y^2 >= x

0 commit comments

Comments
 (0)