@@ -120,6 +120,12 @@ struct BlockSkylineMatrix{T, DATA<:AbstractVector{T}, BS<:BlockSkylineSizes} <:
120120 end
121121end
122122
123+ """
124+ BlockBandedMatrix
125+
126+ A `BlockBandedMatrix` is a subtype of `BlockMatrix` of `BlockArrays.jl` whose
127+ layout of non-zero blocks is banded.
128+ """
123129const BlockBandedMatrix{T} = BlockSkylineMatrix{T, Vector{T}, BlockBandedSizes}
124130
125131# Auxiliary outer constructors
@@ -149,8 +155,10 @@ lengths `rows` and `cols`, respectively, for ragged bands.
149155# Examples
150156
151157```jldoctest
158+ julia> using LinearAlgebra, FillArrays
159+
152160julia> BlockSkylineMatrix(I, [2,3,4], [1,2,3], ([2,0,1],[1,1,1]))
153- 3×3-blocked 9×6 BlockSkylineMatrix{Bool,Array {Bool,1}, BlockBandedMatrices.BlockSkylineSizes{Tuple{BlockArrays.BlockedUnitRange{Array {Int64,1 }},BlockArrays.BlockedUnitRange{Array {Int64,1 }}},Array {Int64,1},Array {Int64,1}, BandedMatrices.BandedMatrix{Int64,Array {Int64,2}, Base.OneTo{Int64}},Array {Int64,1 }}}:
161+ 3×3-blocked 9×6 BlockSkylineMatrix{Bool, Vector {Bool}, BlockBandedMatrices.BlockSkylineSizes{Tuple{BlockArrays.BlockedUnitRange{Vector {Int64}}, BlockArrays.BlockedUnitRange{Vector {Int64}}}, Vector {Int64}, Vector {Int64}, BandedMatrices.BandedMatrix{Int64, Matrix {Int64}, Base.OneTo{Int64}}, Vector {Int64}}}:
154162 1 │ 0 0 │ ⋅ ⋅ ⋅
155163 0 │ 1 0 │ ⋅ ⋅ ⋅
156164 ───┼────────┼─────────
@@ -164,7 +172,7 @@ julia> BlockSkylineMatrix(I, [2,3,4], [1,2,3], ([2,0,1],[1,1,1]))
164172 0 │ ⋅ ⋅ │ 0 0 0
165173
166174julia> BlockSkylineMatrix(Ones(9,6), [2,3,4], [1,2,3], ([2,0,1],[1,1,1]))
167- 3×3-blocked 9×6 BlockSkylineMatrix{Float64,Array {Float64,1}, BlockBandedMatrices.BlockSkylineSizes{Tuple{BlockArrays.BlockedUnitRange{Array {Int64,1 }},BlockArrays.BlockedUnitRange{Array {Int64,1 }}},Array {Int64,1},Array {Int64,1}, BandedMatrices.BandedMatrix{Int64,Array {Int64,2}, Base.OneTo{Int64}},Array {Int64,1 }}}:
175+ 3×3-blocked 9×6 BlockSkylineMatrix{Float64, Vector {Float64}, BlockBandedMatrices.BlockSkylineSizes{Tuple{BlockArrays.BlockedUnitRange{Vector {Int64}}, BlockArrays.BlockedUnitRange{Vector {Int64}}}, Vector {Int64}, Vector {Int64}, BandedMatrices.BandedMatrix{Int64, Matrix {Int64}, Base.OneTo{Int64}}, Vector {Int64}}}:
168176 1.0 │ 1.0 1.0 │ ⋅ ⋅ ⋅
169177 1.0 │ 1.0 1.0 │ ⋅ ⋅ ⋅
170178 ─────┼────────────┼───────────────
@@ -186,6 +194,13 @@ BlockSkylineMatrix
186194@inline BlockSkylineMatrix {T} (:: UndefInitializer , axes:: NTuple{2,AbstractUnitRange{Int}} , lu:: NTuple{2, AbstractVector{Int}} ) where T =
187195 BlockSkylineMatrix {T} (undef, BlockSkylineSizes (axes, lu... ))
188196
197+ """
198+ BlockBandedMatrix{T}(undef, rows::AbstractVector{Int}, cols::AbstractVector{Int},
199+ (l,u)::NTuple{2,Int})
200+
201+ Return an unitialized `sum(rows) × sum(cols)` `BlockBandedMatrix` having `eltype` `T`,
202+ with `rows` by `cols` blocks and `(l,u)` as the block-bandwidth.
203+ """
189204@inline BlockBandedMatrix {T} (:: UndefInitializer , rdims:: AbstractVector{Int} , cdims:: AbstractVector{Int} , lu:: NTuple{2, Int} ) where T =
190205 BlockSkylineMatrix {T} (undef, BlockBandedSizes (rdims, cdims, lu... ))
191206
@@ -257,10 +272,78 @@ BlockBandedMatrix{T}(A::Union{AbstractMatrix,UniformScaling},
257272BlockSkylineMatrix (A:: Union{AbstractMatrix,UniformScaling} ,
258273 rdims:: AbstractVector{Int} , cdims:: AbstractVector{Int} ,
259274 lu:: NTuple{2,AbstractVector{Int}} ) = BlockSkylineMatrix {eltype(A)} (A, rdims, cdims, lu)
275+
276+
277+ """
278+ BlockBandedMatrix(A::Union{AbstractMatrix,UniformScaling},
279+ rows::AbstractVector{Int}, cols::AbstractVector{Int},
280+ (l,u)::NTuple{2,Int})
281+
282+ Return a `sum(rows) × sum(cols)` `BlockBandedMatrix`, with `rows` by `cols` blocks,
283+ with `(l,u)` as the block-bandwidth.
284+ The structural non-zero entries are equal to the corresponding indices of `A`.
285+
286+ # Examples
287+ ```jldoctest
288+ julia> using LinearAlgebra, FillArrays
289+
290+ julia> l,u = 0,1; # block bandwidths
291+
292+ julia> nrowblk, ncolblk = 3, 3; # number of row/column blocks
293+
294+ julia> rows = 1:nrowblk; cols = 1:ncolblk; # block sizes
295+
296+ julia> BlockBandedMatrix(I, rows, cols, (l,u))
297+ 3×3-blocked 6×6 BlockBandedMatrix{Bool}:
298+ 1 │ 0 0 │ ⋅ ⋅ ⋅
299+ ───┼────────┼─────────
300+ ⋅ │ 1 0 │ 0 0 0
301+ ⋅ │ 0 1 │ 0 0 0
302+ ───┼────────┼─────────
303+ ⋅ │ ⋅ ⋅ │ 1 0 0
304+ ⋅ │ ⋅ ⋅ │ 0 1 0
305+ ⋅ │ ⋅ ⋅ │ 0 0 1
306+
307+ julia> BlockBandedMatrix(Ones(sum(rows),sum(cols)), rows, cols, (l,u))
308+ 3×3-blocked 6×6 BlockBandedMatrix{Float64}:
309+ 1.0 │ 1.0 1.0 │ ⋅ ⋅ ⋅
310+ ─────┼────────────┼───────────────
311+ ⋅ │ 1.0 1.0 │ 1.0 1.0 1.0
312+ ⋅ │ 1.0 1.0 │ 1.0 1.0 1.0
313+ ─────┼────────────┼───────────────
314+ ⋅ │ ⋅ ⋅ │ 1.0 1.0 1.0
315+ ⋅ │ ⋅ ⋅ │ 1.0 1.0 1.0
316+ ⋅ │ ⋅ ⋅ │ 1.0 1.0 1.0
317+ ```
318+ """
260319BlockBandedMatrix (A:: Union{AbstractMatrix,UniformScaling} ,
261320 rdims:: AbstractVector{Int} , cdims:: AbstractVector{Int} ,
262321 lu:: NTuple{2,Int} ) = BlockBandedMatrix {eltype(A)} (A, rdims, cdims, lu)
263322
323+ """
324+ BlockBandedMatrix(A::AbstractMatrix, (l,u)::NTuple{2,Int})
325+
326+ Return a `BlockBandedMatrix` with block-bandwidths `(l,u)`, where the
327+ structural non-zero blocks correspond to those of `A`.
328+
329+ Examples
330+ ```jldoctest
331+ julia> using BlockArrays
332+
333+ julia> B = BlockArray(ones(6,6), 1:3, 1:3);
334+
335+ julia> BlockBandedMatrix(B, (1,1))
336+ 3×3-blocked 6×6 BlockBandedMatrix{Float64}:
337+ 1.0 │ 1.0 1.0 │ ⋅ ⋅ ⋅
338+ ─────┼────────────┼───────────────
339+ 1.0 │ 1.0 1.0 │ 1.0 1.0 1.0
340+ 1.0 │ 1.0 1.0 │ 1.0 1.0 1.0
341+ ─────┼────────────┼───────────────
342+ ⋅ │ 1.0 1.0 │ 1.0 1.0 1.0
343+ ⋅ │ 1.0 1.0 │ 1.0 1.0 1.0
344+ ⋅ │ 1.0 1.0 │ 1.0 1.0 1.0
345+ ```
346+ """
264347BlockBandedMatrix (A:: AbstractMatrix , lu:: NTuple{2,Int} ) = BlockBandedMatrix (A, BlockBandedSizes (axes (A), lu... ))
265348
266349function convert (:: Type{BlockSkylineMatrix} , A:: AbstractMatrix )
0 commit comments