Class LtiDigitalFilter
- Direct Known Subclasses:
DigitalDifferentiator
,DigitalIntegrator
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 |
- Author:
- Christopher K. Allen
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLtiDigitalFilter
(int intOrder) Create a new filter object for processing discrete signal trains. -
Method Summary
Modifier and TypeMethodDescriptiondouble
getInputCoefficient
(int iDelay) Return the input coefficient at the given delay index.double
getInputCoefficient
(int iTime, int iDelay) Return the indicated input coefficient determined by the call tosetInputCoefficient(int, double)
.double
getOutputCoefficient
(int iDelay) Return the output coefficient at the given delay index.double
getOutputCoefficient
(int iTime, int iDelay) Return the indicated output coefficient determined by the call tosetOutputCoefficient(int, double)
.void
setInputCoefficient
(int iDelay, double dblVal) Sets an input signal coefficient.void
setInputCoefficients
(double[] arrCoeffs) Sets all the input signal coefficients.void
setOutputCoefficient
(int iDelay, double dblVal) Sets an output signal coefficient.void
setOutputCoefficients
(double[] arrCoeffs) Sets all the output signal coefficients.toString()
Write out the configuration and state of this filter as a string for inspection.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.Methods inherited from class xal.tools.dsp.AbstractDigitalFilter
getCoefficientCount, getOrder, getTimeIndex, reset, response, response
-
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 tosetInputCoefficient(int, double)
. Note that this value is time-independent, that is, the argument iTime is ignored.- Specified by:
getInputCoefficient
in classAbstractDigitalFilter
- 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 tosetOutputCoefficient(int, double)
. Note that this value is time-independent, that is, the argument iTime is ignored.- Specified by:
getOutputCoefficient
in classAbstractDigitalFilter
- 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
Sets an input signal coefficient.- Parameters:
iDelay
- delay index of the coefficientdblVal
- coefficient value- Throws:
IllegalArgumentException
- index outside interval [0,Order]
-
setInputCoefficients
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
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 coefficientdblVal
- coefficient value- Throws:
IndexOutOfBoundsException
- index outside interval [0,Order]
-
setOutputCoefficients
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
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
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
Write out the configuration and state of this filter as a string for inspection.- Overrides:
toString
in classAbstractDigitalFilter
- Returns:
- configuration and state of this filter in text form
- See Also:
-