RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
polefilt.cpp
Go to the documentation of this file.
1 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 //
3 // File = polefilt.cpp
4 //
5 // simulation of analog all-pole filter
6 //
7 
8 #include "polefilt.h"
9 #include <math.h>
10 
11 #ifdef _DEBUG
12 extern std::ofstream DebugFile;
13 #endif
14 
15 //======================================================
16 // constructor that actually initializes filter model
17 //------------------------------------------------------
18 
19 AnalogAllPoleFilt::AnalogAllPoleFilt(Polynomial denom_poly, double h_sub_zero,
20  double delta_t)
21 // : AnalogFilter()
22 {
23  int k, order;
24 
25  order = denom_poly.GetDegree();
26 
27  Integrator = new NumericInteg*[order];
28  Y_Prime = new double[order + 1];
29  B_Coef = new double[order];
30 
31  Order = order;
32  H_Sub_Zero = h_sub_zero;
33 
34  for (k = 0; k < order; k++) {
35  Integrator[k] = new NumericInteg(delta_t);
36  B_Coef[k] = -(denom_poly.GetCoefficient(k));
37 #ifdef _DEBUG
38  DebugFile << "in AnalogAllPoleFilt, B_Coef[" << k << "] = " << B_Coef[k]
39  << std::endl;
40 #endif
41  Y_Prime[k] = 0.0;
42  }
43  return;
44 };
45 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
46 
47 //======================================================
48 //
49 //------------------------------------------------------
50 
51 double
53 {
54  double sum;
55  int k;
56 
57  sum = input;
58  for (k = 0; k < Order; k++) {
59  sum += (Y_Prime[k] * B_Coef[k]);
60  }
61  Y_Prime[Order] = sum;
62 
63  for (k = Order - 1; k >= 0; k--) {
64  Y_Prime[k] = ((Integrator[k])->Integrate(Y_Prime[k + 1]));
65  }
66  return (H_Sub_Zero * Y_Prime[0]);
67 }
NumericInteg ** Integrator
Definition: polefilt.h:20
double * B_Coef
Definition: polefilt.h:23
double GetCoefficient(int k)
Definition: poly.cpp:185
double * Y_Prime
Definition: polefilt.h:21
double Run(double input)
Definition: polefilt.cpp:52
std::ofstream DebugFile
AnalogAllPoleFilt(Polynomial denom_poly, double h_sub_zero, double delta_t)
Definition: polefilt.cpp:19
int GetDegree(void)
Definition: poly.cpp:176
double H_Sub_Zero
Definition: polefilt.h:24