com.oregondsp.signalProcessing.fft
Class CDFT

java.lang.Object
  extended by com.oregondsp.signalProcessing.fft.CDFT

public class CDFT
extends java.lang.Object

Class to calculate the complex discrete Fourier transform of a complex sequence and its inverse using the split-radix algorithm.

This class is designed for efficient calculation of many discrete Fourier transforms of the same length. It is limited to transform lengths that are powers of two and greater than or equal to 32. The class recursively constructs and links smaller DFTs with hard-wired array indices to minimize index calculations during the overall DFT evaluation. This approach may produce large run-time images for very large DFTs. Special hand-coded implementations of length 8 and 16 DFTs eliminate many unnecessary calculations. The code uses precomputed sine and cosine tables and does not implement in-place calculations in order to eliminate the bit reversal step. Consequently, this implementation trades memory for speed.

Example of use:

int N      = 16384;
int log2N  = 14;
float[] xr = new float[N];
float[] xi = new float[N];
float[] Xr = new float[N];
float[] Xi = new float[N];
CDFT Xfm = new CDFT( log2N );

// load data
for ( int i = 0; i < N; i++ ) {
  xr[i] = ...
  xi[i] = ...
}

// evaluate transform of data
Xfm.evaluate( xr, xi, Xr, Xi );

The real and imaginary parts of the transform are stored in Xr and Xi in natural order, with the zeroth discrete frequency value in Xr(0) and Xi(0), and the N-1st value ( 2*pi*(N-1)/N ) in Xr(N-1) and Xi(N-1).

As long as the transform size does not change, the CDFT object does not need to be reinstantiated. Consequently, the data arrays can be reloaded and the evaluate method invoked to compute additional DFTs without incurring the cost of CDFT object instantiation.

It may happen in some applications that the array arguments in the evaluate() and evaluateInverse() methods never change, i.e. the same arrays are used repeatedly. Since this implementation is recursive, the input and output arrays are recursively linked down the chain of smaller DFTs that implement the full DFT. This linking operation can be avoided when the arguments to evaluate() and evaluateInverse() never vary. For this circumstance an alternative constructor is provided, that links the input and output arrays at construction time (for a slight performance improvement). To avoid relinking arrays, this constructor should be paired with the evaluate() and evaluateInverse() methods that have NO arguments. Example:

CDFT Xfm = new CDFT( xr, xi, Xr, Xi, log2N );

// load data
for ( int i = 0; i < N; i++ ) {
  xr[i] = ...
  xi[i] = ...
}

// evaluate transform of data
Xfm.evaluate();

For the inverse transform in this usage, the roles of (xr,xi) and (Xr,Xi) are reversed. The pair (xr,xi) contains the transform real and imaginary parts in natural order, and upon execution of evaluateInverse(), the pair (Xr,Xi) contains the real and imaginary parts of the corresponding sequence (inverse transform).

See "On Computing the Split-Radix FFT", Sorensen, H. V., Heideman, M. T. and Burrus, C. S. IEEE TRANSACTIONS ON ACOUSTICS, SPEECH, AND SIGNAL PROCESSING, VOL. ASSP-34, NO. 1, FEBRUARY, 1986, pp. 152-156.

Author:
David B. Harris, Deschutes Signal Processing LLC

Constructor Summary
CDFT()
          Default constructor.
CDFT(float[] xr, float[] xi, float[] yr, float[] yi, int log2N)
          constructs a CDFT instance with references to sequence and transform arrays
CDFT(int log2N)
          Constructs a CDFT instance without references to sequence and transform arrays
 
Method Summary
static void dftProduct(float[] Xr, float[] Xi, float[] Yr, float[] Yi, float sign)
          Convenience method to multiply two complex transforms of the same size.
 void evaluate()
          evaluates the DFT assuming sequence and transformed arrays have been linked at construction time
 void evaluate(float[] xr, float[] xi, float[] Xr, float[] Xi)
          evaluates the DFT with specified sequence and transform arrays
 void evaluateInverse()
          evaluates the inverse DFT assuming the sequence and transform arrays have been linked at construction time
 void evaluateInverse(float[] Xr, float[] Xi, float[] xr, float[] xi)
          evaluates the inverse DFT with specified transform and sequence arrays
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CDFT

public CDFT()
Default constructor.


CDFT

public CDFT(int log2N)
Constructs a CDFT instance without references to sequence and transform arrays

Parameters:
log2N - base-2 logarithm of the length of the transform

CDFT

public CDFT(float[] xr,
            float[] xi,
            float[] yr,
            float[] yi,
            int log2N)
constructs a CDFT instance with references to sequence and transform arrays

Parameters:
xr - float array containing sequence real part on forward evaluation, transform real part on inverse evaluation
xi - float array containing sequence imaginary part on forward evaluation, transform imaginary part on inverse evaluation
yr - float array containing transform real part on forward evaluation, sequence real part on inverse evaluation
yi - float array containing transform imaginary part on forward evaluation, sequence imaginary part on inverse evaluation
log2N - base-2 logarithm of the length of the transform
Method Detail

evaluate

public void evaluate(float[] xr,
                     float[] xi,
                     float[] Xr,
                     float[] Xi)
evaluates the DFT with specified sequence and transform arrays

Parameters:
xr - float array containing sequence real part
xi - float array containing sequence imaginary part
Xr - float array containing transform real part
Xi - float array containing transform imaginary part

evaluateInverse

public void evaluateInverse(float[] Xr,
                            float[] Xi,
                            float[] xr,
                            float[] xi)
evaluates the inverse DFT with specified transform and sequence arrays

Parameters:
Xr - float array containing transform real part
Xi - float array containing transform imaginary part
xr - float array containing sequence real part
xi - float array containing sequence imaginary part

evaluate

public void evaluate()
evaluates the DFT assuming sequence and transformed arrays have been linked at construction time


evaluateInverse

public void evaluateInverse()
evaluates the inverse DFT assuming the sequence and transform arrays have been linked at construction time


dftProduct

public static void dftProduct(float[] Xr,
                              float[] Xi,
                              float[] Yr,
                              float[] Yi,
                              float sign)
Convenience method to multiply two complex transforms of the same size.

Parameters:
Xr - float array containing the real part of the first transform
Xi - float array containing the imaginary part of the first transform
Yr - float array containing the real part of the second transform before call, real part of the product after call
Yi - float array containing the imaginary part of the second transform before call, imaginary part of the product after call
sign - +1 for convolution type product, -1 for correlation type product