JuliaAlgebra / MultivariatePolynomials.jl

Multivariate polynomials interface
https://juliaalgebra.github.io/MultivariatePolynomials.jl/stable/
Other
134 stars 27 forks source link

Order of monomial vector #269

Closed projekter closed 1 year ago

projekter commented 1 year ago

In pre-0.5 versions, monomial vectors were ordered decreasingly. Accordingly, the documentation for monovec states:

Returns the vector of monomials X in decreasing order and without any duplicates. Calling monomial_vector on [xy, x, xy, x^2y, x] should return [x^2y, xy, x].

This was true:

julia> using DynamicPolynomials
julia> @polyvar x y;
julia> mv = monovec([x*y, x, x*y, x^2*y, x])
3-element MonomialVector{true}:
 x²y
 xy
 x
julia> mv[1] > mv[2] > mv[3]
true

For 0.5, the documentation is unchanged. However, now the vector is sorted in increasing order:

julia> using DynamicPolynomials
julia> @polyvar x y;
julia> mv = monovec([x*y, x, x*y, x^2*y, x])
3-element MonomialVector{DynamicPolynomials.Commutative{DynamicPolynomials.CreationOrder}, Graded{LexOrder}}:
 x
 xy
 x²y
julia> mv[1] < mv[2] < mv[3]
true

Same happens for TypedPolynomials. So I guess the behavior changed intentionally, but the documentation was not updated?

blegat commented 1 year ago

Thanks for reporting this, this is quite a big breaking change so I tried to make it visible and even added a warning in the README of this package but I might have missed that docstring