Skip to content

Commit 28e903d

Browse files
committed
Fix some tests, support laplacian on rectangles
1 parent e4044b3 commit 28e903d

File tree

8 files changed

+27
-13
lines changed

8 files changed

+27
-13
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ HarmonicOrthogonalPolynomials = "0.7"
3838
InfiniteArrays = "0.15"
3939
InfiniteLinearAlgebra = "0.9"
4040
LazyArrays = "2.3.1"
41-
LazyBandedMatrices = "0.11.1"
41+
LazyBandedMatrices = "0.11.3"
4242
QuasiArrays = "0.12"
4343
RecurrenceRelationships = "0.2"
4444
SpecialFunctions = "1, 2"

src/MultivariateOrthogonalPolynomials.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Base.Broadcast: Broadcasted, broadcasted, DefaultArrayStyle
1111
import DomainSets: boundary, EuclideanDomain
1212

1313
import QuasiArrays: LazyQuasiMatrix, LazyQuasiArrayStyle, domain
14-
import ContinuumArrays: @simplify, Weight, weight, grid, plotgrid, TransformFactorization, ExpansionLayout, plotvalues, unweighted, plan_transform, checkpoints, transform_ldiv, AbstractBasisLayout, basis_axes, Inclusion, grammatrix, weaklaplacian, layout_broadcasted, laplacian, abslaplacian, laplacian_axis, abslaplacian_axis, diff_layout
14+
import ContinuumArrays: @simplify, Weight, weight, grid, plotgrid, TransformFactorization, ExpansionLayout, plotvalues, unweighted, plan_transform, checkpoints, transform_ldiv, AbstractBasisLayout, basis_axes, Inclusion, grammatrix, weaklaplacian, layout_broadcasted, laplacian, abslaplacian, laplacian_axis, abslaplacian_axis, diff_layout, operatororder, broadcastbasis
1515

1616
import ArrayLayouts: MemoryLayout, sublayout, sub_materialize
1717
import BlockArrays: block, blockindex, BlockSlice, viewblock, blockcolsupport, AbstractBlockStyle, BlockStyle
@@ -23,7 +23,7 @@ import InfiniteArrays: InfiniteCardinal, OneToInf
2323

2424
import ClassicalOrthogonalPolynomials: jacobimatrix, Weighted, orthogonalityweight, HalfWeighted, WeightedBasis, pad, recurrencecoefficients, clenshaw, weightedgrammatrix, Clenshaw
2525
import HarmonicOrthogonalPolynomials: BivariateOrthogonalPolynomial, MultivariateOrthogonalPolynomial, Plan,
26-
AngularMomentum, BlockOneTo, BlockRange1, interlace,
26+
AngularMomentum, angularmomentum, BlockOneTo, BlockRange1, interlace,
2727
MultivariateOPLayout, AbstractMultivariateOPLayout, MAX_PLOT_BLOCKS
2828

2929
export MultivariateOrthogonalPolynomial, BivariateOrthogonalPolynomial,
@@ -33,7 +33,7 @@ export MultivariateOrthogonalPolynomial, BivariateOrthogonalPolynomial,
3333
Zernike, ZernikeWeight, zerniker, zernikez,
3434
AngularMomentum,
3535
RadialCoordinate, Weighted, Block, jacobimatrix, KronPolynomial, RectPolynomial,
36-
grammatrix, oneto, coordinates, Laplacian, AbsLaplacian
36+
grammatrix, oneto, coordinates, Laplacian, AbsLaplacian, laplacian, abslaplacian, angularmomentum, weaklaplacian
3737

3838

3939
laplacian_axis(::Inclusion{<:SVector{2}}, A; dims...) = diff(A, (2,0); dims...) + diff(A, (0, 2); dims...)

