java.lang.Object
org.bzdev.math.FFT.Factory
- Enclosing class:
- FFT
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear the cache.int
getLength
(int len) Get the supported length for the fast Fourier transform that this factory'snewInstance(int)
method will accept, given a desired length.int
Get the maximum array length the service that meets this factory's constraints will suppport.newInstance
(int len) Create a new instance of a Fast Fourier transform with the default normalization modeFFT.Mode.SYMMETRIC
.newInstance
(int len, FFT.Mode m) Create a new instance of a Fast Fourier transform with a specified normalization mode.void
setCacheSize
(int size) Set the cache size.boolean
Set the name of the FFT service provider to use.boolean
setParameters
(int length, boolean inplace, FFT.LMode mode) Specify the length, in-place, and length-mode that may be used by a factory.
-
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 isFFT.LMode.MAX_LENGTH
, this method will look up the service provider; otherwise the decision will be made during a call tonewInstance(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 thanFFT.LMode.MAX_LENGTH
if the length is ignoredinplace
- true if the user requires an FFT implementation that computes a transform or its inverse in place; false otherwisemode
-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
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 tosetParameters(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'snewInstance(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
Create a new instance of a Fast Fourier transform with the default normalization modeFFT.Mode.SYMMETRIC
. The argument must be an array size supported by the FFT provider, and can be computed using the methodgetLength(int)
.- Parameters:
len
- the array size for the transform that will be created- Returns:
- the new FFT
- See Also:
-
newInstance
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 createdm
- the normalization mode (FFT.Mode.NORMAL
,FFT.Mode.SYMMETRIC
, orFFT.Mode.REVERSED
)- Returns:
- the new FFT
-