Class FastFourierTransform

  • All Implemented Interfaces:
    Function<org.apache.commons.numbers.complex.Complex[],​org.apache.commons.numbers.complex.Complex[]>, UnaryOperator<org.apache.commons.numbers.complex.Complex[]>, ComplexTransform

    public class FastFourierTransform
    extends Object
    implements ComplexTransform
    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 FastFourierTransform.Norm.

    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.

    • Method Detail

      • transformInPlace

        public void transformInPlace​(double[][] dataRI)
        Computes the standard transform of the data. Computation is done in place. Assumed layout of the input data:
        • dataRI[0][i]: Real part of the i-th data point,
        • dataRI[1][i]: Imaginary part of the i-th data point.
        Parameters:
        dataRI - Two-dimensional array of real and imaginary parts of the data.
        Throws:
        IllegalArgumentException - if the number of data points is not a power of two, if the number of rows of the specified array is not two, or the array is not rectangular.
      • apply

        public org.apache.commons.numbers.complex.Complex[] apply​(double[] f)
        Returns the transform of the specified data set.
        Specified by:
        apply in interface ComplexTransform
        Parameters:
        f - the data array to be transformed (signal).
        Returns:
        the transformed array (spectrum).
        Throws:
        IllegalArgumentException - if the length of the data array is not a power of two.
      • apply

        public org.apache.commons.numbers.complex.Complex[] apply​(DoubleUnaryOperator f,
                                                                  double min,
                                                                  double max,
                                                                  int n)
        Returns the transform of the specified function.
        Specified by:
        apply in interface ComplexTransform
        Parameters:
        f - Function to be sampled and transformed.
        min - Lower bound (inclusive) of the interval.
        max - Upper bound (exclusive) of the interval.
        n - Number of sample points.
        Returns:
        the result.
        Throws:
        IllegalArgumentException - if the number of sample points n is not a power of two, if the lower bound is greater than, or equal to the upper bound, if the number of sample points n is negative
      • apply

        public org.apache.commons.numbers.complex.Complex[] apply​(org.apache.commons.numbers.complex.Complex[] f)
        Returns the transform of the specified data set.
        Specified by:
        apply in interface ComplexTransform
        Specified by:
        apply in interface Function<org.apache.commons.numbers.complex.Complex[],​org.apache.commons.numbers.complex.Complex[]>
        Parameters:
        f - the data array to be transformed (signal).
        Returns:
        the transformed array (spectrum).
        Throws:
        IllegalArgumentException - if the length of the data array is not a power of two.