Class FastFFT

java.lang.Object
org.jamdev.jpamutils.spectrogram.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

  • Method Details

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

      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

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

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

      public void fft​(ComplexArray x)
      In place complex fft of complex data.
      Parameters:
      x - Complex data 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 !)
    • ifft

      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
    • ifft

      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
      scale - - true for scaling to be performed
      n - the FFT length
    • 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.
    • nextBinaryExp

      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

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