IT++ Logo
filter.cpp
Go to the documentation of this file.
1 
29 #include <itpp/signal/filter.h>
30 #include <itpp/signal/window.h>
31 #include <itpp/base/matfunc.h>
33 
34 
35 namespace itpp
36 {
37 
38 
39 vec filter(const vec &b, const vec &a, const vec &input)
40 {
42  return f(input);
43 }
44 
45 cvec filter(const vec &b, const vec &a, const cvec &input)
46 {
47  ARMA_Filter<std::complex<double>, double, std::complex<double> > f(b, a);
48  return f(input);
49 }
50 
51 cvec filter(const cvec &b, const cvec &a, const cvec &input)
52 {
53  ARMA_Filter<std::complex<double>, std::complex<double>, std::complex<double> > f(b, a);
54  return f(input);
55 }
56 
57 cvec filter(const cvec &b, const cvec &a, const vec &input)
58 {
59  ARMA_Filter<double, std::complex<double>, std::complex<double> > f(b, a);
60  return f(input);
61 }
62 
63 
64 vec filter(const vec &b, const int one, const vec &input)
65 {
66  it_assert(one == 1, "filter(): in a MA filter a=1");
68  return f(input);
69 }
70 
71 cvec filter(const vec &b, const int one, const cvec &input)
72 {
73  it_assert(one == 1, "filter(): in a MA filter a=1");
74  MA_Filter<std::complex<double>, double, std::complex<double> > f(b);
75  return f(input);
76 }
77 
78 cvec filter(const cvec &b, const int one, const cvec &input)
79 {
80  it_assert(one == 1, "filter(): in a MA filter a=1");
81  MA_Filter<std::complex<double>, std::complex<double>, std::complex<double> > f(b);
82  return f(input);
83 }
84 
85 cvec filter(const cvec &b, const int one, const vec &input)
86 {
87  it_assert(one == 1, "filter(): in a MA filter a=1");
88  MA_Filter<double, std::complex<double>, std::complex<double> > f(b);
89  return f(input);
90 }
91 
92 
93 vec filter(const int one, const vec &a, const vec &input)
94 {
95  it_assert(one == 1, "filter(): in a AR filter b=1");
97  return f(input);
98 }
99 
100 cvec filter(const int one, const vec &a, const cvec &input)
101 {
102  it_assert(one == 1, "filter(): in a AR filter b=1");
103  AR_Filter<std::complex<double>, double, std::complex<double> > f(a);
104  return f(input);
105 }
106 
107 cvec filter(const int one, const cvec &a, const cvec &input)
108 {
109  it_assert(one == 1, "filter(): in a AR filter b=1");
110  AR_Filter<std::complex<double>, std::complex<double>, std::complex<double> > f(a);
111  return f(input);
112 }
113 
114 cvec filter(const int one, const cvec &a, const vec &input)
115 {
116  it_assert(one == 1, "filter(): in a AR filter b=1");
117  AR_Filter<double, std::complex<double>, std::complex<double> > f(a);
118  return f(input);
119 }
120 
121 
122 
123 
124 
125 vec filter(const vec &b, const vec &a, const vec &input, const vec &state_in, vec &state_out)
126 {
128  f.set_state(state_in);
129  vec output = f(input);
130  state_out = f.get_state();
131  return output;
132 }
133 
134 cvec filter(const vec &b, const vec &a, const cvec &input, const cvec &state_in, cvec &state_out)
135 {
136  ARMA_Filter<std::complex<double>, double, std::complex<double> > f(b, a);
137  f.set_state(state_in);
138  cvec output = f(input);
139  state_out = f.get_state();
140  return output;
141 }
142 
143 cvec filter(const cvec &b, const cvec &a, const cvec &input, const cvec &state_in, cvec &state_out)
144 {
145  ARMA_Filter<std::complex<double>, std::complex<double>, std::complex<double> > f(b, a);
146  f.set_state(state_in);
147  cvec output = f(input);
148  state_out = f.get_state();
149  return output;
150 }
151 
152 cvec filter(const cvec &b, const cvec &a, const vec &input, const cvec &state_in, cvec &state_out)
153 {
154  ARMA_Filter<double, std::complex<double>, std::complex<double> > f(b, a);
155  f.set_state(state_in);
156  cvec output = f(input);
157  state_out = f.get_state();
158  return output;
159 }
160 
161 
162 vec filter(const vec &b, const int one, const vec &input, const vec &state_in, vec &state_out)
163 {
164  it_assert(one == 1, "filter(): in a MA filter a=1");
166  f.set_state(state_in);
167  vec output = f(input);
168  state_out = f.get_state();
169  return output;
170 }
171 
172 cvec filter(const vec &b, const int one, const cvec &input, const cvec &state_in, cvec &state_out)
173 {
174  it_assert(one == 1, "filter(): in a MA filter a=1");
175  MA_Filter<std::complex<double>, double, std::complex<double> > f(b);
176  f.set_state(state_in);
177  cvec output = f(input);
178  state_out = f.get_state();
179  return output;
180 }
181 
182 cvec filter(const cvec &b, const int one, const cvec &input, const cvec &state_in, cvec &state_out)
183 {
184  it_assert(one == 1, "filter(): in a MA filter a=1");
185  MA_Filter<std::complex<double>, std::complex<double>, std::complex<double> > f(b);
186  f.set_state(state_in);
187  cvec output = f(input);
188  state_out = f.get_state();
189  return output;
190 }
191 
192 cvec filter(const cvec &b, const int one, const vec &input, const cvec &state_in, cvec &state_out)
193 {
194  it_assert(one == 1, "filter(): in a MA filter a=1");
195  MA_Filter<double, std::complex<double>, std::complex<double> > f(b);
196  f.set_state(state_in);
197  cvec output = f(input);
198  state_out = f.get_state();
199  return output;
200 }
201 
202 
203 vec filter(const int one, const vec &a, const vec &input, const vec &state_in, vec &state_out)
204 {
205  it_assert(one == 1, "filter(): in a AR filter b=1");
207  f.set_state(state_in);
208  vec output = f(input);
209  state_out = f.get_state();
210  return output;
211 }
212 
213 cvec filter(const int one, const vec &a, const cvec &input, const cvec &state_in, cvec &state_out)
214 {
215  it_assert(one == 1, "filter(): in a AR filter b=1");
216  AR_Filter<std::complex<double>, double, std::complex<double> > f(a);
217  f.set_state(state_in);
218  cvec output = f(input);
219  state_out = f.get_state();
220  return output;
221 }
222 
223 cvec filter(const int one, const cvec &a, const cvec &input, const cvec &state_in, cvec &state_out)
224 {
225  it_assert(one == 1, "filter(): in a AR filter b=1");
226  AR_Filter<std::complex<double>, std::complex<double>, std::complex<double> > f(a);
227  f.set_state(state_in);
228  cvec output = f(input);
229  state_out = f.get_state();
230  return output;
231 }
232 
233 cvec filter(const int one, const cvec &a, const vec &input, const cvec &state_in, cvec &state_out)
234 {
235  it_assert(one == 1, "filter(): in a AR filter b=1");
236  AR_Filter<double, std::complex<double>, std::complex<double> > f(a);
237  f.set_state(state_in);
238  cvec output = f(input);
239  state_out = f.get_state();
240  return output;
241 }
242 
243 vec fir1(int N, double cutoff)
244 {
245  vec a(N + 1), h = hamming(N + 1);
246 
247  for (int i = 0;i < length(a);i++) {
248  a[i] = h[i] * sinc(cutoff * (i - N / 2.0));
249  }
250  a /= sum(a);
251  return a;
252 }
253 
254 template class ITPP_EXPORT MA_Filter<double, double, double>;
255 template class ITPP_EXPORT MA_Filter < double, std::complex<double>,
256 std::complex<double> >;
257 template class ITPP_EXPORT MA_Filter<std::complex<double>, double, std::complex<double> >;
258 template class ITPP_EXPORT MA_Filter < std::complex<double>, std::complex<double>,
259 std::complex<double> >;
260 
261 template class ITPP_EXPORT AR_Filter<double, double, double>;
262 template class ITPP_EXPORT AR_Filter < double, std::complex<double>,
263 std::complex<double> >;
264 template class ITPP_EXPORT AR_Filter < std::complex<double>, double,
265 std::complex<double> >;
266 template class ITPP_EXPORT AR_Filter < std::complex<double>, std::complex<double>,
267 std::complex<double> >;
268 
269 template class ITPP_EXPORT ARMA_Filter<double, double, double>;
270 template class ITPP_EXPORT ARMA_Filter < double, std::complex<double>,
271 std::complex<double> >;
272 template class ITPP_EXPORT ARMA_Filter < std::complex<double>, double,
273 std::complex<double> >;
274 template class ITPP_EXPORT ARMA_Filter < std::complex<double>, std::complex<double>,
275 std::complex<double> >;
276 
277 } // namespace itpp
SourceForge Logo

Generated on Sat May 25 2013 16:32:23 for IT++ by Doxygen 1.8.2