src/rect.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,6 @@ function layout_broadcasted(::Tuple{ExpansionLayout{KronOPLayout{2}},KronOPLayou
181181

182182
P * ClenshawKron(C, (recurrencecoefficients(A), recurrencecoefficients(B)), (jacobimatrix(T), jacobimatrix(U)))
183183
end
184+
185+
186+
broadcastbasis(::typeof(+), A::KronPolynomial, B::KronPolynomial) = KronPolynomial(broadcastbasis.(+, A.args, B.args)...)

src/rectdisk.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ const WeightedDunklXuDisk{T} = WeightedBasis{T,<:DunklXuDiskWeight,<:DunklXuDisk
4141

4242
WeightedDunklXuDisk(β) = DunklXuDiskWeight(β) .* DunklXuDisk(β)
4343

44-
function diff(::DunklXuDisk, ::Val{(1,0)}; dims=1)
44+
function diff(P::DunklXuDisk, ::Val{(1,0)}; dims=1)
4545
@assert dims == 1
46+
β = P.β
4647
n = mortar(Fill.(oneto(∞),oneto(∞)))
4748
k = mortar(Base.OneTo.(oneto(∞)))
4849
dat = BlockBroadcastArray(hcat,
@@ -53,7 +54,7 @@ function diff(::DunklXuDisk, ::Val{(1,0)}; dims=1)
5354
DunklXuDisk+1) * _BandedBlockBandedMatrix(dat', axes(k,1), (-1,1), (0,2))
5455
end
5556

56-
function diff(::DunklXuDisk{T}, ::Val{(0,1)}; dims=1) where T
57+
function diff(P::DunklXuDisk{T}, ::Val{(0,1)}; dims=1) where T
5758
@assert dims == 1
5859
β = P.β
5960
k = mortar(Base.OneTo.(oneto(∞)))
@@ -179,7 +180,7 @@ function jacobimatrix(::Val{2}, P::DunklXuDisk)
179180
_BandedBlockBandedMatrix(dat', axes(k,1), (1,1), (1,1))
180181
end
181182

182-
@simplify function *(A::AngularMomentum, P::DunklXuDisk)
183+
function angularmomentum(P::DunklXuDisk)
183184
β = P.β
184185
n = mortar(Fill.(oneto(∞),oneto(∞)))
185186
k = mortar(Base.OneTo.(oneto(∞)))

src/triangle.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ summary(io::IO, P::TriangleWeight) = print(io, "x^$(P.a)*y^$(P.b)*(1-x-y)^$(P.c)
147147

148148
orthogonalityweight(P::JacobiTriangle) = TriangleWeight(P.a, P.b, P.c)
149149

150-
function diff(w_P::JacobiTriangle{T}, ::Val{(1,0)}; dims=1) where T
150+
function diff(P::JacobiTriangle{T}, ::Val{(1,0)}; dims=1) where T
151151
@assert dims == 1
152152
a,b,c = P.a,P.b,P.c
153153
n = mortar(Fill.(oneto(∞),oneto(∞)))
@@ -159,7 +159,7 @@ function diff(w_P::JacobiTriangle{T}, ::Val{(1,0)}; dims=1) where T
159159
JacobiTriangle(a+1,b,c+1) * _BandedBlockBandedMatrix(dat', axes(k,1), (-1,1), (0,1))
160160
end
161161

162-
function diff(w_P::JacobiTriangle{T}, ::Val{(0,1)}; dims=1) where T
162+
function diff(P::JacobiTriangle{T}, ::Val{(0,1)}; dims=1) where T
163163
@assert dims == 1
164164
a,b,c = P.a,P.b,P.c
165165
k = mortar(Base.OneTo.(oneto(∞)))
@@ -169,7 +169,7 @@ end
169169
# TODO: The derivatives below only hold for a, b, c > 0.
170170
function diff(w_P::WeightedTriangle{T}, ::Val{(1,0)}; dims=1) where T
171171
@assert dims == 1
172-
a, b, c = P.P.a, P.P.b, P.P.c
172+
a, b, c = w_P.P.a, w_P.P.b, w_P.P.c
173173
n = mortar(Fill.(oneto(∞),oneto(∞)))
174174
k = mortar(Base.OneTo.(oneto(∞)))
175175
scale = -(2k .+ (b + c - 1))
@@ -181,7 +181,7 @@ end
181181

182182
function diff(w_P::WeightedTriangle{T}, ::Val{(0,1)}; dims=1) where T
183183
@assert dims == 1
184-
a, b, c = P.P.a, P.P.b, P.P.c
184+
a, b, c = w_P.P.a, w_P.P.b, w_P.P.c
185185
k = mortar(Base.OneTo.(oneto(∞)))
186186
WeightedTriangle(a, b-1, c-1) * _BandedBlockBandedMatrix(-one(T) * k', axes(k, 1), (1, -1), (1, -1))
187187
end

test/test_rect.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ using Base: oneto
114114
f = expand(P², splat((x,y) -> -2*((1-y^2) + (1-x^2))))
115115
@test*c)[Block.(1:5)] (W²'f)[Block.(1:5)]
116116
end
117+
118+
@testset "laplacian" begin
119+
Δ =\ laplacian(W²)
120+
c = transform(P², _ -> 1)
121+
f = expand(P², splat((x,y) -> -2*((1-y^2) + (1-x^2))))
122+
@test*c)[Block.(1:5)] (Q² \f)[Block.(1:5)]
123+
@test laplacian(W² * c)[SVector(0.1,0.2)] -2*((1-0.2^2) + (1-0.1^2))
124+
@test abslaplacian(W² * c)[SVector(0.1,0.2)] 2*((1-0.2^2) + (1-0.1^2))
125+
end
117126
end
118127

119128
@testset "Legendre" begin

test/test_rectdisk.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import MultivariateOrthogonalPolynomials: dunklxu_raising, dunklxu_lowering, Ang
6060

6161
@test λ im*imag(λ)
6262

63-
∂θ = AngularMomentum(axes(P, 1))
63+
∂θ = AngularMomentum(P)
6464
A = P \ (∂θ * P)
6565
A2 = P \ (∂θ^2 * P)
6666

test/test_triangle.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import MultivariateOrthogonalPolynomials: tri_forwardrecurrence, grid, TriangleR
88
@test copy(P) P
99
@test P JacobiTriangle{Float64}() JacobiTriangle{Float64}(0,0,0)
1010

11+
𝐱 = axes(P,1)
1112
x,y = coordinates(P)
1213
@test 𝐱[SVector(0.1,0.2)] == SVector(0.1,0.2)
1314
@test x[SVector(0.1,0.2)] == 0.1
@@ -132,7 +133,7 @@ import MultivariateOrthogonalPolynomials: tri_forwardrecurrence, grid, TriangleR
132133

133134
@testset "operators" begin
134135
P = JacobiTriangle()
135-
136+
𝐱 = axes(P,1)
136137

137138
∂ˣ = Derivative(𝐱, (1,0))
138139
∂ʸ = Derivative(𝐱, (0,1))

0 commit comments

Comments
 (0)