@@ -154,14 +154,7 @@ for TYP in (:SumSpace,:PiecewiseSpace)
154154 end
155155end
156156
157- function hasconversion (a:: SumSpace , b:: Space )
158- for n= 1 : length (a. spaces)
159- if hasconversion (a. spaces[n],b) ≠ true
160- return false
161- end
162- end
163- return true
164- end
157+ hasconversion (a:: SumSpace , b:: Space ) = all (s -> hasconversion (s, b), a. spaces)
165158
166159function Conversion (a:: SumSpace , b:: Space )
167160 if ! hasconversion (a, b)
@@ -230,20 +223,32 @@ end
230223
231224for (Op,OpWrap) in ((:Derivative ,:DerivativeWrapper ),(:Integral ,:IntegralWrapper ))
232225 @eval begin
233- $ Op (S:: PiecewiseSpace ,k:: Integer ) =
234- $ OpWrap (InterlaceOperator (Diagonal ([map (s-> $ Op (s,k),components (S))... ]),PiecewiseSpace),k)
235- function $Op (S:: ArraySpace ,k:: Integer )
226+ function $Op (S:: PiecewiseSpace , k:: Number )
227+ assert_integer (k)
228+ t = map (s-> $ Op (s,k),components (S))
229+ D = Diagonal (convert_vector_or_svector (t))
230+ O = InterlaceOperator (D, PiecewiseSpace)
231+ $ OpWrap (O,k)
232+ end
233+ function $Op (S:: ArraySpace , k:: Number )
234+ assert_integer (k)
236235 ops = map (s-> $ Op (s,k),S)
237- $ OpWrap (InterlaceOperator (Diagonal (ops),S,ArraySpace (reshape (rangespace .(ops),size (S)))),k)
236+ RS = ArraySpace (reshape (map (rangespace, ops), size (S)))
237+ O = InterlaceOperator (Diagonal (ops), S, RS)
238+ $ OpWrap (O,k)
238239 end
239240 end
240241end
241242
242- function Derivative (S:: SumSpace ,k:: Integer )
243+ function Derivative (S:: SumSpace , k:: Number )
244+ assert_integer (k)
243245 # we want to map before we decompose, as the map may introduce
244246 # mixed bases.
245247 if typeof (canonicaldomain (S))== typeof (domain (S))
246- DerivativeWrapper (InterlaceOperator (Diagonal ([map (s-> Derivative (s,k),components (S))... ]),SumSpace),k)
248+ t = map (s-> Derivative (s,k),components (S))
249+ D = Diagonal (convert_vector_or_svector (t))
250+ O = InterlaceOperator (D, SumSpace)
251+ DerivativeWrapper (O,k)
247252 else
248253 DefaultDerivative (S,k)
249254 end
@@ -268,17 +273,24 @@ end
268273
269274# # Multiply components
270275
271- function Multiplication (f:: Fun{PW} , sp:: PiecewiseSpace ) where PW <: PiecewiseSpace
276+ function Multiplication (f:: Fun{<:PiecewiseSpace} , sp:: PiecewiseSpace )
272277 p= perm (domain (f). domains,domain (sp). domains) # sort f
273278 vf= components (f)[p]
274-
275- MultiplicationWrapper (f,InterlaceOperator (Diagonal ([map (Multiplication,vf,sp. spaces)... ]),PiecewiseSpace))
279+ t = map (Multiplication,vf,sp. spaces)
280+ D = Diagonal (convert_vector_or_svector (t))
281+ O = InterlaceOperator (D, PiecewiseSpace)
282+ MultiplicationWrapper (f, O)
276283end
277284
278285Multiplication (f:: Fun{SumSpace{SV1,D,R1}} ,sp:: SumSpace{SV2,D,R2} ) where {SV1,SV2,D,R1,R2} =
279286 MultiplicationWrapper (f,mapreduce (g-> Multiplication (g,sp),+ ,components (f)))
280- Multiplication (f:: Fun ,sp:: SumSpace ) =
281- MultiplicationWrapper (f,InterlaceOperator (Diagonal ([map (s-> Multiplication (f,s),components (sp))... ]),SumSpace))
287+
288+ function Multiplication (f:: Fun , sp:: SumSpace )
289+ t = map (s-> Multiplication (f,s),components (sp))
290+ D = Diagonal (convert_vector_or_svector (t))
291+ O = InterlaceOperator (D, SumSpace)
292+ MultiplicationWrapper (f, O)
293+ end
282294
283295Multiplication (f:: Fun , sp:: PiecewiseSpace ) = MultiplicationWrapper (f, Multiplication (Fun (f,sp),sp))
284296
0 commit comments