Skip to content

Commit b2d50f6

Browse files
committed
Fix
1 parent bf1c248 commit b2d50f6

File tree

2 files changed

+4
-116
lines changed

2 files changed

+4
-116
lines changed

src/comp.jl

Lines changed: 4 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Base.==
22

33
# TODO This should be in Base with T instead of Variable{V,M}.
44
# See https://github.com/blegat/MultivariatePolynomials.jl/issues/3
5-
function (==)(x::Vector{Variable{V,M}}, y::Vector{Variable{V,M}}) where {V,M}
5+
function Base.:(==)(x::Vector{Variable{V,M}}, y::Vector{Variable{V,M}}) where {V,M}
66
if length(x) != length(y)
77
false
88
else
@@ -20,118 +20,15 @@ end
2020

2121
const AnyCommutative{O} = Union{Commutative{O},NonCommutative{O}}
2222

23-
function (==)(
24-
x::Variable{<:AnyCommutative{CreationOrder}},
25-
y::Variable{<:AnyCommutative{CreationOrder}},
26-
)
27-
return x.variable_order.order.id == y.variable_order.order.id &&
28-
x.kind == y.kind
29-
end
30-
31-
function Base.isless(
23+
function Base.cmp(
3224
x::Variable{<:AnyCommutative{CreationOrder}},
3325
y::Variable{<:AnyCommutative{CreationOrder}},
3426
)
3527
if x.variable_order.order.id == y.variable_order.order.id
36-
return isless(y.kind, x.kind)
28+
return cmp(y.kind, x.kind)
3729
else
38-
return isless(y.variable_order.order.id, x.variable_order.order.id)
39-
end
40-
end
41-
42-
# Comparison of Monomial
43-
44-
function MP.compare(x::Monomial{V,M}, y::Monomial{V,M}) where {V,M}
45-
return MP.compare(x, y, M)
46-
end
47-
48-
function MP.compare(
49-
x::Monomial{V},
50-
y::Monomial{V},
51-
::Type{MP.InverseLexOrder},
52-
) where {V}
53-
i = MP.nvariables(x)
54-
j = MP.nvariables(y)
55-
@inbounds while i >= 1 && j >= 1
56-
if x.vars[i] < y.vars[j]
57-
if x.z[i] == 0
58-
i -= 1
59-
else
60-
return 1
61-
end
62-
elseif x.vars[i] > y.vars[j]
63-
if y.z[j] == 0
64-
j -= 1
65-
else
66-
return -1
67-
end
68-
elseif x.z[i] != y.z[j]
69-
return x.z[i] - y.z[j]
70-
else
71-
i -= 1
72-
j -= 1
73-
end
74-
end
75-
return 0
76-
end
77-
78-
function MP.compare(
79-
x::Monomial{V},
80-
y::Monomial{V},
81-
::Type{MP.LexOrder},
82-
) where {V}
83-
i = j = 1
84-
@inbounds while i <= nvariables(x) && j <= nvariables(y)
85-
if x.vars[i] > y.vars[j]
86-
if x.z[i] == 0
87-
i += 1
88-
else
89-
return 1
90-
end
91-
elseif x.vars[i] < y.vars[j]
92-
if y.z[j] == 0
93-
j += 1
94-
else
95-
return -1
96-
end
97-
elseif x.z[i] != y.z[j]
98-
return x.z[i] - y.z[j]
99-
else
100-
i += 1
101-
j += 1
102-
end
103-
end
104-
@inbounds while i <= nvariables(x)
105-
if x.z[i] > 0
106-
return 1
107-
end
108-
i += 1
30+
return cmp(y.variable_order.order.id, x.variable_order.order.id)
10931
end
110-
@inbounds while j <= nvariables(y)
111-
if y.z[j] > 0
112-
return -1
113-
end
114-
j += 1
115-
end
116-
return 0
117-
end
118-
119-
function (==)(x::Monomial{V,M}, y::Monomial{V,M}) where {V,M}
120-
return MP.compare(x, y) == 0
121-
end
122-
function (==)(x::Variable{V,M}, y::Monomial{V,M}) where {V,M}
123-
return convert(Monomial{V,M}, x) == y
124-
end
125-
126-
# graded lex ordering
127-
function Base.isless(x::Monomial{V,M}, y::Monomial{V,M}) where {V,M}
128-
return MP.compare(x, y) < 0
129-
end
130-
function Base.isless(x::Monomial{V,M}, y::Variable{V,M}) where {V,M}
131-
return isless(x, convert(Monomial{V,M}, y))
132-
end
133-
function Base.isless(x::Variable{V,M}, y::Monomial{V,M}) where {V,M}
134-
return isless(convert(Monomial{V,M}, x), y)
13532
end
13633

13734
# Comparison of MonomialVector

src/monomial_vector.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,6 @@ function _error_for_negative_degree(deg)
153153
end
154154
end
155155

156-
I = _not_first_indices(n, M)
157-
if state == 0
158-
return (zeros(Int, it.num_vars), 1)
159-
end
160-
z = zeros(Int, it.num_vars)
161-
z[_last_lex_index(it.num_vars, M)] = state
162-
return (z, state + 1)
163-
end
164-
165156
function _fill_exponents!(Z, n, degs, ::Type{Commutative}, M::Type{<:_Lex}, filter::Function)
166157
_error_for_negative_degree.(degs)
167158
maxdeg = maximum(degs, init = 0)

0 commit comments

Comments
 (0)