jfftw
Class FFTWReal

java.lang.Object
  extended by jfftw.FFTW
      extended by jfftw.FFTWReal

public class FFTWReal
extends FFTW

Class to implement simple one-off Real to Complex and Complex to RealFourier transforms using fftw as a native library.

A new plan is created for each FFT. This is sub-optimal for a large number of FFTs, but reasonable for ``one-off''s.


Field Summary
 
Fields inherited from class jfftw.FFTW
BACKWARD, errorStream, ESTIMATE, EXHAUSTIVE, FORWARD, FOURIER, loaded, PATIENT, planFlag, REAL, version
 
Constructor Summary
FFTWReal()
          Default constructor.
FFTWReal(boolean systemWisdom)
          Constructor to optionally load system wisdom file if available.
FFTWReal(FFTW fft)
          Constructor to for a FFTWReal from a FFTW, The PlanFlag is also copied.
FFTWReal(File wisdomFile)
          Constructor to load specified wisdom file is available.
FFTWReal(String wisdomFile)
          Constructor to load specified wisdom file by name.
 
Method Summary
 double[] oneDimensionalBackward(double[] complexArray)
          Method to take a one dimensional Backward FFT of a complex hermition array to give Real output.
 double[] oneDimensionalForward(double[] realArray)
          Method to take a one dimensional Forward FFT of a real data array of n elements.
 double[] threeDimensionalBackward(int width, int height, int depth, double[] complexArray)
          Method to take the three dimensional backward DFT of a hermition complex DFT held in a double array with real/imag parts in even/odd elements, with the i,j Complex components in : *
 double[] threeDimensionalForward(int width, int height, int depth, double[] realArray)
          Method to take the three dimensional Forward DFT of a real cube held in one dimensional double array.
 double[] twoDimensionalBackward(int width, int height, double[] complexArray)
          Method to take the two dimensional backward DFT of a hermition complex DFT held in a double array with real/imag parts in even/odd elements, with the k,l Complex components in
 double[] twoDimensionalForward(int width, int height, double[] realArray)
          Method to take the two-dimensional Forward FFT of a real data held in one dimensional double array.
 
Methods inherited from class jfftw.FFTW
addPlanFlag, clearWisdom, exportWisdom, getPlanFlag, getVersion, getWisdom, loadWisdom, loadWisdom, loadWisdom, readWisdom, setErrorStream, setPlanFlag, setSystemWisdom, writeWisdom
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FFTWReal

public FFTWReal()
Default constructor.


FFTWReal

public FFTWReal(FFTW fft)
Constructor to for a FFTWReal from a FFTW, The PlanFlag is also copied.

Parameters:
fft - the FFTW
Since:
1.1

FFTWReal

public FFTWReal(boolean systemWisdom)
Constructor to optionally load system wisdom file if available.

Parameters:
systemWisdom - if true loads system wisdom file.

FFTWReal

public FFTWReal(File wisdomFile)
Constructor to load specified wisdom file is available.

Parameters:
wisdomFile -

FFTWReal

public FFTWReal(String wisdomFile)
Constructor to load specified wisdom file by name.

Parameters:
wisdomFile -
Method Detail

oneDimensionalForward

public double[] oneDimensionalForward(double[] realArray)
Method to take a one dimensional Forward FFT of a real data array of n elements.

The output is Complex, held in a double[] array with alternative real/imaginary parts with a total of n/2+1 complex pairs.

Note the input and output arrays are of different length.

This method implements out-of-place transforms only, and the input real array is not modified.

Parameters:
realArray - the input real array (not changed)
Returns:
double[] holding the FFT in n/2+1 complex pairs.

oneDimensionalBackward

public double[] oneDimensionalBackward(double[] complexArray)
Method to take a one dimensional Backward FFT of a complex hermition array to give Real output. Th Complex input is held as double array with alternative real/imaginary parts with a total of n/2+1 Complex pairs.

The output is a double array of n elements; note the input and output arrays are of different length.

This method implements out-of-place transforms.

Parameters:
complexArray - array of n/2+1 complex parts
Returns:
double[] real array of n real values

twoDimensionalForward

public double[] twoDimensionalForward(int width,
                                      int height,
                                      double[] realArray)
Method to take the two-dimensional Forward FFT of a real data held in one dimensional double array. the i,j pixel of the real image is located in array element j*width + i.

The Complex FFT is returned in a double array with real/imag parts in even/odd elements, with the k,l Complex components in

Real part in location 2(l x wft + k)
Imag part in location 2(l x wft + k) + 1
where wft = width/2 + 1

Parameters:
width - the image width.
height - the image height.
realArray - the image data in double[] of length width*height.
Returns:
double[] DFT packed into one dimensional array
Throws:
IllegalArgumentException - if width*height does not match the array length.

twoDimensionalBackward

public double[] twoDimensionalBackward(int width,
                                       int height,
                                       double[] complexArray)
Method to take the two dimensional backward DFT of a hermition complex DFT held in a double array with real/imag parts in even/odd elements, with the k,l Complex components in

Real part located at 2(j * wft + i)
Imag part located at 2(j * wft + i) + 1
where wft = width/2 + 1.

The transformed real data is returned in a one-dimension double array with pixel i,j located at element j*width + i.

Parameters:
width - the image width
height - the image height
complexArray - the Fourier data packed in a 1-d array.
Returns:
double[] DFT packed into one dimensional array
Throws:
IllegalArgumentException - if width*height is not consistent with array length.

threeDimensionalForward

public double[] threeDimensionalForward(int width,
                                        int height,
                                        int depth,
                                        double[] realArray)
Method to take the three dimensional Forward DFT of a real cube held in one dimensional double array. the i,j,k pixel of the real cube is located in array element k * width * height + j * width + i

The Complex DFT is returned in a double array with real/imag parts in even/odd elements, with the i,j Complex components in : *

Real part located at 2(k * wft * height + j * wft + i)
Imag part located at 2(k * wft * height + j * wft + i) + 1
where wft = width/2 + 1.

Parameters:
width - the cube width
height - the cube height
depth - the cube depth
realArray - the cube data in double[] of length width*height*depth
Returns:
double[] DFT packed into one dimensional array
Throws:
IllegalArgumentException - if width*height*depth is not equal the array length.

threeDimensionalBackward

public double[] threeDimensionalBackward(int width,
                                         int height,
                                         int depth,
                                         double[] complexArray)
Method to take the three dimensional backward DFT of a hermition complex DFT held in a double array with real/imag parts in even/odd elements, with the i,j Complex components in : *

Real part located at 2(k x wft x height + j x wft + i)
Imag part located at 2(k x wft x height + j x wft + i) + 1
where wft = width/2 + 1.

The transformed real data is returned in a one-dimensional double array with pixel i,j located at element k x width x height + j x width + i.

Parameters:
width - the cube width
height - the cube height
depth - the cube depth
complexArray - Fourier data packed in a 1-d array.
Returns:
double[] DFT packed into one dimensional array
Throws:
IllegalArgumentException - if width, height, depth is not consistent with array length.