1
1
using ApproxFun, MultivariateOrthogonalPolynomials, Test
2
- import MultivariateOrthogonalPolynomials: rectspace, totensor
3
- import ApproxFunBase: plan_transform
2
+ import MultivariateOrthogonalPolynomials: rectspace, totensor, duffy2legendreconic!, legendre2duffyconic!, c_plan_rottriangle, plan_transform
4
3
5
4
@testset " Conic" begin
6
5
@testset " DuffyConic" begin
@@ -28,31 +27,35 @@ import ApproxFunBase: plan_transform
28
27
@test g (t,x,y) ≈ f ((t,x,y))
29
28
end
30
29
31
- @testset " LegendreConicPlan" begin
32
- m,ℓ = (1 ,1 )
33
- f = (txy) -> ((t,x,y) = txy; θ = atan (y,x); Fun (NormalizedJacobi (0 ,2 m+ 1 ,Segment (1 ,0 )),[zeros (ℓ);1 ])(t) * 2 ^ m * t^ m * cos (m* θ))
34
- p = points (LegendreConic (), 10 )
35
- P = plan_transform (LegendreConic (), f .(p))
36
- @test P. duffyplan* f .(p) ≈ Fun (f, DuffyConic ()). coefficients[1 : 12 ]
37
- g = Fun (f, LegendreConic (), 20 )
38
- t,x,y = sqrt (0.1 ^ 2 + 0.2 ^ 2 ),0.1 ,0.2
39
- @test g (t,x,y) ≈ f ((t,x,y))
40
- end
41
-
42
- @testset " Legendre<>DuffyConic" begin
43
- a = randn (10 )
30
+ @testset " Legendre<>DuffyConic" begin
31
+ for k = 0 : 10
32
+ a = [zeros (k); 1.0 ; zeros (5 )]
44
33
F = totensor (rectspace (DuffyConic ()), a)
45
-
34
+ F = pad (F, :, 2 size (F,1 )- 1 )
35
+ T = eltype (a)
36
+ P = c_plan_rottriangle (size (F,1 ), zero (T), zero (T), zero (T))
37
+ @test legendre2duffyconic! (P, duffy2legendreconic! (P, copy (F))) ≈ F
46
38
47
39
b = coefficients (a, LegendreConic (), DuffyConic ())
40
+ @test a ≈ coefficients (b, DuffyConic (), LegendreConic ())[1 : length (a)]
41
+ end
42
+ end
48
43
49
- coefficients (b, DuffyConic (), LegendreConic ())
44
+
45
+ @testset " LegendreConicPlan" begin
46
+ for (m,ℓ) in ((0 ,0 ), (0 ,1 ), (0 ,2 ), (1 ,1 ), (1 ,2 ), (2 ,2 ))
47
+ f = (txy) -> ((t,x,y) = txy; θ = atan (y,x); Fun (NormalizedJacobi (0 ,2 m+ 1 ,Segment (1 ,0 )),[zeros (ℓ);1 ])(t) * 2 ^ m * t^ m * cos (m* θ))
48
+ g = Fun (f, LegendreConic ())
49
+ t,x,y = sqrt (0.1 ^ 2 + 0.2 ^ 2 ),0.1 ,0.2
50
+ @test g (t,x,y) ≈ f ((t,x,y))
50
51
end
52
+ end
51
53
52
- @testset " LegendreConic" begin
53
- f = Fun ((t,x,y) -> 1 , LegendreConic (), 10 )
54
- @test f. coefficients ≈ [1 ; zeros (ncoefficients (f)- 1 )]
55
- @test f (sqrt (0.1 ^ 2 + 0.2 ^ 2 ),0.1 ,0.2 ) ≈ 1
54
+
55
+ @testset " LegendreConic" begin
56
+ f = Fun ((t,x,y) -> 1 , LegendreConic (), 10 )
57
+ @test f. coefficients ≈ [1 ; zeros (ncoefficients (f)- 1 )]
58
+ @test f (sqrt (0.1 ^ 2 + 0.2 ^ 2 ),0.1 ,0.2 ) ≈ 1
56
59
57
60
f = Fun ((t,x,y) -> t, LegendreConic (), 10 )
58
61
@test f (sqrt (0.1 ^ 2 + 0.2 ^ 2 ),0.1 ,0.2 ) ≈ sqrt (0.1 ^ 2 + 0.2 ^ 2 )
@@ -62,4 +65,4 @@ import ApproxFunBase: plan_transform
62
65
63
66
@time Fun ((t,x,y) -> 1 + t+ x+ y, LegendreConic (), 1000 )
64
67
end
65
- end
68
+ end
0 commit comments