6969
7070# # Interlace operator
7171
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}
7373 ops:: Array{Operator{T},p}
7474 domainspace:: DS
7575 rangespace:: RS
7676 domaininterlacer:: DI
7777 rangeinterlacer:: RI
7878 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
7988end
8089
8190const VectorInterlaceOperator = InterlaceOperator{T,1 ,DS,RS} where {T,DS,RS<: Space{D,R} } where {D,R<: AbstractVector }
133142
134143function InterlaceOperator (ops:: AbstractMatrix{<:Operator} ,ds:: Space ,rs:: Space ;
135144 # 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))
137148
138149 dsi = interlacer (ds)
139150 rsi = interlacer (rs)
@@ -143,7 +154,9 @@ function InterlaceOperator(ops::AbstractMatrix{<:Operator},ds::Space,rs::Space;
143154 InterlaceOperator (opsm,ds,rs,
144155 cache (dsi),
145156 cache (rsi),
146- bandwidths)
157+ bandwidths,
158+ blockbandwidths,
159+ israggedbelow)
147160end
148161
149162@inline function _interlace_bandwidths (ops:: VectorOrTupleOfOp , ds, rs, allbanded = all (isbanded, ops))
@@ -165,14 +178,18 @@ end
165178
166179function InterlaceOperator (ops:: VectorOrTupleOfOp , ds:: Space , rs:: Space ;
167180 # 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))
169184
170185 VT = Vector{Operator{promote_eltypeof (ops)}}
171186 opsv = strictconvert (VT, convert_vector (ops))
172187 InterlaceOperator (opsv,ds,rs,
173188 cache (BlockInterlacer (tuple (blocklengths (ds)))),
174189 cache (interlacer (rs)),
175- bandwidths)
190+ bandwidths,
191+ blockbandwidths,
192+ israggedbelow)
176193end
177194
178195interlace_domainspace (ops:: AbstractMatrix , :: Type{NoSpace} ) = domainspace (ops)
@@ -217,7 +234,8 @@ function convert(::Type{Operator{T}},S::InterlaceOperator) where T
217234 else
218235 ops = convert (AbstractArray{Operator{T}}, S. ops)
219236 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)
221239 end
222240end
223241
226244# TODO : More efficient to save bandwidth
227245bandwidths (M:: InterlaceOperator ) = M. bandwidths
228246
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
234248
235249function blockcolstop (M:: InterlaceOperator ,J:: Integer )
236250 if isblockbandedbelow (M)
@@ -262,7 +276,7 @@ function colstop(M::InterlaceOperator, j::Integer)
262276 end
263277end
264278
265- israggedbelow (M:: InterlaceOperator ) = all (israggedbelow,M . ops)
279+ israggedbelow (M:: InterlaceOperator ) = M . israggedbelow
266280
267281getindex (op:: InterlaceOperator ,k:: Integer ,j:: Integer ) =
268282 error (" Higher tensor InterlaceOperators not supported" )
0 commit comments