Skip to content

Commit 26c0610

Browse files
committed
ChebyshevDisk constructor works
1 parent b4c1b99 commit 26c0610

File tree

3 files changed

+35
-16
lines changed

3 files changed

+35
-16
lines changed

src/Disk/Disk.jl

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,29 @@ struct ChebyshevDisk{V,T} <: Space{Disk{V},T}
44
domain::Disk{V}
55
end
66

7-
ChebyshevDisk(d::Disk{V}) where V = ChebyshevDisk{V,eltype(V)}(d)
7+
ChebyshevDisk(d::Disk{V}) where V = ChebyshevDisk{V,complex(eltype(V))}(d)
88
ChebyshevDisk() = ChebyshevDisk(Disk())
99

1010
rectspace(_) = Chebyshev() * Laurent()
1111

12-
1312
function points(S::ChebyshevDisk, N)
1413
pts = points(rectspace(S), N)
15-
fromcanonical.(Ref(S.domain), polar.(pts))
14+
polar.(pts)
1615
end
1716

17+
tensorizer(K::ChebyshevDisk) = Tensorizer((Ones{Int}(∞),Ones{Int}(∞)))
18+
19+
# we have each polynomial
20+
blocklengths(K::ChebyshevDisk) = 1:
21+
22+
for OP in (:block,:blockstart,:blockstop)
23+
@eval begin
24+
$OP(s::ChebyshevDisk,M::Block) = $OP(tensorizer(s),M)
25+
$OP(s::ChebyshevDisk,M) = $OP(tensorizer(s),M)
26+
end
27+
end
28+
29+
1830
plan_transform(S::ChebyshevDisk, n::AbstractVector) =
1931
TransformPlan(S, plan_transform(rectspace(S),n), Val{false})
2032
plan_itransform(S::ChebyshevDisk, n::AbstractVector) =
@@ -25,10 +37,8 @@ function checkerboard(A::AbstractMatrix{T}) where T
2537
m,n = size(A)
2638
C = zeros(T, (m+1)÷2, n)
2739
z = @view(A[1:2:end,1])
28-
e1 = @view(A[1:2:end,4:4:end])
29-
e2 = @view(A[1:2:end,5:4:end])
30-
o1 = @view(A[2:2:end,2:4:end])
31-
o2 = @view(A[2:2:end,3:4:end])
40+
e1,e2 = @view(A[1:2:end,4:4:end]),@view(A[1:2:end,5:4:end])
41+
o1,o2 = @view(A[2:2:end,2:4:end]),@view(A[2:2:end,3:4:end])
3242
C[1:size(z,1),1] .= z
3343
C[1:size(e1,1),4:4:n] .= e1
3444
C[1:size(e2,1),5:4:n] .= e2
@@ -40,13 +50,19 @@ end
4050
function icheckerboard(C::AbstractMatrix{T}) where T
4151
m,n = size(C)
4252
A = zeros(T, 2*m, n)
43-
A[1:2:end,1:2:end] .= C[:,1:2:end]
44-
A[2:2:end,2:2:end] .= C[:,2:2:end]
53+
A[1:2:end,1] .= C[:,1]
54+
A[1:2:end,4:4:end] .= C[:,4:4:end]
55+
A[1:2:end,5:4:end] .= C[:,5:4:end]
56+
A[2:2:end,2:4:end] .= C[:,2:4:end]
57+
A[2:2:end,3:4:end] .= C[:,3:4:end]
4558
A
4659
end
4760

48-
*(P::TransformPlan{<:Any,<:ChebyshevDisk}, v::AbstractArray) = checkerboard(P.plan*v)
49-
*(P::ITransformPlan{<:Any,<:ChebyshevDisk}, v::AbstractArray) = P.plan*icheckerboard(v)
61+
torectcfs(S, v) = fromtensor(rectspace(S), icheckerboard(totensor(S, v)))
62+
fromrectcfs(S, v) = fromtensor(S, checkerboard(totensor(rectspace(S),v)))
63+
64+
*(P::TransformPlan{<:Any,<:ChebyshevDisk}, v::AbstractArray) = fromrectcfs(P.space, P.plan*v)
65+
*(P::ITransformPlan{<:Any,<:ChebyshevDisk}, v::AbstractArray) = P.plan*torectcfs(P.space, v)
5066

51-
evaluate(cfs::AbstractVector, S::ChebyshevDisk, x) = evaluate(cfs, rectspace(S), ipolar(tocanonical(S.domain,x)))
67+
evaluate(cfs::AbstractVector, S::ChebyshevDisk, x) = evaluate(torectcfs(S,cfs), rectspace(S), ipolar(x))
5268

src/MultivariateOrthogonalPolynomials.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import ApproxFunBase: Vec
5858
# Jacobi import
5959
import ApproxFunOrthogonalPolynomials: jacobip, JacobiSD, PolynomialSpace, order
6060

61+
import ApproxFunFourier: polar, ipolar
6162

6263

6364
include("c_transforms.jl")

test/test_disk.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using Revise, ApproxFun, MultivariateOrthogonalPolynomials
22
import MultivariateOrthogonalPolynomials: checkerboard, icheckerboard
33

4-
f = (x,y) -> x*y+cos(y-0.1)+sin(x)+1; ff = Fun((r,θ) -> f(r*cos(θ),r*sin(θ)), (-1..1) × PeriodicSegment());
4+
f = (x,y) -> x*y+cos(y-0.1)+sin(x)+1;
5+
ff = Fun(f, ChebyshevDisk(), 1000)
6+
@test ff(0.1,0.2) f(0.1,0.2)
57

6-
cfs = ApproxFunBase.coefficientmatrix(ff)
7-
icheckerboard(checkerboard(cfs))[1:size(cfs,1),:]
8+
ff = Fun(f, ChebyshevDisk())
9+
@test ff(0.1,0.2) f(0.1,0.2)
810

9-
cfs
11+
plot(ff)

0 commit comments

Comments
 (0)