JuliaAlgebra / DynamicPolynomials.jl

Multivariate polynomials implementation of commutative and non-commutative variables
Other
60 stars 20 forks source link

Bug: Using custom variables for polynomials #119

Open harris-mit opened 1 year ago

harris-mit commented 1 year ago

The following code used to work in older versions:

using DynamicPolynomials
@polyvar var1 var2
v = randn(3);
_mons = monomials([var1, var2], length(v) - 1);
p = sum(_mons .* v)
p + p
ERROR: AssertionError: issorted(Z, lt = grlex)
Stacktrace:
 [1] MonomialVector{true}(vars::Vector{PolyVar{true}}, Z::Vector{Vector{Int64}})
   @ DynamicPolynomials ~/.julia/packages/DynamicPolynomials/jOoxo/src/monovec.jl:11
 [2] plusorminus(p::Polynomial{true, Float64}, q::Polynomial{true, Float64}, op::Function)
   @ DynamicPolynomials ~/.julia/packages/DynamicPolynomials/jOoxo/src/operators.jl:53
 [3] +(x::Polynomial{true, Float64}, y::Polynomial{true, Float64})
   @ DynamicPolynomials ~/.julia/packages/DynamicPolynomials/jOoxo/src/operators.jl:130
 [4] top-level scope
   @ REPL[33]:1
harris-mit commented 1 year ago

Should I just delete the offending assertion errors?

blegat commented 1 year ago

No, the error is expected, things will get worse after the assertion so it's best the program stops there. See the detailed explanation in https://discourse.julialang.org/t/error-in-dynamicpolynomials/89196/2