FFTW doesn't work in a module

FFTW has me thoroughly confused. Consider the following code:

using FFTW
fft(rand(10))

module Testing
using FFTW

f() = fft(rand(10))
export f
end

using .Testing
f()

The fft in the global scope works just fine. However, f errors with

ERROR: LoadError: MethodError: no method matching plan_fft!(::Vector{Float64}, ::Un
itRange{Int64})

I gather that this issue can arise when using AbstractFFTs directly, but I am loading FFTW! What am I doing wrong? (Julia 1.9)

1 Like

I cannot reproduce. What is ] status?

(jl_GLoe9p) pkg> st
Status `/tmp/jl_GLoe9p/Project.toml`
  [7a1cc6ca] FFTW v1.6.0


julia> using FFTW

julia> fft(rand(10))
10-element Vector{ComplexF64}:
    4.896886342005173 + 0.0im
  0.18327191936496529 + 0.29830948141388797im
    0.935521475377004 - 0.17167934311914898im
 -0.17940527689522684 + 0.5852170086797646im
 -0.11841056344565581 - 0.0925211085118875im
   2.3039704664349037 + 0.0im
 -0.11841056344565581 + 0.0925211085118875im
 -0.17940527689522684 - 0.5852170086797646im
    0.935521475377004 + 0.17167934311914898im
  0.18327191936496529 - 0.29830948141388797im

julia> module Testing
       using FFTW

       f() = fft(rand(10))
       export f
       end
Main.Testing

julia> using .Testing

julia> f()
10-element Vector{ComplexF64}:
    6.027681880991698 + 0.0im
   1.1674495100205002 + 0.10481311722367466im
  -1.8103182770071855 + 0.006523397541876766im
 -0.47206067938739077 + 0.17300716642828937im
  -0.4526906680456204 + 0.1266905360758629im
  -0.5400836578665337 + 0.0im
  -0.4526906680456204 - 0.1266905360758629im
 -0.47206067938739077 - 0.17300716642828937im
  -1.8103182770071855 - 0.006523397541876766im
   1.1674495100205002 - 0.10481311722367466im
1 Like