RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
yulewalk.cpp
Go to the documentation of this file.
1 //
2 // File = yulewalk.cpp
3 //
4 
5 #include "yulewalk.h"
6 #include "autometh.h"
7 #include "levin.h"
8 #include <fstream>
9 #include <stdlib.h>
10 
11 #ifdef _DEBUG
12 extern std::ofstream DebugFile;
13 #endif
14 
15 template <class T>
16 YuleWalker<T>::YuleWalker(T* signal, int seq_len, int ar_ord, T* a_vec,
17  double* drv_noise_var, int* err_stat)
18 {
19  int idb;
20  Matrix<T>* corr_mtx;
21  corr_mtx = new AutocorrMethCorrMtx<T>(signal, seq_len, ar_ord);
22 
23  T *correl_vec, sum;
24  correl_vec = corr_mtx->GetCol(1);
25 #ifdef _DEBUG
26  for (idb = 0; idb <= ar_ord; idb++) {
27  DebugFile << "R[" << idb << "] = " << correl_vec[idb] << std::endl;
28  }
29 #endif
30  *err_stat = LevinsonRecursion(correl_vec, ar_ord, a_vec, drv_noise_var);
31  std::cout << "err_stat = " << (*err_stat) << std::endl;
32 
33  sum = 0.0;
34  for (idb = 1; idb <= ar_ord; idb++) {
35  sum += a_vec[idb] * correl_vec[idb];
36  }
37  sum = correl_vec[0] - sum;
38  return;
39 }
40 
41 template <class T>
42 YuleWalker<T>::YuleWalker(T* toep_corr_mtx, int ar_ord, T* a_vec,
43  double* drv_noise_var, int* err_stat)
44 {
45  *err_stat = LevinsonRecursion(toep_corr_mtx, ar_ord, a_vec, drv_noise_var);
46  return;
47 }
48 
49 template class YuleWalker<double>;
50 template class YuleWalker<complex>;
virtual T * GetCol(int col_indx)=0
std::ofstream DebugFile
YuleWalker(T *signal, int seq_len, int ar_ord, T *a_vec, double *drv_noise_var, int *err_stat)
Definition: yulewalk.cpp:16
int LevinsonRecursion(double *toeplitz, int ar_order, double *avec, double *ar_drv_var_ret)
Definition: levin.cpp:15
Definition: matrix.h:9