[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r11607 - gnuradio/branches/developers/n4hy/pfb_iir2/gn
From: |
n4hy |
Subject: |
[Commit-gnuradio] r11607 - gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general |
Date: |
Mon, 17 Aug 2009 11:44:39 -0600 (MDT) |
Author: n4hy
Date: 2009-08-17 11:44:39 -0600 (Mon, 17 Aug 2009)
New Revision: 11607
Modified:
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.cc
Log:
chebyshevord initially add, not tested
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 17:20:47 UTC (rev 11606)
+++
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.cc
2009-08-17 17:44:39 UTC (rev 11607)
@@ -223,69 +223,52 @@
switch (fresp) {
case gr_iirdes::LOWPASS: {
vector<double> rtn(2);
+ double Wa;
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;
+ Wa = Ws[0]/Wp[0];
+ rtn[0] = ceil(acosh(sqrt((qs-1)/(qp-1)))/acosh(Wa));
+ rtn[1] = Wp[0];
return rtn;
}
case gr_iirdes::HIGHPASS: {
+ double Wa;
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;
+ Wa = Wp[0]/Ws[0];
+ rtn[0] = ceil(acosh(sqrt((qs-1)/(qp-1)))/acosh(Wa));
+ rtn[1] = Wp[0]
return rtn;
}
case gr_iirdes::BANDPASS: {
+ double Wa[2];
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[0] = tan(M_PI*Ws[0]);
+ Wp[0] = tan(M_PI*Wp[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;
-
+ for (int i=0;i<2;i++)
+ Wa[i]=(Ws[i]^2-Wp[0]*Wp[1])/(Ws[i]*(Wp[0]-Wp[1]));
+ Wa[0]=fmin(Wa[0],Wa[1]);
+ rtn[0] = ceil(acosh(sqrt((qs-1)/(qp-1)))/acosh(Wa[0]));
+ rtn[1]=Wp[0];
+ rtn[2]=Wp[1];
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;
-
+ throw std::invalid_argument
+ ("bandstop filter not implemented yet");
return rtn;
}}
return (vector<double>) NULL;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r11607 - gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general,
n4hy <=