commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r11634 - gnuradio/branches/developers/n4hy/pfb_iir/gnu


From: n4hy
Subject: [Commit-gnuradio] r11634 - gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general
Date: Wed, 2 Sep 2009 12:59:26 -0600 (MDT)

Author: n4hy
Date: 2009-09-02 12:59:26 -0600 (Wed, 02 Sep 2009)
New Revision: 11634

Modified:
   
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.cc
   
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.h
Log:
doing the S plane transform function, not complete. It is the toughest piece of 
this puzzle.  All the rest is easy

Modified: 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.cc
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.cc
        2009-08-31 06:54:53 UTC (rev 11633)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.cc
        2009-09-02 18:59:26 UTC (rev 11634)
@@ -458,13 +458,69 @@
 }
 
 vector<double>
-gr_iirdes::sftrans(gr_iirdes::filter_response ft,
+gr_iirdes::sftrans(gr_iirdes::filter_response fresp,
                   std::vector<double> zero,
                   std::vector<double> pole,
                   double k,
-                  std::vector<double> W,
-                  bool stop)
+                  std::vector<double> W)
 {
   vector<double> rtn;
+  int lz=zero.length()/2;
+  int lp=pole.length()/2;
+  double C=1;
+    
+  switch (fresp) {
+  case gr_iirdes::LOWPASS: {
+  }
+  case gr_iirdes::HIGHPASS: {
+  }
+  case gr_iirdes::BANDPASS: {
+    if (W.length() != 2)
+      throw std::invalid_argument("sftrans: BANDSTOP frequency list must be 
two long");
+
+    double Fl=W(1), Fh=W(2);
+  }
+  case gr_iirdes::BANDSTOP: {
+
+## ----------------  -------------------------  ------------------------
+## Band Stop         zero: b +/- sqrt(b^2-FhFl)   pole: b +/- sqrt(b^2-FhFl)
+##        S(Fh-Fl)   pole: +/- sqrt(-FhFl)         zero: +/- sqrt(-FhFl)
+## S -> C --------   gain: -x                   gain: -1/x
+##        S^2+FhFl   b=C/x (Fh-Fl)/2            b=C/x (Fh-Fl)/2
+## ----------------  -------------------------  ------------------------
+
+    if (W.length() != 2)
+      throw std::invalid_argument("sftrans: BANDSTOP frequency list must be 
two long");
+
+    double Fl=W(1), Fh=W(2);
+
+    if ((lz > lp) || (lp==0))
+      throw std::invalid_argument("sftrans: must have at least as many poles 
as zeros in s-plane");
+    if (lz == 0) {
+      gr_complex Z=1;
+      for (int i=0;i<lp;i++)
+       Z *= gr_complex(-pole(2*i),-pole(2*i+1));
+      k /= Z.real();
+    } else if (lp == 0) {
+      gr_complex Z=1;
+      for (int i=0;i<lp;i++)
+       Z *= gr_complex(-zero(2*i),-zero(2*i+1));
+      k *= Z.real();
+    } else {
+      gr_complex Z=1;
+      for (int i=0;i<lp;i++)
+       Z *= gr_complex(-zero(2*i),-zero(2*i+1));
+      for (int i=0;i<lp;i++)
+       Z /= gr_complex(-pole(2*i),-pole(2*i+1));
+      k *= Z.real();
+    }
+    for (int i=0;i<lp;i++) {
+      gr_complex Z = gr_complex(pole(2*i),pole(2*i+1));
+      Z = (C*(Fh-Fl))/2.0/Z;
+      //Z = 
+
+  }
+  }
+    
   return rtn;
 }

Modified: 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.h
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.h
 2009-08-31 06:54:53 UTC (rev 11633)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir/gnuradio-core/src/lib/general/gr_iirdes.h
 2009-09-02 18:59:26 UTC (rev 11634)
@@ -84,8 +84,7 @@
          std::vector<double> zero,
          std::vector<double> pole,
          double k,
-         std::vector<double> W,
-         bool stop);
+         std::vector<double> W);
 
   static std::vector<double>
   butterord(filter_response ft,





reply via email to

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