8080
8181domain (P:: PlusOperator ) = commondomain (P. ops)
8282
83- _extractops (A, :: Any ) = SVector {1} (A)
83+ _extractops (A, :: Any ) = [A]
8484_extractops (A:: PlusOperator , :: typeof (+ )) = A. ops
8585
8686function + (A:: Operator , B:: Operator )
@@ -265,6 +265,9 @@ struct TimesOperator{T,BW,SZ,O<:Operator{T},BBW,SBBW} <: Operator{T}
265265 end
266266end
267267
268+ operatortype (:: T ) where {T<: Operator } = T
269+ operatortype (:: TimesOperator{<:Any,<:Any,<:Any,O} ) where {O} = O
270+
268271const PlusOrTimesOp = Union{PlusOperator,TimesOperator}
269272
270273bandwidthssum (f, ops) = mapfoldl (f, (t1, t2) -> t1 .+ t2, ops, init= (0 , 0 ))
@@ -329,8 +332,10 @@ Base.@constprop :aggressive function promotetimes(opsin,
329332 anytimesop = any (x -> x isa TimesOperator, ops)
330333 TimesOperator (convert_vector (ops), bw, sz, bbw, sbbw, ibbb, irb, isaf; anytimesop)
331334end
335+ maybenarroweltype (:: AbstractVector{Operator{T}} ) where {T} = Operator{T}
336+ maybenarroweltype (opsin) = mapreduce (operatortype, promote_type, opsin)
332337function __promotetimes (opsin, dsp, anytimesop)
333- ops = Vector {Operator{promote_eltypeof (opsin)} } (undef, 0 )
338+ ops = Vector {maybenarroweltype (opsin)} (undef, 0 )
334339 sizehint! (ops, length (opsin))
335340
336341 for k in reverse (eachindex (opsin))
@@ -597,7 +602,7 @@ anyplustimes(::typeof(*), op::TimesOperator, ops...) = true
597602anyplustimes (f) = false
598603
599604collateops (op, As:: Operator... ) = collateops (op, Val (anyplustimes (op, As... )), As... )
600- collateops (op, :: Val{true} , As... ) = mapreduce ( x -> _extractops (x, op), vcat, As )
605+ collateops (op, :: Val{true} , As... ) = reduce (vcat, map ( x -> _extractops (x, op), As) )
601606collateops (op, :: Val{false} , As... ) = As
602607
603608* (A:: Operator , B:: Operator ) = A_mul_B (A, B)
@@ -611,7 +616,7 @@ function A_mul_B(A::Operator, B::Operator; dspB=domainspace(B), rspA=rangespace(
611616 elseif isconstop (B)
612617 promotedomainspace (strictconvert (Number, B) * A, dspB)
613618 else
614- promotetimes (collateops (* , A, B), dspB, false )
619+ promotetimes (collateops (* , A : rangespace (B) , B), dspB, false )
615620 end
616621end
617622
0 commit comments