Base class template for Infinite Impulse Response filter (IIR) More...
#include <gnuradio/filter/iir_filter.h>
Public Member Functions | |
iir_filter (const std::vector< tap_type > &fftaps, const std::vector< tap_type > &fbtaps, bool oldstyle=true) noexcept(false) | |
Construct an IIR with the given taps. | |
iir_filter () | |
o_type | filter (const i_type input) |
compute a single output value. | |
void | filter_n (o_type output[], const i_type input[], long n) |
compute an array of N output values. input must have N valid entries. | |
unsigned | ntaps_ff () const |
unsigned | ntaps_fb () const |
void | set_taps (const std::vector< tap_type > &fftaps, const std::vector< tap_type > &fbtaps) |
install new taps. | |
gr_complex | filter (const gr_complex input) |
gr_complex | filter (const gr_complex input) |
gr_complex | filter (const gr_complex input) |
Protected Attributes | |
bool | d_oldstyle |
std::vector< tap_type > | d_fftaps |
std::vector< tap_type > | d_fbtaps |
int | d_latest_n |
int | d_latest_m |
std::vector< acc_type > | d_prev_output |
std::vector< i_type > | d_prev_input |
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:
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:
Another example for handling complex samples with double-precision taps (see filter::iir_filter_ccz):
|
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.
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.
When oldstyle
is set FALSE, the input and output satisfy a difference equation of the form
with the corresponding rational system function
where: len(fbtaps)-1
, len(fftaps)-1
.
fbtaps
[0], is ignored.
References d_oldstyle, and set_taps().
|
inline |
References d_latest_m, and d_latest_n.
gr_complex gr::filter::kernel::iir_filter< gr_complex, gr_complex, float, gr_complex >::filter | ( | const gr_complex | input | ) |
gr_complex gr::filter::kernel::iir_filter< gr_complex, gr_complex, double, gr_complexd >::filter | ( | const gr_complex | input | ) |
gr_complex gr::filter::kernel::iir_filter< gr_complex, gr_complex, gr_complexd, gr_complexd >::filter | ( | const gr_complex | input | ) |
o_type gr::filter::kernel::iir_filter< i_type, o_type, tap_type, acc_type >::filter | ( | const i_type | input | ) |
compute a single output value.
References d_fbtaps, d_fftaps, d_latest_m, d_latest_n, d_prev_input, d_prev_output, ntaps_fb(), and ntaps_ff().
Referenced by filter_n().
void gr::filter::kernel::iir_filter< i_type, o_type, tap_type, acc_type >::filter_n | ( | o_type | output[], |
const i_type | input[], | ||
long | n ) |
compute an array of N output values. input
must have N valid entries.
References filter().
|
inline |
|
inline |
|
inline |
install new taps.
References d_fbtaps, d_fftaps, d_latest_m, d_latest_n, d_oldstyle, d_prev_input, and d_prev_output.
Referenced by iir_filter().
|
protected |
Referenced by filter(), ntaps_fb(), and set_taps().
|
protected |
Referenced by filter(), ntaps_ff(), and set_taps().
|
protected |
Referenced by filter(), iir_filter(), and set_taps().
|
protected |
Referenced by filter(), iir_filter(), and set_taps().
|
protected |
Referenced by iir_filter(), and set_taps().
|
protected |
Referenced by filter(), and set_taps().
|
protected |
Referenced by filter(), and set_taps().