Skip to content

Commit

Permalink
Merge pull request #17 from milankl/mk/plantypes
Browse files Browse the repository at this point in the history
plan_(b)rfft types as in FFTW
  • Loading branch information
daanhb authored Sep 2, 2022
2 parents 926042f + 64969bd commit fc6bea9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/fft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,11 @@ end
# This is the reason for using StridedArray below. We also have to carefully
# distinguish between real and complex arguments.

plan_fft(x::StridedArray{T}, region) where {T <: ComplexFloats} = DummyFFTPlan{Complex{real(T)},false,typeof(region)}(region)
plan_fft!(x::StridedArray{T}, region) where {T <: ComplexFloats} = DummyFFTPlan{Complex{real(T)},true,typeof(region)}(region)
plan_fft(x::StridedArray{T}, region) where {T <: ComplexFloats} = DummyFFTPlan{T,false,typeof(region)}(region)
plan_fft!(x::StridedArray{T}, region) where {T <: ComplexFloats} = DummyFFTPlan{T,true,typeof(region)}(region)

plan_bfft(x::StridedArray{T}, region) where {T <: ComplexFloats} = DummybFFTPlan{Complex{real(T)},false,typeof(region)}(region)
plan_bfft!(x::StridedArray{T}, region) where {T <: ComplexFloats} = DummybFFTPlan{Complex{real(T)},true,typeof(region)}(region)
plan_bfft(x::StridedArray{T}, region) where {T <: ComplexFloats} = DummybFFTPlan{T,false,typeof(region)}(region)
plan_bfft!(x::StridedArray{T}, region) where {T <: ComplexFloats} = DummybFFTPlan{T,true,typeof(region)}(region)

# The ifft plans are automatically provided in terms of the bfft plans above.
# plan_ifft(x::StridedArray{T}, region) where {T <: ComplexFloats} = DummyiFFTPlan{Complex{real(T)},false,typeof(region)}(region)
Expand All @@ -302,8 +302,8 @@ plan_dct!(x::StridedArray{T}, region) where {T <: AbstractFloats} = DummyDCTPlan
plan_idct(x::StridedArray{T}, region) where {T <: AbstractFloats} = DummyiDCTPlan{T,false,typeof(region)}(region)
plan_idct!(x::StridedArray{T}, region) where {T <: AbstractFloats} = DummyiDCTPlan{T,true,typeof(region)}(region)

plan_rfft(x::StridedArray{T}, region) where {T <: RealFloats} = DummyrFFTPlan{Complex{real(T)},false,typeof(region)}(length(x), region)
plan_brfft(x::StridedArray{T}, n::Integer, region) where {T <: ComplexFloats} = DummybrFFTPlan{Complex{real(T)},false,typeof(region)}(n, region)
plan_rfft(x::StridedArray{T}, region) where {T <: RealFloats} = DummyrFFTPlan{T,false,typeof(region)}(length(x), region)
plan_brfft(x::StridedArray{T}, n::Integer, region) where {T <: ComplexFloats} = DummybrFFTPlan{T,false,typeof(region)}(n, region)

# A plan for irfft is created in terms of a plan for brfft.
# plan_irfft(x::StridedArray{T}, n::Integer, region) where {T <: ComplexFloats} = DummyirFFTPlan{Complex{real(T)},false,typeof(region)}(n, region)
Expand Down
7 changes: 7 additions & 0 deletions test/fft_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ function test_fftw()
@test !( plan_rfft(rand(T,10), 1:1) isa GenericFFT.DummyPlan )
@test !( plan_brfft(rand(Complex{T},10), 19) isa GenericFFT.DummyPlan )
@test !( plan_brfft(rand(Complex{T},10), 19, 1:1) isa GenericFFT.DummyPlan )

# check that GenericFFT and FFTW plans have the same parametric type
@test plan_rfft(rand(Float16,10)) isa AbstractFFTs.Plan{Float16}
@test plan_rfft(rand(Float64,10)) isa AbstractFFTs.Plan{Float64}

@test plan_brfft(rand(Complex{Float16},10),19) isa AbstractFFTs.Plan{Complex{Float16}}
@test plan_brfft(rand(Complex{Float64},10),19) isa AbstractFFTs.Plan{Complex{Float64}}
end
end

Expand Down

0 comments on commit fc6bea9

Please sign in to comment.