69
69
70
70
# # Interlace operator
71
71
72
- struct InterlaceOperator{T,p,DS,RS,DI,RI,BI} <: Operator{T}
72
+ struct InterlaceOperator{T,p,DS,RS,DI,RI,BI,BBW } <: Operator{T}
73
73
ops:: Array{Operator{T},p}
74
74
domainspace:: DS
75
75
rangespace:: RS
76
76
domaininterlacer:: DI
77
77
rangeinterlacer:: RI
78
78
bandwidths:: BI
79
+ blockbandwidths:: BBW
80
+ israggedbelow:: Bool
81
+
82
+ function InterlaceOperator (ops:: Array{Operator{T},p} , ds:: DS , rs:: RS , dsi:: DI , rsi:: RI , bw:: BI ,
83
+ blockbandwidths:: BBW = bandwidthsmax (ops, blockbandwidths),
84
+ israggedbelow:: Bool = all (israggedbelow, ops)) where {T,p,DS,RS,DI,RI,BI,BBW}
85
+
86
+ new {T,p,DS,RS,DI,RI,BI,BBW} (ops, ds, rs, dsi, rsi, bw, blockbandwidths, israggedbelow)
87
+ end
79
88
end
80
89
81
90
const VectorInterlaceOperator = InterlaceOperator{T,1 ,DS,RS} where {T,DS,RS<: Space{D,R} } where {D,R<: AbstractVector }
133
142
134
143
function InterlaceOperator (ops:: AbstractMatrix{<:Operator} ,ds:: Space ,rs:: Space ;
135
144
# calculate bandwidths TODO : generalize
136
- bandwidths = interlace_bandwidths (ops, ds, rs))
145
+ bandwidths = interlace_bandwidths (ops, ds, rs),
146
+ blockbandwidths = bandwidthsmax (ops, blockbandwidths),
147
+ israggedbelow = all (israggedbelow, ops))
137
148
138
149
dsi = interlacer (ds)
139
150
rsi = interlacer (rs)
@@ -143,7 +154,9 @@ function InterlaceOperator(ops::AbstractMatrix{<:Operator},ds::Space,rs::Space;
143
154
InterlaceOperator (opsm,ds,rs,
144
155
cache (dsi),
145
156
cache (rsi),
146
- bandwidths)
157
+ bandwidths,
158
+ blockbandwidths,
159
+ israggedbelow)
147
160
end
148
161
149
162
@inline function _interlace_bandwidths (ops:: VectorOrTupleOfOp , ds, rs, allbanded = all (isbanded, ops))
@@ -165,14 +178,18 @@ end
165
178
166
179
function InterlaceOperator (ops:: VectorOrTupleOfOp , ds:: Space , rs:: Space ;
167
180
# calculate bandwidths
168
- bandwidths = interlace_bandwidths (ops, ds, rs))
181
+ bandwidths = interlace_bandwidths (ops, ds, rs),
182
+ blockbandwidths = bandwidthsmax (ops, blockbandwidths),
183
+ israggedbelow = all (israggedbelow, ops))
169
184
170
185
VT = Vector{Operator{promote_eltypeof (ops)}}
171
186
opsv = strictconvert (VT, convert_vector (ops))
172
187
InterlaceOperator (opsv,ds,rs,
173
188
cache (BlockInterlacer (tuple (blocklengths (ds)))),
174
189
cache (interlacer (rs)),
175
- bandwidths)
190
+ bandwidths,
191
+ blockbandwidths,
192
+ israggedbelow)
176
193
end
177
194
178
195
interlace_domainspace (ops:: AbstractMatrix , :: Type{NoSpace} ) = domainspace (ops)
@@ -217,7 +234,8 @@ function convert(::Type{Operator{T}},S::InterlaceOperator) where T
217
234
else
218
235
ops = convert (AbstractArray{Operator{T}}, S. ops)
219
236
InterlaceOperator (ops,domainspace (S),rangespace (S),
220
- S. domaininterlacer,S. rangeinterlacer,S. bandwidths)
237
+ S. domaininterlacer,S. rangeinterlacer,S. bandwidths,
238
+ S. blockbandwidths, S. israggedbelow)
221
239
end
222
240
end
223
241
226
244
# TODO : More efficient to save bandwidth
227
245
bandwidths (M:: InterlaceOperator ) = M. bandwidths
228
246
229
- blockbandwidths (M:: InterlaceOperator ) =
230
- (mapreduce (op-> blockbandwidth (op,1 ),max,M. ops),
231
- mapreduce (op-> blockbandwidth (op,2 ),max,M. ops))
232
-
233
- isblockbanded (M:: InterlaceOperator ) = all (isblockbanded,M. ops)
247
+ blockbandwidths (M:: InterlaceOperator ) = M. blockbandwidths
234
248
235
249
function blockcolstop (M:: InterlaceOperator ,J:: Integer )
236
250
if isblockbandedbelow (M)
@@ -262,7 +276,7 @@ function colstop(M::InterlaceOperator, j::Integer)
262
276
end
263
277
end
264
278
265
- israggedbelow (M:: InterlaceOperator ) = all (israggedbelow,M . ops)
279
+ israggedbelow (M:: InterlaceOperator ) = M . israggedbelow
266
280
267
281
getindex (op:: InterlaceOperator ,k:: Integer ,j:: Integer ) =
268
282
error (" Higher tensor InterlaceOperators not supported" )
0 commit comments