Package xal.tools.dsp

Class LtiDigitalFilter

Direct Known Subclasses:
DigitalDifferentiator, DigitalIntegrator

public class LtiDigitalFilter extends AbstractDigitalFilter

Implements the fundamental behavior and characteristics of a Linear, Time-Invariant (LTI) digital filter of finite order with real coefficients. Child classes can implement methods for determining the filter coefficients for desired bandwidth and other transfer characteristics (i.e., Butterworth, Chebychev, etc.). Once the filter coefficients are determined this class contains most of the common behavior of a general digital filter.

The transfer characteristics for an Nth order digital filter are given by the following:

   b0yn + b1yn-1 + … + bNyn-N = a0xn + a1xn-1 + … + aNxn-N

where n is the current ("time") index, the {xn} are the inputs to the filter at time n, the {ak} are the input coefficients for delay k, the {yn} are the filter outputs at time n, and the {bk} are the output coefficients for delay k. The equation can be rearranged to explicitly demonstrate the current output yn in terms of the past N inputs and outputs

   yn = ( a0xn + a1xn-1 + … + aNxn-N - b1yn-1 - … - bNyn-N )/b0

Note that the coefficient b0 is essentially just an attenuation/amplification factor. (In fact, a zeroth-order digital filter is just that.) The current class initializes itself with the value b0 = 1.0. This case is the only nonzero initial value for the input and output coefficients and is done simply to avoid a pathological filter.

Taking the Z transform of the above equations yields the transfer function H(z) where z is the transform variable (whose domain is the unit circle in the complex plane). The transfer function has the general form
  

a0 + a1z-1 + … + aNz-N
H(z) = ———————————
b0 + b1z-1 + … + bNz-N
Clearly then the filter is linear. Note that for the Discrete Fourier Transform (DFT) and the frequencies ν = 1,…,Ν-1 the transform variable is equal to zν = ei2πν/Ν.

Author:
Christopher K. Allen
See Also:
  • Constructor Details

    • LtiDigitalFilter

      public LtiDigitalFilter(int intOrder)
      Create a new filter object for processing discrete signal trains.
      Parameters:
      intOrder - filter order
  • Method Details

    • getInputCoefficient

      public double getInputCoefficient(int iTime, int iDelay)
      Return the indicated input coefficient determined by the call to setInputCoefficient(int, double). Note that this value is time-independent, that is, the argument iTime is ignored.
      Specified by:
      getInputCoefficient in class AbstractDigitalFilter
      Parameters:
      iTime - current time index (ignored)
      iDelay - delay index of the filter coefficient
      Returns:
      the input coefficient for the given delay index
      See Also:
    • getOutputCoefficient

      public double getOutputCoefficient(int iTime, int iDelay)
      Return the indicated output coefficient determined by the call to setOutputCoefficient(int, double). Note that this value is time-independent, that is, the argument iTime is ignored.
      Specified by:
      getOutputCoefficient in class AbstractDigitalFilter
      Parameters:
      iTime - current time index (ignored)
      iDelay - delay index of the filter coefficient
      Returns:
      the output coefficient for the given delay index
      See Also:
    • setInputCoefficient

      public void setInputCoefficient(int iDelay, double dblVal) throws IllegalArgumentException
      Sets an input signal coefficient.
      Parameters:
      iDelay - delay index of the coefficient
      dblVal - coefficient value
      Throws:
      IllegalArgumentException - index outside interval [0,Order]
    • setInputCoefficients

      public void setInputCoefficients(double[] arrCoeffs) throws IllegalArgumentException
      Sets all the input signal coefficients. The elements of the argument array should be indexed by delay; that is, the 0th element corresponds to no delay, the 1st element to the unit delay, etc.
      Parameters:
      arrCoeffs - array of input coefficients
      Throws:
      IllegalArgumentException - argument has wrong array size
    • setOutputCoefficient

      public void setOutputCoefficient(int iDelay, double dblVal) throws IndexOutOfBoundsException
      Sets an output signal coefficient. Note that since an index of zero represents the current output it is an inverse scaling value.
      Parameters:
      iDelay - delay index of the coefficient
      dblVal - coefficient value
      Throws:
      IndexOutOfBoundsException - index outside interval [0,Order]
    • setOutputCoefficients

      public void setOutputCoefficients(double[] arrCoeffs) throws IllegalArgumentException
      Sets all the output signal coefficients. The elements of the argument array should be indexed by delay; that is, the 0th element corresponds to no delay, the 1st element to the unit delay, etc.
      Parameters:
      arrCoeffs - array of output coefficients
      Throws:
      IllegalArgumentException - argument has wrong array size
    • getInputCoefficient

      public double getInputCoefficient(int iDelay) throws IndexOutOfBoundsException
      Return the input coefficient at the given delay index.
      Parameters:
      iDelay - delay index of coefficient
      Returns:
      input coefficient at delay given delay index.
      Throws:
      IndexOutOfBoundsException - delay index larger than filter order
      See Also:
    • getOutputCoefficient

      public double getOutputCoefficient(int iDelay) throws IndexOutOfBoundsException
      Return the output coefficient at the given delay index.
      Parameters:
      iDelay - delay index of coefficient
      Returns:
      output coefficient at delay given delay index.
      Throws:
      IndexOutOfBoundsException - delay index larger than filter order
      See Also:
    • transferFunction

      public JSci.maths.Complex transferFunction(JSci.maths.Complex z)
      Compute and return the value of the discrete transfer function for the given value of z, the Z-transform variable.
      Parameters:
      z - Z-transform variable (lies on the unit circle)
      Returns:
      value of this filter's transfer function at z
    • toString

      public String toString()
      Write out the configuration and state of this filter as a string for inspection.
      Overrides:
      toString in class AbstractDigitalFilter
      Returns:
      configuration and state of this filter in text form
      See Also: