The class FFTW and the two extending classes FFTWReal and FFTWComplex offer lower level access to the underlying FFTW library and support one, two and three dimensional FFT using either interleaved or split double[] arrays. This is a more flexible interface since it does not force you to use my DataArray class to hold your data, and since it bypasses most sanity checking and oop(ing), it is more efficient. You are however responsible for formatting the data arrays yourself, and especially for real data, understanding what FFTW has given you!.
Efficiency: This interface still create a new plan for EACH FFT which is OK for large "one-off" tranforms but is less than ideal for multiple small transforms, for example for a real-time spectrum analyser.
Please note: that getting the calls to these classes wrong can result in the most entertaining results, usually crashing your JRE is a messy heap, (the fun of C). Please check your call and data very carefully before screaming "bug".
There are three FFTW classes that do the work, and also two support classes that are useful in manipulating data in double[] arrays:
- FFTW class to load the native library and manage the wisdom files. Not used itself, but via the next two extending classes.
- FFTWComplex class to implement complex FFT in one, two, or three dimension on either interleaved or split format performing either in-plane or out-of-plane transforms.
- FFTWReal class to implement real transforms in one, two or three dimensions. The Complex Fourier transform are in interleaved format, and since they do not occupy the same amount of space as the real space, only out-of-place transforms are available.
- Complex being a class for handling Complex numbers held at two doubles. This class has a full set of methods that implements just about every complex operation.
- ArrayUtil collection of static methods to do useful things to interleaved and split arrays. There are all written with array index access and not via getter/setter (not very OOP!), so should be fairly efficient.
Demo Programs Source
- Demo program showing the use of FFTWComplex to take in-place and out-of-plane one dimensional FFT using interleaved array FFTWComplexDemo.java
- Exact repeat of the above demo using split array with real and imaginary data in seperate arrays FFTWComplexDemoSplit.java
- OneDimensionalReal.java takes a one dimensional FFT of a real tophat using FFTWReal (uses ptplot to display modulus)
- TwoDimensionDemo.java take two dimensional FFT of complex data using FFTWComplex with both in-plane and out-of-plane transforms.
- CubeTest.java takes three-dimensional transform of rather large cube, may take a while on small systems.
- SplitTwoDimensional.java take two dimensional complex FFT in interleaved and split format and compares the results.