Loading...
Searching...
No Matches
gr::filter::kernel::iir_filter< i_type, o_type, tap_type, acc_type > Class Template Reference

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

## Detailed Description

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:

gr::filter::kernel::iir_filter<float,float,double,double> iir_filt(fftaps, fbtaps);
...
float y = iir_filt.filter(x);
<or>
iir_filt.filter(y, x, N); // y and x are float arrays
gr::filter::kernel::iir_filter
Base class template for Infinite Impulse Response filter (IIR)
Definition iir_filter.h:71

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);
gr
GNU Radio logging wrapper.
Definition basic_block.h:29

## Constructor & Destructor Documentation

## iir_filter() [1/2]

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 )

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: - input signal, - output signal, - k-th feedback tap, - k-th feed-forward tap, - `len(fbtaps)-1`, - `len(fftaps)-1`.

, that is `fbtaps`[0], is ignored.

## iir_filter() [2/2]

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 | ( |  | ) |

inline

## Member Function Documentation

## filter() [1/4]

gr_complex gr::filter::kernel::iir_filter< gr_complex, gr_complex, float, gr_complex >::filter | ( | const gr_complex | input | ) |

## filter() [2/4]

gr_complex gr::filter::kernel::iir_filter< gr_complex, gr_complex, double, gr_complexd >::filter | ( | const gr_complex | input | ) |

## filter() [3/4]

gr_complex gr::filter::kernel::iir_filter< gr_complex, gr_complex, gr_complexd, gr_complexd >::filter | ( | const gr_complex | input | ) |

## filter() [4/4]

template<class i_type , class o_type , class tap_type , class acc_type >

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.

Returns
  the filtered input value.

## filter_n()

template<class i_type , class o_type , class tap_type , class acc_type >

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.

## ntaps_fb()

template<class i_type , class o_type , class tap_type , class acc_type >

unsigned gr::filter::kernel::iir_filter< i_type, o_type, tap_type, acc_type >::ntaps_fb | ( |  | ) | const

inline

## ntaps_ff()

template<class i_type , class o_type , class tap_type , class acc_type >

unsigned gr::filter::kernel::iir_filter< i_type, o_type, tap_type, acc_type >::ntaps_ff | ( |  | ) | const

inline

Returns
  number of taps in filter.

## set_taps()

template<class i_type , class o_type , class tap_type , class acc_type >

void gr::filter::kernel::iir_filter< i_type, o_type, tap_type, acc_type >::set_taps | ( | const std::vector< tap_type > & | fftaps,
|  | const std::vector< tap_type > & | fbtaps )

inline

install new taps.

## Member Data Documentation

## d_fbtaps

template<class i_type , class o_type , class tap_type , class acc_type >

std::vector<tap_type> gr::filter::kernel::iir_filter< i_type, o_type, tap_type, acc_type >::d_fbtaps

protected

## d_fftaps

template<class i_type , class o_type , class tap_type , class acc_type >

std::vector<tap_type> gr::filter::kernel::iir_filter< i_type, o_type, tap_type, acc_type >::d_fftaps

protected

## d_latest_m

template<class i_type , class o_type , class tap_type , class acc_type >

int gr::filter::kernel::iir_filter< i_type, o_type, tap_type, acc_type >::d_latest_m

protected

## d_latest_n

template<class i_type , class o_type , class tap_type , class acc_type >

int gr::filter::kernel::iir_filter< i_type, o_type, tap_type, acc_type >::d_latest_n

protected

## d_oldstyle

template<class i_type , class o_type , class tap_type , class acc_type >

bool gr::filter::kernel::iir_filter< i_type, o_type, tap_type, acc_type >::d_oldstyle

protected

## d_prev_input

template<class i_type , class o_type , class tap_type , class acc_type >

std::vector<i_type> gr::filter::kernel::iir_filter< i_type, o_type, tap_type, acc_type >::d_prev_input

protected

## d_prev_output

template<class i_type , class o_type , class tap_type , class acc_type >

std::vector<acc_type> gr::filter::kernel::iir_filter< i_type, o_type, tap_type, acc_type >::d_prev_output

protected

The documentation for this class was generated from the following file:

- iir_filter.h