JuliaMath / JuliaMath/FFTW.jl

both FFTW and Base export "FFTW"

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

Description

Been trying to get some code running on v0.7 and running into difficulties with getting FFTW to work in my modules. Here is a simplified module that gives me errors.

```
module Fields

export r𝔽, Flat

using FFTW
import Base: *, \

abstract type Flat{Θpix,nside} end

struct r𝔽{P<:Flat,T<:Real,F}
Δx::T
Δk::T
Ωk::T
Ωx::T
period::T
nyq::T
k::Vector{Matrix{T}}
x::Vector{Matrix{T}}
FFT::F
end

# real FFT generated function constructor
@generated function r𝔽(::Type{P},::Type{T}) where T<:Real where P<:Flat{Θpix, nside} where {Θpix, nside}
Δx = deg2rad(Θpix/60)
period = Δx*nside
Δk = 2π/period
Ωk = Δk^2
Ωx = Δx^2
nyq = 2π / (2Δx)
k_side = ifftshift(-nside÷2:(nside-1)÷2) * Δk
x_side = ifftshift(-nside÷2:(nside-1)÷2) * Δx
k = [reshape(k_side, 1, nside), reshape(k_side[1:nside÷2+1], nside÷2+1, 1)]
x = [reshape(x_side, 1, nside), reshape(x_side, nside, 1)]
FFT = Ωx / (2π) * plan_rfft(rand(T,nside,nside); flags=FFTW.PATIENT, timelimit=4)
r𝔽{P,T,typeof(FFT)}(Δx, Δk, Ωk, Ωx, period, nyq, k, x, FFT)
end

(*)(g::r𝔽{P,T}, x) where P<:Flat where T = g.FFT * x
(\)(g::r𝔽{P,T}, x) where P<:Flat where T = g.FFT \ x

end
```

I want the following code block to run ...

```
using Main.Fields

nside = 1024
Θpix = 2.0
Px = Flat{Θpix,nside}
Tx = Float32
g = r𝔽(Px,Tx)

fx = rand(nside, nside)
fk = g * fx
y = g \ fk
```

.... but I get the following error in the line:

```
julia> g = r𝔽(Px,Tx)
WARNING: both FFTW and Base export "FFTW"; uses of it in module Fields must be qualified
ERROR: UndefVarError: FFTW not defined
Stacktrace:
[1] #s1#1(::Any, ::Any, ::Any, ::Any, ::Any, ::Type, ::Any) at ./REPL[1]:34
[2] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any,N} where N) at ./boot.jl:443
[3] In toplevel scope

```

Any ideas what is going on?

Here is my version info:
```
julia> versioninfo()
Julia Version 0.7.0-DEV.2454
Commit 00dafe28c0* (2017-11-07 15:53 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin17.2.0)
CPU: Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, broadwell)
```

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.