Package samer.units

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 Detail

      • bitrev

        public int[] bitrev
      • H

        public double[] H
      • imag

        public double[] imag
      • N

        protected int N
      • real

        public double[] real
      • zeros

        protected double[] zeros
    • Constructor Detail

      • FFT

        public FFT(int n)
    • Method Detail

      • size

        public int size()
      • input

        public final void input(double[] Y)
      • brevcopy

        public final void brevcopy(double[] src,
                                   double[] dst)
      • outputPower

        public final void outputPower(double[] S)
      • calculate

        public final void calculate()
      • invert

        public void invert()
      • setWindow

        public void setWindow(Function fn)