Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

irfft not supported for PaddedView but rfft is #106

Open
danmackinlay opened this issue Aug 4, 2019 · 1 comment
Open

irfft not supported for PaddedView but rfft is #106

danmackinlay opened this issue Aug 4, 2019 · 1 comment

Comments

@danmackinlay
Copy link

danmackinlay commented Aug 4, 2019

PaddedView arrays are partly supported

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.

@danmackinlay
Copy link
Author

Possibly related: @favba's comment on discourse about the special relationship between FFTs and StridedArrays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant