Skip to content

Add grammatrix(::KronPolynomial) #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "MultivariateOrthogonalPolynomials"
uuid = "4f6956fd-4f93-5457-9149-7bfc4b2ce06d"
version = "0.9.1"
version = "0.9.2"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
14 changes: 7 additions & 7 deletions src/rect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,23 @@ function weaklaplacian(P::RectPolynomial)
A,B = P.args
Δ_A,Δ_B = weaklaplacian(A), weaklaplacian(B)
M_A,M_B = grammatrix(A), grammatrix(B)
KronTrav(Δ_A,M_B) + KronTrav(M_A,Δ_B)
KronTrav(M_B,Δ_A) + KronTrav(Δ_B,M_A)
end

function \(P::RectPolynomial, Q::RectPolynomial)
PA,PB = P.args
QA,QB = Q.args
krontrav(PA\QA, PB\QB)
krontrav(PB\QB, PA\QA)
end

@simplify function *(Ac::QuasiAdjoint{<:Any,<:RectPolynomial}, B::RectPolynomial)
PA,PB = Ac'.args
QA,QB = B.args
KronTrav(PA'QA, PB'QB)
KronTrav(PB'QB, PA'QA)
end

grammatrix(P::KronPolynomial) = KronTrav(reverse(grammatrix.(P.args))...)


struct ApplyPlan{T, F, Pl}
f::F
Expand All @@ -102,10 +104,8 @@ function *(A::TensorPlan, B::AbstractArray)
B
end

function checkpoints(P::RectPolynomial)
x,y = checkpoints.(P.args)
SVector.(x, y')
end
checkpoints(P::ProductDomain) = tensorgrid(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 dims == 1
Expand Down
10 changes: 10 additions & 0 deletions test/test_rect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ using Base: oneto
@test (Y * (TU \ f))[KR] ≈ (TU \ h)[KR]
end

@testset "gram matrix" begin
P = Legendre()
Q = Ultraspherical(3/2)
PQ = RectPolynomial(P, Q)
M = grammatrix(PQ)
f = expand(PQ, splat((x,y) -> exp(x*cos(y + 1))))
g = expand(PQ, splat((x,y) -> sin(x*cos(y + 1)+2)))
@test coefficients(g)[1:100]'M[1:100,1:100] * coefficients(f)[1:100] ≈ sum(expand(T², 𝐱 -> f[𝐱]g[𝐱]))
end

@testset "Conversion" begin
T = ChebyshevT()
U = ChebyshevU()
Expand Down
Loading