From f4e359a4fd523e79225b3bcdbb3fead0a92c8b97 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Thu, 11 Jun 2026 21:10:05 +0100 Subject: [PATCH 1/4] support sum on any function defined on a disk --- src/disk.jl | 2 ++ test/test_disk.jl | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/disk.jl b/src/disk.jl index 58cd7f8..88a8712 100644 --- a/src/disk.jl +++ b/src/disk.jl @@ -71,6 +71,8 @@ summary(io::IO, P::Zernike) = print(io, "Zernike($(P.a), $(P.b))") orthogonalityweight(Z::Zernike) = ZernikeWeight(Z.a, Z.b) +basis_axes(::Inclusion{<:Any,<:UnitDisk}, v) = Zernike() + zerniker(ℓ, m, a, b, r::T) where T = sqrt(convert(T,2)^(m+a+b+2-iszero(m))/π) * r^m * normalizedjacobip((ℓ-m) ÷ 2, b, m+a, 2r^2-1) zerniker(ℓ, m, b, r) = zerniker(ℓ, m, zero(b), b, r) zerniker(ℓ, m, r) = zerniker(ℓ, m, zero(r), r) diff --git a/test/test_disk.jl b/test/test_disk.jl index 9667d99..7dc5c8d 100644 --- a/test/test_disk.jl +++ b/test/test_disk.jl @@ -563,8 +563,10 @@ end @testset "sum" begin P = Zernike() + x,y = coordinates(P) @test sum(expand(P, 𝐱 -> 1)) ≈ π - @test sum(expand(P, 𝐱 -> ((x,y) = 𝐱; exp(x*cos(y))))) ≈ 3.4898933353782744 + @test sum(expand(P, 𝐱 -> ((x,y) = 𝐱; exp(x*cos(y))))) ≈ sum(exp.(x.*cos.(y))) ≈ 3.4898933353782744 + @test [sum(P[:,k] .* P[:,j]) for k=1:10, j=1:10] ≈ I end @testset "Show" begin From a24a057ddc1592cd1692f9fad1e500761954c705 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Thu, 11 Jun 2026 21:12:28 +0100 Subject: [PATCH 2/4] support sum with generator on disk --- src/MultivariateOrthogonalPolynomials.jl | 2 +- src/disk.jl | 1 + test/test_disk.jl | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/MultivariateOrthogonalPolynomials.jl b/src/MultivariateOrthogonalPolynomials.jl index 472b6a2..fabbef7 100644 --- a/src/MultivariateOrthogonalPolynomials.jl +++ b/src/MultivariateOrthogonalPolynomials.jl @@ -10,7 +10,7 @@ import Base: axes, in, ==, +, -, /, *, ^, \, copy, copyto!, OneTo, getindex, siz import Base.Broadcast: Broadcasted, broadcasted, DefaultArrayStyle import DomainSets: boundary, EuclideanDomain -import QuasiArrays: LazyQuasiMatrix, LazyQuasiArrayStyle, domain, vec_layout, reshape_layout +import QuasiArrays: LazyQuasiMatrix, LazyQuasiArrayStyle, domain, vec_layout, reshape_layout, pointchoice 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, KronExpansionLayout import ArrayLayouts: MemoryLayout, sublayout, sub_materialize diff --git a/src/disk.jl b/src/disk.jl index 88a8712..0c4da65 100644 --- a/src/disk.jl +++ b/src/disk.jl @@ -1,4 +1,5 @@ ClassicalOrthogonalPolynomials.checkpoints(d::UnitDisk{T}) where T = [SVector{2,T}(0.1,0.2), SVector{2,T}(0.2,0.3)] +pointchoice(d::UnitDisk{T}) where T = SVector{2,T}(0,0) """ ZernikeWeight(a, b) diff --git a/test/test_disk.jl b/test/test_disk.jl index 7dc5c8d..9aa50e5 100644 --- a/test/test_disk.jl +++ b/test/test_disk.jl @@ -565,7 +565,7 @@ end P = Zernike() x,y = coordinates(P) @test sum(expand(P, 𝐱 -> 1)) ≈ π - @test sum(expand(P, 𝐱 -> ((x,y) = 𝐱; exp(x*cos(y))))) ≈ sum(exp.(x.*cos.(y))) ≈ 3.4898933353782744 + @test sum(expand(P, 𝐱 -> ((x,y) = 𝐱; exp(x*cos(y))))) ≈ sum(exp.(x.*cos.(y))) ≈ sum(((x,y) = 𝐱; exp.(x.*cos.(y))) for 𝐱 in UnitDisk()) ≈ 3.4898933353782744 @test [sum(P[:,k] .* P[:,j]) for k=1:10, j=1:10] ≈ I end From 5e60a939b1a809a24cec6a4671c4a1732f68e9dd Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Fri, 12 Jun 2026 12:15:26 +0100 Subject: [PATCH 3/4] move up --- src/rect.jl | 4 ---- test/test_disk.jl | 24 ++++++++++++------------ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/rect.jl b/src/rect.jl index 8eec709..98e9c9b 100644 --- a/src/rect.jl +++ b/src/rect.jl @@ -109,10 +109,6 @@ function *(A::TensorPlan, B::AbstractArray) B end -checkpoints(P::ProductDomain) = tensorgrid(map(checkpoints, components(P))...) -tensorgrid(x,y) = SVector.(x, y') - - function plan_transform(P::KronPolynomial{d,<:Any,<:Fill}, (B,)::Tuple{Block{1}}, dims=1:1) where d @assert only(dims) == 1 diff --git a/test/test_disk.jl b/test/test_disk.jl index 9aa50e5..308cbf5 100644 --- a/test/test_disk.jl +++ b/test/test_disk.jl @@ -328,6 +328,18 @@ import ForwardDiff: hessian g = MultivariateOrthogonalPolynomials.plotgrid(W[:,1:3]) @test all(rep[1].args .≈ (first.(g),last.(g),u[g])) end + + @testset "sum" begin + P = Zernike() + x,y = coordinates(P) + @test sum(expand(P, 𝐱 -> 1)) ≈ π + @test sum(expand(P, 𝐱 -> ((x,y) = 𝐱; exp(x*cos(y))))) ≈ sum(exp.(x.*cos.(y))) ≈ sum(exp.(x.*cos.(y)) for (x,y) in UnitDisk()) ≈ 3.4898933353782744 + @test [sum(P[:,k] .* P[:,j]) for k=1:10, j=1:10] ≈ I + end + + @testset "Show" begin + @test stringmime("text/plain", Zernike()) == "Zernike(0.0, 0.0)" + end end @testset "Fractional Laplacian on Unit Disk" begin @@ -560,16 +572,4 @@ end end end end - - @testset "sum" begin - P = Zernike() - x,y = coordinates(P) - @test sum(expand(P, 𝐱 -> 1)) ≈ π - @test sum(expand(P, 𝐱 -> ((x,y) = 𝐱; exp(x*cos(y))))) ≈ sum(exp.(x.*cos.(y))) ≈ sum(((x,y) = 𝐱; exp.(x.*cos.(y))) for 𝐱 in UnitDisk()) ≈ 3.4898933353782744 - @test [sum(P[:,k] .* P[:,j]) for k=1:10, j=1:10] ≈ I - end - - @testset "Show" begin - @test stringmime("text/plain", Zernike()) == "Zernike(0.0, 0.0)" - end end From f1b24e20ce891e7f16f25e71136fd502f578037a Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Fri, 12 Jun 2026 15:54:08 +0100 Subject: [PATCH 4/4] Update test_disk.jl --- test/test_disk.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_disk.jl b/test/test_disk.jl index 308cbf5..7ee8535 100644 --- a/test/test_disk.jl +++ b/test/test_disk.jl @@ -333,7 +333,7 @@ import ForwardDiff: hessian P = Zernike() x,y = coordinates(P) @test sum(expand(P, 𝐱 -> 1)) ≈ π - @test sum(expand(P, 𝐱 -> ((x,y) = 𝐱; exp(x*cos(y))))) ≈ sum(exp.(x.*cos.(y))) ≈ sum(exp.(x.*cos.(y)) for (x,y) in UnitDisk()) ≈ 3.4898933353782744 + @test sum(expand(P, 𝐱 -> let (x,y) = 𝐱; exp(x*cos(y)) end)) ≈ sum(exp.(x.*cos.(y))) ≈ sum(exp.(x.*cos.(y)) for (x,y) in UnitDisk()) ≈ 3.4898933353782744 @test [sum(P[:,k] .* P[:,j]) for k=1:10, j=1:10] ≈ I end