jfftw
Class ComplexDataArray

java.lang.Object
  extended by jfftw.DataArray
      extended by jfftw.ComplexDataArray
All Implemented Interfaces:
Cloneable

public class ComplexDataArray
extends DataArray

Class to handle Complex Data arrays in either Real or Fourier space. This is the simplest fft interface with simple support for one, two and three dimensional complex data with, almost, all indexing problems covered by the support methods.

Novice users should start here, and use the more complex RealDataArray or the low-level FFTW if they want need either more efficient interface or have data formatted other than the interleaved complex implemented here.


Field Summary
 
Fields inherited from class jfftw.DataArray
conversionFlag, currentWidth, dataBuffer, depth, errorStream, fftw, height, space, width
 
Constructor Summary
ComplexDataArray(BufferedImage bi, int band)
          Constructor to form the a two-dimensional ComplexDataArray from a band of a Java BufferedImage.
ComplexDataArray(DataArray data)
          Form a ComplexDataArray from supplied DataArray.
ComplexDataArray(int w)
          Constructor to form a one-dimensional ComplexDataArray, which defaults to FFTW.REAL space.
ComplexDataArray(int w, int h)
          Constructor to form a two-dimensional ComplexDataArray, which defaults to FFTW.REAL space.
ComplexDataArray(int w, int h, int d)
          Constructor to form a three-dimensional ComplexDataArray, which defaults to FFTW.REAL space.
ComplexDataArray(int w, int h, int d, double[] da)
          Form a general ComplexDataArray with specified dimensional and supplied data array, which is NOT copied, it is used internally.
 
Method Summary
 void add(int i, double a)
          Add a double to real part of element
 void add(int i, double a, double b)
          Add a Complex to specified
 void checker()
          Method to apply a +/1 checker patterns to the Complex data, used to form centred FFTW.
 ComplexDataArray clone()
          Form a deep clone of current ComplexDataArray, including data.
 void conjugate(int i)
          Form the conjugate of the element on one-dimensions by negating the imaginary parts.
 void fourier()
          Method to take in-place fft.
 Complex getComplex(int i)
          Method to get a Complex element in one-dimensional case.
 double getDouble(int i)
          Method to get the double value of the element on one-dimensions where the Complex real conversion is controlled by setConversion(), which defaults to Complex.MODULUS.
 FFTWComplex getFFTW()
          Method to get underlying FFTWComplex
 void mult(int i, double a)
          Multiply an element by a double
 void mult(int i, double a, double b)
          Multiply an element by a Complex specified
 void setComplex(int i, double a, double b)
          Method to set a Complex point in one-dimension with two doubles.
 void setDouble(int i, double a)
          Method to set the Real part of an element with a double, the imaginary part is not modified.
 
Methods inherited from class jfftw.DataArray
add, add, add, add, add, add, centreFourier, clear, conjugate, conjugate, conjugate, getComplex, getComplex, getConversion, getCurrentWidth, getDataBuffer, getDepth, getDouble, getDouble, getHeight, getNormalisation, getRealDataArray, getRealDataArray, getSpace, getType, getWidth, isComplex, length, maxModSqr, mult, mult, mult, mult, mult, mult, mult, mult, mult, multConjugate, normaliseDB, power, powerSpectrum, setComplex, setComplex, setComplex, setComplex, setComplex, setConversion, setDataBuffer, setDimensions, setDouble, setDouble, setNormalisation, setSpace, sizeMatch, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComplexDataArray

public ComplexDataArray(int w,
                        int h,
                        int d)
Constructor to form a three-dimensional ComplexDataArray, which defaults to FFTW.REAL space.

All data is pre-initialised to zero.

Parameters:
w - the width (primary) dimension
h - the height (secondary) dimension
d - the depth (third) dimension

ComplexDataArray

public ComplexDataArray(int w,
                        int h)
Constructor to form a two-dimensional ComplexDataArray, which defaults to FFTW.REAL space.

Parameters:
w - the width (primary) dimension
h - the height (secondary) dimension

ComplexDataArray

public ComplexDataArray(int w)
Constructor to form a one-dimensional ComplexDataArray, which defaults to FFTW.REAL space.

Parameters:
w - the width (primary) dimension

