RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mod_yuwa.cpp
Go to the documentation of this file.
1 //
2 // File = mod_yuwa.cpp
3 //
4 
5 #include "mod_yuwa.h"
6 #include "autometh.h"
7 #include "gen_lev.h"
8 #include "matrix_t.h"
9 #include "yulewalk.h"
10 #include <fstream>
11 #include <stdlib.h>
12 
13 #ifdef _DEBUG
14 extern std::ofstream DebugFile;
15 #endif
16 
17 template <class T>
18 ModYuleWalker<T>::ModYuleWalker(T* signal, int seq_len, int ar_order,
19  int ma_order)
20 {
21  int err_stat;
22  double epsilon = 0.0001;
23 
24  matrix<T> a_work(1, ar_order, 1, ar_order);
25  matrix<T> b_work(1, ar_order, 1, ar_order);
26 
27  Ar_Order = ar_order;
28  Ma_Order = ma_order;
29  A_Vec = new T[ar_order + 1];
30  Correl_Matrix =
31  new AutocorrMethCorrMtx<T>(signal, seq_len, ar_order + ma_order + 1);
32  Toeplitz_Corr_Matrix = Correl_Matrix->GetCol(1);
33 
34  err_stat = GeneralizedLevinson(Toeplitz_Corr_Matrix, ar_order, ma_order,
35  epsilon, A_Vec);
36 #ifdef _DEBUG
37  DebugFile << "returned to ModYuleWalker" << std::endl;
38  DebugFile << "err_stat = " << err_stat << std::endl;
39  for (int indx = 0; indx <= ar_order; indx++) {
40  DebugFile << "A_Vec[ " << indx << " ] = " << A_Vec[indx] << std::endl;
41  }
42 #endif
43  return;
44 }
45 
46 template <class T>
48 {
49  delete Correl_Matrix;
50  delete[] Toeplitz_Corr_Matrix;
51  delete[] A_Vec;
52  return;
53 }
54 
55 template <class T>
56 T*
58 {
59  T *a_vec, *src_ptr, *dest_ptr;
60  src_ptr = A_Vec;
61  a_vec = new T[Ar_Order + 1];
62  dest_ptr = a_vec;
63  for (int i = 0; i <= Ar_Order; i++) {
64  *dest_ptr = *src_ptr;
65  dest_ptr++;
66  src_ptr++;
67  }
68  return (a_vec);
69 }
70 
71 template <class T>
72 double
74 {
75  return (Ar_Drv_Var);
76 };
77 
78 template class ModYuleWalker<double>;
79 template class ModYuleWalker<complex>;
T * GetCol(int col_indx)
Definition: toeplitz.cpp:19
double GetDrivingVariance(void)
Definition: mod_yuwa.cpp:73
ModYuleWalker(T *signal, int seq_len, int ar_order, int ma_order)
Definition: mod_yuwa.cpp:18
~ModYuleWalker(void)
Definition: mod_yuwa.cpp:47
std::ofstream DebugFile
int GeneralizedLevinson(double *acf, int ar_ord, int ma_ord, double epsilon, double *a_vec)
Definition: gen_lev.cpp:12
T * GetCoeffs(void)
Definition: mod_yuwa.cpp:57