Class Complex

java.lang.Object
ffx.numerics.fft.Complex

public class Complex extends Object
Compute the FFT of complex, double precision data of arbitrary length n. This class uses a mixed radix method and has special methods to handle factors [2, 3, 4, 5, 6, 7] and a general method for larger prime factors.
Since:
1.0
Author:
Michal J. Schnieders
Derived from:
Bruce R. Miller (bruce.miller@nist.gov)
Contribution of the National Institute of Standards and Technology, not subject to copyright.
Derived from:
GSL (Gnu Scientific Library) FFT Code by Brian Gough (bjg@network-theory.co.uk)
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Complex(int n)
    Construct a Complex instance for interleaved data of length n.
    Complex(int n, DataLayout1D dataLayout, int imOffset)
    Construct a Complex instance for data of length n.
    Complex(int n, DataLayout1D dataLayout, int imOffset, int nFFTs)
    Construct a Complex instance for data of length n.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    dft(double[] in, double[] out)
    Static DFT method used to test the FFT.
    static void
    dftBlocked(double[] in, double[] out)
    Static DFT method used to test the FFT.
    void
    fft(double[] data, int offset, int stride)
    Compute the Fast Fourier Transform of data leaving the result in data.
    void
    fft(double[] data, int offset, int stride, int nextFFT)
    Compute the Fast Fourier Transform of data leaving the result in data.
    int[]
    Getter for the field factors.
    void
    ifft(double[] data, int offset, int stride)
    Compute the (un-normalized) inverse FFT of data, leaving it in place.
    void
    ifft(double[] data, int offset, int stride, int nextFFT)
    Compute the (un-normalized) inverse FFT of data, leaving it in place.
    void
    inverse(double[] data, int offset, int stride)
    Compute the normalized inverse FFT of data, leaving it in place.
    void
    inverse(double[] data, int offset, int stride, int nextFFT)
    Compute the normalized inverse FFT of data, leaving it in place.
    static void
    main(String[] args)
    Test the Complex FFT.
    static boolean
    Check if a dimension is a preferred dimension.
    void
    setMinSIMDLoopLength(int minSIMDLoopLength)
    Configure the minimum SIMD inner loop length.
    void
    setUseSIMD(boolean useSIMD)
    Configure use of SIMD operators.
    String representation of the Complex FFT.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Complex

      public Complex(int n)
      Construct a Complex instance for interleaved data of length n. Factorization of n is designed to use special methods for small factors, and a general routine for large odd prime factors. Scratch memory is created of length 2*n, which is reused each time a transform is computed.
      Parameters:
      n - Number of complex numbers (n .GT. 1).
    • Complex

      public Complex(int n, DataLayout1D dataLayout, int imOffset)
      Construct a Complex instance for data of length n. The offset to each imaginary part relative to the real part is given by im. Factorization of n is designed to use special methods for small factors. Scratch memory is created of length 2*n, which is reused each time a transform is computed.
      Parameters:
      n - Number of complex numbers (n .GT. 1).
      dataLayout - Data layout (interleaved or blocked).
      imOffset - Offset to the imaginary part of each complex number relative to its real part.
    • Complex

      public Complex(int n, DataLayout1D dataLayout, int imOffset, int nFFTs)
      Construct a Complex instance for data of length n. The offset to each imaginary part relative to the real part is given by im. Factorization of n is designed to use special methods for small factors. Scratch memory is created of length 2*n, which is reused each time a transform is computed.
      Parameters:
      n - Number of complex numbers (n .GT. 1).
      dataLayout - Data layout (interleaved or blocked).
      imOffset - Offset to the imaginary part of each complex number relative to its real part.
      nFFTs - Number of FFTs to process (default = 1).
  • Method Details

    • toString

      public String toString()
      String representation of the Complex FFT.
      Overrides:
      toString in class Object
      Returns:
      a String.
    • setUseSIMD

      public void setUseSIMD(boolean useSIMD)
      Configure use of SIMD operators.
      Parameters:
      useSIMD - True to use SIMD operators.
    • setMinSIMDLoopLength

      public void setMinSIMDLoopLength(int minSIMDLoopLength)
      Configure the minimum SIMD inner loop length. For interleaved data, the default minimum SIMD loop length is 1 using AVX-128 (1 Real and 1 Imaginary per load). For blocked data, the default minimum SIMD loop length is 1 using AVX-128 (2 Real or 2 Imaginary per load). Setting this value higher than one reverts to scalar operations for short inner loop lengths.
      Parameters:
      minSIMDLoopLength - Minimum SIMD inner loop length.
    • preferredDimension

      public static boolean preferredDimension(int dim)
      Check if a dimension is a preferred dimension.
      Parameters:
      dim - the dimension to check.
      Returns:
      true if the dimension is a preferred dimension.
    • getFactors

      public int[] getFactors()
      Getter for the field factors.
      Returns:
      an array of int.
    • fft

      public void fft(double[] data, int offset, int stride)
      Compute the Fast Fourier Transform of data leaving the result in data. The array data must contain the data points in the following locations:
       Re(d[i]) = data[offset + stride*i]
       Im(d[i]) = data[offset + stride*i + im]
       

      where im is 1 for interleaved data or a constant set when the class was constructed.

      Parameters:
      data - an array of double.
      offset - the offset to the beginning of the data.
      stride - the stride between data points.
    • fft

      public void fft(double[] data, int offset, int stride, int nextFFT)
      Compute the Fast Fourier Transform of data leaving the result in data. The array data must contain the data points in the following locations:
       Re(d[i]) = data[offset + stride*i] + k * nextFFT
       Im(d[i]) = data[offset + stride*i + im] + k * nextFFT
       

      where im is 1 for interleaved data or a constant set when the class was constructed. The value of k is the FFT number (0 to nFFTs-1). The value of nextFFT is the stride between FFT data sets. The nextFFT value is ignored if the number of FFTs is 1.

      Parameters:
      data - an array of double.
      offset - the offset to the beginning of the data.
      stride - the stride between data points.
      nextFFT - the offset to the beginning of the next FFT when nFFTs > 1.
    • ifft

      public void ifft(double[] data, int offset, int stride)
      Compute the (un-normalized) inverse FFT of data, leaving it in place. The frequency domain data must be in wrap-around order, and be stored in the following locations:
       Re(D[i]) = data[offset + stride*i]
       Im(D[i]) = data[offset + stride*i + im]
       
      Parameters:
      data - an array of double.
      offset - the offset to the beginning of the data.
      stride - the stride between data points.
    • ifft

      public void ifft(double[] data, int offset, int stride, int nextFFT)
      Compute the (un-normalized) inverse FFT of data, leaving it in place. The frequency domain data must be in wrap-around order, and be stored in the following locations:
       Re(d[i]) = data[offset + stride*i] + k * nextFFT
       Im(d[i]) = data[offset + stride*i + im] + k * nextFFT
       

      where im is 1 for interleaved data or a constant set when the class was constructed. The value of k is the FFT number (0 to nFFTs-1). The value of nextFFT is the stride between FFT data sets. The nextFFT value is ignored if the number of FFTs is 1.

      Parameters:
      data - an array of double.
      offset - the offset to the beginning of the data.
      stride - the stride between data points.
      nextFFT - the offset to the beginning of the next FFT when nFFTs > 1.
    • inverse

      public void inverse(double[] data, int offset, int stride)
      Compute the normalized inverse FFT of data, leaving it in place. The frequency domain data must be stored in the following locations:
       Re(d[i]) = data[offset + stride*i]
       Im(d[i]) = data[offset + stride*i + im]
       

      where im is 1 for interleaved data or a constant set when the class was constructed.

      Parameters:
      data - an array of double.
      offset - the offset to the beginning of the data.
      stride - the stride between data points.
    • inverse

      public void inverse(double[] data, int offset, int stride, int nextFFT)
      Compute the normalized inverse FFT of data, leaving it in place. The frequency domain data must be stored in the following locations:
       Re(d[i]) = data[offset + stride*i] + k * nextFFT
       Im(d[i]) = data[offset + stride*i + im] + k * nextFFT
       

      where im is 1 for interleaved data or a constant set when the class was constructed. The value of k is the FFT number (0 to nFFTs-1). The value of nextFFT is the stride between FFT data sets. The nextFFT value is ignored if the number of FFTs is 1.

      Parameters:
      data - an array of double.
      offset - the offset to the beginning of the data.
      stride - the stride between data points.
      nextFFT - the offset to the beginning of the next FFT when nFFTs > 1.
    • dft

      public static void dft(double[] in, double[] out)
      Static DFT method used to test the FFT.
      Parameters:
      in - input array.
      out - output array.
    • dftBlocked

      public static void dftBlocked(double[] in, double[] out)
      Static DFT method used to test the FFT.
      Parameters:
      in - input array.
      out - output array.
    • main

      public static void main(String[] args) throws Exception
      Test the Complex FFT.
      Parameters:
      args - an array of String objects.
      Throws:
      Exception - if any.
      Since:
      1.0