RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
stpinvar.cpp
Go to the documentation of this file.
1 //
2 // File = stpinvar.cpp
3 //
4 
5 #include "stpinvar.h"
6 
7 void
8 StepInvar(complex* pole, int num_poles, complex* zero, int num_zeros,
9  double h_sub_zero, double big_t, complex* a, complex* b)
10 {
11  int k, n, j, max_coef;
12  complex *delta, *big_a;
13  complex beta, denom, numer, work2;
14 
15  delta = new complex[num_poles + 1];
16  big_a = new complex[num_poles + 1];
17 
18  for (j = 0; j <= num_poles; j++) {
19  delta[j] = complex(0.0, 0.0);
20  a[j] = complex(0.0, 0.0);
21  b[j] = complex(0.0, 0.0);
22  }
23  pole[0] = complex(0.0, 0.0);
24 
25  //---------------------------------------------------
26  // compute partial fraction expansion coefficients
27 
28  for (k = 0; k <= num_poles; k++) {
29  numer = complex(h_sub_zero, 0.0);
30  for (n = 1; n <= num_zeros; n++) {
31  numer *= (pole[n] - zero[n]);
32  }
33  denom = complex(1.0, 0.0);
34  for (n = 0; n <= num_poles; n++) {
35  if (n == k)
36  continue;
37  denom *= (pole[k] - pole[n]);
38  }
39  big_a[k] = numer / denom;
40  }
41 
42  //-------------------------------------
43  // compute numerator coefficients
44 
45  for (k = 1; k <= num_poles; k++) {
46  delta[0] = complex(1.0, 0.0);
47  for (n = 1; n <= num_poles; n++) {
48  delta[n] = complex(0.0, 0.0);
49  }
50  max_coef = 0;
51  for (n = 0; n <= num_poles; n++) {
52  if (n == k)
53  continue;
54  max_coef++;
55  beta = -cexp(big_t * pole[n]);
56 
57  for (j = max_coef; j >= 1; j--) {
58  delta[j] += (beta * delta[j - 1]);
59  }
60  }
61  for (j = 0; j < num_poles; j++) {
62  b[j] += (big_a[k] * delta[j]);
63  }
64 
65  // multiply by 1-z**(-1)
66  beta = complex(-1.0, 0.0);
67  for (j = num_poles + 1; j >= 1; j--) {
68  b[j] += (beta * b[j - 1]);
69  }
70  }
71 
72  //-------------------------------------
73  // compute denominator coefficients
74 
75  a[0] = complex(1.0, 0.0);
76  for (n = 1; n <= num_poles; n++) {
77  beta = -cexp(big_t * pole[n]);
78  for (j = n; j >= 1; j--) {
79  a[j] += (beta * a[j - 1]);
80  }
81  }
82  for (j = 1; j <= num_poles; j++) {
83  a[j] = -a[j];
84  }
85 
86  delete[] delta;
87  delete[] big_a;
88 
89  return;
90 }
void StepInvar(complex *pole, int num_poles, complex *zero, int num_zeros, double h_sub_zero, double big_t, complex *a, complex *b)
Definition: stpinvar.cpp:8
complex cexp(const complex _z)
Definition: complex.h:139