JuliaAlgebra / DynamicPolynomials.jl

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

Substitution of rational constants #47

Closed ahumenberger closed 5 years ago

ahumenberger commented 5 years ago

It seems there is an issue regarding substitution:

@polyvar n
M = [1//1 n^2; 0//1 1//1]
sx = x -> subs(x, n=>n-1)
sx.(M)

yields

ERROR: AssertionError: !(isempty(z))
Stacktrace:
 [1] monoeval(::Array{Int64,1}, ::Array{Polynomial{true,Int64},1}) at /Users/ahumenberger/.julia/packages/DynamicPolynomials/hlNtQ/src/subs.jl:56
 [2] _subs at /Users/ahumenberger/.julia/packages/DynamicPolynomials/hlNtQ/src/subs.jl:68 [inlined]
 [3] substitute at /Users/ahumenberger/.julia/packages/DynamicPolynomials/hlNtQ/src/subs.jl:89 [inlined]
 [4] subs(::Term{true,Rational{Int64}}, ::Pair{PolyVar{true},Polynomial{true,Int64}}) at /Users/ahumenberger/.julia/packages/MultivariatePolynomials/JSgfU/src/substitution.jl:113
 [5] (::getfield(Main, Symbol("##9#10")))(::Term{true,Rational{Int64}}) at ./REPL[26]:1
 [6] top-level scope at none:0

On closer inspection it turns out that subs cannot handle the rational constants which are of type Term{true,Rational{Int64}}. For M = [1//1 1//1; 0//1 1//1] the above works fine since the elements within M are of type Rational{Int64}. M = [n n^2; n^3 n^4] works as well.

blegat commented 5 years ago

Thanks for reporting the bug !