Output
Filter coeffs:
-0.0051 0.0134 0.1474 0.3444 0.3444 0.1474 0.0134 -0.0051
Impulse response:
-0.0051 0.0134 0.1474 0.3444 0.3444 0.1474 0.0134 -0.0051 0 0 0
*0 0 0 0
IIR theor. impulse response:
0.2500 0.7250 0.9025 0.8123 0.7310 0.6579 0.5921 0.5329 0.4796
*0.4317 0.3885 ... IIR output: 0.2500 0.7250 0.9025 0.8123 0.7310
*0.6579 0.5921 0.5329 0.4796 0.4317 0.3885 0.3496 0.3147 0.2832
*0.2549
Delay three samples:
0 0 0 0.2500 0.7250 0.9025 0.8123 0.7310 0.6579
*0.5921 0.5329 0.4796 0.4317 0.3885 0.3496
Source
{
vec b;
int N = 15;
vec X(N);
X.zeros();
X[0] = 1;
vec Y(N);
Y.zeros();
for (int n = 0; n < N; n++)
{
Y[n] = fir_filt(X[n]);
}
std::cout << "Filter coeffs: \n" << b.t() << std::endl;
std::cout << "Impulse response:\n" << Y.t() << std::endl;
vec a;
b << 0.25 << 0.5 << 0.25 << endr;
a << 1.0 << -0.9 << endr;
std::cout
<< "IIR theor. impulse response: \n 0.2500 0.7250 0.9025 0.8123 "
" 0.7310 0.6579 0.5921 0.5329 0.4796 0.4317 0.3885 ..."
<< std::endl;
std::cout << "IIR output: \n" << Y.t() << std::endl;
std::cout <<
"Delay three samples:\n" << del.
delay(Y).t() << std::endl;
return 0;
}