Skip to content

Commit 14ac1f7

Browse files
committed
Add diagm example
1 parent 27de9e9 commit 14ac1f7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/dense.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ Construct a matrix with elements of the vector as diagonal elements.
399399
By default, the matrix is square and its size is given by
400400
`length(v)`, but a non-square size `m`×`n` can be specified
401401
by passing `m,n` as the first arguments.
402+
If the diagonal of the matrix contains more elements than `v`,
403+
the trailing elements will be zeros.
402404
403405
# Examples
404406
```jldoctest
@@ -407,6 +409,13 @@ julia> diagm([1,2,3])
407409
1 0 0
408410
0 2 0
409411
0 0 3
412+
413+
julia> diagm(4, 5, [1,2,3])
414+
4×5 Matrix{Int64}:
415+
1 0 0 0 0
416+
0 2 0 0 0
417+
0 0 3 0 0
418+
0 0 0 0 0
410419
```
411420
"""
412421
diagm(v::AbstractVector) = diagm(0 => v)

0 commit comments

Comments
 (0)