IT++ Logo

Filtering
[Signal Processing (SP) Module]

Classes

class  itpp::Filter< T1, T2, T3 >
 Virtual Filter Base Class.The class is templated as follows:. More...
class  itpp::MA_Filter< T1, T2, T3 >
 Moving Average Filter Base Class.This class implements a moving average (MA) filter according to

\[ y(n) = b(0)*x(n) + b(1)*x(n-1) + ... + b(N)*x(n-N) \]

where b is the filter coefficients, x is the input and y is the output. More...

class  itpp::AR_Filter< T1, T2, T3 >
 Autoregressive (AR) Filter Base Class.This class implements a autoregressive (AR) filter according to

\[ a(0)*y(n) = x(n) - a(1)*y(n-1) - ... - a(N)*y(n-N) \]

where a is the filter coefficients, x is the input and y is the output. More...

class  itpp::ARMA_Filter< T1, T2, T3 >
 Autoregressive Moving Average (ARMA) Filter Base Class.This class implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

. More...

class  itpp::Freq_Filt< Num_T >
 Freq_Filt Frequency domain filtering using the overlap-add techniqueThe Freq_Filt class implements an FFT based filter using the overlap-add technique. The data is filtered by first transforming the input sequence into the frequency domain with an efficient FFT implementation (i.e. FFTW) and then multiplied with a Fourier transformed version of the impulse response. The resulting data is then inversed Fourier transformed to return a filtered time domain signal. More...

Functions

vec itpp::fir1 (int N, double cutoff)
 Design a Nth order FIR filter with cut-off frequency cutoff using the window method.
void itpp::filter_design_autocorrelation (const int N, const vec &f, const vec &m, vec &R)
 Calculate autocorrelation from the specified frequency-response (suitable for filter design).
void itpp::modified_yule_walker (const int m, const int n, const int N, const vec &R, vec &a)
 Estimation of AR-part in an ARMA model given the autocorrelation.
void itpp::arma_estimator (const int m, const int n, const vec &R, vec &b, vec &a)
 Estimation of ARMA model given the autocorrelation.
void itpp::yulewalk (const int N, const vec &f, const vec &m, vec &b, vec &a)
 ARMA filter design using a least-squares fit to the specified frequency-response.



vec itpp::filter (const vec &b, const vec &a, const vec &input)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

void itpp::polystab (const vec &a, vec &out)
 Polynomial Stabilization.
void itpp::freqz (const cvec &b, const cvec &a, const int N, cvec &h, vec &w)
 Frequency response of filter.
cvec itpp::filter (const vec &b, const vec &a, const cvec &input)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const cvec &b, const cvec &a, const cvec &input)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const cvec &b, const cvec &a, const vec &input)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

vec itpp::filter (const vec &b, const int one, const vec &input)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const vec &b, const int one, const cvec &input)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const cvec &b, const int one, const cvec &input)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const cvec &b, const int one, const vec &input)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

vec itpp::filter (const int one, const vec &a, const vec &input)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const int one, const vec &a, const cvec &input)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const int one, const cvec &a, const cvec &input)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const int one, const cvec &a, const vec &input)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

vec itpp::filter (const vec &b, const vec &a, const vec &input, const vec &state_in, vec &state_out)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const vec &b, const vec &a, const cvec &input, const cvec &state_in, cvec &state_out)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const cvec &b, const cvec &a, const cvec &input, const cvec &state_in, cvec &state_out)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const cvec &b, const cvec &a, const vec &input, const cvec &state_in, cvec &state_out)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

vec itpp::filter (const vec &b, const int one, const vec &input, const vec &state_in, vec &state_out)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const vec &b, const int one, const cvec &input, const cvec &state_in, cvec &state_out)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const cvec &b, const int one, const cvec &input, const cvec &state_in, cvec &state_out)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const cvec &b, const int one, const vec &input, const cvec &state_in, cvec &state_out)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

