MultivariatePolynomials.jl
MultivariatePolynomials.jl copied to clipboard
Monomial ordering
Could elaborate which monomial ordering is currently used? Lexicographic? And is this enforced by the interface, i.e. MultivariatePolynomials, or is it depending on the implementation, i.e. DynamicPolynomials etc.? And would it maybe make sense to be able to specify the ordering?
Currently the ordering used is graded lexicographic order by DynamicPolynomials and TypedPolynomials. I agree that it would be nice to query the ordering used and be able to choose the monomial ordering in e.g. @polyvar
.
There are actually two things. The first one is the ordering and the other is the ordering of the variables itself. Currently we have the following behaviour:
DynamicPolynomials.@polyvar b a
results in the variable ordering b
> a
but TypedPolynomials.@polyvar b a
results in a
> b
. This is quite subtle and could lead to some surprises.
cc: @rdeits
Yes, DynamicPolynomials
compares variables using creation order while TypedPolynomials
compares them with names. There is the same subtlety with ==
:-P
The problem is that in TypedPolynomials the only identity a Variable has is its literal name, so that's the only information I can possibly use for comparison. Perhaps this is just something we have to document better?
With the 0.5 release, there is the possibility to have different monomial orderings (although it is not fully implemented yet, as for example DP.monomials
always generates graded lex order and therefore fails to produce valid monomial vectors, as mentioned in https://github.com/JuliaAlgebra/DynamicPolynomials.jl/issues/138).
However, unless I'm mistaken, a way to query this ordering is still missing: While there is ordering(::APL)
, this gives the AbstractOrdering
of the polynomial, which does not seem to be related in any way with the AbstractMonomialOrdering
of the monomials.
There is no such monomial_ordering(::Monomial{V,M}) where {V,M} = M
, as for example the implementation in DynamicPolynomials would look like.
Oops, indeed this ordering
and AbstractOrdering
are not in sync with the rest, we should make it match