Package xal.tools.dsp

Class FourierSineTransform

java.lang.Object
xal.tools.dsp.FourierSineTransform

public class FourierSineTransform extends Object

This class encapsulates many aspects of the Fourier sine transform. Although this is a discrete transform, it is not a Fast Fourier Transform (FFT). Specifically, we do not fully exploit the dyadic nature of the transform kernel. In fact, we explicitly compute this kernel which, in the discrete version, is a matrix. Thus, this transform can potentially be quite expensive for large data sets. What we have here then, is essentially a convenient wrapper around a real, symmetric matrix which makes this class look like a magical transformer.

The advantages of the sine transform are that it only involves real numbers (i.e., primitives of type double). The transform is somewhat generalized in that we assume a base frequency of π rather than 2π so that we can transform even functions as well as odd ones. (The FFT has "positive" and "negative" frequencies.) The only caveat is that the function f being transformed is assumed to have value zero at the boundaries (as does the sine kernel). There are two approaches here, either we pad the given function by zero (adding two data points), or we construct the transform so that the recovered function (via inverse transform) always has a zero values at the boundaries. Here we choose the later, preferring not to change the dimensions of the data.

The transform performed here is given by

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


where [f^] is the vector of transformed data, [K] is the real symmetric matrix kernel, and [f] is data vector of input function values. The elements Kmn of the matrix kernel are given by

   Kmn = (2/(N-1))½ sin πmn/(N-1)

where N is the size of the data vector [f], and indices m, n range over the values 0,…,N. The factor (2/(N-1))½ is a normalization constant; specifically, the value of the L2 norm ||sin πn/(N-1)||. It's presence ensures the dual nature of the transform, specifically [K].[K] = [I] where [I] is the identity matrix (sans the initial and final 1 entry).

From the value of Kmn we see that the stride in [f^] is 1/2T, where T is the period of the interval over which f is defined. Thus, the largest frequency we can see is (N-1)/2T. Also, we see that there is no specific DC component. That is, the DC (or zero-frequency) component of the signal has a projection upon all the odd-frequency components in this general Fourier sine transform. Thus, it cannot be identified separately as in the traditional Fourier transform.

Author:
Christopher K. Allen
  • Constructor Summary

    Constructors
    Constructor
    Description
    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.
    double[]
    powerSpectrum(double[] arrFunc)
    Compute and return the discrete power spectrum for the given function.
    double[]
    transform(double[] arrFunc)
    Compute and return the Fourier sine transform of the given function.

    Methods inherited from class java.lang.Object

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

    • FourierSineTransform

      public FourierSineTransform(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)
    • 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 double[] transform(double[] arrFunc) throws IllegalArgumentException

      Compute and return the Fourier sine transform of the given function. Note that this transform is essential dual to itself, thus, the transform and the inverse transform are the same operation. This fact follows from the normalization used so that the transform matrix is essentially a root of unity.

      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
    • 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 positive.

      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 - discrete function
      Returns:
      discrete power spectrum of given function
      Throws:
      IllegalArgumentException - invalid function dimension