vec itpp::filter (const int one, const vec &a, const vec &input, const vec &state_in, vec &state_out)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const int one, const vec &a, const cvec &input, const cvec &state_in, cvec &state_out)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const int one, const cvec &a, const cvec &input, const cvec &state_in, cvec &state_out)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

cvec itpp::filter (const int one, const cvec &a, const vec &input, const cvec &state_in, cvec &state_out)
 ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

void itpp::polystab (const cvec &a, cvec &out)
 Polynomial Stabilization.
cvec itpp::freqz (const cvec &b, const cvec &a, const int N)
 Polynomial Stabilization.
cvec itpp::freqz (const cvec &b, const cvec &a, const vec &w)
 Polynomial Stabilization.
void itpp::freqz (const vec &b, const vec &a, const int N, cvec &h, vec &w)
 Polynomial Stabilization.
cvec itpp::freqz (const vec &b, const vec &a, const int N)
 Polynomial Stabilization.
cvec itpp::freqz (const vec &b, const vec &a, const vec &w)
 Polynomial Stabilization.
vec itpp::polystab (const vec &a)
 Polynomial Stabilization.
cvec itpp::polystab (const cvec &a)
 Polynomial Stabilization.
void itpp::poly (const vec &r, vec &p)
 Create a polynomial of the given rootsCreate a polynomial p with roots r.
void itpp::poly (const cvec &r, cvec &p)
 Create a polynomial of the given rootsCreate a polynomial p with roots r.
void itpp::roots (const vec &p, cvec &r)
 Calculate the roots of the polynomialCalculate the roots r of the polynomial p.
void itpp::roots (const cvec &p, cvec &r)
 Create a polynomial of the given rootsCreate a polynomial p with roots r.
