StackOverflowError, MutableArithmetics jump variables

I’m taking a look to see if we can fix this in MutableArithmetics. I understand the cause, but a fix is a bit tricky,

In the mean time, you can avoid the problem by ensuring that the matrix and vector have a single concrete type, like JuMP.NonlinearExpr

julia> using JuMP

julia> rotate(angle) = [cos(angle) -sin(angle); -sin(angle) cos(angle)]
rotate (generic function with 1 method)

julia> begin
           model = Model()
           @variable(model, x[1:2])
           @variable(model, angle)
           v = NonlinearExpr[x[1], x[2]]
           c = rotate(angle) * v
       end
2-element Vector{NonlinearExpr}:
 (+(0.0) + (cos(angle) * +(x[1]))) + (-(sin(angle)) * +(x[2]))
 (+(0.0) + (-(sin(angle)) * +(x[1]))) + (cos(angle) * +(x[2]))

Edit: upstream issue: StackOverflow with * between non-concrete types · Issue #336 · jump-dev/MutableArithmetics.jl · GitHub

1 Like