diff --git a/src/dense.jl b/src/dense.jl index 0656a24a..9e7eff4f 100644 --- a/src/dense.jl +++ b/src/dense.jl @@ -399,6 +399,7 @@ Construct a matrix with elements of the vector as diagonal elements. By default, the matrix is square and its size is given by `length(v)`, but a non-square size `m`×`n` can be specified by passing `m,n` as the first arguments. +The diagonal will be zero-padded if necessary. # Examples ```jldoctest @@ -407,6 +408,13 @@ julia> diagm([1,2,3]) 1 0 0 0 2 0 0 0 3 + +julia> diagm(4, 5, [1,2,3]) +4×5 Matrix{Int64}: + 1 0 0 0 0 + 0 2 0 0 0 + 0 0 3 0 0 + 0 0 0 0 0 ``` """ diagm(v::AbstractVector) = diagm(0 => v)