FFTW.jl icon indicating copy to clipboard operation
FFTW.jl copied to clipboard

Expose full guru interface API

Open gasagna opened this issue 7 years ago • 4 comments

The current plan_* API does not expose the full functionality that the C FFTW API has, namely the ability to specify a custom stride pattern and the number of transforms to perform.

In my use case I have dense arrays of a custom number type VarNum{T}, wrapping two Ts, and need to perform transforms on the x and y components separately. For instance, consider:

struct VarNum{T<:Number} <: Number
    x::T
    y::T
end

# arrays
u = Matrix{VarNum{Float64}}(10, 10)
U = Matrix{VarNum{Complex{Float64}}}(10, 6)

# create and apply plan
p = plan_rftt(u, [2, 1])
A_mul_B!(U, p, U)

I have somehow hacked into FFTW.jl code as much as needed to achieve what I want. This required doubling the strides of VarNum arrays, doubling the howmany parameter, and defining appropriate methods for VarNum arrays. I feel, though, that such functionality might be useful to many other people and it would be good to have it in the package.

gasagna avatar Aug 17 '17 19:08 gasagna

In the Hadamard.jl package, I also had to ccall the low-level guru interface. It's not too hard, but it is worth thinking about a higher-level way to expose this.

stevengj avatar Aug 17 '17 19:08 stevengj

I would be happy to prepare a pull request, because I need this quite badly at the moment. I need guidance, though, since I know the guru API up to a certain point.

The design space allows some flexibility here, depending on how much functionality we want to expose. For my use case, a julian trait-based dispatch mechanisms with trait functions acting on the number type (i.e. strides and howmany) would be sufficient, but the guru API is vastly more flexible, e.g. split arrays, and a one-to-one map to the C API might be a better start.

gasagna avatar Aug 18 '17 10:08 gasagna

Yeah. As you know, guru interface is already in FFTW.jl but for internal use. You can reuse it. https://github.com/JuliaMath/FFTW.jl/blob/master/src/fft.jl#L491

appleparan avatar Aug 18 '17 11:08 appleparan

@appleparan Thanks. I was wondering what kind of API and functionality we want to have on the Julia side.

gasagna avatar Aug 18 '17 11:08 gasagna