Skip to content

Commit 69fa500

Browse files
committed
Add diagm example (#1298)
1 parent 465b5b9 commit 69fa500

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/dense.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ Construct a matrix with elements of the vector as diagonal elements.
402402
By default, the matrix is square and its size is given by
403403
`length(v)`, but a non-square size `m`×`n` can be specified
404404
by passing `m,n` as the first arguments.
405+
The diagonal will be zero-padded if necessary.
405406
406407
# Examples
407408
```jldoctest
@@ -410,6 +411,13 @@ julia> diagm([1,2,3])
410411
1 0 0
411412
0 2 0
412413
0 0 3
414+
415+
julia> diagm(4, 5, [1,2,3])
416+
4×5 Matrix{Int64}:
417+
1 0 0 0 0
418+
0 2 0 0 0
419+
0 0 3 0 0
420+
0 0 0 0 0
413421
```
414422
"""
415423
diagm(v::AbstractVector) = diagm(0 => v)

0 commit comments

Comments
 (0)