80
80
81
81
domain (P:: PlusOperator ) = commondomain (P. ops)
82
82
83
- _extractops (A, :: Any ) = SVector {1} (A)
83
+ _extractops (A, :: Any ) = [A]
84
84
_extractops (A:: PlusOperator , :: typeof (+ )) = A. ops
85
85
86
86
function + (A:: Operator , B:: Operator )
@@ -265,6 +265,9 @@ struct TimesOperator{T,BW,SZ,O<:Operator{T},BBW,SBBW} <: Operator{T}
265
265
end
266
266
end
267
267
268
+ operatortype (:: T ) where {T<: Operator } = T
269
+ operatortype (:: TimesOperator{<:Any,<:Any,<:Any,O} ) where {O} = O
270
+
268
271
const PlusOrTimesOp = Union{PlusOperator,TimesOperator}
269
272
270
273
bandwidthssum (f, ops) = mapfoldl (f, (t1, t2) -> t1 .+ t2, ops, init= (0 , 0 ))
@@ -329,8 +332,10 @@ Base.@constprop :aggressive function promotetimes(opsin,
329
332
anytimesop = any (x -> x isa TimesOperator, ops)
330
333
TimesOperator (convert_vector (ops), bw, sz, bbw, sbbw, ibbb, irb, isaf; anytimesop)
331
334
end
335
+ maybenarroweltype (:: AbstractVector{Operator{T}} ) where {T} = Operator{T}
336
+ maybenarroweltype (opsin) = mapreduce (operatortype, promote_type, opsin)
332
337
function __promotetimes (opsin, dsp, anytimesop)
333
- ops = Vector {Operator{promote_eltypeof (opsin)} } (undef, 0 )
338
+ ops = Vector {maybenarroweltype (opsin)} (undef, 0 )
334
339
sizehint! (ops, length (opsin))
335
340
336
341
for k in reverse (eachindex (opsin))
@@ -597,7 +602,7 @@ anyplustimes(::typeof(*), op::TimesOperator, ops...) = true
597
602
anyplustimes (f) = false
598
603
599
604
collateops (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) )
601
606
collateops (op, :: Val{false} , As... ) = As
602
607
603
608
* (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(
611
616
elseif isconstop (B)
612
617
promotedomainspace (strictconvert (Number, B) * A, dspB)
613
618
else
614
- promotetimes (collateops (* , A, B), dspB, false )
619
+ promotetimes (collateops (* , A : rangespace (B) , B), dspB, false )
615
620
end
616
621
end
617
622
0 commit comments