Closed
Description
It would be useful to allow diagm(v)
for a vector v
, for the common case of wanting that vector on the main diagonal:
julia> using LinearAlgebra
julia> v = [3, 4]
2-element Array{Int64,1}:
3
4
julia> diagm(v)
ERROR: MethodError: no method matching diagm(::Array{Int64,1})
Closest candidates are:
diagm(::Pair{#s623,#s622} where #s622<:(AbstractArray{T,1} where T) where #s623<:Integer...) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/dense.jl:291
Stacktrace:
[1] top-level scope at none:0
julia> diagm(0=>v)
2×2 Array{Int64,2}:
3 0
0 4