@@ -240,8 +240,13 @@ struct TimesOperator{T,BI} <: Operator{T}
240240 end
241241end
242242
243- bandwidthssum (P, k) = bandwidthssum (P)[k]
243+ bandwidthssum (P, k:: Integer ) = bandwidthssum (P)[k]
244244bandwidthssum (P) = mapreduce (bandwidths, (t1, t2) -> t1 .+ t2, P, init = (0 ,0 ))
245+ _bandwidthssum (A:: Operator , B:: Operator ) = __bandwidthssum (bandwidths (A), bandwidths (B))
246+ __bandwidthssum (A:: NTuple{2,InfiniteCardinal{0}} , B:: NTuple{2,InfiniteCardinal{0}} ) = A
247+ __bandwidthssum (A:: NTuple{2,InfiniteCardinal{0}} , B) = A
248+ __bandwidthssum (A, B:: NTuple{2,InfiniteCardinal{0}} ) = B
249+ __bandwidthssum (A, B) = reduce ((t1, t2) -> t1 .+ t2, (A, B), init = (0 ,0 ))
245250
246251TimesOperator (ops:: Vector{Operator{T}} ,bi:: Tuple{N1,N2} ) where {T,N1,N2} =
247252 TimesOperator {T,typeof(bi)} (ops,bi)
@@ -251,13 +256,13 @@ TimesOperator(ops::Vector{OT}) where {OT<:Operator} =
251256 TimesOperator (convert (Vector{Operator{eltype (OT)}},ops),bandwidthssum (ops))
252257
253258TimesOperator (A:: TimesOperator ,B:: TimesOperator ) =
254- TimesOperator (Operator{promote_type (eltype (A),eltype (B))}[A. ops; B. ops])
259+ TimesOperator (Operator{promote_type (eltype (A),eltype (B))}[A. ops; B. ops], _bandwidthssum (A, B) )
255260TimesOperator (A:: TimesOperator ,B:: Operator ) =
256- TimesOperator (Operator{promote_type (eltype (A),eltype (B))}[A. ops; B])
261+ TimesOperator (Operator{promote_type (eltype (A),eltype (B))}[A. ops; B], _bandwidthssum (A, B) )
257262TimesOperator (A:: Operator ,B:: TimesOperator ) =
258- TimesOperator (Operator{promote_type (eltype (A),eltype (B))}[A; B. ops])
263+ TimesOperator (Operator{promote_type (eltype (A),eltype (B))}[A; B. ops], _bandwidthssum (A, B) )
259264TimesOperator (A:: Operator ,B:: Operator ) =
260- TimesOperator (Operator{promote_type (eltype (A),eltype (B))}[A,B])
265+ TimesOperator (Operator{promote_type (eltype (A),eltype (B))}[A,B], _bandwidthssum (A, B) )
261266
262267
263268== (A:: TimesOperator ,B:: TimesOperator )= A. ops== B. ops
0 commit comments