JuliaMath / JuliaMath/FFTW.jl

`irfft` not supported for `PaddedView` but `rfft` is

Open
#106 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
300
Forks
61
PR merge metrics
No merged PRs in 30d

Description

[PaddedView](https://github.com/JuliaArrays/PaddedViews.jl) arrays are partly supported

```julia
using AbstractFFTs
using PaddedViews

shortsamp = cos.(0:256 * pi / 16);
paddedsamp = PaddedView(0.0f0, shortsamp, (512,))
fftshortsamp = rfft(shortsamp);
fftpaddedsamp = rfft(paddedsamp); # RFFT of padded array OK
paddedfftshortsamp = PaddedView(0.0f0, fftshortsamp, (257,)) ;
irfft(fftpaddedsamp, 512);
irfft(paddedfftshortsamp, 512); ## IRFFT of padded array not OK
```
results in an error at the last line

```
MethodError: no method matching plan_brfft(::PaddedView{Complex{Float64},1,Tuple{Base.OneTo{Int64}},Array{Complex{Float64},1}}, ::Int64, ::UnitRange{Int64})
Closest candidates are:
plan_brfft(!Matched::Union{DenseArray{Complex{Float32},N}, ReinterpretArray{Complex{Float32},N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray}, ReshapedArray{Complex{Float32},N,A,MI} where MI<:Tuple{Vararg{SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray}, SubArray{Complex{Float32},N,A,I,L} where L where I<:Tuple{Vararg{Union{Int64, AbstractRange{Int64}, AbstractCartesianIndex},N} where N} where A<:Union{ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, DenseArray}}, ::Integer, ::Any; flags, timelimit) where N at /home/dan/.julia/packages/FFTW/2okGQ/src/fft.jl:678
plan_brfft(!Matched::Union{DenseArray{Complex{Float64},N}, ReinterpretArray{Complex{Float64},N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray}, ReshapedArray{Complex{Float64},N,A,MI} where MI<:Tuple{Vararg{SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray}, SubArray{Complex{Float64},N,A,I,L} where L where I<:Tuple{Vararg{Union{Int64, AbstractRange{Int64}, AbstractCartesianIndex},N} where N} where A<:Union{ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, DenseArray}}, ::Integer, ::Any; flags, timelimit) where N at /home/dan/.julia/packages/FFTW/2okGQ/src/fft.jl:678
plan_brfft(::AbstractArray, ::Integer; kws...) at /home/dan/.julia/packages/AbstractFFTs/PUqOK/src/definitions.jl:285

Stacktrace:
[1] #plan_irfft#19(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::PaddedView{Complex{Float64},1,Tuple{Base.OneTo{Int64}},Array{Complex{Float64},1}}, ::Int64, ::UnitRange{Int64}) at /home/dan/.julia/packages/AbstractFFTs/PUqOK/src/definitions.jl:334
[2] plan_irfft(::PaddedView{Complex{Float64},1,Tuple{Base.OneTo{Int64}},Array{Complex{Float64},1}}, ::Int64, ::UnitRange{Int64}) at /home/dan/.julia/packages/AbstractFFTs/PUqOK/src/definitions.jl:334
[3] #plan_irfft#18(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::PaddedView{Complex{Float64},1,Tuple{Base.OneTo{Int64}},Array{Complex{Float64},1}}, ::Int64) at /home/dan/.julia/packages/AbstractFFTs/PUqOK/src/definitions.jl:285
[4] plan_irfft(::PaddedView{Complex{Float64},1,Tuple{Base.OneTo{Int64}},Array{Complex{Float64},1}}, ::Int64) at /home/dan/.julia/packages/AbstractFFTs/PUqOK/src/definitions.jl:285
[5] irfft(::PaddedView{Complex{Float64},1,Tuple{Base.OneTo{Int64}},Array{Complex{Float64},1}}, ::Int64) at /home/dan/.julia/packages/AbstractFFTs/PUqOK/src/definitions.jl:283
[6] top-level scope at In[62]:10
```

It seems like if we do the RFFT we should also also be able to invert it. Perhaps it's as simple as extending that union type. I can prepare a patch for this but want to check in whether that is sane first.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.