Skip to content

Commit c0e7f98

Browse files
committed
Restore Diagonal constructors
1 parent 327af4a commit c0e7f98

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/diagonal.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ julia> Diagonal(A)
9999
⋅ 5
100100
```
101101
"""
102-
(::Type{D})(A::AbstractMatrix) where {D<:Diagonal} = D(diag(A))
102+
Diagonal(A::AbstractMatrix) = Diagonal(diag(A))
103+
Diagonal{T}(A::AbstractMatrix) where T = Diagonal{T}(diag(A))
104+
Diagonal{T,V}(A::AbstractMatrix) where {T,V<:AbstractVector{T}} = Diagonal{T,V}(diag(A))
103105
function convert(::Type{T}, A::AbstractMatrix) where T<:Diagonal
104106
checksquare(A)
105107
isdiag(A) ? T(A) : throw(InexactError(:convert, T, A))

0 commit comments

Comments
 (0)