DynamicPolynomials.jl icon indicating copy to clipboard operation
DynamicPolynomials.jl copied to clipboard

Variables on non-vector arrays breaks

Open projekter opened this issue 6 months ago • 1 comments

The definition of variables, https://github.com/JuliaAlgebra/DynamicPolynomials.jl/blob/f8fe6867f0ff41ab3cddfa17c8a658634d0f688b/src/DynamicPolynomials.jl#L63 is supposed to work on (abstract) arrays of any shape. However, by broadcasting the variables, the shape is retained, and mergevars actually expects a Vector of Vectors: https://github.com/JuliaAlgebra/DynamicPolynomials.jl/blob/f8fe6867f0ff41ab3cddfa17c8a658634d0f688b/src/var.jl#L283 So calling variables on, say, a matrix, won't work. mergevars should probably also accept AbstractArray{Vector{PV}} (as well as mergevars_to!)? Or variables should work only on Vectors (even AbstractVector would be problematic, I guess, since the output type of broadcasting is created via similar, which need not give a Vector)? Or since it is not in the MP specification, variables shouldn't support any array input at all?

projekter avatar May 22 '25 13:05 projekter

Good catch, I'd vote for mergevars to accept an AbstractArray

blegat avatar May 23 '25 09:05 blegat