vec itpp::polyval (const vec &p, const vec &x)
 Evaluate polynomialEvaluate the polynomial p (of length $N+1$ at the points x The output is given by

\[ p_0 x^N + p_1 x^{N-1} + \ldots + p_{N-1} x + p_N \]

.

cvec itpp::polyval (const vec &p, const cvec &x)
 Create a polynomial of the given rootsCreate a polynomial p with roots r.
cvec itpp::polyval (const cvec &p, const vec &x)
 Create a polynomial of the given rootsCreate a polynomial p with roots r.
cvec itpp::polyval (const cvec &p, const cvec &x)
 Create a polynomial of the given rootsCreate a polynomial p with roots r.
vec itpp::poly (const vec &r)
 Create a polynomial of the given rootsCreate a polynomial p with roots r.
cvec itpp::poly (const cvec &r)
 Create a polynomial of the given rootsCreate a polynomial p with roots r.
cvec itpp::roots (const vec &p)
 Create a polynomial of the given rootsCreate a polynomial p with roots r.
cvec itpp::roots (const cvec &p)
 Create a polynomial of the given rootsCreate a polynomial p with roots r.
vec itpp::xcorr_old (const vec &x, const int max_lag=-1, const std::string scaleopt="none")
 Auto-correlation calculation.
vec itpp::xcorr (const vec &x, const int max_lag, const std::string scaleopt)
 Auto-correlation calculation.
vec itpp::xcorr (const vec &x, const vec &y, const int max_lag, const std::string scaleopt)
 Auto-correlation calculation.
void itpp::xcorr (const vec &x, const vec &y, vec &out, const int max_lag, const std::string scaleopt)
 Auto-correlation calculation.
void itpp::xcorr_old (const vec &x, const vec &y, vec &out, const int max_lag=-1, const std::string scaleopt="none")
 Cross-correlation calculation.
vec itpp::xcorr_old (const vec &x, const vec &y, const int max_lag=-1, const std::string scaleopt="none")
 Cross-correlation calculation.

Function Documentation

vec itpp::filter ( const vec b,
const vec a,
const vec input 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

void itpp::polystab ( const vec a,
vec out 
)

Polynomial Stabilization.

Author:
Tony Ottosson

Stabilizes the polynomial transfer function by replacing all roots outside the unit cirlce with their reflection inside the unit circle.

Referenced by itpp::polystab().

void itpp::freqz ( const cvec b,
const cvec a,
const int  N,
cvec h,
vec w 
)

Frequency response of filter.

Author:
Tony Ottosson

Calculates the N-point frequency response of the supplied digital filter over the frequencies w. If w is not given the response is evaluated over the range 0 to $\pi$ with N values. The default value of N is 512.

If w is supplied polyval() is used. Otherwise the calculation is based on the fft.

void itpp::filter_design_autocorrelation ( const int  N,
const vec f,
const vec m,
vec R 
)

Calculate autocorrelation from the specified frequency-response (suitable for filter design).

Author:
Tony Ottosson

Calculates the autocorrelation function of size N corresponding to the specified frequency response. Useful as a first step in designing filters.

The vectors f and m is the frequency response. The frequencies should be between 0 and 1.0 (equal to half the sample rate) in increasing order. Both 0.0 and 1.0 must be included. The frequency response is upsampled to 512 points and the autocorrelation is ifft of the power magnitude response of the upsampled frequency response.

void itpp::modified_yule_walker ( const int  m,
const int  n,
const int  N,
const vec R,
vec a 
)

Estimation of AR-part in an ARMA model given the autocorrelation.

Author:
Tony Ottosson

Estimates the AR-part of an ARMA model from the given autocorrelation. The AR part is of order n. The overdetermined modified Yule-Walker equations are used.

If $N>n$ then the system is overdetermined and a least squares solution is used. As a rule of thumb use $N = 4 n$

The parameter m is the order of the MA-part such that $R(k) = 0, \forall \|k\| > m$.

The supplied autocorrelation should at least be of size N.

References: Stoica and Moses, Introduction to spectral analysis, Prentice Hall, 1997.

void itpp::arma_estimator ( const int  m,
const int  n,
const vec R,
vec b,
vec a 
)

Estimation of ARMA model given the autocorrelation.

Author:
Tony Ottosson

Estimates an ARMA model from the given autocorrelation. The AR part is of order n and the MA part is of order m.

The AR part (the denominator) is calcuated using the modified Yule-Walker equations. The the MA part (the nominator) is calculated by calculating the inverse magnitude spectrum using FFTs of size 512 which is an AR-system. This AR-system is then solved using the Levinson-Durbin algorithm.

The supplied autocorrelation is windowed using a Hamming window of size $2(m+n)$ and hence should at least be of that size.

References: [1] Stoica and Moses, Introduction to spectral analysis, Prentice Hall, 1997. [2] B. Friedlander and B. Porat, The modified Yule-Walker method of ARMA spectral estimation, IEEE Trans. Aerospace and Electronic Systems, Vol. AES-20, No. 2, pp. 158--173, March 1984.

void itpp::yulewalk ( const int  N,
const vec f,
const vec m,
vec b,
vec a 
)

ARMA filter design using a least-squares fit to the specified frequency-response.

Author:
Tony Ottosson

The arma_estimator() function is used to calculate the a and b coefficients.

The vectors f and m is the frequency response. The frequencies should be between 0 and 1.0 (equal to half the sample rate) in increasing order. Both 0.0 and 1.0 must be included. The filter_design_autocorrelation() fucnction is used to interpolate the frequency response and calculate the corresponding autocorrelation.

Observe: this function will not always give exactly the same result as the matlab yulewalk function.

cvec itpp::filter ( const vec b,
const vec a,
const cvec input 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const cvec b,
const cvec a,
const cvec input 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const cvec b,
const cvec a,
const vec input 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

vec itpp::filter ( const vec b,
const int  one,
const vec input 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const vec b,
const int  one,
const cvec input 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const cvec b,
const int  one,
const cvec input 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const cvec b,
const int  one,
const vec input 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

vec itpp::filter ( const int  one,
const vec a,
const vec input 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const int  one,
const vec a,
const cvec input 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const int  one,
const cvec a,
const cvec input 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const int  one,
const cvec a,
const vec input 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

vec itpp::filter ( const vec b,
const vec a,
const vec input,
const vec state_in,
vec state_out 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const vec b,
const vec a,
const cvec input,
const cvec state_in,
cvec state_out 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const cvec b,
const cvec a,
const cvec input,
const cvec state_in,
cvec state_out 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const cvec b,
const cvec a,
const vec input,
const cvec state_in,
cvec state_out 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

vec itpp::filter ( const vec b,
const int  one,
const vec input,
const vec state_in,
vec state_out 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const vec b,
const int  one,
const cvec input,
const cvec state_in,
cvec state_out 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const cvec b,
const int  one,
const cvec input,
const cvec state_in,
cvec state_out 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const cvec b,
const int  one,
const vec input,
const cvec state_in,
cvec state_out 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

vec itpp::filter ( const int  one,
const vec a,
const vec input,
const vec state_in,
vec state_out 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const int  one,
const vec a,
const cvec input,
const cvec state_in,
cvec state_out 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const int  one,
const cvec a,
const cvec input,
const cvec state_in,
cvec state_out 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

cvec itpp::filter ( const int  one,
const cvec a,
const vec input,
const cvec state_in,
cvec state_out 
)

ARMA filter functionThese functions implements a autoregressive moving average (ARMA) filter according to

\[ a(0)*y(n) = b(0)*x(n) + b(1)*x(n-1) + \ldots + b(N_b)*x(n-N_b) - a(1)*y(n-1) - \ldots - a(N_a)*y(n-N_a) \]

.

where a and b are the filter coefficients, x is the input and y is the output.

Setting a=1 gives a MA filter and b=1 gives a AR filter. The length of the output vector equals the length of the input vector. The state vectors state_in and state_out is of length $max(N_a, n_b) - 1$.

If no start state state_in is given it is set to zero.

void itpp::polystab ( const cvec a,
cvec out 
)

Polynomial Stabilization.

Author:
Tony Ottosson

Stabilizes the polynomial transfer function by replacing all roots outside the unit cirlce with their reflection inside the unit circle.

cvec itpp::freqz ( const cvec b,
const cvec a,
const int  N 
)

Polynomial Stabilization.

Author:
Tony Ottosson

Stabilizes the polynomial transfer function by replacing all roots outside the unit cirlce with their reflection inside the unit circle.

cvec itpp::freqz ( const cvec b,
const cvec a,
const vec w 
)

Polynomial Stabilization.

Author:
Tony Ottosson

Stabilizes the polynomial transfer function by replacing all roots outside the unit cirlce with their reflection inside the unit circle.

void itpp::freqz ( const vec b,
const vec a,
const int  N,
cvec h,
vec w 
)

Polynomial Stabilization.

Author:
Tony Ottosson

Stabilizes the polynomial transfer function by replacing all roots outside the unit cirlce with their reflection inside the unit circle.

cvec itpp::freqz ( const vec b,
const vec a,
const int  N 
)

Polynomial Stabilization.

Author:
Tony Ottosson

Stabilizes the polynomial transfer function by replacing all roots outside the unit cirlce with their reflection inside the unit circle.

cvec itpp::freqz ( const vec b,
const vec a,
const vec w 
)

Polynomial Stabilization.

Author:
Tony Ottosson

Stabilizes the polynomial transfer function by replacing all roots outside the unit cirlce with their reflection inside the unit circle.

vec itpp::polystab ( const vec a  )  [inline]

Polynomial Stabilization.

Author:
Tony Ottosson

Stabilizes the polynomial transfer function by replacing all roots outside the unit cirlce with their reflection inside the unit circle.

Definition at line 56 of file filter_design.h.

References itpp::polystab().

cvec itpp::polystab ( const cvec a  )  [inline]

Polynomial Stabilization.

Author:
Tony Ottosson

Stabilizes the polynomial transfer function by replacing all roots outside the unit cirlce with their reflection inside the unit circle.

Definition at line 58 of file filter_design.h.

References itpp::polystab().

vec itpp::xcorr_old ( const vec x,
const int  max_lag = -1,
const std::string  scaleopt = "none" 
)

Auto-correlation calculation.

z=xcorr(x,max_lag), where x and is a length M vector (M>1), returns the length 2*max_lag+1 auto-correlation sequence z. (lags: -max_lag,...,0,...,max_lag)

For max_lag=-1 the auto-correlation sequence is of length 2*M-1, i.e., the cross correlation for all possible lags.

Scaling options scaleopt:

  • none => No scaling of the auto-correlation vector
  • biased => Scales the auto-correlation vector by 1/M
  • unbiased => Scales the auto-correlation vector by 1/(M-abs(lag))
  • coeff => Normalises the auto-correlation so that acf(x)=1 for zero lag.
Note:
max_lag <= M-1
Parameters:
x (Input) Vector of samples
max_lag (Input) Maximum lag for which the auto-correlation is calculated. The output vector is of size 2*maxlag+1. Default value max_lag=-1 calculates the auto-correlations for all possible lags.
scaleopt (Input) Indicates how the auto-correlation function should be scaled. Default value: "none" indicates that no scaling is done.
Returns:
The auto-correlation of x.
vec itpp::xcorr ( const vec x,
const int  max_lag,
const std::string  scaleopt 
)

Auto-correlation calculation.

z=xcorr(x,max_lag), where x and is a length M vector (M>1), returns the length 2*max_lag+1 auto-correlation sequence z. (lags: -max_lag,...,0,...,max_lag)

For max_lag=-1 the auto-correlation sequence is of length 2*M-1, i.e., the cross correlation for all possible lags.

Scaling options scaleopt:

  • none => No scaling of the auto-correlation vector
  • biased => Scales the auto-correlation vector by 1/M
  • unbiased => Scales the auto-correlation vector by 1/(M-abs(lag))
  • coeff => Normalises the auto-correlation so that acf(x)=1 for zero lag.
Note:
max_lag <= M-1
Parameters:
x (Input) Vector of samples
max_lag (Input) Maximum lag for which the auto-correlation is calculated. The output vector is of size 2*maxlag+1. Default value max_lag=-1 calculates the auto-correlations for all possible lags.
scaleopt (Input) Indicates how the auto-correlation function should be scaled. Default value: "none" indicates that no scaling is done.
Returns:
The auto-correlation of x.
vec itpp::xcorr ( const vec x,
const vec y,
const int  max_lag,
const std::string  scaleopt 
)

Auto-correlation calculation.

z=xcorr(x,max_lag), where x and is a length M vector (M>1), returns the length 2*max_lag+1 auto-correlation sequence z. (lags: -max_lag,...,0,...,max_lag)

For max_lag=-1 the auto-correlation sequence is of length 2*M-1, i.e., the cross correlation for all possible lags.

Scaling options scaleopt:

  • none => No scaling of the auto-correlation vector
  • biased => Scales the auto-correlation vector by 1/M
  • unbiased => Scales the auto-correlation vector by 1/(M-abs(lag))
  • coeff => Normalises the auto-correlation so that acf(x)=1 for zero lag.
Note:
max_lag <= M-1
Parameters:
x (Input) Vector of samples
max_lag (Input) Maximum lag for which the auto-correlation is calculated. The output vector is of size 2*maxlag+1. Default value max_lag=-1 calculates the auto-correlations for all possible lags.
scaleopt (Input) Indicates how the auto-correlation function should be scaled. Default value: "none" indicates that no scaling is done.
Returns:
The auto-correlation of x.
void itpp::xcorr ( const vec x,
const vec y,
vec out,
const int  max_lag,
const std::string  scaleopt 
)

Auto-correlation calculation.

z=xcorr(x,max_lag), where x and is a length M vector (M>1), returns the length 2*max_lag+1 auto-correlation sequence z. (lags: -max_lag,...,0,...,max_lag)

For max_lag=-1 the auto-correlation sequence is of length 2*M-1, i.e., the cross correlation for all possible lags.

Scaling options scaleopt:

  • none => No scaling of the auto-correlation vector
  • biased => Scales the auto-correlation vector by 1/M
  • unbiased => Scales the auto-correlation vector by 1/(M-abs(lag))
  • coeff => Normalises the auto-correlation so that acf(x)=1 for zero lag.
Note:
max_lag <= M-1
Parameters:
x (Input) Vector of samples
max_lag (Input) Maximum lag for which the auto-correlation is calculated. The output vector is of size 2*maxlag+1. Default value max_lag=-1 calculates the auto-correlations for all possible lags.
scaleopt (Input) Indicates how the auto-correlation function should be scaled. Default value: "none" indicates that no scaling is done.
Returns:
The auto-correlation of x.
void itpp::xcorr_old ( const vec x,
const vec y,
vec out,
const int  max_lag = -1,
const std::string  scaleopt = "none" 
)

Cross-correlation calculation.

z=xcorr(x,y,max_lag), where x and y are length M vectors (M>1), returns the length 2*max_lag+1 cross-correlation sequence z. (lags: -max_lag,...,0,...,max_lag)

For max_lag=-1 the cross-correlation sequence is of length 2*M-1, i.e., the cross-correlation for all possible lags.

Scaling options scaleopt:

  • none => No scaling of the cross-correlation vector
  • biased => Scales the cross-correlation vector by 1/M
  • unbiased => Scales the cross-correlation vector by 1/(M-abs(lag))
  • coeff => Normalises the cross-correlation to 1 for zero lag.
Note:
max_lag <= M-1
If x and y are of different length, the shortest one is zero-padded
Parameters:
x (Input) Vector of samples
y (Input) Vector of samples
out (Output) The cross correlation between x and y.
max_lag (Input) Maximum lag for which the cross-correlation is calculated. The output vector is of size 2*maxlag+1. Default value: max_lag=-1 calculates the cross-correlations for all possible lags
scaleopt (Input) Indicates how the cross-correlation function should be scaled. Default value: "none" indicates that no scaling is done
vec itpp::xcorr_old ( const vec x,
const vec y,
const int  max_lag = -1,
const std::string  scaleopt = "none" 
)

Cross-correlation calculation.

z=xcorr(x,y,max_lag), where x and y are length M vectors (M>1), returns the length 2*max_lag+1 cross-correlation sequence z. (lags: -max_lag,...,0,...,max_lag)

For max_lag=-1 the cross-correlation sequence is of length 2*M-1, i.e., the cross-correlation for all possible lags.

Scaling options scaleopt:

  • none => No scaling of the cross-correlation vector
  • biased => Scales the cross-correlation vector by 1/M
  • unbiased => Scales the cross-correlation vector by 1/(M-abs(lag))
  • coeff => Normalises the cross-correlation to 1 for zero lag.
Note:
max_lag <= M-1
If x and y are of different length, the shortest one is zero-padded
Parameters:
x (Input) Vector of samples
y (Input) Vector of samples
max_lag (Input) Maximum lag for which the cross-correlation is calculated. The output vector is of size 2*maxlag+1. Default value: max_lag=-1 calculates the cross-correlations for all possible lags
scaleopt (Input) Indicates how the cross-correlation function should be scaled. Default value: "none" indicates that no scaling is done
Returns:
The cross correlation between x and y.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SourceForge Logo

Generated on Tue Nov 23 08:45:12 2010 for IT++ by Doxygen 1.6.1