A Survey of Gaussian Convolution Algorithms
Macros | Functions
filter_util.c File Reference

Filtering utility functions. More...

Detailed Description

Filtering utility functions.

Author
Pascal Getreuer getre.nosp@m.uer@.nosp@m.cmla..nosp@m.ens-.nosp@m.cacha.nosp@m.n.fr

Copyright (c) 2012-2013, Pascal Getreuer All rights reserved.

This program is free software: you can redistribute it and/or modify it under, at your option, the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version, or the terms of the simplified BSD license.

You should have received a copy of these licenses along with this program. If not, see http://www.gnu.org/licenses/ and http://www.opensource.org/licenses/bsd-license.html.

Definition in file filter_util.c.

#include "filter_util.h"
#include <assert.h>
#include <math.h>
#include <string.h>

Go to the source code of this file.

Macros

#define MAX_Q   7
 Maximum possible value of q in init_recursive_filter()
 

Functions

void recursive_filter_impulse (num *h, long N, const num *b, int p, const num *a, int q)
 Compute taps of the impulse response of a causal recursive filter. More...
 
void init_recursive_filter (num *dest, const num *src, long N, long stride, const num *b, int p, const num *a, int q, num sum, num tol, long max_iter)
 Initialize a causal recursive filter with boundary extension. More...
 

Function Documentation

void init_recursive_filter ( num dest,
const num src,
long  N,
long  stride,
const num b,
int  p,
const num a,
int  q,
num  sum,
num  tol,
long  max_iter 
)

Initialize a causal recursive filter with boundary extension.

Parameters
destdestination array with size of at least q
srcinput signal of length N
Nlength of src
stridethe stride between successive samples of src
bnumerator coefficients
plargest delay of the numerator
adenominator coefficients
qlargest delay of the denominator
sumthe L^1 norm of the impulse response
tolaccuracy tolerance
max_itermaximum number of samples to use for approximation

This routine initializes a recursive filter,

\[ \begin{aligned} u_n &= b_0 f_n + b_1 f_{n-1} + \cdots + b_p f_{n-p} &\quad - a_1 u_{n-1} - a_2 u_{n-2} - \cdots - a_q u_{n-q}, \end{aligned} \]

with boundary extension by approximating the infinite sum

\[ u_m=\sum_{n=-m}^\infty h_{n+m}\Tilde{f}_{-n} \approx \sum_{n=-m}^{k-1} h_{n+m} \Tilde{f}_{-n}, \quad m = 0, \ldots, q - 1. \]

Definition at line 86 of file filter_util.c.

void recursive_filter_impulse ( num h,
long  N,
const num b,
int  p,
const num a,
int  q 
)

Compute taps of the impulse response of a causal recursive filter.

Parameters
hdestination array of size N
Nnumber of taps to compute (beginning from n = 0)
bnumerator coefficients
plargest delay of the numerator
adenominator coefficients
qlargest delay of the denominator

Computes taps $ h_0, \ldots, h_{N-1} $ of the impulse response of the recursive filter

\[ H(z) = \frac{b[0] + b[1]z^{-1} + \cdots + b[p]z^{-p}} {1 + a[1]z^{-1} + \cdots + a[q]z^{-q}}, \]

or equivalently

\[ \begin{aligned} h[n] = & b[0]\delta_n + b[1]\delta_{n-1}+\cdots + b[p]\delta_{n-p}\\ & -a[1]h[n-1]-\cdots -a[q]h[n-q], \end{aligned} \]

for n = 0, ..., N-1 where $ \delta $ is the unit impulse. In the denominator coefficient array, element a[0] is not used.

Definition at line 47 of file filter_util.c.