Package fftManager

Class FastFFT

java.lang.Object
fftManager.FastFFT

public class FastFFT extends 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 transforms library with standard PAMGUARD transform classes.
Author:
Doug Gillespie
  • Constructor Details Link icon

    • FastFFT Link icon

      public FastFFT()
  • Method Details Link icon

    • rfft Link icon

      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.
    • rfft Link icon

      public ComplexArray rfft(double[] x, int n)
      FFT of real data. Will return only the first half of the FFT, since second is simply complex conjugate of the first.
      Parameters:
      x - waveform (will be padded or truncated to length n)
      n - length of FFT
      Returns:
      Complex spectrum
    • rfftFull Link icon

      public ComplexArray rfftFull(double[] x, int n)
    • fft Link icon

      public void fft(Complex[] x)
      In place fft of complex data.
      Parameters:
      x - complex array
    • fft Link icon

      public void fft(ComplexArray x)
      In place complex fft of complex data.
      Parameters:
      x - Complex data array.
    • fft Link icon

      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 Link icon

      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 !)
    • ifft Link icon

      public void ifft(ComplexArray x, int n)
      Inverse FFT for Complex data.
      I FFT is performed 'in place' so data are overwritten
      Parameters:
      x - ComplexArray - the input data.
      n - the FFT length
    • realInverse Link icon

      public double[] realInverse(ComplexArray x)
      Inverse transform of what was real data. Will automatically assume a second half complex conj of the first half. This can be used to transform back data used in cross correlations rather than trying to fill in the second half of the conjugate, which is not really possible with the missing middle point of the FFT.
      Parameters:
      x - Complex input data, which originally came from real.
      Returns:
      real data array 2x the length of the Complex input (i.e. same length as double array within complex input).
    • ifft Link icon

      public void ifft(ComplexArray x, int n, boolean scale)
      Inverse FFT for Complex data.
      I FFT is performed 'in place' so data are overwritten
      Parameters:
      x - ComplexArray - the input data
      n - the FFT length
      scale - - true for scaling to be performed
    • nextBinaryExp Link icon

      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.
    • nextBinaryExp Link icon

      public static int nextBinaryExp(int startPower, 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:
      startPower - power of 2 to start at (e,g. 1 will return a minimum of 2)
      sourceNumber -
      Returns:
      The next highest 2^ of the input, unless input is itself a binary exponential.
    • log2 Link icon

      public static int log2(int num)
      Parameters:
      FFTlength -
      Returns:
      log2 of FFTlength, -1 if not natural power of 2