[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r11605 - in gnuradio/branches/developers/n4hy/pfb_iir2
From: |
n4hy |
Subject: |
[Commit-gnuradio] r11605 - in gnuradio/branches/developers/n4hy/pfb_iir2: gnuradio-core/src/lib/general gnuradio-examples/python/apps/filter_design_tool |
Date: |
Mon, 17 Aug 2009 11:09:31 -0600 (MDT) |
Author: n4hy
Date: 2009-08-17 11:09:30 -0600 (Mon, 17 Aug 2009)
New Revision: 11605
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
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/apps/filter_design_tool/iirdestest.py
Log:
begin adding chebyshev order routine
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-17 00:45:55 UTC (rev 11604)
+++
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.cc
2009-08-17 17:09:30 UTC (rev 11605)
@@ -218,9 +218,78 @@
double Rp,
double Rs)
{
- vector<double> rtn(2);
- if ((fresp == BANDPASS) || (fresp == BANDSTOP)) rtn.resize(3);
- return rtn;
+ double qs = log(pow(10.,(Rs/10.0)) - 1.0);
+ double qp = log(pow(10.,(Rp/10.0)) - 1.0);
+ switch (fresp) {
+ case gr_iirdes::LOWPASS: {
+ vector<double> rtn(2);
+ if (Wp[0]>=Ws[0])
+ throw std::invalid_argument ("For lowpass filter Wp < Ws");
+
+ Ws[0] = tan(M_PI*Ws[0]);
+ Wp[0] = tan(M_PI*Wp[0]);
+ rtn[0] = ceil(0.5*(qs - qp)/log(Ws[0]/Wp[0]));
+ rtn[1] = exp(log(Wp[0]) - qp/2/rtn[0]);
+ rtn[1] = atan(rtn[1])/M_PI;
+ return rtn;
+ }
+ case gr_iirdes::HIGHPASS: {
+ vector<double> rtn(2);
+ if (Ws[0]>=Wp[0]) throw std::invalid_argument ("For highpass filter Wp >
Ws");
+ Ws[0]= 0.5-Ws[0];
+ Wp[0]= 0.5-Wp[0];
+ Ws[0] = tan(M_PI*Ws[0]);
+ Wp[0] = tan(M_PI*Wp[0]);
+ rtn[0] = ceil(0.5*(qs - qp)/log(Ws[0]/Wp[0]));
+ rtn[1] = exp(log(Wp[0]) - qp/2/rtn[0]);
+ rtn[1] = 0.5-atan(rtn[1])/M_PI;
+ return rtn;
+ }
+ case gr_iirdes::BANDPASS: {
+ vector<double> rtn(3);
+ if ((Ws[0]>=Wp[0]) ||
+ (Wp[0]>=Wp[1]) ||
+ (Wp[1]>=Ws[1])) throw std::invalid_argument
+ ("For bandpass filter Ws[0]<Wp[0]<Wp[1]<Ws[1]");
+ Ws[0] = tan(M_PI*(0.5-Ws[0]));
+ Ws[1] = tan(M_PI*Ws[1]);
+ Wp[0] = tan(M_PI*(0.5-Wp[0]));
+ Wp[1] = tan(M_PI*Wp[1]);
+ rtn[0] = ceil(fmax(0.5*(qs - qp)/log(Ws[0]/Wp[0]),
+ 0.5*(qs - qp)/log(Ws[1]/Wp[1]))/2.0);
+
+ rtn[1] = exp(log(Wp[0]) - qp/2/rtn[0]);
+ rtn[2] = exp(log(Wp[1]) - qp/2/rtn[0]);
+
+ rtn[1] = 0.5-atan(rtn[1])/M_PI;
+ rtn[2] = atan(rtn[2])/M_PI;
+
+ return rtn;
+ }
+ case gr_iirdes::BANDSTOP: {
+ vector<double> rtn(3);
+ if ((Wp[0]>=Ws[0]) ||
+ (Ws[0]>=Ws[1]) ||
+ (Ws[1]>=Wp[1])) throw std::invalid_argument
+ ("For bandstop filter Wp[0]<Ws[0]<Ws[1]<Wp[1]");
+
+ Ws[0] = tan(M_PI*Ws[0]);
+ Ws[1] = tan(M_PI*(0.5-Ws[1]));
+ Wp[0] = tan(M_PI*Wp[0]);
+ Wp[1] = tan(M_PI*(0.5-Wp[1]));
+ rtn[0] = ceil(fmax(0.5*(qs - qp)/log(Ws[0]/Wp[0]),
+ 0.5*(qs - qp)/log(Ws[1]/Wp[1]))/2.0);
+
+ rtn[1] = exp(log(Wp[0]) - qp/2/rtn[0]);
+ rtn[2] = exp(log(Wp[1]) - qp/2/rtn[0]);
+
+ rtn[1] = atan(rtn[2])/M_PI;
+ rtn[2] = 0.5-atan(rtn[1])/M_PI;
+
+ return rtn;
+ }}
+ return (vector<double>) NULL;
+
}
vector<double>
@@ -353,11 +422,11 @@
}
-vector<gr_complexd>
-gr_iirdes::sftrans(vector<gr_complexd> zeropolek,
+vector<double>
+gr_iirdes::sftrans(vector<double> zeropolek,
vector<double> W,
bool stop)
{
- vector<gr_complexd> rtn;
+ vector<double> rtn;
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-17 00:45:55 UTC (rev 11604)
+++
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.h
2009-08-17 17:09:30 UTC (rev 11605)
@@ -79,8 +79,8 @@
tf2zpg(std::vector<double> tf);
- static std::vector<gr_complexd>
- sftrans(std::vector<gr_complexd> zeropolek,
+ static std::vector<double>
+ sftrans(std::vector<double> zeropolek,
std::vector<double> W,
bool stop);
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-17 00:45:55 UTC (rev 11604)
+++
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.i
2009-08-17 17:09:30 UTC (rev 11605)
@@ -75,8 +75,8 @@
tf2zpg(std::vector<double> tf);
- static std::vector<gr_complexd>
- sftrans(std::vector<gr_complexd> zeropolek,
+ static std::vector<double>
+ sftrans(std::vector<double> zeropolek,
std::vector<double> W,
bool stop);
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-17 00:45:55 UTC (rev 11604)
+++
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/apps/filter_design_tool/iirdestest.py
2009-08-17 17:09:30 UTC (rev 11605)
@@ -30,8 +30,10 @@
print numbers
-tf=[0.0976, 0.1953, 0.0976,0.3333, -0.9428, 1.0]
+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)
print zpg
+
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r11605 - in gnuradio/branches/developers/n4hy/pfb_iir2: gnuradio-core/src/lib/general gnuradio-examples/python/apps/filter_design_tool,
n4hy <=