1
1
using Revise, ApproxFun, MultivariateOrthogonalPolynomials
2
2
import MultivariateOrthogonalPolynomials: checkerboard, icheckerboard, CDisk2CxfPlan
3
3
import ApproxFunBase: totensor
4
- import ApproxFunOrthogonalPolynomials: jacobip
4
+ import ApproxFunOrthogonalPolynomials: jacobip, chebyshevt
5
+
6
+
7
+
8
+
5
9
6
10
f = (x,y) -> x* y+ cos (y- 0.1 )+ sin (x)+ 1 ;
7
11
ff = Fun (f, ChebyshevDisk (), 1000 )
8
-
9
12
@test ff (0.1 ,0.2 ) ≈ f (0.1 ,0.2 )
13
+
10
14
ff = Fun (f, ChebyshevDisk ())
11
15
@test ff (0.1 ,0.2 ) ≈ f (0.1 ,0.2 )
12
16
17
+ function chebydiskeval (c:: AbstractMatrix{T} , r, θ) where T
18
+ ret = zero (T)
19
+ for j = 1 : 2 : size (c,2 ), k= 1 : size (c,1 )
20
+ m,ℓ = j ÷ 2 , k- 1
21
+ ret += c[k,j] * cos (m* θ) * cos ((2 ℓ+ isodd (m))* acos (r))
22
+ end
23
+ for j = 2 : 2 : size (c,2 ), k= 1 : size (c,1 )
24
+ m = j ÷ 2 ; ℓ = k- 1
25
+ ret += c[k,j] * sin (m* θ) * cos ((2 ℓ+ isodd (m))* acos (r))
26
+ end
27
+ ret
28
+ end
29
+
30
+
31
+ for (m,ℓ) in ((0 ,1 ),(0 ,2 ),(0 ,3 ), (1 ,0 ), (1 ,1 ), (1 ,2 ), (2 ,0 ), (2 ,1 ),(3 ,0 ),(3 ,4 ))
32
+ p1 = (r,θ) -> cos (m* θ) * cos ((2 ℓ+ isodd (m))* acos (r))
33
+ f = Fun ((x,y) -> p1 (sqrt (x^ 2 + y^ 2 ), atan (y,x)), ChebyshevDisk ())
34
+ c = totensor (f. space, chop (f. coefficients,1E-12 ))
35
+ @test c[ℓ+ 1 , 2 m+ 1 ] ≈ 1
36
+ @test f (0.1 cos (0.2 ),0.1 sin (0.2 )) ≈ chebydiskeval (c, 0.1 , 0.2 )
37
+
38
+ if m > 0
39
+ p2 = (r,θ) -> sin (m* θ) * cos ((2 ℓ+ isodd (m))* acos (r))
40
+ f = Fun ((x,y) -> p2 (sqrt (x^ 2 + y^ 2 ), atan (y,x)), ChebyshevDisk ())
41
+ c = totensor (f. space, chop (f. coefficients,1E-12 ))
42
+ @test c[ℓ+ 1 , 2 m] ≈ 1
43
+ @test f (0.1 cos (0.2 ),0.1 sin (0.2 )) ≈ chebydiskeval (c, 0.1 , 0.2 )
44
+ end
45
+ end
13
46
14
47
f = Fun ((x,y) -> 1 , ChebyshevDisk ()); n = 1 ;
15
48
c = totensor (f. space, f. coefficients)
@@ -31,14 +64,19 @@ f = Fun((x,y) -> x, ChebyshevDisk()); n = 2;
31
64
@test d ≈ [0.0 0.0 0.5 0.0 0.0 ; 0.0 0.0 0.0 0.0 0.0 ]
32
65
33
66
34
- m,ℓ = (0 ,2 );
35
- m,ℓ = (1 ,1 );
36
- m,ℓ = (2 ,2 );
37
- m,ℓ = ( 2 , 4 );
67
+ # m,ℓ = (0,2);
68
+ # m,ℓ = (1,1);
69
+ # m,ℓ = (2,2);
70
+
38
71
72
+ m,ℓ = (2 ,4 );
39
73
p1 = (r,θ) -> sqrt (2 ℓ+ 2 )* r^ m* jacobip ((ℓ- m)÷ 2 , m, 0 , 2 r^ 2 - 1 )* cos (m* θ)/ sqrt (2 π)
40
74
f = Fun ((x,y) -> p1 (sqrt (x^ 2 + y^ 2 ), atan (y,x)), ChebyshevDisk ());
75
+ @test f (0.1 * cos (0.2 ),0.1 * sin (0.2 )) ≈ p1 (0.1 ,0.2 )
41
76
c = totensor (f. space, chop (f. coefficients,1E-12 ))
77
+ @test chebydiskeval (c, 0.1 , 0.2 ) ≈ p1 (0.1 ,0.2 )
78
+
79
+
42
80
n = size (c,1 ); c = sqrt (2 π)* pad (c,n,4 n- 3 )
43
81
P = CDisk2CxfPlan (n)
44
82
d = P \ c
0 commit comments