jfftw
Class RealDataArray

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

public class RealDataArray
extends DataArray

Class to handle Real Data arrays in either Real or Fourier space. Data in real space in held a double[] array on row order, but in Fourier space in Complex pairs with Hermition symmetry. For width of N the symmetry is given by F(k,m,n) = F*(N-k,m,n).

Note 1: in Fourier space the data width is given by getFourierWidth()

Note 2: The underlying FTTW is taking out-of-place transforms so the length and location of the internal databuffer WILL change when a transform is taken.

Warning to novice users; read and understand about FFTs before using this especially on two or three dimensions.


Field Summary
 
Fields inherited from class jfftw.DataArray
conversionFlag, currentWidth, dataBuffer, depth, errorStream, fftw, height, space, width
 
Constructor Summary
RealDataArray(BufferedImage bi, int band)
          Constructor to form the a two-dimensional RealDataArray from a band of a Java BufferedImage.
RealDataArray(int w)
          Constructor to form a one-dimensional RealDataArray, in real space.
RealDataArray(int w, int h)
          Constructor to form a two-dimensional RealDataArray, in real space.
RealDataArray(int w, int h, int d)
          Constructor to form a three-dimensional RealDataArray in real space.
RealDataArray(int w, int h, int d, double[] da)
          Forms a general RealDataArray taking its data from the a supplied double[] assumed to be in the correct (row) order.
RealDataArray(RealDataArray data)
          Form a RealDataArray with all parameters taken from the specified RealDataArray.
 
Method Summary
 void add(int i, double a)
          Add a double to an element
 void add(int i, double a, double b)
          Add a Complex specified by two doubles to an element
 void checker()
          Method to apply a checker in either Real or Fourier space.
 RealDataArray clone()
          Form a deep clone of current RealDataArray, including data.
 void conjugate(int i)
          Form the conjugate of the ith Complex element.
 void fourier()
          Method to take in-place fft.
 Complex getComplex(int i)
          Method to get a Complex in one-dimensional case.
 double getDouble(int i)
          Method to get value of element as a double.
 FFTWReal getFFTW()
          Method to get underlying FFTWReal
 void mult(int i, double a)
          Multiply an element by a double, works in both real and fourier space.
 void mult(int i, double a, double b)
          Multiply an element by a Complex specified by two doubles in Fourier space.
 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 a double point in one-dimensions.
 
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

RealDataArray

public RealDataArray(int w,
                     int h,
                     int d)
Constructor to form a three-dimensional RealDataArray in real space.

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

RealDataArray

public RealDataArray(int w,
                     int h)
Constructor to form a two-dimensional RealDataArray, in real space.

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

RealDataArray

public RealDataArray(int w)
Constructor to form a one-dimensional RealDataArray, in real space.

Parameters:
w - the width (primary) dimension

RealDataArray

public RealDataArray(RealDataArray data)
Form a RealDataArray with all parameters taken from the specified RealDataArray. The underlying data will also be copied.

This is valid in both real and Fourier space.

Parameters:
data - the RealDataArray

RealDataArray

public RealDataArray(int w,
                     int h,
                     int d,
                     double[] da)
Forms a general RealDataArray taking its data from the a supplied double[] assumed to be in the correct (row) order.

Warning: when fourier() method is called the result will be relocated to a new double[] array which can be accessed by getDataBuffer(). Really understand what you are doing before playing with this!

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.

RealDataArray

public RealDataArray(BufferedImage bi,
                     int band)
Constructor to form the a two-dimensional RealDataArray from a band of a Java BufferedImage.

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 RealDataArray clone()
Form a deep clone of current RealDataArray, including data.

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

getDouble

public double getDouble(int i)
Method to get value of element as a double. If in real space is just the element, but in Fourier, conversion from Complex to real is controlled by setConversion(), which defaults to Complex.MODULUS.

For multi-dimensional array may be indexed as a one-dimenional array of length width*height*depth. Use this feature to bypass the array bound checking overhead.

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

getComplex

public Complex getComplex(int i)
Method to get a Complex in one-dimensional case. If in Fourier space you get the expected element, while in real you get the real element converted to a Complex with the imaginary part set to zero.

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

setDouble

public void setDouble(int i,
                      double a)
Method to set a double point in one-dimensions. In real space does what in expected, and in Fourier set the element to (a,0).

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

setComplex

public void setComplex(int i,
                       double a,
                       double b)
Method to set a Complex point in one-dimension with two doubles. If the data is in real space, then the complex is converted to a double using the current conversion rules.

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

mult

public void mult(int i,
                 double a)
Multiply an element by a double, works in both real and fourier space.

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 by two doubles in Fourier space. In real space this will fail with printed errors message.

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 an element

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

add

public void add(int i,
                double a,
                double b)
Add a Complex specified by two doubles to an element

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 ith Complex element. In in real space it is ignored.

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

getFFTW

public FFTWReal getFFTW()
Method to get underlying FFTWReal

Overrides:
getFFTW in class DataArray
Returns:
FFTWReal 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.

Specified by:
fourier in class DataArray

checker

public void checker()
Method to apply a checker in either Real or Fourier space.

Specified by:
checker in class DataArray