Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down