www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Idiomatic FFT(W) Wrapper

reply Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
Have anybody constructed an idiomatic D wrapper for FFTW?

http://www.fftw.org/fftw3_doc/Tutorial.html#Tutorial

I'm specifically concerned about

- `RefCounted`-wrapping of the C structures `fftw_complex` and 
`fftw_plan`
- range semantics, lazy evaluation and caching of result in
   stream-based architectures; `fftw_plan`, `fftw_execute`
- slicing and scope
- seamless interoperability with Mir 
(https://github.com/libmir/mir)
Jul 13
parent John Colvin <john.loughran.colvin gmail.com> writes:
On Thursday, 13 July 2017 at 12:49:40 UTC, Per Nordlöw wrote:
 Have anybody constructed an idiomatic D wrapper for FFTW?
No, sorry, although I have used the library quite a bit in D.
 http://www.fftw.org/fftw3_doc/Tutorial.html#Tutorial

 I'm specifically concerned about

 - `RefCounted`-wrapping of the C structures `fftw_complex` and 
 `fftw_plan`
Sounds useful perhaps for fftw_plan. fftw_complex is just `typedef double fftw_complex[2];` so I'm not sure what you're getting at there. It's worth remembering that "wisdom" is separate from (and shared between) plans in fftw, so constructing and destroying plans can be very cheap and there's often no need to have multiple owners of a single plan.
 - range semantics, lazy evaluation and caching of result in
   stream-based architectures; `fftw_plan`, `fftw_execute`
The discrete fourier transform is a global algorithm that can be lazy in input or output, but not both. I'm pretty sure the fast fourier transform algorithm for DFT cannot be lazy in either. Do you mean creating some sort of lazy short-time-fourier-transform (STFT or spectrogram or whatever other name people like)? Or are you thinking about 1-D transforms in multi-dimensional data (arguably the same thing actually)?
 - slicing and scope
??
 - seamless interoperability with Mir 
 (https://github.com/libmir/mir)
This would definitely be nice to have For most common use-cases I find fftw is dead simple to use with the C API though. So simple that I never even bother making bindings, I just declare what I need as I need it (which in a single application has never been more than about 10 declarations).
Jul 13