Error that I would like help reading- about creating matrices

question

#1

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


#2

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).

Try

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.


#3

Also, please quote your code with backticks.


#4

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