1
-
2
-
3
1
function check_data_sizes (data:: AbstractMatrix , raxis, (l,u), (λ,μ))
4
2
if blocksize (data,1 ) ≠ l + u + 1 && ! (blocksize (data,1 ) == 0 && (- l > u || - λ > μ))
5
3
throw (ArgumentError (" Data matrix must have number of row blocks equal to number of block bands" ))
40
38
41
39
const DefaultBandedBlockBandedMatrix{T} = BandedBlockBandedMatrix{T, PseudoBlockMatrix{T, Matrix{T}, NTuple{2 ,DefaultBlockAxis}}, DefaultBlockAxis}
42
40
43
- @inline _BandedBlockBandedMatrix (data:: AbstractMatrix , axes:: NTuple{2,AbstractUnitRange{Int}} , lu:: NTuple{2,Int} , λμ:: NTuple{2,Int} ) =
44
- _BandedBlockBandedMatrix (PseudoBlockArray (data,(blockedrange (Fill (sum (λμ)+ 1 ,sum (lu)+ 1 )),axes[2 ])), axes[1 ], lu, λμ)
41
+ @inline _BandedBlockBandedMatrix (data:: AbstractMatrix , axes:: NTuple{2,AbstractUnitRange{Int}} , lu:: NTuple{2,Int} , λμ:: NTuple{2,Int} ) =
42
+ _BandedBlockBandedMatrix (PseudoBlockArray (data,(blockedrange (Fill (sum (λμ)+ 1 ,sum (lu)+ 1 )),axes[2 ])), axes[1 ], lu, λμ)
45
43
46
44
_BandedBlockBandedMatrix (data:: AbstractMatrix ,rblocksizes:: AbstractVector{Int} , cblocksizes:: AbstractVector{Int} , lu:: NTuple{2,Int} , λμ:: NTuple{2,Int} ) =
47
45
_BandedBlockBandedMatrix (data, (blockedrange (rblocksizes),blockedrange (cblocksizes)), lu, λμ)
@@ -63,11 +61,46 @@ BandedBlockBandedMatrix{T,B}(::UndefInitializer, rblocksizes::AbstractVector{Int
63
61
64
62
65
63
"""
66
- BandedBlockBandedMatrix{T}(undef, (rows, cols), (l, u), (λ, μ))
67
-
68
- returns an undef `sum(rows)`×`sum(cols)` banded-block-banded matrix `A`
69
- of type `T` with block-bandwidths `(l,u)` and where `A[Block(K,J)]`
70
- is a `BandedMatrix{T}` of size `rows[K]`×`cols[J]` with bandwidths `(λ,μ)`.
64
+ BandedBlockBandedMatrix{T}(M::Union{UndefInitializer,UniformScaling,AbstractMatrix},
65
+ rows, cols, (l, u), (λ, μ))
66
+
67
+ returns a `sum(rows)`×`sum(cols)` banded-block-banded matrix `A` of
68
+ type `T` with block-bandwidths `(l,u)` and where `A[Block(K,J)]` is a
69
+ `BandedMatrix{T}` of size `rows[K]`×`cols[J]` with bandwidths `(λ,μ)`.
70
+
71
+ # Examples
72
+
73
+ ```jldoctest
74
+ julia> BandedBlockBandedMatrix(I, [3,4,3], [3,4,3], (1,1), (1,1))
75
+ 3×3-blocked 10×10 BandedBlockBandedMatrix{Bool,BlockArrays.PseudoBlockArray{Bool,2,Array{Bool,2},Tuple{BlockArrays.BlockedUnitRange{Array{Int64,1}},BlockArrays.BlockedUnitRange{Array{Int64,1}}}},BlockArrays.BlockedUnitRange{Array{Int64,1}}}:
76
+ 1 0 ⋅ │ 0 0 ⋅ ⋅ │ ⋅ ⋅ ⋅
77
+ 0 1 0 │ 0 0 0 ⋅ │ ⋅ ⋅ ⋅
78
+ ⋅ 0 1 │ ⋅ 0 0 0 │ ⋅ ⋅ ⋅
79
+ ─────────┼──────────────┼─────────
80
+ 0 0 ⋅ │ 1 0 ⋅ ⋅ │ 0 0 ⋅
81
+ 0 0 0 │ 0 1 0 ⋅ │ 0 0 0
82
+ ⋅ 0 0 │ ⋅ 0 1 0 │ ⋅ 0 0
83
+ ⋅ ⋅ 0 │ ⋅ ⋅ 0 1 │ ⋅ ⋅ 0
84
+ ─────────┼──────────────┼─────────
85
+ ⋅ ⋅ ⋅ │ 0 0 ⋅ ⋅ │ 1 0 ⋅
86
+ ⋅ ⋅ ⋅ │ 0 0 0 ⋅ │ 0 1 0
87
+ ⋅ ⋅ ⋅ │ ⋅ 0 0 0 │ ⋅ 0 1
88
+
89
+ julia> BandedBlockBandedMatrix(Ones{Int}(10,13), [3,4,3], [4,5,4], (1,1), (1,1))
90
+ 3×3-blocked 10×13 BandedBlockBandedMatrix{Int64,BlockArrays.PseudoBlockArray{Int64,2,Array{Int64,2},Tuple{BlockArrays.BlockedUnitRange{Array{Int64,1}},BlockArrays.BlockedUnitRange{Array{Int64,1}}}},BlockArrays.BlockedUnitRange{Array{Int64,1}}}:
91
+ 1 1 ⋅ ⋅ │ 1 1 ⋅ ⋅ ⋅ │ ⋅ ⋅ ⋅ ⋅
92
+ 1 1 1 ⋅ │ 1 1 1 ⋅ ⋅ │ ⋅ ⋅ ⋅ ⋅
93
+ ⋅ 1 1 1 │ ⋅ 1 1 1 ⋅ │ ⋅ ⋅ ⋅ ⋅
94
+ ────────────┼─────────────────┼────────────
95
+ 1 1 ⋅ ⋅ │ 1 1 ⋅ ⋅ ⋅ │ 1 1 ⋅ ⋅
96
+ 1 1 1 ⋅ │ 1 1 1 ⋅ ⋅ │ 1 1 1 ⋅
97
+ ⋅ 1 1 1 │ ⋅ 1 1 1 ⋅ │ ⋅ 1 1 1
98
+ ⋅ ⋅ 1 1 │ ⋅ ⋅ 1 1 1 │ ⋅ ⋅ 1 1
99
+ ────────────┼─────────────────┼────────────
100
+ ⋅ ⋅ ⋅ ⋅ │ 1 1 ⋅ ⋅ ⋅ │ 1 1 ⋅ ⋅
101
+ ⋅ ⋅ ⋅ ⋅ │ 1 1 1 ⋅ ⋅ │ 1 1 1 ⋅
102
+ ⋅ ⋅ ⋅ ⋅ │ ⋅ 1 1 1 ⋅ │ ⋅ 1 1 1
103
+ ```
71
104
"""
72
105
BandedBlockBandedMatrix
73
106
@@ -127,17 +160,17 @@ BandedBlockBandedMatrix{T}(m::Union{AbstractMatrix, UniformScaling},
127
160
BandedBlockBandedMatrix {T,B,R} (m:: Union{AbstractMatrix, UniformScaling} ,
128
161
rdims:: AbstractVector{Int} , cdims:: AbstractVector{Int} ,
129
162
lu:: NTuple{2,Int} , λμ:: NTuple{2,Int} ) where {T,B,R<: AbstractUnitRange{Int} } =
130
- BandedBlockBandedMatrix {T,B,R} (m, (blockedrange (rdims),blockedrange (cdims)), lu, λμ)
163
+ BandedBlockBandedMatrix {T,B,R} (m, (blockedrange (rdims),blockedrange (cdims)), lu, λμ)
131
164
132
165
BandedBlockBandedMatrix {T,B} (m:: Union{AbstractMatrix, UniformScaling} ,
133
166
rdims:: AbstractVector{Int} , cdims:: AbstractVector{Int} ,
134
167
lu:: NTuple{2,Int} , λμ:: NTuple{2,Int} ) where {T,B} =
135
- BandedBlockBandedMatrix {T,B} (m, (blockedrange (rdims),blockedrange (cdims)), lu, λμ)
168
+ BandedBlockBandedMatrix {T,B} (m, (blockedrange (rdims),blockedrange (cdims)), lu, λμ)
136
169
137
170
BandedBlockBandedMatrix {T} (m:: Union{AbstractMatrix, UniformScaling} ,
138
171
rdims:: AbstractVector{Int} , cdims:: AbstractVector{Int} ,
139
172
lu:: NTuple{2,Int} , λμ:: NTuple{2,Int} ) where T =
140
- BandedBlockBandedMatrix {T} (m, (blockedrange (rdims),blockedrange (cdims)), lu, λμ)
173
+ BandedBlockBandedMatrix {T} (m, (blockedrange (rdims),blockedrange (cdims)), lu, λμ)
141
174
142
175
143
176
BandedBlockBandedMatrix (A:: Union{AbstractMatrix,UniformScaling} ,
@@ -147,12 +180,12 @@ BandedBlockBandedMatrix(A::Union{AbstractMatrix,UniformScaling},
147
180
BandedBlockBandedMatrix (A:: Union{AbstractMatrix,UniformScaling} ,
148
181
rdims:: AbstractVector{Int} , cdims:: AbstractVector{Int} ,
149
182
lu:: NTuple{2,Int} , λμ:: NTuple{2,Int} ) =
150
- BandedBlockBandedMatrix (A, (blockedrange (rdims),blockedrange (cdims)), lu, λμ)
151
-
152
-
183
+ BandedBlockBandedMatrix (A, (blockedrange (rdims),blockedrange (cdims)), lu, λμ)
184
+
185
+
153
186
function BandedBlockBandedMatrix {T,Blocks,RR} (A:: AbstractMatrix , axes:: NTuple{2,AbstractUnitRange{Int}} , lu:: NTuple{2,Int} , λμ:: NTuple{2,Int} ) where {T,Blocks,RR<: AbstractUnitRange{Int} }
154
187
ret = BandedBlockBandedMatrix {T,Blocks,RR} (Zeros {T} (size (A)), axes, lu, λμ)
155
- L,M = λμ
188
+ L,M = λμ
156
189
for J = blockaxes (ret,2 ), K = blockcolsupport (ret, J)
157
190
kr, jr = axes[1 ][K], axes[2 ][J]
158
191
@@ -189,7 +222,7 @@ similar(A::BandedBlockBandedMatrix, ::Type{T}, axes::NTuple{2,AbstractUnitRange{
189
222
@inline similar (A:: BandedBlockBandedMatrix , :: Type{T} , axes:: Tuple{BlockedUnitRange,AbstractUnitRange{Int}} ) where T =
190
223
BandedBlockBandedMatrix {T} (undef, axes, blockbandwidths (A), subblockbandwidths (A))
191
224
@inline similar (A:: BandedBlockBandedMatrix , :: Type{T} , axes:: Tuple{AbstractUnitRange{Int},BlockedUnitRange} ) where T =
192
- BandedBlockBandedMatrix {T} (undef, axes, blockbandwidths (A), subblockbandwidths (A))
225
+ BandedBlockBandedMatrix {T} (undef, axes, blockbandwidths (A), subblockbandwidths (A))
193
226
@inline similar (A:: BandedBlockBandedMatrix , :: Type{T} , axes:: Tuple{BlockedUnitRange,BlockedUnitRange} ) where T =
194
227
BandedBlockBandedMatrix {T} (undef, axes, blockbandwidths (A), subblockbandwidths (A))
195
228
@@ -225,10 +258,10 @@ end
225
258
bandedblockbandedcolumns (L:: AbstractColumnMajor ) = BandedBlockBandedColumnMajor ()
226
259
bandedblockbandedcolumns (_) = BandedBlockBandedColumns {UnknownLayout} ()
227
260
228
- MemoryLayout (:: Type{<:BandedBlockBandedMatrix{<:Any,BLOCKS}} ) where BLOCKS =
261
+ MemoryLayout (:: Type{<:BandedBlockBandedMatrix{<:Any,BLOCKS}} ) where BLOCKS =
229
262
bandedblockbandedcolumns (MemoryLayout (BLOCKS))
230
263
bandedblockbandedbroadcaststyle (_) = BandedBlockBandedStyle ()
231
- BroadcastStyle (:: Type{<:BandedBlockBandedMatrix{<:Any,BLOCKS}} ) where BLOCKS =
264
+ BroadcastStyle (:: Type{<:BandedBlockBandedMatrix{<:Any,BLOCKS}} ) where BLOCKS =
232
265
bandedblockbandedbroadcaststyle (BroadcastStyle (BLOCKS))
233
266
234
267
isbandedblockbanded (_) = false
@@ -431,7 +464,7 @@ isbanded(A::SubArray{<:Any,2,<:BandedBlockBandedMatrix}) = MemoryLayout(typeof(A
431
464
isbandedblockbanded (A:: SubArray{<:Any,2,<:BandedBlockBandedMatrix} ) = MemoryLayout (typeof (A)) == BandedBlockBandedColumnMajor ()
432
465
433
466
434
- subblockbandwidths (V:: SubArray{<:Any,2,<:Any,<:Tuple{<:BlockSlice{BlockRange1},<:BlockSlice{BlockRange1}}} ) =
467
+ subblockbandwidths (V:: SubArray{<:Any,2,<:Any,<:Tuple{<:BlockSlice{BlockRange1},<:BlockSlice{BlockRange1}}} ) =
435
468
subblockbandwidths (parent (V))
436
469
437
470
function blockbandwidths (V:: SubArray{<:Any,2,<:Any,<:Tuple{<:BlockSlice{BlockRange1},<:BlockSlice{Block1}}} )
0 commit comments