Error that I would like help reading- about creating matrices

I have posted the error below, I am new to Julia and would take any suggestions on interpreting/fixing it:

MethodError: no method matching kron(::Array{JuMP.GenericAffExpr{Float64,JuMP.Variable},2}, ::UniformScaling{Int64})
Closest candidates are:
kron(::Any, ::Any, ::Any, ::Any…) at operators.jl:424
kron(::Union{Array{T,1}, Array{T,2}} where T, ::SparseMatrixCSC) at sparse\linalg.jl:785
kron(::AbstractArray{T,2}, ::AbstractArray{S,2}) where {T, S} at linalg\dense.jl:313

It would be helpful if you could also post your input.

I find UniformScaling slightly awkward to use in that it is not an AbstractArray (i.e. it doesn’t not always behave like an array), so it doesn’t always have methods defined for it).


kron(x, Diagonal(ones(N)))

where x is your first argument and N is the number of dimensions in your second argument. This should work but is probably not the most efficient way of doing whatever it is you’re trying to achieve.


Also, please quote your code with backticks.

1 Like

Thank you! I may give more information when I can for better performance however your suggestion has worked in the meantime.

1 Like