ComplexDataArray

public ComplexDataArray(int w,
                        int h,
                        int d,
                        double[] da)
Form a general ComplexDataArray with specified dimensional and supplied data array, which is NOT copied, it is used internally.

Use with care, you must format the supplied data in the correct row interleaved format. If you are using this in a main program, consider using the low-level level FFTWComplex class.

Parameters:
w - the width (primary) dimension
h - the height (secondary) dimension
d - the depth (third) dimension
da - the data array.
Throws:
IllegalArgumentException - if length of data array does not match parameters.

ComplexDataArray

public ComplexDataArray(DataArray data)
Form a ComplexDataArray from supplied DataArray.

If supplied with ComplexDataArray it will produce a clone including the data.

For a RealDataArray the real values will be used to set the real parts with imaginary defaulting to zero. Note: this will only work for RealDataArray in real space.

Parameters:
data - the specifying DataArray
Throws:
IllegalArgumentException - if real array is in Fourier space.

ComplexDataArray

public ComplexDataArray(BufferedImage bi,
                        int band)
Constructor to form the a two-dimensional ComplexDataArray from a band of a Java BufferedImage. The real parts are set by the image data, with the imaginary parts set to zero.

Parameters:
bi - the BufferedImage supplying the size and data
band - the band to be used. If negative or greater that available bands, then the centre band will be used, so the zero band on a monochrome image, or band 1 of a tricoloured image.
Method Detail

clone

public ComplexDataArray clone()
Form a deep clone of current ComplexDataArray, including data.

Overrides:
clone in class Object
Returns:
ComplexDataArray cloned of current.

getComplex

public Complex getComplex(int i)
Method to get a Complex element in one-dimensional case. This implements the abstract methods defined in DataArray and handles the internal indexing.

For a multi-dimensional array this can be treated as a one-dimensional array length width*height*depth allowing more efficiency one-dimensional access. This bypasses the array bound checking.

Specified by:
getComplex in class DataArray
Parameters:
i - the element index

getDouble

public double getDouble(int i)
Method to get the double value of the element on one-dimensions where the Complex real conversion is controlled by setConversion(), which defaults to Complex.MODULUS.

Specified by:
getDouble in class DataArray
Parameters:
i - the element index.

setComplex

public void setComplex(int i,
                       double a,
                       double b)
Method to set a Complex point in one-dimension with two doubles.

Specified by:
setComplex in class DataArray
Parameters:
i - the element index
a - the real part
b - the imaginary part

setDouble

public void setDouble(int i,
                      double a)
Method to set the Real part of an element with a double, the imaginary part is not modified.

Specified by:
setDouble in class DataArray
Parameters:
i - the element index
a - the double value

mult

public void mult(int i,
                 double a)
Multiply an element by a double

Specified by:
mult in class DataArray
Parameters:
i - the element index
a - the multiplier

mult

public void mult(int i,
                 double a,
                 double b)
Multiply an element by a Complex specified

Specified by:
mult in class DataArray
Parameters:
i - the element index
a - the real part
b - the imaginary part

add

public void add(int i,
                double a)
Add a double to real part of element

Specified by:
add in class DataArray
Parameters:
i - the element index
a - to be added to real part

add

public void add(int i,
                double a,
                double b)
Add a Complex to specified

Specified by:
add in class DataArray
Parameters:
i - the element index
a - the real part
b - the imaginary part

conjugate

public void conjugate(int i)
Form the conjugate of the element on one-dimensions by negating the imaginary parts.

Specified by:
conjugate in class DataArray
Parameters:
i - the element to be conjugated.

getFFTW

public FFTWComplex getFFTW()
Method to get underlying FFTWComplex

Overrides:
getFFTW in class DataArray
Returns:
FFTWComplex used to do transforms.

fourier

public void fourier()
Method to take in-place fft. If the space is REAL, then forward fft is taken, else inverse. Normalisation by total data size will occur on the inverse transform provided that the set normalisation flag is set to true

Specified by:
fourier in class DataArray
See Also:
DataArray.setNormalisation(boolean)

checker

public void checker()
Method to apply a +/1 checker patterns to the Complex data, used to form centred FFTW.

Specified by:
checker in class DataArray