diff --git a/src/comparison.jl b/src/comparison.jl index cfa9cb9..430533a 100644 --- a/src/comparison.jl +++ b/src/comparison.jl @@ -311,18 +311,13 @@ Base.@pure function Base.cmp(v1::AbstractVariable, v2::AbstractVariable) return -cmp(name(v1), name(v2)) end -function Base.cmp(m1::AbstractMonomial, m2::AbstractMonomial) - s1, s2 = promote_variables(m1, m2) - return cmp(ordering(m1)(), exponents(s1), exponents(s2)) +function Base.:(==)(m1::AbstractMonomialLike, m2::AbstractMonomialLike) + return iszero(cmp(m1, m2)) end -function compare( - m1::AbstractMonomial, - m2::AbstractMonomial, - ::Type{O}, -) where {O<:AbstractMonomialOrdering} +function Base.cmp(m1::AbstractMonomial, m2::AbstractMonomial) s1, s2 = promote_variables(m1, m2) - return cmp(O(), exponents(s1), exponents(s2)) + return cmp(ordering(m1)(), exponents(s1), exponents(s2)) end # Implement this to make coefficients be compared with terms. @@ -344,7 +339,7 @@ function Base.cmp(t1::AbstractTermLike, t2::AbstractTermLike) return Δ end -Base.isless(t1::AbstractTermLike, t2::AbstractTermLike) = compare(t1, t2) < 0 +Base.isless(t1::AbstractTermLike, t2::AbstractTermLike) = cmp(t1, t2) < 0 """ struct ExponentsIterator{M}( diff --git a/src/default_polynomial.jl b/src/default_polynomial.jl index a7b45bf..a02c113 100644 --- a/src/default_polynomial.jl +++ b/src/default_polynomial.jl @@ -93,7 +93,7 @@ Base.one(p::Polynomial) = one(typeof(p)) Base.zero(::Type{Polynomial{C,T,A}}) where {C,T,A} = Polynomial{C,T,A}(A()) Base.zero(t::Polynomial) = zero(typeof(t)) -compare_monomials(a, b) = compare(monomial(a), monomial(b)) +compare_monomials(a, b) = cmp(monomial(a), monomial(b)) function join_terms( terms1::AbstractArray{<:Term}, @@ -294,7 +294,7 @@ function __polynomial_merge!( if tp isa Int && j isa Int tp = get1(tp) end - compare(monomial(*(monomials(q)[j], monomial.(t)...)), monomial(tp)) + cmp(monomial(*(monomials(q)[j], monomial.(t)...)), monomial(tp)) end end get2 = let t = t, q = q @@ -385,7 +385,7 @@ function __polynomial_merge!( if tp isa Int && j isa Int tp = get1(tp) end - compare(monomial(monomial(t) * monomials(q)[j]), monomial(tp)) + cmp(monomial(monomial(t) * monomials(q)[j]), monomial(tp)) end end get2 = let t = t, q = q @@ -460,7 +460,7 @@ function __polynomial_merge!( if t isa Int && j isa Int t = get1(t) end - compare(monomials(q)[j], monomial(t)) + cmp(monomials(q)[j], monomial(t)) end end get2 = let q = q diff --git a/src/sequences.jl b/src/sequences.jl index deee5c1..6106e65 100644 --- a/src/sequences.jl +++ b/src/sequences.jl @@ -18,7 +18,7 @@ function merge_sorted!( while i1 <= lastindex(v1) && i2 <= lastindex(v2) x1 = v1[i1] x2 = v2[i2] - Δ = compare(x1, x2) + Δ = cmp(x1, x2) if Δ < 0 if filter(x1) result[i] = x1