Skip to content

Commit 8df8c7b

Browse files
committed
Add getindex for DunklXuDisk and tests
1 parent ecd43a1 commit 8df8c7b

File tree

2 files changed

+50
-13
lines changed

2 files changed

+50
-13
lines changed

src/rectdisk.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ struct DunklXuDisk{T, V} <: BivariateOrthogonalPolynomial{T}
77
β::V
88
end
99

10+
DunklXuDisk{T}(β) where T = DunklXuDisk{T, typeof(β)}(β)
1011
DunklXuDisk::T) where T = DunklXuDisk{float(T), T}(β)
1112
DunklXuDisk() = DunklXuDisk(0)
13+
DunklXuDisk{T}() where T = DunklXuDisk{T}(0)
1214

1315
==(D1::DunklXuDisk, D2::DunklXuDisk) = D1.β == D2.β
1416

@@ -18,6 +20,17 @@ copy(A::DunklXuDisk) = A
1820
show(io::IO, P::DunklXuDisk) = summary(io, P)
1921
summary(io::IO, P::DunklXuDisk) = print(io, "DunklXuDisk($(P.β))")
2022

23+
function getindex(P::DunklXuDisk{T}, 𝐱::StaticVector{2}, JR::BlockOneTo) where T
24+
x,y = 𝐱
25+
n = Int(last(JR))
26+
ret = zeros(T, n, n)
27+
β = P.β
28+
ρ = sqrt(1-x^2)
29+
for j = 1:n
30+
ret[1:n-j+1,j] = Jacobi{T}(j+β-1/2, j+β-1/2)[x,1:n-j+1] * ρ^(j-1) * Jacobi{T}(β, β)[y/ρ,j]
31+
end
32+
DiagTrav(ret)
33+
end
2134

2235
"""
2336
DunklXuDiskWeight(β)
@@ -37,6 +50,11 @@ axes(P::DunklXuDiskWeight{T}) where T = (Inclusion(UnitDisk{T}()),)
3750
show(io::IO, P::DunklXuDiskWeight) = summary(io, P)
3851
summary(io::IO, P::DunklXuDiskWeight) = print(io, "(1-x^2-y^2)^$(P.β) on the unit disk")
3952

53+
function getindex(P::DunklXuDiskWeight, 𝐱::StaticVector{2})
54+
r = norm(𝐱)
55+
(1-r^2)^P.β
56+
end
57+
4058
const WeightedDunklXuDisk{T} = WeightedBasis{T,<:DunklXuDiskWeight,<:DunklXuDisk}
4159

4260
WeightedDunklXuDisk(β) = DunklXuDiskWeight(β) .* DunklXuDisk(β)

test/test_rectdisk.jl

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using MultivariateOrthogonalPolynomials, StaticArrays, BlockArrays, BlockBandedMatrices, ArrayLayouts, Base64,
22
QuasiArrays, Test, ClassicalOrthogonalPolynomials, BandedMatrices, FastTransforms, LinearAlgebra
33
import MultivariateOrthogonalPolynomials: dunklxu_raising, dunklxu_lowering, AngularMomentum
4+
using ForwardDiff
45

56
@testset "Dunkl-Xu disk" begin
67
@testset "basics" begin
@@ -13,6 +14,11 @@ import MultivariateOrthogonalPolynomials: dunklxu_raising, dunklxu_lowering, Ang
1314
@test xy[SVector(0.1,0.2)] == SVector(0.1,0.2)
1415
@test x[SVector(0.1,0.2)] == 0.1
1516
@test y[SVector(0.1,0.2)] == 0.2
17+
18+
ρ = sqrt(1-0.1^2)
19+
@test P[SVector(0.1,0.2),1] 1
20+
@test P[SVector(0.1,0.2),Block(2)] [0.15,0.2]
21+
@test P[SVector(0.1,0.2),Block(3)] [jacobip(2,1/2,1/2,0.1),jacobip(1,3/2,3/2,0.1)*ρ*legendrep(1,0.2/ρ),ρ^2*legendrep(2,0.2/ρ)]
1622
end
1723

1824
@testset "operators" begin
@@ -29,26 +35,39 @@ import MultivariateOrthogonalPolynomials: dunklxu_raising, dunklxu_lowering, Ang
2935

3036
x, y = coordinates(P)
3137

32-
L = WP \ WQ
33-
R = Q \ P
38+
@testset "lowering/raising" begin
39+
L = WP \ WQ
40+
@test WP[SVector(0.1,0.2),Block.(1:6)]'L[Block.(1:6),Block.(1:4)] WQ[SVector(0.1,0.2),Block.(1:4)]'
41+
R = Q \ P
42+
@test Q[SVector(0.1,0.2),Block.(1:4)]'R[Block.(1:4),Block.(1:4)] P[SVector(0.1,0.2),Block.(1:4)]'
3443

35-
X = P \ (x .* P)
36-
Y = P \ (y .* P)
44+
@test (DunklXuDisk() \ WeightedDunklXuDisk(1.0))[Block.(1:N), Block.(1:N)] (WeightedDunklXuDisk(0.0) \ WeightedDunklXuDisk(1.0))[Block.(1:N), Block.(1:N)]
45+
end
3746

38-
@test (L * R)[Block.(1:N), Block.(1:N)] (I - X^2 - Y^2)[Block.(1:N), Block.(1:N)]
3947

40-
@test (DunklXuDisk() \ WeightedDunklXuDisk(1.0))[Block.(1:N), Block.(1:N)] (WeightedDunklXuDisk(0.0) \ WeightedDunklXuDisk(1.0))[Block.(1:N), Block.(1:N)]
48+
@testset "jacobi" begin
49+
X = P \ (x .* P)
50+
Y = P \ (y .* P)
4151

42-
∂x = Derivative(P, (1,0))
43-
∂y = Derivative(P, (0,1))
52+
@test (L * R)[Block.(1:N), Block.(1:N)] (I - X^2 - Y^2)[Block.(1:N), Block.(1:N)]
53+
@test P[SVector(0.1,0.2),Block.(1:5)]'X[Block.(1:5),Block.(1:4)] 0.1P[SVector(0.1,0.2),Block.(1:4)]'
54+
@test P[SVector(0.1,0.2),Block.(1:5)]'Y[Block.(1:5),Block.(1:4)] 0.2P[SVector(0.1,0.2),Block.(1:4)]'
55+
end
4456

45-
Dx = Q \ (∂x * P)
46-
Dy = Q \ (∂y * P)
57+
@testset "derivatives" begin
58+
∂x = Derivative(P, (1,0))
59+
∂y = Derivative(P, (0,1))
4760

48-
Mx = Q \ (x .* Q)
49-
My = Q \ (y .* Q)
61+
Dx = Q \ (∂x * P)
62+
Dy = Q \ (∂y * P)
63+
64+
@test Q[SVector(0.1,0.2),Block.(1:3)]'Dx[Block.(1:3),Block.(1:4)] [ForwardDiff.gradient(𝐱 -> DunklXuDisk{eltype(𝐱)}(P.β)[𝐱,k], SVector(0.1,0.2))[1] for k=1:10]'
65+
Mx = Q \ (x .* Q)
66+
My = Q \ (y .* Q)
67+
68+
A = (Mx * Dy - My * Dx)[Block.(1:N), Block.(1:N)]
69+
end
5070

51-
A = (Mx * Dy - My * Dx)[Block.(1:N), Block.(1:N)]
5271

5372
B = (Q \ P)[Block.(1:N), Block.(1:N)]
5473

0 commit comments

Comments
 (0)