jump-dev / MutableArithmetics.jl

Interface for arithmetics on mutable types in Julia
Mozilla Public License 2.0
50 stars 8 forks source link

Confusing error in mul! #251

Closed odow closed 10 months ago

odow commented 10 months ago
julia> using JuMP

julia> model = Model()
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.

julia> @variable(model, x[1:2], container = DenseAxisArray)
1-dimensional DenseAxisArray{VariableRef,1,...} with index sets:
    Dimension 1, Base.OneTo(2)
And data, a 2-element Vector{VariableRef}:
 x[1]
 x[2]

julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> A*x
ERROR: MethodError: no method matching -(::CartesianIndex{1}, ::Int64)

Closest candidates are:
  -(::T, ::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}
   @ Base int.jl:86
  -(::Union{MathOptInterface.VariableIndex, MathOptInterface.ScalarAffineFunction{T}, MathOptInterface.ScalarQuadraticFunction{T}, MathOptInterface.VectorAffineFunction{T}, MathOptInterface.VectorOfVariables, MathOptInterface.VectorQuadraticFunction{T}}, ::T) where T<:Number
   @ MathOptInterface ~/.julia/packages/MathOptInterface/pgWRA/src/Utilities/functions.jl:1591
  -(::T, ::Integer) where T<:AbstractChar
   @ Base char.jl:227
  ...

Stacktrace:
 [1] _add_mul_array
   @ ~/.julia/packages/MutableArithmetics/solfs/src/implementations/LinearAlgebra.jl:306 [inlined]
 [2] buffered_operate!
   @ ~/.julia/packages/MutableArithmetics/solfs/src/implementations/LinearAlgebra.jl:340 [inlined]
 [3] operate!
   @ ~/.julia/packages/MutableArithmetics/solfs/src/implementations/LinearAlgebra.jl:359 [inlined]
 [4] operate_to!(C::Vector{AffExpr}, #unused#::typeof(*), A::Matrix{Int64}, B::JuMP.Containers.DenseAxisArray{VariableRef, 1, Tuple{Base.OneTo{Int64}}, Tuple{JuMP.Containers._AxisLookup{Base.OneTo{Int64}}}})
   @ MutableArithmetics ~/.julia/packages/MutableArithmetics/solfs/src/implementations/LinearAlgebra.jl:377
 [5] _mul!
   @ ~/.julia/packages/MutableArithmetics/solfs/src/dispatch.jl:142 [inlined]
 [6] mul!
   @ ~/.julia/packages/MutableArithmetics/solfs/src/dispatch.jl:157 [inlined]
 [7] *(A::Matrix{Int64}, x::JuMP.Containers.DenseAxisArray{VariableRef, 1, Tuple{Base.OneTo{Int64}}, Tuple{JuMP.Containers._AxisLookup{Base.OneTo{Int64}}}})
   @ LinearAlgebra ~/.julia/juliaup/julia-1.9.3+0.x64.apple.darwin14/share/julia/stdlib/v1.9/LinearAlgebra/src/matmul.jl:56
 [8] top-level scope
   @ REPL[43]:1