Filter Realization
The digital filter realization problem is concerned with numerically computing the output signal y(n) via the difference equation
y(n) = b0x(n) + b1x(n – 1) + ... + bMx(nM)
         – a1y(n – 1) – a2y(n – 2) – ... – aNy(nN)
with input signal x(n). The PV‑WAVE Signal Processing Toolkit includes functions for realizing FIR,  IIR and multirate digital filters.
Standard FIR and IIR Filter Realization
Functions for realizing FIR and IIR filters are summarized in Table 1-6: FIR and IIR Filter Realization. For detailed information, see Chapter 2: Reference (A to F), Chapter 3: Reference (G to P), and Chapter 4: Reference (Q to Z).
 
FIR and IIR Filter Realization
Function
Description
FILTER(*)
Basic FIR and IIR filter realization
FIRFILT (*)
Convolution and FFT-based filter realization of FIR filters
IIRFILT (*)
Causal and anti-causal (forward-backward) IIR filter realization
*   function uses digital filter data structure
FILTER implements both FIR and IIR filters in a fashion that is transparent to you, and it is the workhorse used in most applications. The FIRFILT and IIRFILT functions provide you with increased control over how the FIR and IIR filters are realized.
The following example shows a typical application of the FILTER function.
!P.Multi = [0, 1, 1]
t = FINDGEN(1024)
; Generate two narrow band signals and combine them.
s1 = SIN(0.6*t)
s2 = SIN(1.2*t)
x = s1 + s2
; Generate the abscissa values for the normalized frequency.
f = FINDGEN(512)/511
; Plot magnitude frequency response of the combined signal.
PLOT, f, (ABS(FFTCOMP(x, /Complex)))(0:512), Title = 'Original'
; Approximate a bandpass filter to isolate the first signal.
h = FIRDESIGN(101, 0.1, 0.25, /Bandpass)
; Apply the filter to the signal.
y = FILTER(h, x)
; Plot the magnitude frequency response of the filtered signal.
PLOT, f, (ABS(FFTCOMP(y, /Complex)))(0:512), Title = 'Filtered'
The original combined narrow band signal is shown in (a) and the results of the example code using the FILTER function are shown in (b) of Figure 1-6: Filtering.
 
Figure 1-6: Filtering
 
The next example illustrates how IIRFILT may be used to perform causal and anti-causal filtering.
!P.Multi = [0, 1, 2]
; Generate a square wave. 
x = ((INDGEN(1024)+64) MOD 256) GT 128
; Design an elliptical lowpass filter.
h = IIRDESIGN(5, 0.25, 0.01, 0.01, /Ellip)
; Plot the causal filtering of the square wave.
PLOT, IIRFILT(h, x), Title = 'Causal Filtering'
; Plot the anti-causal (forward-backward) filtering of the 
; square wave. Notice that the result is symmetric, and there
; is no phase distortion.
PLOT, IIRFILT(h, x, /Forward_back), $
Title = 'Anti-Causal Filtering'
Figure 1-7: Causal and Anti-Causal Filtering (a) shows the causal (forward) filter results and (b) shows the anti-causal (forward-backward) filter results obtained by applying the IIRFILT function to the square wave.
 
Figure 1-7: Causal and Anti-Causal Filtering
Multirate Filter Realization
Functions and procedures for realizing multirate filters are summarized in Table 1-7: Multirate Filter Realization Routines. For detailed information, see Chapter 2: Reference (A to F) and Chapter 4: Reference (Q to Z).
 
Multirate Filter Realization Routines
Routine
Description
FILTDOWN (*)
Decimation filter
FILTUP(*)
Interpolation filter
QMF (*)
Quadrature mirror filter
*   routine uses digital filter data structure
FILTDOWN and FILTUP can be combined to achieve most multirate signal processing techniques. The commonly used quadrature mirror filter operation is provided in the QMF procedure.