fftManager
Class FastFFT

java.lang.Object
  extended by fftManager.FastFFT

public class FastFFT
extends java.lang.Object

FFT Wrapper which uses the edu.emory.mathcs.jtransforms.fft transforms library for the actual FFT calculations.
These are simple wrappers to use the transofrms library with standard PAMGUARD transform classes.

Author:
Doug Gillespie

Field Summary
private  edu.emory.mathcs.jtransforms.fft.DoubleFFT_1D doubleFFT_1D
           
private  edu.emory.mathcs.jtransforms.fft.DoubleFFT_2D doubleFFT_2D
           
private  double[] dummyX
          Dummy data for input to the doubleFFT_1D function
private  int transformSize
           
 
Constructor Summary
FastFFT()
           
 
Method Summary
 void fft(Complex[] x)
          In place fft of complex data.
 void fft(Complex[][] x)
          In lace FFT of a 2D complex array.
 void ifft(Complex[] x, int m)
          Inverse FFT for Complex data.
static int log2(int num)
           
static int nextBinaryExp(int sourceNumber)
          Finds the next highest binary exponential of the input integer.
(package private)  double[][] packComplexToDouble(Complex[][] c)
           
private  double[] packComplexToDouble(Complex[] c, double[] d)
          Packs a complex array into a double array of twice the length
Will allocate double array if necessary
(package private)  Complex[][] packDoubleToComplex(double[][] d, Complex[][] c)
           
private  Complex[] packDoubleToComplex(double[] d, Complex[] c)
           
 Complex[] rfft(double[] x, Complex[] y, int m)
          Fast FFT function for real data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

doubleFFT_1D

private edu.emory.mathcs.jtransforms.fft.DoubleFFT_1D doubleFFT_1D

doubleFFT_2D

private edu.emory.mathcs.jtransforms.fft.DoubleFFT_2D doubleFFT_2D

transformSize

private int transformSize

dummyX

private double[] dummyX
Dummy data for input to the doubleFFT_1D function

Constructor Detail

FastFFT

public FastFFT()
Method Detail

rfft

public Complex[] rfft(double[] x,
                      Complex[] y,
                      int m)
Fast FFT function for real data.

Parameters:
x - real data array
y - preallocated Complex array for output data (can be null)
m - log2 of the FFT length (sorry !)
Returns:
Complex FFT data.

fft

public void fft(Complex[] x)
In place fft of complex data.

Parameters:
x - complex array

fft

public void fft(Complex[][] x)
In lace FFT of a 2D complex array. Will use the multithreading abilities of the JTransofrms library.

Parameters:
x -

ifft

public void ifft(Complex[] x,
                 int m)
Inverse FFT for Complex data.
I FFT is performed 'in place' so data are overwritten

Parameters:
x - Complex Data
m - log2 of the FFT length (sorry !)

nextBinaryExp

public static int nextBinaryExp(int sourceNumber)
Finds the next highest binary exponential of the input integer. If the input is itself a binary exponential, then the result is itself. E.g. given 7 returns 8, 8 returns 8, 9 returns 16. Notes has limit of 2^100. Matlab calls this function nextpow2; it's also akin to frexp in C.

Parameters:
sourceNumber -
Returns:
The next highest 2^ of the input, unless input is itself a binary exponential.

log2

public static int log2(int num)

packComplexToDouble

double[][] packComplexToDouble(Complex[][] c)

packDoubleToComplex

Complex[][] packDoubleToComplex(double[][] d,
                                Complex[][] c)

packComplexToDouble

private double[] packComplexToDouble(Complex[] c,
                                     double[] d)
Packs a complex array into a double array of twice the length
Will allocate double array if necessary

Parameters:
c - Complex array
d - double array
Returns:
double array

packDoubleToComplex

private Complex[] packDoubleToComplex(double[] d,
                                      Complex[] c)