Skip to content

Commit 1ff9937

Browse files
committed
make tests more exhaustive
1 parent efd46fe commit 1ff9937

File tree

1 file changed

+44
-6
lines changed

1 file changed

+44
-6
lines changed

test/test_disk.jl

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,48 @@
11
using Revise, ApproxFun, MultivariateOrthogonalPolynomials
22
import MultivariateOrthogonalPolynomials: checkerboard, icheckerboard, CDisk2CxfPlan
33
import ApproxFunBase: totensor
4-
import ApproxFunOrthogonalPolynomials: jacobip
4+
import ApproxFunOrthogonalPolynomials: jacobip, chebyshevt
5+
6+
7+
8+
59

610
f = (x,y) -> x*y+cos(y-0.1)+sin(x)+1;
711
ff = Fun(f, ChebyshevDisk(), 1000)
8-
912
@test ff(0.1,0.2) f(0.1,0.2)
13+
1014
ff = Fun(f, ChebyshevDisk())
1115
@test ff(0.1,0.2) f(0.1,0.2)
1216

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, 2m+1] 1
36+
@test f(0.1cos(0.2),0.1sin(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, 2m] 1
43+
@test f(0.1cos(0.2),0.1sin(0.2)) chebydiskeval(c, 0.1, 0.2)
44+
end
45+
end
1346

1447
f = Fun((x,y) -> 1, ChebyshevDisk()); n = 1;
1548
c = totensor(f.space, f.coefficients)
@@ -31,14 +64,19 @@ f = Fun((x,y) -> x, ChebyshevDisk()); n = 2;
3164
@test d [0.0 0.0 0.5 0.0 0.0; 0.0 0.0 0.0 0.0 0.0]
3265

3366

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+
3871

72+
m,ℓ = (2,4);
3973
p1 = (r,θ) -> sqrt(2+2)*r^m*jacobip((ℓ-m)÷2, m, 0, 2r^2-1)*cos(m*θ)/sqrt(2π)
4074
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)
4176
c = totensor(f.space, chop(f.coefficients,1E-12))
77+
@test chebydiskeval(c, 0.1, 0.2) p1(0.1,0.2)
78+
79+
4280
n = size(c,1); c = sqrt(2π)*pad(c,n,4n-3)
4381
P = CDisk2CxfPlan(n)
4482
d = P \ c

0 commit comments

Comments
 (0)