50 for (
int i = 0; i < r.size(); i++) {
52 r(i) = std::complex<double>(1.0) /
conj(r(i));
54 out =
real(std::complex<double>(a(0)) *
poly(r));
62 for (
int i = 0; i < r.size(); i++) {
64 r(i) = std::complex<double>(1.0) /
conj(r(i));
71 void freqz(
const cvec &b,
const cvec &a,
const int N, cvec &h, vec &w)
85 cvec
freqz(
const cvec &b,
const cvec &a,
const int N)
96 cvec
freqz(
const cvec &b,
const cvec &a,
const vec &w)
98 int la = a.size(), lb = b.size(), k =
std::max(la, lb);
111 void freqz(
const vec &b,
const vec &a,
const int N, cvec &h, vec &w)
125 cvec
freqz(
const vec &b,
const vec &a,
const int N)
130 freqz(b, a, N, h, w);
136 cvec
freqz(
const vec &b,
const vec &a,
const vec &w)
138 int la = a.size(), lb = b.size(), k =
std::max(la, lb);
155 it_assert(f.size() == m.size(),
"filter_design_autocorrelation: size of f and m vectors does not agree");
158 it_assert(f(0) == 0.0,
"filter_design_autocorrelation: first frequency must be 0.0");
159 it_assert(f(N_f - 1) == 1.0,
"filter_design_autocorrelation: last frequency must be 1.0");
163 vec m_interp(N_fft + 1);
170 int jstart = 0, jstop;
172 for (
int i = 0; i < N_f - 1; i++) {
174 jstop =
floor_i(f(i + 1) * (N_fft + 1)) - 1;
177 for (
int j = jstart; j <= jstop; j++) {
178 inc = double(j - jstart) / double(jstop - jstart);
179 m_interp(j) = m(i) * (1 - inc) + m(i + 1) * inc;
199 it_assert(m > 0,
"modified_yule_walker: m must be > 0");
200 it_assert(n > 0,
"modified_yule_walker: n must be > 0");
201 it_assert(N <= R.size(),
"modified_yule_walker: autocorrelation function too short");
214 vec rh = - R(m + 1, m + M);
230 it_assert(m > 0,
"arma_estimator: m must be > 0");
231 it_assert(n > 0,
"arma_estimator: n must be > 0");
232 it_assert(2*(m + n) <= R.size(),
"arma_estimator: autocorrelation function too short");
237 vec Rwindow =
elem_mult(R.left(N), 0.54 + 0.46 *
cos(
pi *
linspace(0.0,
double(N - 1), N) /
double(N - 1)));
244 vec r_causal = Rwindow;
250 vec b_causal =
backslash(H_inv_a, r_causal);
258 cvec q =
ifft(cepstrum);
261 q.set_subvector(N_fft / 2,
zeros_c(N_fft / 2));
269 void yulewalk(
const int N,
const vec &f,
const vec &m, vec &b, vec &a)
271 it_assert(f.size() == m.size(),
"yulewalk: size of f and m vectors does not agree");
274 it_assert(f(0) == 0.0,
"yulewalk: first frequency must be 0.0");
275 it_assert(f(N_f - 1) == 1.0,
"yulewalk: last frequency must be 1.0");