Class FFT
- java.lang.Object
-
- samer.units.FFT
-
- Direct Known Subclasses:
- FFTVector, RescaledIFT
public class FFT extends java.lang.Object
Fast Fourier Transform
by Samer Abdallah
15 December 1999
Mostly from my old C++ version, though I should credit the following FFT code for the idea of using a lookup table for the bit reversal and also a complete lookup table of sines:
> From the Unix Version 2.4 by Steve Sampson, Public Domain, > September 1988. > Adapted for Java by Ben Stoltz
, September 1997 > > Refer to http://www.neato.org/~ben/Fft.html for updates and related > resources. My old version computed the bit-reversed indices on the fly - silly really - don't know why I didn't think of a lookup table myself. Also, it had a lookup table of sines and cosines of the form sin( 2*PI/k) with k going 1, 2, 4, 8 .. N. This version has complete tables for sin and cosine - which is a bit of a waste of memory, but frankly, who cares?
Usage
It is the user's responsibility to fill the arrays real and imag with data IN THE CORRECT BITREVERSED ORDER. This is easy enough using the bitrev lookup table - something like this would do the trick:
for (int i=0; i
The arrays are used destructively, so it is also the user's responsibility, eg, to reset the imaginary parts to zero even if they are always zero. The results ends up in the arrays real and imag
-
-
Field Summary
Fields Modifier and Type Field and Description int[]
bitrev
double[]
H
double[]
imag
protected int
N
double[]
real
protected ComplexVector
W
protected double[]
zeros
-
Constructor Summary
Constructors Constructor and Description FFT(int n)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
brevcopy(double[] src, double[] dst)
void
calculate()
void
input(double[] Y)
void
input(Vec.Iterator it)
void
invert()
void
outputPower(double[] S)
void
setWindow(Function fn)
int
size()
-
-
-
Field Detail
-
bitrev
public int[] bitrev
-
H
public double[] H
-
imag
public double[] imag
-
N
protected int N
-
real
public double[] real
-
W
protected ComplexVector W
-
zeros
protected double[] zeros
-
-
Method Detail
-
size
public int size()
-
input
public final void input(double[] Y)
-
brevcopy
public final void brevcopy(double[] src, double[] dst)
-
input
public final void input(Vec.Iterator it)
-
outputPower
public final void outputPower(double[] S)
-
calculate
public final void calculate()
-
invert
public void invert()
-
setWindow
public void setWindow(Function fn)
-
-