Class FFT.Factory

java.lang.Object
org.bzdev.math.FFT.Factory
Enclosing class:
FFT

public static class FFT.Factory extends Object
Factory class for creating FFT instances that satisfy various criteria. FFT factories can be configured to cache previous results, with the cache having a finite size. Constructing an FFT requires a potentially large number of sin and cosine computations. For some applications, it is useful to store previously computed FFTs.
  • Constructor Details

    • Factory

      public Factory()
  • Method Details

    • setCacheSize

      public void setCacheSize(int size)
      Set the cache size.

      Calling this method will clear the cache, even if the argument matches the existing cache size.

      Parameters:
      size - the new cache size; 0 or negative for no caching
    • clearCache

      public void clearCache()
      Clear the cache. This will free up memory without changing the cache size.
    • setParameters

      public boolean setParameters(int length, boolean inplace, FFT.LMode mode) throws IllegalArgumentException
      Specify the length, in-place, and length-mode that may be used by a factory.

      This method replaces any configuration set by prior calls to it, and by prior calls to setName(String). If the third parameter is FFT.LMode.MAX_LENGTH, this method will look up the service provider; otherwise the decision will be made during a call to newInstance(int).

      Calling this method will clear the cache.

      Parameters:
      length - the maximum length of the arrays storing the real or imaginary components used for input or output; 0 or negative for modes other than FFT.LMode.MAX_LENGTH if the length is ignored
      inplace - true if the user requires an FFT implementation that computes a transform or its inverse in place; false otherwise
      mode - FFT.LMode.DESIRED_LENGTH if the length argument represents a desired length; FFT.LMode.MAX_LENGTH if the length argument is an upper bound on the array lengths; FFT.LMode.EXACT_LENGTH if the length argument represents a specific length
      Returns:
      true on success; false if there is no FFT service that matches the specified parameters
      Throws:
      IllegalArgumentException - an argument was illegal
    • setName

      public boolean setName(String name)
      Set the name of the FFT service provider to use. Calling this method replaces any configuration set by prior calls to this method and by prior calls to setParameters(int,boolean,FFT.LMode).

      Calling this method will also clear the cache.

      Parameters:
      name - the name of the provider; null if the default provider is to be used.
      Returns:
      true if the name is a valid name; false otherwise
    • getMaxLength

      public int getMaxLength()
      Get the maximum array length the service that meets this factory's constraints will suppport.
      Returns:
      the maximum length
    • getLength

      public int getLength(int len)
      Get the supported length for the fast Fourier transform that this factory's newInstance(int) method will accept, given a desired length. The value returned is the array length for arguments passed to an FFT's transform and inverse methods.
      Parameters:
      len - the desired length
      Returns:
      the smallest supported length larger than or equal to the desired length
    • newInstance

      public FFT newInstance(int len)
      Create a new instance of a Fast Fourier transform with the default normalization mode FFT.Mode.SYMMETRIC. The argument must be an array size supported by the FFT provider, and can be computed using the method getLength(int).
      Parameters:
      len - the array size for the transform that will be created
      Returns:
      the new FFT
      See Also:
    • newInstance

      public FFT newInstance(int len, FFT.Mode m)
      Create a new instance of a Fast Fourier transform with a specified normalization mode. The len must be an array size supported by the FFT provider.
      Parameters:
      len - the array size for the transform that will be created
      m - the normalization mode (FFT.Mode.NORMAL, FFT.Mode.SYMMETRIC, or FFT.Mode.REVERSED)
      Returns:
      the new FFT