commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r11586 - gnuradio/branches/developers/n4hy/pfb_iir2/gn


From: n4hy
Subject: [Commit-gnuradio] r11586 - gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general
Date: Wed, 12 Aug 2009 13:09:55 -0600 (MDT)

Author: n4hy
Date: 2009-08-12 13:09:55 -0600 (Wed, 12 Aug 2009)
New Revision: 11586

Modified:
   
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.cc
   
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.h
   
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.i
Log:
buggy but getting there on tf2zpk

Modified: 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.cc
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.cc
       2009-08-12 18:38:51 UTC (rev 11585)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.cc
       2009-08-12 19:09:55 UTC (rev 11586)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2002,2007,2008 Free Software Foundation, Inc.
+ * Copyright 2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -299,7 +299,32 @@
 gr_iirdes::zpk
 gr_iirdes::tf2zpg(gr_iirdes::transfer_function tf)
 {
+  int size = tf.a.size();
+  gsl_poly_complex_workspace *w;
+  double a(size),b(size),z(2*size);
   gr_iirdes::zpk rtn;
+  
+  if (size < 2) throw std::invalid_argument
+                 ("transfer function to pole, zero, gain calculation requires 
order 2 or greater");
+
+  std::vector<double> 
+  rtn.p.resize(size);
+  w = gsl_poly_complex_workspace_alloc(size);
+  for (int i=0;i<size;i++)
+    a[i]=tf.a[i],
+      b[i]=tf.b[i];
+  // compute zeros
+  gsl_poly_complex_solve (a, size, w, z);
+  // store them in the zeros in the zpk array
+  for (int i=0;i<size;i++)
+    rtn.z[i]=gr_complex(z[2*i],z[2*i+1]);
+
+  // compute poles
+  gsl_poly_complex_solve (b, size, w, z);
+  for (int i=0;i<size;i++)
+    rtn.p[i]=gr_complex(z[2*i],z[2*i+1]);
+  rtn.k = tf.b[0]/tf.a[0];
+
   return rtn;
 }
 

Modified: 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.h
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.h
        2009-08-12 18:38:51 UTC (rev 11585)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.h
        2009-08-12 19:09:55 UTC (rev 11586)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2002,2008 Free Software Foundation, Inc.
+ * Copyright 2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -27,8 +27,12 @@
 
 #include <cmath>
 #include <vector>
+#include <gr_complex.h>
+#ifndef __cplusplus
+#define __cplusplus
+#endif
+#include <gsl/gsl_poly.h>
 
-
 class gr_iirdes {
 
  public:
@@ -56,9 +60,9 @@
   } transfer_function;
 
   typedef struct _zpk {
-    std::vector<double> Z;
-    std::vector<double> P;
-    std::vector<double> k;
+    std::vector<gr_complex> *z;
+    std::vector<gr_complex> *p;
+    double k;
   } zpk;
 
   typedef struct _sos {

Modified: 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.i
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.i
        2009-08-12 18:38:51 UTC (rev 11585)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.i
        2009-08-12 19:09:55 UTC (rev 11586)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2002,2008 Free Software Foundation, Inc.
+ * Copyright 2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]