Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/blockdiagonal.jl
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# Core functionality for the `BlockDiagonal` type

"""
BlockDiagonal{T, V<:AbstractMatrix{T}} <: AbstractMatrix{T}
BlockDiagonal{T, V<:AbstractMatrix{T}, AV<:AbstractVector{V}} <: AbstractMatrix{T}

A matrix with matrices on the diagonal, and zeros off the diagonal.
"""
struct BlockDiagonal{T, V<:AbstractMatrix{T}} <: AbstractMatrix{T}
blocks::Vector{V}
struct BlockDiagonal{T, V<:AbstractMatrix{T}, AV<:AbstractVector{V}} <: AbstractMatrix{T}
blocks::AV

function BlockDiagonal{T, V}(blocks::Vector{V}) where {T, V<:AbstractMatrix{T}}
return new{T, V}(blocks)
function BlockDiagonal{T, V, AV}(blocks::AV) where {T, V<:AbstractMatrix{T}, AV<:AbstractVector{V}}
return new{T, V, AV}(blocks)
end
end

function BlockDiagonal(blocks::Vector{V}) where {T, V<:AbstractMatrix{T}}
return BlockDiagonal{T, V}(blocks)
function BlockDiagonal(blocks::AV) where {T, V<:AbstractMatrix{T}, AV<:AbstractVector{V}}
return BlockDiagonal{T, V, AV}(blocks)
end

BlockDiagonal(B::BlockDiagonal) = B

is_square(A::AbstractMatrix) = size(A, 1) == size(A, 2)

"""
blocks(B::BlockDiagonal{T, V}) -> Vector{V}
blocks(B::BlockDiagonal{T, V, AV}) -> AV

Return the on-diagonal blocks of B.
"""
Expand Down