33 #include <itpp/itexports.h>
53 template <
class T1,
class T2,
class T3>
70 virtual T3
filter(
const T1 Sample) = 0;
97 template <
class T1,
class T2,
class T3>
119 virtual T3 filter(
const T1 Sample);
151 template <
class T1,
class T2,
class T3>
173 virtual T3 filter(
const T1 Sample);
209 template <
class T1,
class T2,
class T3>
235 virtual T3 filter(
const T1 Sample);
268 ITPP_EXPORT vec
filter(
const vec &b,
const vec &a,
const vec &input);
269 ITPP_EXPORT cvec
filter(
const vec &b,
const vec &a,
const cvec &input);
270 ITPP_EXPORT cvec
filter(
const cvec &b,
const cvec &a,
const cvec &input);
271 ITPP_EXPORT cvec
filter(
const cvec &b,
const cvec &a,
const vec &input);
273 ITPP_EXPORT vec
filter(
const vec &b,
const int one,
const vec &input);
274 ITPP_EXPORT cvec
filter(
const vec &b,
const int one,
const cvec &input);
275 ITPP_EXPORT cvec
filter(
const cvec &b,
const int one,
const cvec &input);
276 ITPP_EXPORT cvec
filter(
const cvec &b,
const int one,
const vec &input);
278 ITPP_EXPORT vec
filter(
const int one,
const vec &a,
const vec &input);
279 ITPP_EXPORT cvec
filter(
const int one,
const vec &a,
const cvec &input);
280 ITPP_EXPORT cvec
filter(
const int one,
const cvec &a,
const cvec &input);
281 ITPP_EXPORT cvec
filter(
const int one,
const cvec &a,
const vec &input);
284 ITPP_EXPORT vec
filter(
const vec &b,
const vec &a,
const vec &input,
const vec &state_in, vec &state_out);
285 ITPP_EXPORT cvec
filter(
const vec &b,
const vec &a,
const cvec &input,
const cvec &state_in, cvec &state_out);
286 ITPP_EXPORT cvec
filter(
const cvec &b,
const cvec &a,
const cvec &input,
const cvec &state_in, cvec &state_out);
287 ITPP_EXPORT cvec
filter(
const cvec &b,
const cvec &a,
const vec &input,
const cvec &state_in, cvec &state_out);
289 ITPP_EXPORT vec
filter(
const vec &b,
const int one,
const vec &input,
const vec &state_in, vec &state_out);
290 ITPP_EXPORT cvec
filter(
const vec &b,
const int one,
const cvec &input,
const cvec &state_in, cvec &state_out);
291 ITPP_EXPORT cvec
filter(
const cvec &b,
const int one,
const cvec &input,
const cvec &state_in, cvec &state_out);
292 ITPP_EXPORT cvec
filter(
const cvec &b,
const int one,
const vec &input,
const cvec &state_in, cvec &state_out);
294 ITPP_EXPORT vec
filter(
const int one,
const vec &a,
const vec &input,
const vec &state_in, vec &state_out);
295 ITPP_EXPORT cvec
filter(
const int one,
const vec &a,
const cvec &input,
const cvec &state_in, cvec &state_out);
296 ITPP_EXPORT cvec
filter(
const int one,
const cvec &a,
const cvec &input,
const cvec &state_in, cvec &state_out);
297 ITPP_EXPORT cvec
filter(
const int one,
const cvec &a,
const vec &input,
const cvec &state_in, cvec &state_out);
306 ITPP_EXPORT vec
fir1(
int N,
double cutoff);
314 template <
class T1,
class T2,
class T3>
319 for (
int i = 0; i < x.
length(); i++) {
328 template <
class T1,
class T2,
class T3>
335 template <
class T1,
class T2,
class T3>
342 template <
class T1,
class T2,
class T3>
354 template <
class T1,
class T2,
class T3>
357 it_assert(init ==
true,
"MA_Filter: filter coefficients are not set!");
362 for (
int n = 0; n < mem.size(); n++) {
363 state(n) = mem(offset);
364 offset = (offset + 1) % mem.size();
370 template <
class T1,
class T2,
class T3>
373 it_assert(init ==
true,
"MA_Filter: filter coefficients are not set!");
374 it_assert(state.
size() == mem.size(),
"MA_Filter: Invalid state vector!");
380 template <
class T1,
class T2,
class T3>
383 it_assert(init ==
true,
"MA_Filter: Filter coefficients are not set!");
387 int L = mem.length() - inptr;
389 for (
int i = 0; i < L; i++) {
390 s += coeffs(i) * mem(inptr + i);
392 for (
int i = 0; i < inptr; i++) {
393 s += coeffs(L + i) * mem(i);
398 inptr += mem.length();
405 template <
class T1,
class T2,
class T3>
412 template <
class T1,
class T2,
class T3>
418 template <
class T1,
class T2,
class T3>
422 it_assert(a(0) != T2(0),
"AR_Filter: a(0) cannot be 0!");
428 mem.set_size(coeffs.size() - 1,
false);
435 template <
class T1,
class T2,
class T3>
438 it_assert(init ==
true,
"AR_Filter: filter coefficients are not set!");
443 for (
int n = 0; n < mem.size(); n++) {
444 state(n) = mem(offset);
445 offset = (offset + 1) % mem.size();
451 template <
class T1,
class T2,
class T3>
454 it_assert(init ==
true,
"AR_Filter: filter coefficients are not set!");
455 it_assert(state.
size() == mem.size(),
"AR_Filter: Invalid state vector!");
461 template <
class T1,
class T2,
class T3>
464 it_assert(init ==
true,
"AR_Filter: Filter coefficients are not set!");
470 int L = mem.size() - inptr;
471 for (
int i = 0; i < L; i++) {
472 s -= mem(i + inptr) * coeffs(i + 1);
474 for (
int i = 0; i < inptr; i++) {
475 s -= mem(i) * coeffs(L + i + 1);
488 template <
class T1,
class T2,
class T3>
495 template <
class T1,
class T2,
class T3>
501 template <
class T1,
class T2,
class T3>
505 it_assert(a(0) != T2(0),
"ARMA_Filter: a(0) cannot be 0!");
516 template <
class T1,
class T2,
class T3>
519 it_assert(init ==
true,
"ARMA_Filter: filter coefficients are not set!");
524 for (
int n = 0; n < mem.size(); n++) {
525 state(n) = mem(offset);
526 offset = (offset + 1) % mem.size();
532 template <
class T1,
class T2,
class T3>
535 it_assert(init ==
true,
"ARMA_Filter: filter coefficients are not set!");
536 it_assert(state.
size() == mem.size(),
"ARMA_Filter: Invalid state vector!");
542 template <
class T1,
class T2,
class T3>
545 it_assert(init ==
true,
"ARMA_Filter: Filter coefficients are not set!");
549 for (
int i = 0; i < acoeffs.size() - 1; i++) {
550 z -= mem((i + inptr) % mem.size()) * acoeffs(i + 1);
554 for (
int i = 0; i < bcoeffs.size() - 1; i++) {
555 s += mem((i + inptr) % mem.size()) * bcoeffs(i + 1);
573 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT MA_Filter<double, double, double>;
574 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT MA_Filter< double, std::complex<double>,
575 std::complex<double> >;
576 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT MA_Filter< std::complex<double>, double,
577 std::complex<double> >;
578 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT MA_Filter< std::complex<double>, std::complex<double>,
579 std::complex<double> >;
581 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT AR_Filter<double, double, double>;
582 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT AR_Filter< double, std::complex<double>,
583 std::complex<double> >;
584 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT AR_Filter< std::complex<double>,
585 double, std::complex<double> >;
586 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT AR_Filter< std::complex<double>, std::complex<double>,
587 std::complex<double> >;
589 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT ARMA_Filter<double, double, double>;
590 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT ARMA_Filter< double, std::complex<double>,
591 std::complex<double> >;
592 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT ARMA_Filter< std::complex<double>,
593 double, std::complex<double> >;
594 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT ARMA_Filter< std::complex<double>, std::complex<double>,
595 std::complex<double> >;
601 #endif // #ifndef FILTER_H