Package org.hipparchus.transform
Class FastFourierTransformer
- java.lang.Object
-
- org.hipparchus.transform.FastFourierTransformer
-
- All Implemented Interfaces:
Serializable
public class FastFourierTransformer extends Object implements Serializable
Implements the Fast Fourier Transform for transformation of one-dimensional real or complex data sets. For reference, see Applied Numerical Linear Algebra, ISBN 0898713897, chapter 6.There are several variants of the discrete Fourier transform, with various normalization conventions, which are specified by the parameter
DftNormalization
.The current implementation of the discrete Fourier transform as a fast Fourier transform requires the length of the data set to be a power of 2. This greatly simplifies and speeds up the code. Users can pad the data with zeros to meet this requirement. There are other flavors of FFT, for reference, see S. Winograd, On computing the discrete Fourier transform, Mathematics of Computation, 32 (1978), 175 - 199.
- See Also:
DftNormalization
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FastFourierTransformer(DftNormalization normalization)
Creates a new instance of this class, with various normalization conventions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Complex[]
transform(double[] f, TransformType type)
Returns the (forward, inverse) transform of the specified real data set.Complex[]
transform(UnivariateFunction f, double min, double max, int n, TransformType type)
Returns the (forward, inverse) transform of the specified real function, sampled on the specified interval.Complex[]
transform(Complex[] f, TransformType type)
Returns the (forward, inverse) transform of the specified complex data set.static void
transformInPlace(double[][] dataRI, DftNormalization normalization, TransformType type)
Computes the standard transform of the specified complex data.
-
-
-
Constructor Detail
-
FastFourierTransformer
public FastFourierTransformer(DftNormalization normalization)
Creates a new instance of this class, with various normalization conventions.- Parameters:
normalization
- the type of normalization to be applied to the transformed data
-
-
Method Detail
-
transformInPlace
public static void transformInPlace(double[][] dataRI, DftNormalization normalization, TransformType type)
Computes the standard transform of the specified complex data. The computation is done in place. The input data is laid out as followsdataRI[0][i]
is the real part of thei
-th data point,dataRI[1][i]
is the imaginary part of thei
-th data point.
- Parameters:
dataRI
- the two dimensional array of real and imaginary parts of the datanormalization
- the normalization to be applied to the transformed datatype
- the type of transform (forward, inverse) to be performed- Throws:
MathIllegalArgumentException
- if the number of rows of the specified array is not two, or the array is not rectangularMathIllegalArgumentException
- if the number of data points is not a power of two
-
transform
public Complex[] transform(double[] f, TransformType type)
Returns the (forward, inverse) transform of the specified real data set.- Parameters:
f
- the real data array to be transformedtype
- the type of transform (forward, inverse) to be performed- Returns:
- the complex transformed array
- Throws:
MathIllegalArgumentException
- if the length of the data array is not a power of two
-
transform
public Complex[] transform(UnivariateFunction f, double min, double max, int n, TransformType type)
Returns the (forward, inverse) transform of the specified real function, sampled on the specified interval.- Parameters:
f
- the function to be sampled and transformedmin
- the (inclusive) lower bound for the intervalmax
- the (exclusive) upper bound for the intervaln
- the number of sample pointstype
- the type of transform (forward, inverse) to be performed- Returns:
- the complex transformed array
- Throws:
MathIllegalArgumentException
- if the lower bound is greater than, or equal to the upper boundMathIllegalArgumentException
- if the number of sample pointsn
is negativeMathIllegalArgumentException
- if the number of sample pointsn
is not a power of two
-
transform
public Complex[] transform(Complex[] f, TransformType type)
Returns the (forward, inverse) transform of the specified complex data set.- Parameters:
f
- the complex data array to be transformedtype
- the type of transform (forward, inverse) to be performed- Returns:
- the complex transformed array
- Throws:
MathIllegalArgumentException
- if the length of the data array is not a power of two
-
-