juliafftifft

Error using ifft with Julia


I try to compute the inverse fourier transform of a array of coefficients using ifft with Julia.

I have N complex numbers on an array organized as : Y=[Y_0,.., Y_(N-1)] representing my Fourier coefficients and by computing

ifft(Y)

I get the following error message :

MethodError: no method matching plan_bfft(::Array{Complex,1},
::UnitRange{Int64}) Closest candidates are:  
plan_bfft{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:601  
plan_bfft{T<:Real}(::AbstractArray{T<:Real,N}, ::Any; kws...) at
dft.jl:205  
plan_bfft{T<:Union{Integer,Rational{T<:Integer}}}(::AbstractArray{Complex{T<:Union{Integer,Rational}},N},
::Any; kws...) at dft.jl:207   ...

in #plan_ifft#15(::Array{Any,1}, ::Function, ::Array{Complex,1},
::UnitRange{Int64}) at ./dft.jl:268  in #plan_ifft#3(::Array{Any,1},
::Function, ::Array{Complex,1}) at ./dft.jl:58  in
ifft(::Array{Complex,1}) at ./dft.jl:56

Could anyone help with this?

when I ask typeof(Y) the answer is Array{Complex,1}.

Thank you


Solution

  • Just a guess here: ifft expects the array elements to be of type Complex{Float64}, not Complex. Furthermore,

    julia> Complex<:Complex{Float64}
    false
    

    How did you get an array of Complex?

    When using Complex{Float64} things work correctly:

    julia> Y=complex([1.,2.,3.],[4.,3.,2.])
    3-element Array{Complex{Float64},1}:
     1.0+4.0im
     2.0+3.0im
     3.0+2.0im
    
    julia> ifft(Y)
    3-element Array{Complex{Float64},1}:
           2.0+3.0im     
     -0.788675+0.211325im
     -0.211325+0.788675im