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, throwLoadException, version
 
Constructor Summary
FFTWReal()
          Default constructor, does nothing but load the sharable library.
FFTWReal(boolean systemWisdom)
          Constructor to optionally load system wisdom file if available.
FFTWReal(FFTW fft)
          Constructor to form a FFTWReal from a any FFTW.
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[] oneDimensionalBackward(double[] complexArray, double[] realArray)
          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 with output to specifed array.
 double[] oneDimensionalForward(double[] realArray, double[] complexArray)
          Method to take a one dimensional Forward FFT of a real data array of n elements with output to specifed array.
 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[] threeDimensionalBackward(int width, int height, int depth, double[] complexArray, double[] realArray)
          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[] threeDimensionalForward(int width, int height, int depth, double[] realArray, double[] complexArray)
          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 held as follows:
 double[] twoDimensionalBackward(int width, int height, double[] complexArray, double[] realArray)
          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 held as follows:
 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.
 double[] twoDimensionalForward(int width, int height, double[] realArray, double[] complexArray)
          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, loadWisdomFromString, readWisdom, 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, does nothing but load the sharable library.


FFTWReal

public FFTWReal(FFTW fft)
Constructor to form a FFTWReal from a any 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(String wisdomFile)
Constructor to load specified wisdom file by name.

Parameters:
wisdomFile -
Method Detail

oneDimensionalForward

public double[] oneDimensionalForward(double[] realArray,
                                      double[] complexArray)
Method to take a one dimensional Forward FFT of a real data array of n elements with output to specifed array. The complex output array contains (n/2 + 1) complex pairs.

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

Parameters:
realArray - the input real array (not changed)
complexArray - the output array, must be of length 2*(n/2 + 1). If null OR the wrong length a new array will be created.
Returns:
double[] holding the FFT in n/2+1 complex pairs.

oneDimensionalForward

public double[] oneDimensionalForward(double[] realArray)
Method to take a one dimensional Forward FFT of a real data array of n elements with output to specifed array. The complex output array contains (n/2 + 1) complex pairs.

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 in a new array.

oneDimensionalBackward

public double[] oneDimensionalBackward(double[] complexArray,
                                       double[] realArray)
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.

Parameters:
complexArray - array of n/2+1 complex parts
realArray - output array of length n. If null or wrong length a new array will be created.
Returns:
double[] real array of n real values

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.

Parameters:
complexArray - array of n/2+1 complex parts
Returns:
double[] real array of n real values which will be in a new array.

twoDimensionalForward

public double[] twoDimensionalForward(int width,
                                      int height,
                                      double[] realArray,
                                      double[] complexArray)
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 with:

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.
complexArray - the output array of length 2*height*(width/2 + 1). If null or wrong length, then a new array will be created.
Returns:
double[] DFT packed into one dimensional array
Throws:
IllegalArgumentException - if width*height does not match the array length.

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 with:

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,
                                       double[] realArray)
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 held as follows:

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.
realArray - the returned real data of length width*height. If null or wrong length, then a new array will be created.
Returns:
double[] DFT packed into one dimensional array
Throws:
IllegalArgumentException - if width*height is not consistent with 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 held as follows:

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,
                                        double[] complexArray)
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 array of length width*height*depth
complexArray - the output array, must be of length 2*depth*height*(width/2 + 1). If null or wrong length, a new array will be allocated.
Returns:
double[] DFT packed into one dimensional array
Throws:
IllegalArgumentException - if width*height*depth is not equal the 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 array 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,
                                         double[] realArray)
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.
realArray - real output array, must be of length width*height*depth. If null or wrong length, then a new array will be allocated.
Returns:
double[] DFT packed into one dimensional array
Throws:
IllegalArgumentException - if width, height, depth is not consistent with 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.