Skip to content

Commit 2d8f462

Browse files
authored
Use Jacobi transforms from FastTransforms (#160)
* Use Jacobi transforms from FastTransforms * Use th_cheb2jac
1 parent c528c95 commit 2d8f462

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ClassicalOrthogonalPolynomials"
22
uuid = "b30e2e7b-c4ee-47da-9d5f-2c5c27239acd"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "0.11.9"
4+
version = "0.11.10"
55

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
@@ -33,7 +33,7 @@ ContinuumArrays = "0.16"
3333
DomainSets = "0.6, 0.7"
3434
FFTW = "1.1"
3535
FastGaussQuadrature = "0.5, 1"
36-
FastTransforms = "0.15.2"
36+
FastTransforms = "0.15.10"
3737
FillArrays = "1"
3838
HypergeometricFunctions = "0.3.4"
3939
InfiniteArrays = "0.12.11, 0.13"

src/classical/jacobi.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ singularitiesbroadcast(::typeof(*), V::Union{NoSingularities,SubQuasiArray}...)
6969

7070
abstract type AbstractJacobi{T} <: OrthogonalPolynomial{T} end
7171

72+
struct JacobiTransformPlan{T, CHEB2JAC, DCT} <: Plan{T}
73+
cheb2jac::CHEB2JAC
74+
chebtransform::DCT
75+
end
76+
77+
JacobiTransformPlan(c2l, ct) = JacobiTransformPlan{promote_type(eltype(c2l),eltype(ct)),typeof(c2l),typeof(ct)}(c2l, ct)
78+
79+
*(P::JacobiTransformPlan, x::AbstractArray) = P.cheb2jac*(P.chebtransform*x)
80+
81+
7282
include("legendre.jl")
7383

7484
singularitiesbroadcast(::typeof(*), ::LegendreWeight, b::AbstractJacobiWeight) = b
@@ -94,6 +104,13 @@ Jacobi(P::Legendre{T}) where T = Jacobi(zero(T), zero(T))
94104

95105
basis_singularities(w::JacobiWeight) = Weighted(Jacobi(w.a, w.b))
96106

107+
function plan_grid_transform(P::Jacobi{T}, szs::NTuple{N,Int}, dims=1:N) where {T,N}
108+
arr = Array{T}(undef, szs...)
109+
x = grid(P, size(arr,1))
110+
x, JacobiTransformPlan(FastTransforms.plan_th_cheb2jac!(arr, P.a, P.b, dims), plan_chebyshevtransform(arr, dims))
111+
end
112+
113+
97114
"""
98115
jacobip(n, a, b, z)
99116
@@ -179,7 +196,7 @@ ldiv(P::Jacobi{V}, f::Inclusion{T}) where {T,V} = _op_ldiv(P, f)
179196
ldiv(P::Jacobi{V}, f::AbstractQuasiFill{T,1}) where {T,V} = _op_ldiv(P, f)
180197
function transform_ldiv(P::Jacobi{V}, f::AbstractQuasiArray) where V
181198
T = ChebyshevT{V}()
182-
pad(cheb2jac(paddeddata(T \ f), P.a, P.b), axes(P,2), tail(axes(f))...)
199+
pad(FastTransforms.th_cheb2jac(paddeddata(T \ f), P.a, P.b, 1), axes(P,2), tail(axes(f))...)
183200
end
184201

185202

src/classical/legendre.jl

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,10 @@ function transform_ldiv(::Legendre{V}, f::Union{AbstractQuasiVector,AbstractQuas
9898
pad(th_cheb2leg(paddeddata(dat)), axes(dat)...)
9999
end
100100

101-
struct LegendreTransformPlan{T, CHEB2LEG, DCT} <: Plan{T}
102-
cheb2leg::CHEB2LEG
103-
chebtransform::DCT
104-
end
105-
106-
LegendreTransformPlan(c2l, ct) = LegendreTransformPlan{promote_type(eltype(c2l),eltype(ct)),typeof(c2l),typeof(ct)}(c2l, ct)
107-
108-
*(P::LegendreTransformPlan, x::AbstractArray) = P.cheb2leg*(P.chebtransform*x)
109-
110101
function plan_grid_transform(P::Legendre{T}, szs::NTuple{N,Int}, dims=1:N) where {T,N}
111102
arr = Array{T}(undef, szs...)
112103
x = grid(P, size(arr,1))
113-
x, LegendreTransformPlan(FastTransforms.plan_th_cheb2leg!(arr, dims), plan_chebyshevtransform(arr, dims))
104+
x, JacobiTransformPlan(FastTransforms.plan_th_cheb2leg!(arr, dims), plan_chebyshevtransform(arr, dims))
114105
end
115106

116107

test/test_jacobi.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ import ClassicalOrthogonalPolynomials: recurrencecoefficients, basis, MulQuasiMa
197197
P = Jacobi(1/2,0.)
198198
x = axes(P,1)
199199
@test (P * (P \ exp.(x)))[0.1] exp(0.1)
200+
@test P[:,1:20] \ exp.(x) (P \ exp.(x))[1:20]
200201

201202
@test P[0.1,:]' * (P \ [exp.(x) cos.(x)]) [exp(0.1) cos(0.1)]
202203

@@ -219,8 +220,8 @@ import ClassicalOrthogonalPolynomials: recurrencecoefficients, basis, MulQuasiMa
219220
x = axes(P,1)
220221
u = P * (P \ exp.(x))
221222
@test u[0.1] exp(0.1)
222-
# U = P * (P \ [exp.(x) cos.(x)]) # not good at multiscale
223-
@test_broken U[0.1,:] [exp(0.1),cos(0.1)]
223+
U = P * (P \ [exp.(x) cos.(x)])
224+
@test U[0.1,:] [exp(0.1),cos(0.1)]
224225
end
225226

226227
@testset "special cases" begin

0 commit comments

Comments
 (0)