@@ -120,6 +120,12 @@ struct BlockSkylineMatrix{T, DATA<:AbstractVector{T}, BS<:BlockSkylineSizes} <:
120
120
end
121
121
end
122
122
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
+ """
123
129
const BlockBandedMatrix{T} = BlockSkylineMatrix{T, Vector{T}, BlockBandedSizes}
124
130
125
131
# Auxiliary outer constructors
@@ -149,8 +155,10 @@ lengths `rows` and `cols`, respectively, for ragged bands.
149
155
# Examples
150
156
151
157
```jldoctest
158
+ julia> using LinearAlgebra, FillArrays
159
+
152
160
julia> 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}}}:
154
162
1 │ 0 0 │ ⋅ ⋅ ⋅
155
163
0 │ 1 0 │ ⋅ ⋅ ⋅
156
164
───┼────────┼─────────
@@ -164,7 +172,7 @@ julia> BlockSkylineMatrix(I, [2,3,4], [1,2,3], ([2,0,1],[1,1,1]))
164
172
0 │ ⋅ ⋅ │ 0 0 0
165
173
166
174
julia> 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}}}:
168
176
1.0 │ 1.0 1.0 │ ⋅ ⋅ ⋅
169
177
1.0 │ 1.0 1.0 │ ⋅ ⋅ ⋅
170
178
─────┼────────────┼───────────────
@@ -186,6 +194,13 @@ BlockSkylineMatrix
186
194
@inline BlockSkylineMatrix {T} (:: UndefInitializer , axes:: NTuple{2,AbstractUnitRange{Int}} , lu:: NTuple{2, AbstractVector{Int}} ) where T =
187
195
BlockSkylineMatrix {T} (undef, BlockSkylineSizes (axes, lu... ))
188
196
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
+ """
189
204
@inline BlockBandedMatrix {T} (:: UndefInitializer , rdims:: AbstractVector{Int} , cdims:: AbstractVector{Int} , lu:: NTuple{2, Int} ) where T =
190
205
BlockSkylineMatrix {T} (undef, BlockBandedSizes (rdims, cdims, lu... ))
191
206
@@ -257,10 +272,78 @@ BlockBandedMatrix{T}(A::Union{AbstractMatrix,UniformScaling},
257
272
BlockSkylineMatrix (A:: Union{AbstractMatrix,UniformScaling} ,
258
273
rdims:: AbstractVector{Int} , cdims:: AbstractVector{Int} ,
259
274
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
+ """
260
319
BlockBandedMatrix (A:: Union{AbstractMatrix,UniformScaling} ,
261
320
rdims:: AbstractVector{Int} , cdims:: AbstractVector{Int} ,
262
321
lu:: NTuple{2,Int} ) = BlockBandedMatrix {eltype(A)} (A, rdims, cdims, lu)
263
322
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
+ """
264
347
BlockBandedMatrix (A:: AbstractMatrix , lu:: NTuple{2,Int} ) = BlockBandedMatrix (A, BlockBandedSizes (axes (A), lu... ))
265
348
266
349
function convert (:: Type{BlockSkylineMatrix} , A:: AbstractMatrix )
0 commit comments