Package xal.tools.dsp

Class FourierExpTransform

java.lang.Object
xal.tools.dsp.FourierExpTransform

public class FourierExpTransform extends Object

Class embodying the classic Discrete Fourier Transform (DFT). Although this is a discrete transform, it is not a Fast Fourier Transform (FFT). Specifically, we do not exploit the dyadic nature of the transform kernel. In fact, we explicitly compute both the forward and inverse kernels which, in the discrete version, are matrices. Thus, the transform can potentially be expensive for large signal sizes (of order O(N²)). The advantage here is that we may consider arbitrary signal sizes N > 0. That is, N does not need to be a power of 2 as with the FFT, requiring the given signal to be padded accordingly.

The transform performed here is given by

   [f^] = [K]·[f]

where [f^] is the complex vector of DFT data, [K] is the complex symmetric matrix kernel, and [f] is the real vector (e.i., type double[]) of input function values. The elements Kmn of the matrix kernel are given by

   Kmn = z-mn/N½

where N is the size of the data vector [f], indices m, n range over the values 0,…,N-1, and z is the generator of the transform kernel given by

   zei2π/N

The factor 1/N½ is a normalization constant; specifically, the value of the L2 norm ||ei2πn/N||.

The inverse transform (back to the "time" domain) is given by

   [f] = [K-1]·[f^]

where the elements Kmn-1 of the kernel are given by

   Kmn-1 = zmn/N½

Clearly [K-1]·[K] = [I] where [I] is the N×N identity matrix.

From the value of Kmn and z it can be inferred that the stride in [f^] is 1/T, where T is the length of the time interval over which f is taken. Because the DFT considers both positive and negative frequency components, the largest frequency we can see is ½N/T, corresponding to the discrete frequency N/2. Referring to the definition of z, the positive (discrete) frequency components cover the indices n = 0,…,floor(N/2) while the negative frequency components are located at the indices n = floor(N/2)+1,…,N-1 (in reverse order). Topologically, the positive frequencies {n} occur for zn on the top half-plane and the negative frequencies {n} occur for zn on the bottom half-plane.

Author:
Christopher K. Allen
  • Constructor Summary

    Constructors
    Constructor
    Description
    FourierExpTransform(int szData)
    Create a new sine transform object for transforming data vectors of size szData.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    compFreqStrideFromInterval(double dblDelta)
    Compute and return the value of the frequency stride for this transform given the time stride (time interval between data points).
    double
    compFreqStrideFromPeriod(double dblPeriod)
    Compute and return the value of the frequency stride for this transform given the total time period over which the data is taken.
    int
    Return the expected size of the data, which is also the dimensions of the kernel.
    JSci.maths.Complex
    Return the exponential transform generator.
    double[]
    inverse(JSci.maths.vectors.AbstractComplexVector vecTrans)
    Compute and return the Fourier exponential transform of the given function.
    double[]
    powerSpectrum(double[] arrFunc)
    Compute and return the discrete power spectrum for the given function.
    Write out contents to string.
    JSci.maths.vectors.AbstractComplexVector
    transform(double[] arrFunc)
    Compute and return the Fourier exponential transform of the given function.

    Methods inherited from class java.lang.Object

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

    • FourierExpTransform

      public FourierExpTransform(int szData)
      Create a new sine transform object for transforming data vectors of size szData. During construction the szData×szData transform matrix kernel is built. Upon completion the returned transform object is able to transform any double[] object of the appropriate size.
      Parameters:
      szData -
      See Also:
  • Method Details

    • getDataSize

      public int getDataSize()
      Return the expected size of the data, which is also the dimensions of the kernel.
      Returns:
      size of the transform vectors (that is, the value N)
    • getKernelGenerator

      public JSci.maths.Complex getKernelGenerator()

      Return the exponential transform generator. All the inverse transform kernel elements are multiples of the this value while all forward transform kernel elements are multiples of the inverse of this value.

      Note that z lies on the unit circle of the complex plane.

      Returns:
      the transform generator
    • compFreqStrideFromPeriod

      public double compFreqStrideFromPeriod(double dblPeriod)
      Compute and return the value of the frequency stride for this transform given the total time period over which the data is taken.
      Parameters:
      dblPeriod - total length of the data window
      Returns:
      frequency interval (stride) between transformed data points
    • compFreqStrideFromInterval

      public double compFreqStrideFromInterval(double dblDelta)
      Compute and return the value of the frequency stride for this transform given the time stride (time interval between data points).
      Parameters:
      dblDelta - time interval between data points
      Returns:
      frequency interval (stride) between transformed data points
    • transform

      public JSci.maths.vectors.AbstractComplexVector transform(double[] arrFunc) throws IllegalArgumentException

      Compute and return the Fourier exponential transform of the given function.

      The returned values are ordered so that the lowest frequency components come first. That is, the components are indexed according to their discrete frequency. Note also that the zero-frequency component of a sine transform is identically zero, as is the Nth component. Thus, the first and last values will always be zero.

      Parameters:
      arrFunc - vector array of function values (zero values on either end)
      Returns:
      vector array of transformed value
      Throws:
      IllegalArgumentException - invalid function dimension
    • inverse

      public double[] inverse(JSci.maths.vectors.AbstractComplexVector vecTrans) throws IllegalArgumentException

      Compute and return the Fourier exponential transform of the given function.

      The returned values are ordered so that the lowest frequency components come first. That is, the components are indexed according to their discrete frequency. Note also that the zero-frequency component of a sine transform is identically zero, as is the Nth component. Thus, the first and last values will always be zero.

      Parameters:
      vecTrans - vector array of inverse transform values (zero values on either end)
      Returns:
      vector array of transformed value
      Throws:
      IllegalArgumentException - invalid function dimension
    • powerSpectrum

      public double[] powerSpectrum(double[] arrFunc) throws IllegalArgumentException

      Compute and return the discrete power spectrum for the given function. The power spectrum is the square of the frequency spectrum and, therefore, is always real and positive.

      The returned values are ordered so that the lowest frequency components are located at the end points. Specifically, due to the nature of the discrete Fourier transform the spectrum has the topology of the circle. The frequency N - 1 is actually the negative frequency -1. Thus, the negative frequency -n is located at index N - n. The largest frequency is at index N/2.

      Parameters:
      arrFunc - discrete function
      Returns:
      discrete power spectrum of given function
      Throws:
      IllegalArgumentException - invalid function dimension
    • toString

      public String toString()
      Write out contents to string.
      Overrides:
      toString in class Object
      See Also: