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 |
gov.sns.tools.dsp.AbstractDigitalFilter
Constructor and Description |
---|
LtiDigitalFilter(int intOrder)
Create a new filter object for processing discrete signal trains.
|
Modifier and Type | Method and Description |
---|---|
double |
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 to
setInputCoefficient(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 to
setOutputCoefficient(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.
|
java.lang.String |
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.
|
getCoefficientCount, getOrder, getTimeIndex, reset, response, response
public LtiDigitalFilter(int intOrder)
intOrder
- filter orderpublic double getInputCoefficient(int iTime, int iDelay)
setInputCoefficient(int, double)
. Note that
this value is time-independent, that is, the argument iTime is
ignored.getInputCoefficient
in class AbstractDigitalFilter
iTime
- current time index (ignored)iDelay
- delay index of the filter coefficientgov.sns.tools.dsp.LtiDigitalFilter#setInputCoefficient(int, double)
,
gov.sns.tools.dsp.AbstractDigitalFilter#getInputCoefficient(int, int)
public double getOutputCoefficient(int iTime, int iDelay)
setOutputCoefficient(int, double)
. Note that
this value is time-independent, that is, the argument iTime is
ignored.getOutputCoefficient
in class AbstractDigitalFilter
iTime
- current time index (ignored)iDelay
- delay index of the filter coefficientgov.sns.tools.dsp.LtiDigitalFilter#setOutputCoefficient(int, double)
,
gov.sns.tools.dsp.AbstractDigitalFilter#getOutputCoefficient(int, int)
public void setInputCoefficient(int iDelay, double dblVal) throws java.lang.IllegalArgumentException
iDelay
- delay index of the coefficientdblVal
- coefficient valuejava.lang.IllegalArgumentException
- index outside interval [0,Order]public void setInputCoefficients(double[] arrCoeffs) throws java.lang.IllegalArgumentException
arrCoeffs
- array of input coefficientsjava.lang.IllegalArgumentException
- argument has wrong array sizepublic void setOutputCoefficient(int iDelay, double dblVal) throws java.lang.IndexOutOfBoundsException
iDelay
- delay index of the coefficientdblVal
- coefficient valuejava.lang.IndexOutOfBoundsException
- index outside interval [0,Order]public void setOutputCoefficients(double[] arrCoeffs) throws java.lang.IllegalArgumentException
arrCoeffs
- array of output coefficientsjava.lang.IllegalArgumentException
- argument has wrong array sizepublic double getInputCoefficient(int iDelay) throws java.lang.IndexOutOfBoundsException
iDelay
- delay index of coefficientjava.lang.IndexOutOfBoundsException
- delay index larger than filter ordersetInputCoefficient(int, double)
public double getOutputCoefficient(int iDelay) throws java.lang.IndexOutOfBoundsException
iDelay
- delay index of coefficientjava.lang.IndexOutOfBoundsException
- delay index larger than filter ordersetOutputCoefficient(int, double)
public JSci.maths.Complex transferFunction(JSci.maths.Complex z)
z
- Z-transform variable (lies on the unit circle)public java.lang.String toString()
toString
in class AbstractDigitalFilter
Object.toString()