@@ -4,6 +4,106 @@ export monomial_vector,
4
4
sort_monomial_vector,
5
5
merge_monomial_vectors
6
6
7
+ export LexOrder, InverseLexOrder, Reverse, Graded
8
+
9
+ """
10
+ abstract type AbstractMonomialOrdering end
11
+
12
+ Abstract type for monomial ordering as defined in [CLO13, Definition 2.2.1, p. 55]
13
+
14
+ [CLO13] Cox, D., Little, J., & OShea, D.
15
+ *Ideals, varieties, and algorithms: an introduction to computational algebraic geometry and commutative algebra*.
16
+ Springer Science & Business Media, **2013**.
17
+ """
18
+ abstract type AbstractMonomialOrdering end
19
+
20
+ """
21
+ compare(a, b, order::AbstractMonomialOrdering)
22
+
23
+ Returns a negative number if `a < b`, a positive number if `a > b` and zero if `a == b`.
24
+ """
25
+ function compare end
26
+
27
+ """
28
+ struct LexOrder <: AbstractMonomialOrdering end
29
+
30
+ Lexicographic (Lex for short) Order often abbreviated as *lex* order as defined in [CLO13, Definition 2.2.3, p. 56]
31
+
32
+ The [`Graded`](@ref) version is often abbreviated as *grlex* order and is defined in [CLO13, Definition 2.2.5, p. 58]
33
+
34
+ [CLO13] Cox, D., Little, J., & OShea, D.
35
+ *Ideals, varieties, and algorithms: an introduction to computational algebraic geometry and commutative algebra*.
36
+ Springer Science & Business Media, **2013**.
37
+ """
38
+ struct LexOrder <: AbstractMonomialOrdering end
39
+
40
+ """
41
+ struct InverseLexOrder <: AbstractMonomialOrdering end
42
+
43
+ Inverse Lex Order defined in [CLO13, Exercise 2.2.6, p. 61] where it is abbreviated as *invlex*.
44
+ It corresponds to [`LexOrder`](@ref) but with the variables in reverse order.
45
+
46
+ The [`Graded`](@ref) version can be abbreviated as *grinvlex* order.
47
+ It is defined in [BDD13, Definition 2.1] where it is called *Graded xel order*.
48
+
49
+ [CLO13] Cox, D., Little, J., & OShea, D.
50
+ *Ideals, varieties, and algorithms: an introduction to computational algebraic geometry and commutative algebra*.
51
+ Springer Science & Business Media, **2013**.
52
+ [BDD13] Batselier, K., Dreesen, P., & De Moor, B.
53
+ *The geometry of multivariate polynomial division and elimination*.
54
+ SIAM Journal on Matrix Analysis and Applications, 34(1), 102-125, *2013*.
55
+ """
56
+ struct InverseLexOrder <: AbstractMonomialOrdering end
57
+
58
+ """
59
+ struct Graded{O<:AbstractMonomialOrdering} <: AbstractMonomialOrdering
60
+ same_degree_ordering::O
61
+ end
62
+
63
+ Monomial ordering defined by:
64
+ * `degree(a) == degree(b)` then the ordering is determined by `same_degree_ordering`,
65
+ * otherwise, it is the ordering between the integers `degree(a)` and `degree(b)`.
66
+ """
67
+ struct Graded{O<: AbstractMonomialOrdering } <: AbstractMonomialOrdering
68
+ same_degree_ordering:: O
69
+ end
70
+
71
+ _deg (exponents) = sum (exponents)
72
+ _deg (mono:: AbstractMonomial ) = degree (mono)
73
+
74
+ function compare (a, b, ordering:: Graded )
75
+ deg_a = _deg (a)
76
+ deg_b = _deg (b)
77
+ if deg_a == deg_b
78
+ return compare (a, b, ordering. same_degree_ordering)
79
+ else
80
+ return deg_a - deg_b
81
+ end
82
+ end
83
+
84
+ """
85
+ struct Reverse{O<:AbstractMonomialOrdering} <: AbstractMonomialOrdering
86
+ reverse_order::O
87
+ end
88
+
89
+ Monomial ordering defined by `compare(a, b, order) = compare(b, a, order.reverse_order)`..
90
+
91
+ Reverse Lex Order defined in [CLO13, Exercise 2.2.9, p. 61] where it is abbreviated as *rinvlex*.
92
+ can be obtained as `Reverse(InverseLexOrder())`.
93
+
94
+ The Graded Reverse Lex Order often abbreviated as *grevlex* order defined in [CLO13, Definition 2.2.6, p. 58]
95
+ can be obtained as `Graded(Reverse(InverseLexOrder()))`.
96
+
97
+ [CLO13] Cox, D., Little, J., & OShea, D.
98
+ *Ideals, varieties, and algorithms: an introduction to computational algebraic geometry and commutative algebra*.
99
+ Springer Science & Business Media, **2013**.
100
+ """
101
+ struct Reverse{O<: AbstractMonomialOrdering } <: AbstractMonomialOrdering
102
+ reverse_ordering:: O
103
+ end
104
+
105
+ compare (a, b, ordering:: Reverse ) = compare (b, a, ordering. reverse_ordering)
106
+
7
107
function monomials (v:: AbstractVariable , degree, args... )
8
108
return monomials ((v,), degree, args... )
9
109
end
0 commit comments