org.opensourcephysics.numerics
Class FFT2D

java.lang.Object
  extended byorg.opensourcephysics.numerics.FFT2D

public class FFT2D
extends java.lang.Object

FFT2D computes the FFT of 2 dimensional complex, double precision data. This class has been copied from Bruce Miller's FFT package for use in the Open Source Physics Project. The original package contains code for other transformations and other data types. The data is stored in a 1-dimensional array in Row-Major order. The physical layout in the array data, of the mathematical data d[i,j] is as follows:

    Re(d[i,j]) = data[i*rowspan + 2*j]
    Im(d[i,j]) = data[i*rowspan + 2*j + 1]
 
where rowspan must be at least 2*ncols (it defaults to 2*ncols). The transformed data is returned in the original data array in wrap-around order along each dimension.


Constructor Summary
FFT2D(int nrows, int ncols)
          Create an FFT for transforming nrows*ncols points of Complex, double precision data.
 
Method Summary
 void backtransform(double[] data)
          Compute the (unnomalized) inverse FFT of data, leaving it in place.
protected  void checkData(double[] data, int rowspan)
           
 double getFreqMax(double min, double max, int n)
          Gets the maximum frequency given the domain and the number of points.
 double getFreqMin(double min, double max, int n)
          Gets the minimum frequency given the domain and the number of points.
 double[] getNaturalFreqX(double delta)
          Gets an array containing the frequencies in natural order.
 double[] getNaturalFreqX(double xmin, double xmax)
          Gets an array containing the frequencies in natural order.
 double[] getNaturalFreqY(double delta)
          Gets an array containing the frequencies in natural order if samples in the orginal data are separated by delta in y.
 double[] getNaturalFreqY(double ymin, double ymax)
          Gets an array containing the frequencies in natural order.
 double[] getNaturalModes(int n)
          Gets an array containing the mode numbers in natural order.
 double[] getNaturalOmegaX(double delta)
          Gets an array containing the angular frequencies (wavenumbers) in natural order.
 double[] getNaturalOmegaX(double xmin, double xmax)
          Gets an array containing the angular frequencies (wavenumbers) in natural order.
 double[] getNaturalOmegaY(double delta)
          Gets an array containing the frequencies in natural order if samples in the orginal data are separated by delta in y.
 double[] getNaturalOmegaY(double ymin, double ymax)
          Gets an array containing the frequencies in natural order.
 double[] getWrappedFreq(double delta, int n)
          Gets an array containing the frequencies in wrap-around order.
 double[] getWrappedModes(int n)
          Gets an array containing the mode numbers in wrap-around order.
 double[] getWrappedOmegaX(double xmin, double xmax)
          Gets an array containing the angular frequencies (wavenumbers) in natural order.
 double[] getWrappedOmegaY(double ymin, double ymax)
          Gets an array containing the angular frequencies (wavenumbers) in natural order.
 void inverse(double[] data)
          Compute the (nomalized) inverse FFT of data, leaving it in place.
 void toNaturalOrder(double[] data)
          Reorder and normalize the transformed data from most negative frequency to most positive frequency leaving the result in data.
 void transform(double[] data)
          Compute the Fast Fourier Transform of data leaving the result in data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FFT2D

public FFT2D(int nrows,
             int ncols)
Create an FFT for transforming nrows*ncols points of Complex, double precision data.

Parameters:
nrows -
ncols -
Method Detail

checkData

protected void checkData(double[] data,
                         int rowspan)

transform

public void transform(double[] data)
Compute the Fast Fourier Transform of data leaving the result in data. The array data must be dimensioned (at least) 2*nrows*ncols, consisting of alternating real and imaginary parts.

Parameters:
data -

backtransform

public void backtransform(double[] data)
Compute the (unnomalized) inverse FFT of data, leaving it in place.

Parameters:
data -

inverse

public void inverse(double[] data)
Compute the (nomalized) inverse FFT of data, leaving it in place.

Parameters:
data -

getFreqMin

public double getFreqMin(double min,
                         double max,
                         int n)
Gets the minimum frequency given the domain and the number of points.

Parameters:
min - double
max - double
n - int
Returns:
double

getFreqMax

public double getFreqMax(double min,
                         double max,
                         int n)
Gets the maximum frequency given the domain and the number of points.

Parameters:
min - double
max - double
n - int
Returns:
double

getNaturalModes

public double[] getNaturalModes(int n)
Gets an array containing the mode numbers in natural order.

Returns:
array of mode numbers

getWrappedModes

public double[] getWrappedModes(int n)
Gets an array containing the mode numbers in wrap-around order.

Returns:
array of mode numbers

getWrappedOmegaX

public double[] getWrappedOmegaX(double xmin,
                                 double xmax)
Gets an array containing the angular frequencies (wavenumbers) in natural order. The first data point is at xmin (tmin) and the last data point is at xmax (tmax).

Parameters:
xmin -
xmax -
Returns:
the array of frequencies

getWrappedOmegaY

public double[] getWrappedOmegaY(double ymin,
                                 double ymax)
Gets an array containing the angular frequencies (wavenumbers) in natural order. The first data point is at ymin and the last data point is at ymax.

Parameters:
ymin -
ymax -
Returns:
the array of frequencies

getWrappedFreq

public double[] getWrappedFreq(double delta,
                               int n)
Gets an array containing the frequencies in wrap-around order. Samples in the data are separated by delta.

Parameters:
delta -
Returns:
the array of frequencies

getNaturalFreqX

public double[] getNaturalFreqX(double delta)
Gets an array containing the frequencies in natural order. Data are separated by delta.

Parameters:
delta -
Returns:
the array of frequencies

getNaturalFreqX

public double[] getNaturalFreqX(double xmin,
                                double xmax)
Gets an array containing the frequencies in natural order. The first data point is at xmin (tmin) and the last data point is at xmax (tmax).

Parameters:
xmin -
xmax -
Returns:
the array of frequencies

getNaturalOmegaX

public double[] getNaturalOmegaX(double delta)
Gets an array containing the angular frequencies (wavenumbers) in natural order. Data are separated by delta.

Parameters:
delta -
Returns:
the array of frequencies

getNaturalOmegaX

public double[] getNaturalOmegaX(double xmin,
                                 double xmax)
Gets an array containing the angular frequencies (wavenumbers) in natural order. The first data point is at xmin (tmin) and the last data point is at xmax (tmax).

Parameters:
xmin -
xmax -
Returns:
the array of frequencies

getNaturalFreqY

public double[] getNaturalFreqY(double delta)
Gets an array containing the frequencies in natural order if samples in the orginal data are separated by delta in y.

Parameters:
delta -
Returns:
the array of frequencies

getNaturalFreqY

public double[] getNaturalFreqY(double ymin,
                                double ymax)
Gets an array containing the frequencies in natural order. The first data point is at ymin and the last data point is at ymax.

Parameters:
ymin -
ymax -
Returns:
the array of frequencies

getNaturalOmegaY

public double[] getNaturalOmegaY(double delta)
Gets an array containing the frequencies in natural order if samples in the orginal data are separated by delta in y.

Parameters:
delta -
Returns:
the array of frequencies

getNaturalOmegaY

public double[] getNaturalOmegaY(double ymin,
                                 double ymax)
Gets an array containing the frequencies in natural order. The first data point is at ymin and the last data point is at ymax.

Parameters:
ymin -
ymax -
Returns:
the array of frequencies

toNaturalOrder

public void toNaturalOrder(double[] data)
Reorder and normalize the transformed data from most negative frequency to most positive frequency leaving the result in data.

Parameters:
data -