template<class i_type, class o_type, class tap_type, class acc_type>
class gr::filter::kernel::iir_filter< i_type, o_type, tap_type, acc_type >
Base class template for Infinite Impulse Response filter (IIR)
This class provides a templated kernel for IIR filters. These iir_filters can be instantiated with a set of feed-forward and feed-back taps in the constructor. We then call the iir_filter::filter function to add a new sample to the filter, or iir_filter::filter_n to add a vector of samples to be filtered.
Instantiating a filter means defining the templates for the data types being processed by the filter. There are four templates:
- i_type the data type of the input data (i.e., float).
- o_type the data type of the output data (i.e., float).
- tap_type the data type of the filter taps (i.e., double).
- acc_type the data type of the internal accumulator (i.e., double).
The acc_type is specified to control how data is handled internally in the filter. This should always be the highest precision data type of any of the first three. Often, IIR filters require double-precision values in the taps for stability, and so the internal accumulator should also be double precision.
Example:
...
float y = iir_filt.filter(x);
<or>
iir_filt.filter(y, x, N);
Another example for handling complex samples with double-precision taps (see filter::iir_filter_ccz):
gr:;filter::kernel::iir_filter<gr_complex, gr_complex, gr_complexd, gr_complexd> iir_filt(fftaps, fbtaps);
template<class i_type, class o_type, class tap_type, class acc_type>
gr::filter::kernel::iir_filter< i_type, o_type, tap_type, acc_type >::iir_filter |
( |
const std::vector< tap_type > & |
fftaps, |
|
|
const std::vector< tap_type > & |
fbtaps, |
|
|
bool |
oldstyle = true |
|
) |
| |
throw | ( | std::invalid_argument |
| ) | | |
|
inline |
Construct an IIR with the given taps.
This filter uses the Direct Form I implementation, where fftaps
contains the feed-forward taps, and fbtaps
the feedback ones.
fftaps
and fbtaps
must have equal numbers of taps
oldstyle:
The old style of the IIR filter uses feedback taps that are negative of what most definitions use (scipy and Matlab among them). This parameter keeps using the old GNU Radio style and is set to TRUE by default. When taps generated from scipy, Matlab, or gr_filter_design, use the new style by setting this to FALSE.
The input and output satisfy a difference equation of the form
with the corresponding rational system function