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

Some DFT issues #17896

Closed
timholy opened this issue Aug 8, 2016 · 0 comments
Closed

Some DFT issues #17896

timholy opened this issue Aug 8, 2016 · 0 comments
Assignees
Milestone

Comments

@timholy
Copy link
Member

timholy commented Aug 8, 2016

I'm working on a PR to fix these (which will also generalize FFT to non-1 indices), but I may get interrupted for a couple of days so I thought I'd at least document some problems I noticed just from browsing the current code.

First, at least rfft fails for anything other than StridedArrays:

julia> a = randn(10)
10-element Array{Float64,1}:
  0.0243352
 -1.70058  
  2.23913  
 -0.0130746
 -1.10423  
 -0.259103 
  0.871204 
 -0.799567 
 -0.0846184
 -0.676859 

julia> b = view(a, 1:8)
8-element SubArray{Float64,1,Array{Float64,1},Tuple{UnitRange{Int64}},true}:
  0.0243352
 -1.70058  
  2.23913  
 -0.0130746
 -1.10423  
 -0.259103 
  0.871204 
 -0.799567 

julia> rfft(b)
5-element Array{Complex{Float64},1}:
 -0.741877+0.0im     
 -0.446848-0.904787im
  -4.19023+1.14704im 
   2.70397+1.83107im 
   4.80277+0.0im     

julia> b = view(a, [1:8;])
8-element SubArray{Float64,1,Array{Float64,1},Tuple{Array{Int64,1}},false}:
  0.0243352
 -1.70058  
  2.23913  
 -0.0130746
 -1.10423  
 -0.259103 
  0.871204 
 -0.799567 

julia> rfft(b)
ERROR: MethodError: no method matching plan_rfft(::SubArray{Float64,1,Array{Float64,1},Tuple{Array{Int64,1}},false}, ::UnitRange{Int64})
Closest candidates are:
  plan_rfft{N}(::Union{Base.ReshapedArray{Float32,N,A<:DenseArray,MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N}}},DenseArray{Float32,N},SubArray{Float32,N,A<:Union{Base.ReshapedArray{T,N,A<:DenseArray,MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N}}},DenseArray},I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex,Colon,Int64,Range{Int64}},N}},L}}, ::Any; flags, timelimit) at fft/FFTW.jl:636
  plan_rfft{N}(::Union{Base.ReshapedArray{Float64,N,A<:DenseArray,MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N}}},DenseArray{Float64,N},SubArray{Float64,N,A<:Union{Base.ReshapedArray{T,N,A<:DenseArray,MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N}}},DenseArray},I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex,Colon,Int64,Range{Int64}},N}},L}}, ::Any; flags, timelimit) at fft/FFTW.jl:636
  plan_rfft{T<:Union{Integer,Rational{T<:Integer}}}(::AbstractArray{T<:Union{Integer,Rational},N}, ::Any; kws...) at dft.jl:191
  ...
 in #plan_rfft#7(::Array{Any,1}, ::Function, ::SubArray{Float64,1,Array{Float64,1},Tuple{Array{Int64,1}},false}) at ./dft.jl:38
 in rfft(::SubArray{Float64,1,Array{Float64,1},Tuple{Array{Int64,1}},false}) at ./dft.jl:36

Second, Float16 is an AbstractFloat but is not supported by FFTW, so:

julia> a = randn(Float16, 8)
8-element Array{Float16,1}:
 -1.7412  
  0.38818 
  0.066711
 -0.64893 
  1.3623  
 -0.48633 
 -1.1904  
 -0.023666

julia> fft(a)
ERROR: MethodError: no method matching plan_fft(::Array{Complex{Float16},1}, ::UnitRange{Int64})
Closest candidates are:
  plan_fft{T<:Union{Complex{Float32},Complex{Float64}},N}(::Union{Base.ReshapedArray{T<:Union{Complex{Float32},Complex{Float64}},N,A<:DenseArray,MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N}}},DenseArray{T<:Union{Complex{Float32},Complex{Float64}},N},SubArray{T<:Union{Complex{Float32},Complex{Float64}},N,A<:Union{Base.ReshapedArray{T,N,A<:DenseArray,MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N}}},DenseArray},I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex,Colon,Int64,Range{Int64}},N}},L}}, ::Any; flags, timelimit) at fft/FFTW.jl:585
  plan_fft{T<:Real}(::AbstractArray{T<:Real,N}, ::Any; kws...) at dft.jl:185
  plan_fft{T<:Union{Integer,Rational{T<:Integer}}}(::AbstractArray{Complex{T<:Union{Integer,Rational}},N}, ::Any; kws...) at dft.jl:187
  ...
 in fft(::Array{Float16,1}, ::UnitRange{Int64}) at ./dft.jl:184 (repeats 2 times)

even though

julia> a = round(Int, 10*randn(8))
8-element Array{Int64,1}:
  -8
  -3
   1
 -20
  -2
  15
  -5
   2

julia> fft(a)
8-element Array{Complex{Float64},1}:
    -20.0+0.0im    
 -3.17157+22.2843im
     -6.0-30.0im   
 -8.82843+34.2843im
     -8.0+0.0im    
 -8.82843-34.2843im
     -6.0+30.0im   
 -3.17157-22.2843im

works fine.

@timholy timholy added this to the 0.5.x milestone Aug 8, 2016
@timholy timholy self-assigned this Aug 8, 2016
timholy added a commit that referenced this issue Aug 11, 2016
Support non-1 indices and fix type problems in DFT (fixes #17896)
tkelman pushed a commit that referenced this issue Aug 20, 2016
tkelman added a commit that referenced this issue Aug 22, 2016
)"

This reverts commit 05197a5.
un-backports #17919 for now so that we don't break DSP.jl

Revert "circcopy! needs qualification with Base. for 0.5"

This reverts commit d0a632b.
tkelman added a commit that referenced this issue Aug 22, 2016
)"

This reverts commit 05197a5.
un-backports #17919 for now so that we don't break DSP.jl

Revert "circcopy! needs qualification with Base. for 0.5"

This reverts commit d0a632b.
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