File tree Expand file tree Collapse file tree 1 file changed +23
-18
lines changed Expand file tree Collapse file tree 1 file changed +23
-18
lines changed Original file line number Diff line number Diff line change @@ -53,8 +53,9 @@ julia> I(2)
53
53
⋅ 1
54
54
```
55
55
56
- Note that a one-column matrix is not treated like a vector, but instead calls the
57
- method `Diagonal(A::AbstractMatrix)` which extracts 1-element `diag(A)`:
56
+ !!! note
57
+ A one-column matrix is not treated like a vector, but instead calls the
58
+ method `Diagonal(A::AbstractMatrix)` which extracts 1-element `diag(A)`:
58
59
59
60
```jldoctest
60
61
julia> A = transpose([7.0 13.0])
@@ -72,27 +73,31 @@ Diagonal(V::AbstractVector)
72
73
"""
73
74
Diagonal(A::AbstractMatrix)
74
75
75
- Construct a matrix from the diagonal of `A`.
76
+ Construct a matrix from the principal diagonal of `A`.
77
+ The input matrix `A` may be rectangular, but the output will
78
+ be square.
76
79
77
80
# Examples
78
81
```jldoctest
79
- julia> A = permutedims(reshape(1:15, 5, 3))
80
- 3×5 Matrix{Int64}:
81
- 1 2 3 4 5
82
- 6 7 8 9 10
83
- 11 12 13 14 15
82
+ julia> A = [1 2; 3 4]
83
+ 2×2 Matrix{Int64}:
84
+ 1 2
85
+ 3 4
86
+
87
+ julia> D = Diagonal(A)
88
+ 2×2 Diagonal{Int64, Vector{Int64}}:
89
+ 1 ⋅
90
+ ⋅ 4
91
+
92
+ julia> A = [1 2 3; 4 5 6]
93
+ 2×3 Matrix{Int64}:
94
+ 1 2 3
95
+ 4 5 6
84
96
85
97
julia> Diagonal(A)
86
- 3×3 Diagonal{$Int , Vector{$Int }}:
87
- 1 ⋅ ⋅
88
- ⋅ 7 ⋅
89
- ⋅ ⋅ 13
90
-
91
- julia> diag(A, 2)
92
- 3-element Vector{$Int }:
93
- 3
94
- 9
95
- 15
98
+ 2×2 Diagonal{Int64, Vector{Int64}}:
99
+ 1 ⋅
100
+ ⋅ 5
96
101
```
97
102
"""
98
103
Diagonal (A:: AbstractMatrix ) = Diagonal (diag (A))
You can’t perform that action at this time.
0 commit comments