Skip to content

Commit a1024f2

Browse files
authored
Support planning Chebyshev via specifying type and size (#236)
* Support planning Chebyshev via specifying type and size * Update Project.toml
1 parent e1db1ca commit a1024f2

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "FastTransforms"
22
uuid = "057dd010-8810-581a-b7be-e3fc3b93f78c"
3-
version = "0.15.13"
3+
version = "0.15.14"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/chebyshevtransform.jl

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ function plan_chebyshevtransform(x::AbstractArray{T,N}, ::Val{2}, dims...; kws..
4949
ChebyshevTransformPlan{T,2}(FFTW.plan_r2r(x, SECONDKIND, dims...; kws...))
5050
end
5151

52-
plan_chebyshevtransform!(x::AbstractArray, dims...; kws...) = plan_chebyshevtransform!(x, Val(1), dims...; kws...)
53-
plan_chebyshevtransform(x::AbstractArray, dims...; kws...) = plan_chebyshevtransform(x, Val(1), dims...; kws...)
54-
5552

5653
# convert x if necessary
5754
@inline _plan_mul!(y::AbstractArray{T}, P::Plan{T}, x::StridedArray{T}) where T = mul!(y, P, x)
@@ -221,9 +218,6 @@ function plan_ichebyshevtransform(x::AbstractArray{T}, ::Val{2}, dims...; kws...
221218
inv(plan_chebyshevtransform(x, Val(2), dims...; kws...))
222219
end
223220

224-
plan_ichebyshevtransform!(x::AbstractArray, dims...; kws...) = plan_ichebyshevtransform!(x, Val(1), dims...; kws...)
225-
plan_ichebyshevtransform(x::AbstractArray, dims...; kws...) = plan_ichebyshevtransform(x, Val(1), dims...; kws...)
226-
227221
@inline function _icheb1_prescale!(d::Number, x::AbstractArray)
228222
lmul_dim_begin!(2, d, x)
229223
x
@@ -369,9 +363,6 @@ function plan_chebyshevutransform(x::AbstractArray{T,N}, ::Val{2}, dims...; kws.
369363
ChebyshevUTransformPlan{T,2}(FFTW.plan_r2r(x, USECONDKIND, dims...; kws...))
370364
end
371365

372-
plan_chebyshevutransform!(x::AbstractArray, dims...; kws...) = plan_chebyshevutransform!(x, Val(1), dims...; kws...)
373-
plan_chebyshevutransform(x::AbstractArray, dims...; kws...) = plan_chebyshevutransform(x, Val(1), dims...; kws...)
374-
375366

376367
_permfirst(d, N) = [d; 1:d-1; d+1:N]
377368

@@ -526,9 +517,6 @@ function plan_ichebyshevutransform(x::AbstractArray{T,N}, ::Val{2}, dims...; kws
526517
end
527518

528519

529-
plan_ichebyshevutransform!(x::AbstractArray, dims...; kws...) = plan_ichebyshevutransform!(x, Val(1), dims...; kws...)
530-
plan_ichebyshevutransform(x::AbstractArray, dims...; kws...) = plan_ichebyshevutransform(x, Val(1), dims...; kws...)
531-
532520
# second kind Chebyshev transforms share a plan with their inverse
533521
# so we support this via inv
534522
inv(P::ChebyshevUTransformPlan{T,2}) where {T} = IChebyshevUTransformPlan{T,2}(P.plan)
@@ -744,3 +732,14 @@ end
744732
copyto!(x, IChebyshevTransformPlan{T,1,Nothing,false,N,R}() * x)
745733
# *(P::IChebyshevTransformPlan{T,SECONDKIND,false,Nothing}, x::AbstractVector{T}) where T =
746734
# IChebyshevTransformPlan{T,SECONDKIND,true,Nothing}() * copy(x)
735+
736+
737+
for pln in (:plan_chebyshevtransform!, :plan_chebyshevtransform,
738+
:plan_chebyshevutransform!, :plan_chebyshevutransform,
739+
:plan_ichebyshevutransform, :plan_ichebyshevutransform!,
740+
:plan_ichebyshevtransform, :plan_ichebyshevtransform!)
741+
@eval begin
742+
$pln(x::AbstractArray, dims...; kws...) = $pln(x, Val(1), dims...; kws...)
743+
$pln(::Type{T}, szs, dims...; kwds...) where T = $pln(Array{T}(undef, szs...), dims...; kwds...)
744+
end
745+
end

test/chebyshevtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,4 +478,10 @@ using FastTransforms, Test
478478
@test_throws ErrorException plan_chebyshevtransform(randn(5)) * randn(5,5)
479479
@test_throws ErrorException plan_ichebyshevtransform(randn(5)) * randn(5,5)
480480
end
481+
482+
@testset "plan via size" begin
483+
X = randn(3,4)
484+
p = plan_chebyshevtransform(Float64, (3,4))
485+
@test p * X == chebyshevtransform(X)
486+
end
481487
end

0 commit comments

Comments
 (0)