JuliaAlgebra / DynamicPolynomials.jl

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

BoundsError trying to calculate x^0*y for non commutative x and y #71

Closed H-M-H closed 3 years ago

H-M-H commented 3 years ago
julia> using DynamicPolynomials

julia> @ncpolyvar x y
(x, y)

julia> x^0*y
ERROR: BoundsError: attempt to access 1-element Array{PolyVar{false},1} at index [0]
Stacktrace:
 [1] getindex at ./array.jl:809 [inlined]
 [2] multiplyvar at /home/hmh/.julia/packages/DynamicPolynomials/JAy5x/src/ncmult.jl:33 [inlined]
 [3] *(::Monomial{false}, ::PolyVar{false}) at /home/hmh/.julia/packages/DynamicPolynomials/JAy5x/src/ncmult.jl:93
 [4] top-level scope at REPL[3]:1
 [5] run_repl(::REPL.AbstractREPL, ::Any) at /build/julia/src/julia-1.5.2/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:288

It appears this problem arises because x^0 is not the same things as one(Monomial{false}).

blegat commented 3 years ago

Thanks for reporting this ! It should be fixed on master

H-M-H commented 3 years ago

Wow, that was quick! Thank you!