-
-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
stdlibJulia's standard libraryJulia's standard library
Description
Currently, block diagonal matrices don't correctly support istril or istriu
julia> D = Diagonal([[1 2; 3 4], [5 6; 7 8]])
2×2 Diagonal{Array{Int64,2},Array{Array{Int64,2},1}}:
[1 2; 3 4] ⋅
⋅ [5 6; 7 8]
julia> A = [1 2 0 0; 3 4 0 0; 0 0 5 6; 0 0 7 8] # full matrix of D
4×4 Array{Int64,2}:
1 2 0 0
3 4 0 0
0 0 5 6
0 0 7 8
julia> istriu(D)
true
julia> istriu(A)
falseThese can be solved by adding
istril(D::Diagonal{<:Number}) = true
istril(D::Diagonal) = all(istril, D.diag)etc.
Once this is fixed, what should the intended behavior of tril(D, k), triu(D, k), diag(D, k), etc. be?
tril(D, k) can just recursively check the blocks but should we make diag(D, k) actually return the k-th super diagonal of the 'full' matrix?
I realize this is quite low on the priority list, but it seems like block diagonal matrices were hastily added and a lot of support is missing.
Metadata
Metadata
Assignees
Labels
stdlibJulia's standard libraryJulia's standard library