[Top][All Lists]

```Author: n4hy
Date: 2009-08-13 14:16:03 -0600 (Thu, 13 Aug 2009)
New Revision: 11589

Modified:

Log:
transfer function to zeros, poles, gain added, but not completely tested.  Uses
gsl polynomial solver

Modified:
===================================================================
---
2009-08-12 22:52:44 UTC (rev 11588)
+++
2009-08-13 20:16:03 UTC (rev 11589)
@@ -301,33 +301,38 @@
{
int size = tf.a.size();
gsl_poly_complex_workspace *w;
-  double *a,*b;
-  gr_complexd *z;
+  double *a,*b,*z;
gr_iirdes::zpk rtn;
-  gr_complexd *zero, *pole;
+

if (size < 2) throw std::invalid_argument
("transfer function to pole, zero, gain calculation requires
order 2 or greater");
-
+  rtn.order = size;
+  rtn.z = new gr_complexd(size);
+  rtn.p = new gr_complexd(size);
w = gsl_poly_complex_workspace_alloc(size);
-  z = new gr_complexd(size);
+  z = new double(size);
a = new double(size);
b = new double(size);
+
for (int i=0;i<size;i++) {
a[i]=tf.a[i];
b[i]=tf.b[i];
+    z[2*i]=0;
+    z[2*i+1]=0;
}
-
+
// compute zeros
-  gsl_poly_complex_solve (&a[0], size, w, (double *)z);
+  gsl_poly_complex_solve (&a[0], size, w, z);
// store them in the zeros in the zpk array
for (int i=0;i<size;i++)
-    zero[i]=z[i];
+    rtn.z[i] = gr_complexd(z[2*i],z[2*i+1]);

// compute poles
-  gsl_poly_complex_solve (&b[0], size, w, (double *)z);
+  gsl_poly_complex_solve (&b[0], size, w, z);
for (int i=0;i<size;i++)
-    pole[i]=z[i];
+    rtn.p[i] = gr_complexd(z[2*i],z[2*i+1]);
+
rtn.k = tf.b[0]/tf.a[0];

return rtn;

Modified:
===================================================================
---
2009-08-12 22:52:44 UTC (rev 11588)
+++
2009-08-13 20:16:03 UTC (rev 11589)
@@ -60,14 +60,15 @@
} transfer_function;

typedef struct _zpk {
-    std::vector<gr_complexd> *z;
-    std::vector<gr_complexd> *p;
+    gr_complexd *z;
+    gr_complexd *p;
+    int order;
double k;
} zpk;

typedef struct _sos {
-    std::vector<double> Num;
-    std::vector<double> Den;
+    std::vector<double> num;
+    std::vector<double> den;
double g;
} sos;

Modified:
===================================================================
---
2009-08-12 22:52:44 UTC (rev 11588)
+++
2009-08-13 20:16:03 UTC (rev 11589)
@@ -50,14 +50,14 @@
} transfer_function;

typedef struct _zpk {
-    std::vector<double> *z;
-    std::vector<double> *p;
+    std::vector<gr_complexd> z;
+    std::vector<gr_complexd> p;
double               k;
} zpk;

typedef struct _sos {
-    std::vector<double> Num;
-    std::vector<double> Den;
+    std::vector<double> num;
+    std::vector<double> den;
double g;
} sos;

Modified:
===================================================================
---
2009-08-12 22:52:44 UTC (rev 11588)
+++
2009-08-13 20:16:03 UTC (rev 11589)
@@ -29,3 +29,5 @@
30)
print numbers

+
+

```