@@ -84,13 +84,16 @@ import Base: oneto
8484 F = Fun (L)
8585 @test L (0.1 , 0.2 ) ≈ F (0.1 , 0.2 )
8686
87+ x = Fun (); y = x;
8788 D1 = Derivative (space (L), [1 ,0 ])
8889 D2 = Derivative (space (L), [0 ,1 ])
89- @test (D2 * L)(0.1 , 0.2 ) ≈ Fun ()(0.1 )
90- @test (D1 * L)(0.1 , 0.2 ) ≈ Fun ()(0.2 )
91- @test (D1[L] * L)(0.1 , 0.2 ) ≈ 2 Fun ()(0.1 ) * Fun ()(0.2 )^ 2
92- @test ((Derivative () ⊗ I) * L)(0.1 , 0.2 ) ≈ Fun ()(0.2 )
93- @test ((I ⊗ Derivative ()) * L)(0.1 , 0.2 ) ≈ Fun ()(0.1 )
90+ @test (D2 * L)(0.1 , 0.2 ) ≈ x (0.1 )
91+ @test (D1 * L)(0.1 , 0.2 ) ≈ y (0.2 )
92+ # @test ((L * D1) * L)(0.1, 0.2) ≈ x(0.1) * (y(0.2))^2
93+ # @test ((L * D2) * L)(0.1, 0.2) ≈ (x(0.1))^2 * y(0.2)
94+ @test (D1[L] * L)(0.1 , 0.2 ) ≈ 2 x (0.1 ) * y (0.2 )^ 2
95+ @test ((Derivative () ⊗ I) * L)(0.1 , 0.2 ) ≈ y (0.2 )
96+ @test ((I ⊗ Derivative ()) * L)(0.1 , 0.2 ) ≈ x (0.1 )
9497 end
9598
9699
@@ -335,14 +338,40 @@ import Base: oneto
335338 @test F (1.5 ,1.5im ) ≈ hankelh1 (0 ,10 abs (1.5im - 1.5 ))
336339
337340 P = ProductFun ((x,y)-> x* y, Chebyshev () ⊗ Chebyshev ())
338- @test Evaluation (1 ) * P == Fun ()
339- @test Evaluation (- 1 ) * P == - Fun ()
341+ x = Fun (); y = x;
342+ @test Evaluation (1 ) * P == x
343+ @test Evaluation (- 1 ) * P == - x
340344 D1 = Derivative (Chebyshev () ⊗ Chebyshev (), [1 ,0 ])
341345 D2 = Derivative (Chebyshev () ⊗ Chebyshev (), [0 ,1 ])
342- @test (D2 * P)(0.1 , 0.2 ) ≈ Fun ()(0.1 )
343- @test (D1 * P)(0.1 , 0.2 ) ≈ Fun ()(0.2 )
344- @test ((I ⊗ Derivative ()) * P)(0.1 , 0.2 ) ≈ Fun ()(0.1 )
345- @test ((Derivative () ⊗ I) * P)(0.1 , 0.2 ) ≈ Fun ()(0.2 )
346+ @test (D2 * P)(0.1 , 0.2 ) ≈ x (0.1 )
347+ @test (D1 * P)(0.1 , 0.2 ) ≈ y (0.2 )
348+ # @test ((P * D1) * P)(0.1, 0.2) ≈ x(0.1) * (y(0.2))^2
349+ # @test ((P * D2) * P)(0.1, 0.2) ≈ (x(0.1))^2 * y(0.2)
350+ @test ((I ⊗ Derivative ()) * P)(0.1 , 0.2 ) ≈ x (0.1 )
351+ @test ((Derivative () ⊗ I) * P)(0.1 , 0.2 ) ≈ y (0.2 )
352+
353+ # MultivariateFun methods
354+ f = invoke (* , Tuple{KroneckerOperator, ApproxFunBase. MultivariateFun},
355+ Derivative () ⊗ I, P)
356+ @test f (0.1 , 0.2 ) ≈ y (0.2 )
357+ O = invoke (* , Tuple{ApproxFunBase. MultivariateFun, KroneckerOperator},
358+ P, Derivative () ⊗ I)
359+ @test (O * Fun (P))(0.1 , 0.2 ) ≈ x (0.1 ) * (y (0.2 ))^ 2
360+
361+ @testset " chopping" begin
362+ M = [0 0 0 ; 0 1 0 ; 0 0 1 ]
363+ P = ProductFun (M, Chebyshev () ⊗ Chebyshev (), chopping = true )
364+ @test coefficients (P) == M
365+ M = [0 0 0 ; 0 1 0 ; 0 0 1e-100 ]
366+ P = ProductFun (M, Chebyshev () ⊗ Chebyshev (), chopping = true )
367+ @test coefficients (P) == @view M[1 : 2 , 1 : 2 ]
368+ M = [0 0 0 ; 0 1 0 ; 0 0 0 ]
369+ P = ProductFun (M, Chebyshev () ⊗ Chebyshev (), chopping = true )
370+ @test coefficients (P) == @view M[1 : 2 , 1 : 2 ]
371+ # M = zeros(3,3)
372+ # P = ProductFun(M, Chebyshev() ⊗ Chebyshev(), chopping = true)
373+ # @test all(iszero, coefficients(P))
374+ end
346375 end
347376
348377 @testset " Functional*Fun" begin
0 commit comments