Skip to content

Commit 12907c9

Browse files
authored
2D Legendre transform (#143)
1 parent 4593054 commit 12907c9

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ BlockBandedMatrices = "0.11.5"
3131
ClassicalOrthogonalPolynomials = "0.7"
3232
ContinuumArrays = "0.12"
3333
DomainSets = "0.5, 0.6"
34-
FastTransforms = "0.14"
34+
FastTransforms = "0.15"
3535
FillArrays = "0.13"
3636
HarmonicOrthogonalPolynomials = "0.4"
3737
InfiniteArrays = "0.12"

src/MultivariateOrthogonalPolynomials.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Base.Broadcast: Broadcasted, broadcasted, DefaultArrayStyle
1111
import DomainSets: boundary
1212

1313
import QuasiArrays: LazyQuasiMatrix, LazyQuasiArrayStyle, domain
14-
import ContinuumArrays: @simplify, Weight, weight, grid, plotgrid, TransformFactorization, ExpansionLayout, plotvalues, unweighted, plan_grid_transform, checkpoints
14+
import ContinuumArrays: @simplify, Weight, weight, grid, plotgrid, TransformFactorization, ExpansionLayout, plotvalues, unweighted, plan_grid_transform, checkpoints, transform_ldiv
1515

1616
import ArrayLayouts: MemoryLayout, sublayout, sub_materialize
1717
import BlockArrays: block, blockindex, BlockSlice, viewblock, blockcolsupport, AbstractBlockStyle, BlockStyle

src/rect.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,12 @@ end
8383
Base.@propagate_inbounds function getindex(f::Mul{MultivariateOPLayout{2},<:DiagTravLayout{<:PaddedLayout}}, x::SVector, j...)
8484
@inbounds checkbounds(ApplyQuasiArray(*,f.A,f.B), x, j...)
8585
Base.unsafe_getindex(f, x, j...)
86+
end
87+
88+
## Special Legendre case
89+
90+
function transform_ldiv(K::KronPolynomial{d,V,<:Fill{<:Legendre}}, f::Union{AbstractQuasiVector,AbstractQuasiMatrix}) where {d,V}
91+
T = KronPolynomial{d}(Fill(ChebyshevT{V}(), size(K.args)...))
92+
dat = (T \ f).array
93+
DiagTrav(pad(cheb2leg(paddeddata(dat)), axes(dat)...))
8694
end

test/test_rect.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import ClassicalOrthogonalPolynomials: expand
2929
\ x
3030
f = expand(T², 𝐱 -> ((x,y) = 𝐱; exp(x*cos(y-0.1))))
3131
@test f[SVector(0.1,0.2)] exp(0.1*cos(0.1))
32-
32+
3333
U = ChebyshevU()
3434
= RectPolynomial(Fill(U, 2))
3535

@@ -81,4 +81,14 @@ import ClassicalOrthogonalPolynomials: expand
8181
K = Block.(1:200); @time L = Δ[K,K]; @time qr(L);
8282
\(qr(Δ), [1; zeros(∞)]; tolerance=1E-1)
8383
end
84+
85+
@testset "Legendre" begin
86+
P = Legendre()
87+
= RectPolynomial(Fill(P, 2))
88+
𝐱 = axes(P²,1)
89+
f =/\ broadcast(𝐱 -> ((x,y) = 𝐱; exp(x*cos(y))), 𝐱)
90+
@test f[SVector(0.1,0.2)] exp(0.1cos(0.2))
91+
92+
@test (P²[:,Block.(1:100)] \ f) f.args[2][Block.(1:100)]
93+
end
8494
end

0 commit comments

Comments
 (0)