1- using MultivariateOrthogonalPolynomials, ClassicalOrthogonalPolynomials, StaticArrays, LinearAlgebra, Test
1+ using MultivariateOrthogonalPolynomials, ClassicalOrthogonalPolynomials, StaticArrays, LinearAlgebra, BlockArrays, FillArrays, Test
2+ import ClassicalOrthogonalPolynomials: expand
23
34@testset " RectPolynomial" begin
45 @testset " Evaluation" begin
56 T = ChebyshevT ()
67 T² = RectPolynomial (T, T)
7- xy = SVector (0.1 ,0.2 )
8- @test T²[xy , Block (1 )[1 ]] == T²[xy , 1 ]
9- @test T²[xy , Block (1 )] == T²[xy , Block .(1 : 1 )]
10- @test T²[xy , Block (2 )] == [0.1 ,0.2 ]
11- @test T²[xy , Block (3 )] ≈ [cos (2 * acos (0.1 )), 0.1 * 0.2 , cos (2 * acos (0.2 ))]
8+ 𝐱 = SVector (0.1 ,0.2 )
9+ @test T²[𝐱 , Block (1 )[1 ]] == T²[𝐱 , 1 ]
10+ @test T²[𝐱 , Block (1 )] == T²[𝐱 , Block .(1 : 1 )]
11+ @test T²[𝐱 , Block (2 )] == [0.1 ,0.2 ]
12+ @test T²[𝐱 , Block (3 )] ≈ [cos (2 * acos (0.1 )), 0.1 * 0.2 , cos (2 * acos (0.2 ))]
1213
1314 U = ChebyshevU ()
1415 V = KronPolynomial (T, U)
15- @test V[xy, Block (1 )[1 ]] == V[xy, 1 ]
16- @test V[xy, Block (1 )] == V[xy, Block .(1 : 1 )]
17- @test V[xy, Block (2 )] == [0.1 ,2 * 0.2 ]
18- @test V[xy, Block (3 )] ≈ [cos (2 * acos (0.1 )), 2 * 0.1 * 0.2 , sin (3 * acos (0.2 ))/ sin (acos (0.2 ))]
16+ @test V[𝐱, Block (1 )[1 ]] == V[𝐱, 1 ]
17+ @test V[𝐱, Block (1 )] == V[𝐱, Block .(1 : 1 )]
18+ @test V[𝐱, Block (2 )] == [0.1 ,2 * 0.2 ]
19+ @test V[𝐱, Block (3 )] ≈ [cos (2 * acos (0.1 )), 2 * 0.1 * 0.2 , sin (3 * acos (0.2 ))/ sin (acos (0.2 ))]
20+ end
21+
22+ @testset " Transform" begin
23+ T = ChebyshevT ()
24+ T² = RectPolynomial (Fill (T, 2 ))
25+ T²ₙ = T²[:,Block .(Base. OneTo (5 ))]
26+ 𝐱 = axes (T²ₙ,1 )
27+ x,y = first .(𝐱),last .(𝐱)
28+ @test T²ₙ \ one .(x) == [1 ; zeros (14 )]
29+ T² \ x
30+ f = expand (T², 𝐱 -> ((x,y) = 𝐱; exp (x* cos (y- 0.1 ))))
31+ @test f[SVector (0.1 ,0.2 )] ≈ exp (0.1 * cos (0.1 ))
32+
33+ U = ChebyshevU ()
34+ U² = RectPolynomial (Fill (U, 2 ))
35+
36+ a,b = f. args
37+ f[SVector (0.1 ,0.2 )]
38+
39+ a,b = T² , (T² \ broadcast (𝐱 -> ((x,y) = 𝐱; exp (x* cos (y))), 𝐱))
1940 end
2041
2142 @testset " Conversion" begin
@@ -33,8 +54,8 @@ using MultivariateOrthogonalPolynomials, ClassicalOrthogonalPolynomials, StaticA
3354 T² = RectPolynomial (T, T)
3455 U² = RectPolynomial (U, U)
3556 C² = RectPolynomial (C, C)
36- xy = axes (T²,1 )
37- D_x,D_y = PartialDerivative {1} (xy ),PartialDerivative {2} (xy )
57+ 𝐱 = axes (T²,1 )
58+ D_x,D_y = PartialDerivative {1} (𝐱 ),PartialDerivative {2} (𝐱 )
3859 D_x* T²
3960 D_y* T²
4061 U²\ D_x* T²
@@ -53,8 +74,8 @@ using MultivariateOrthogonalPolynomials, ClassicalOrthogonalPolynomials, StaticA
5374 W² = RectPolynomial (W, W)
5475 P² = RectPolynomial (P, P)
5576 Q² = RectPolynomial (Q, Q)
56- xy = axes (W²,1 )
57- D_x,D_y = PartialDerivative {1} (xy ),PartialDerivative {2} (xy )
77+ 𝐱 = axes (W²,1 )
78+ D_x,D_y = PartialDerivative {1} (𝐱 ),PartialDerivative {2} (𝐱 )
5879 Δ = Q²\ (D_x^ 2 + D_y^ 2 )* W²
5980
6081 K = Block .(1 : 200 ); @time L = Δ[K,K]; @time qr (L);
0 commit comments