commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r11604 - in gnuradio/branches/developers/n4hy/pfb_iir2


From: n4hy
Subject: [Commit-gnuradio] r11604 - in gnuradio/branches/developers/n4hy/pfb_iir2: gnuradio-core/src/lib/general gnuradio-examples/python/apps/filter_design_tool
Date: Sun, 16 Aug 2009 18:45:56 -0600 (MDT)

Author: n4hy
Date: 2009-08-16 18:45:55 -0600 (Sun, 16 Aug 2009)
New Revision: 11604

Modified:
   
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.cc
   
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/apps/filter_design_tool/iirdestest.py
Log:
swig does not seem to handle gr_complexd well at all. I give up.  The 
transformation from transfer function to pole-zero-gain now works perfectly

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-16 15:31:19 UTC (rev 11603)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.cc
       2009-08-17 00:45:55 UTC (rev 11604)
@@ -28,8 +28,8 @@
 
 #include <gr_iirdes.h>
 #include <stdexcept>
+#include <malloc.h>
 
-
 using std::vector;
 
 #define IIReps 2.2e-14 /* threshold for zero or integer taken from Octave
@@ -310,44 +310,47 @@
 {
 
   int size = tf.size()/2;
-  gsl_poly_complex_workspace *w;
-  double a[size],b[size];
-  double *z;
-  vector<double> rtn;
-  rtn[0]=0;
-  /*  
+  double *a,*b,*z;
   if (size < 2) throw std::invalid_argument
-                 ("transfer function to pole, zero, gain calculation requires 
order 2 or greater");
+   ("transfer function to pole, zero, gain calculation requires order 2 or 
greater");
 
+  gsl_poly_complex_workspace *w;
+  vector<double> rtn(4*size-3);
+
+  //  for(int i=0;i<4*size-3;i++) rtn[i]=0;
+  w = gsl_poly_complex_workspace_alloc(size);
+  a = (double *)malloc(size*sizeof(double));
+  b = (double *)malloc(size*sizeof(double));
   for (int i=0;i<size;i++) {
     a[i]=tf[i];
     b[i]=tf[i+size];
   }
+ 
+  z = (double *)malloc(2*(size-1)*sizeof(double));
 
-  w = gsl_poly_complex_workspace_alloc(size);
-  z = new double(2*size);
-
-
-  for (int i=0;i<size;i++) {
+  for (int i=0;i<size-1;i++) {
     z[2*i]=0;
     z[2*i+1]=0;
   }
-  
+    
   // 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[i] = gr_complexd(z[2*i],z[2*i+1]);
+  for (int i=0;i<size-1;i++)
+    rtn[2*i]=z[2*i],rtn[2*i+1]=z[2*i+1];
 
   // compute poles
   gsl_poly_complex_solve (b, size, w, z);
-  for (int i=0;i<size;i++)
-    rtn[i+size] = gr_complexd(z[2*i],z[2*i+1]);
+  for (int i=0;i<size-1;i++)
+    rtn[2*i+2*size-2]=z[2*i],rtn[2*i+2*size-1]=z[2*i+1];
 
-  delete z;
+  gsl_poly_complex_workspace_free(w);
+  rtn[4*size-4]=b[0]/a[0];
+  free(z);
+  free(a);
+  free(b);
+  return rtn;
 
-  */
-  return rtn;
 }
 
 vector<gr_complexd>

Modified: 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/apps/filter_design_tool/iirdestest.py
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/apps/filter_design_tool/iirdestest.py
   2009-08-16 15:31:19 UTC (rev 11603)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/apps/filter_design_tool/iirdestest.py
   2009-08-17 00:45:55 UTC (rev 11604)
@@ -26,11 +26,11 @@
                               [.2, .3],
                               [.1, .4],
                               .1,
-                              30)
+                              110)
 print numbers
 
 
-tf=[0.0976, 0.1953, 0.0976, 1.0, -0.9428, 0.3333]
+tf=[0.0976, 0.1953, 0.0976,0.3333, -0.9428, 1.0]
 order = gr.iirdes.tf2order(tf)
 print order
 zpg = gr.iirdes.tf2zpg(tf)





reply via email to

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