filter.cpp
Go to the documentation of this file.
#include <itpp/signal/filter.h>
#include <itpp/signal/window.h>
#include <itpp/base/matfunc.h>
#include <itpp/base/math/trig_hyp.h>
namespace itpp
{
vec filter(const vec &b, const vec &a, const vec &input)
{
ARMA_Filter<double, double, double> f(b, a);
return f(input);
}
cvec filter(const vec &b, const vec &a, const cvec &input)
{
ARMA_Filter<std::complex<double>, double, std::complex<double> > f(b, a);
return f(input);
}
cvec filter(const cvec &b, const cvec &a, const cvec &input)
{
ARMA_Filter<std::complex<double>, std::complex<double>, std::complex<double> > f(b, a);
return f(input);
}
cvec filter(const cvec &b, const cvec &a, const vec &input)
{
ARMA_Filter<double, std::complex<double>, std::complex<double> > f(b, a);
return f(input);
}
vec filter(const vec &b, const int one, const vec &input)
{
it_assert(one == 1, "filter(): in a MA filter a=1");
MA_Filter<double, double, double> f(b);
return f(input);
}
cvec filter(const vec &b, const int one, const cvec &input)
{
it_assert(one == 1, "filter(): in a MA filter a=1");
MA_Filter<std::complex<double>, double, std::complex<double> > f(b);
return f(input);
}
cvec filter(const cvec &b, const int one, const cvec &input)
{
it_assert(one == 1, "filter(): in a MA filter a=1");
MA_Filter<std::complex<double>, std::complex<double>, std::complex<double> > f(b);
return f(input);
}
cvec filter(const cvec &b, const int one, const vec &input)
{
it_assert(one == 1, "filter(): in a MA filter a=1");
MA_Filter<double, std::complex<double>, std::complex<double> > f(b);
return f(input);
}
vec filter(const int one, const vec &a, const vec &input)
{
it_assert(one == 1, "filter(): in a AR filter b=1");
AR_Filter<double, double, double> f(a);
return f(input);
}
cvec filter(const int one, const vec &a, const cvec &input)
{
it_assert(one == 1, "filter(): in a AR filter b=1");
AR_Filter<std::complex<double>, double, std::complex<double> > f(a);
return f(input);
}
cvec filter(const int one, const cvec &a, const cvec &input)
{
it_assert(one == 1, "filter(): in a AR filter b=1");
AR_Filter<std::complex<double>, std::complex<double>, std::complex<double> > f(a);
return f(input);
}
cvec filter(const int one, const cvec &a, const vec &input)
{
it_assert(one == 1, "filter(): in a AR filter b=1");
AR_Filter<double, std::complex<double>, std::complex<double> > f(a);
return f(input);
}
vec filter(const vec &b, const vec &a, const vec &input, const vec &state_in, vec &state_out)
{
ARMA_Filter<double, double, double> f(b, a);
f.set_state(state_in);
vec output = f(input);
state_out = f.get_state();
return output;
}
cvec filter(const vec &b, const vec &a, const cvec &input, const cvec &state_in, cvec &state_out)
{
ARMA_Filter<std::complex<double>, double, std::complex<double> > f(b, a);
f.set_state(state_in);
cvec output = f(input);
state_out = f.get_state();
return output;
}
cvec filter(const cvec &b, const cvec &a, const cvec &input, const cvec &state_in, cvec &state_out)
{
ARMA_Filter<std::complex<double>, std::complex<double>, std::complex<double> > f(b, a);
f.set_state(state_in);
cvec output = f(input);
state_out = f.get_state();
return output;
}
cvec filter(const cvec &b, const cvec &a, const vec &input, const cvec &state_in, cvec &state_out)
{
ARMA_Filter<double, std::complex<double>, std::complex<double> > f(b, a);
f.set_state(state_in);
cvec output = f(input);
state_out = f.get_state();
return output;
}
vec filter(const vec &b, const int one, const vec &input, const vec &state_in, vec &state_out)
{
it_assert(one == 1, "filter(): in a MA filter a=1");
MA_Filter<double, double, double> f(b);
f.set_state(state_in);
vec output = f(input);
state_out = f.get_state();
return output;
}
cvec filter(const vec &b, const int one, const cvec &input, const cvec &state_in, cvec &state_out)
{
it_assert(one == 1, "filter(): in a MA filter a=1");
MA_Filter<std::complex<double>, double, std::complex<double> > f(b);
f.set_state(state_in);
cvec output = f(input);
state_out = f.get_state();
return output;
}
cvec filter(const cvec &b, const int one, const cvec &input, const cvec &state_in, cvec &state_out)
{
it_assert(one == 1, "filter(): in a MA filter a=1");
MA_Filter<std::complex<double>, std::complex<double>, std::complex<double> > f(b);
f.set_state(state_in);
cvec output = f(input);
state_out = f.get_state();
return output;
}
cvec filter(const cvec &b, const int one, const vec &input, const cvec &state_in, cvec &state_out)
{
it_assert(one == 1, "filter(): in a MA filter a=1");
MA_Filter<double, std::complex<double>, std::complex<double> > f(b);
f.set_state(state_in);
cvec output = f(input);
state_out = f.get_state();
return output;
}
vec filter(const int one, const vec &a, const vec &input, const vec &state_in, vec &state_out)
{
it_assert(one == 1, "filter(): in a AR filter b=1");
AR_Filter<double, double, double> f(a);
f.set_state(state_in);
vec output = f(input);
state_out = f.get_state();
return output;
}
cvec filter(const int one, const vec &a, const cvec &input, const cvec &state_in, cvec &state_out)
{
it_assert(one == 1, "filter(): in a AR filter b=1");
AR_Filter<std::complex<double>, double, std::complex<double> > f(a);
f.set_state(state_in);
cvec output = f(input);
state_out = f.get_state();
return output;
}
cvec filter(const int one, const cvec &a, const cvec &input, const cvec &state_in, cvec &state_out)
{
it_assert(one == 1, "filter(): in a AR filter b=1");
AR_Filter<std::complex<double>, std::complex<double>, std::complex<double> > f(a);
f.set_state(state_in);
cvec output = f(input);
state_out = f.get_state();
return output;
}
cvec filter(const int one, const cvec &a, const vec &input, const cvec &state_in, cvec &state_out)
{
it_assert(one == 1, "filter(): in a AR filter b=1");
AR_Filter<double, std::complex<double>, std::complex<double> > f(a);
f.set_state(state_in);
cvec output = f(input);
state_out = f.get_state();
return output;
}
vec fir1(int N, double cutoff)
{
vec a(N + 1), h = hamming(N + 1);
for (int i = 0;i < length(a);i++) {
a[i] = h[i] * sinc(cutoff * (i - N / 2.0));
}
a /= sum(a);
return a;
}
template class ITPP_EXPORT MA_Filter<double, double, double>;
template class ITPP_EXPORT MA_Filter < double, std::complex<double>,
std::complex<double> >;
template class ITPP_EXPORT MA_Filter<std::complex<double>, double, std::complex<double> >;
template class ITPP_EXPORT MA_Filter < std::complex<double>, std::complex<double>,
std::complex<double> >;
template class ITPP_EXPORT AR_Filter<double, double, double>;
template class ITPP_EXPORT AR_Filter < double, std::complex<double>,
std::complex<double> >;
template class ITPP_EXPORT AR_Filter < std::complex<double>, double,
std::complex<double> >;
template class ITPP_EXPORT AR_Filter < std::complex<double>, std::complex<double>,
std::complex<double> >;
template class ITPP_EXPORT ARMA_Filter<double, double, double>;
template class ITPP_EXPORT ARMA_Filter < double, std::complex<double>,
std::complex<double> >;
template class ITPP_EXPORT ARMA_Filter < std::complex<double>, double,
std::complex<double> >;
template class ITPP_EXPORT ARMA_Filter < std::complex<double>, std::complex<double>,
std::complex<double> >;
} // namespace itpp
itpp::ARMA_Filter
Autoregressive Moving Average (ARMA) Filter Base Class.
Definition filter.h:211
itpp::ARMA_Filter::get_state
Vec< T3 > get_state() const
Get state of filter.
Definition filter.h:517
itpp::ARMA_Filter::set_state
void set_state(const Vec< T3 > &state)
Set state of filter.
Definition filter.h:533
itpp::AR_Filter
Autoregressive (AR) Filter Base Class.
Definition filter.h:153
itpp::AR_Filter::get_state
Vec< T3 > get_state() const
Get state of filter.
Definition filter.h:436
itpp::AR_Filter::set_state
void set_state(const Vec< T3 > &state)
Set state of filter.
Definition filter.h:452
itpp::MA_Filter
Moving Average Filter Base Class.
Definition filter.h:99
itpp::MA_Filter::set_state
void set_state(const Vec< T3 > &state)
Set state of filter.
Definition filter.h:371
itpp::MA_Filter::get_state
Vec< T3 > get_state() const
Get state of filter.
Definition filter.h:355
filter.h
Definitions of Filter classes and functions.
it_assert
#define it_assert(t, s)
Abort if t is not true.
Definition itassert.h:94
itpp::fir1
vec fir1(int N, double cutoff)
Design a Nth order FIR filter with cut-off frequency cutoff using the window method.
Definition filter.cpp:243
itpp::filter
vec filter(const vec &b, const vec &a, const vec &input)
ARMA filter function.
Definition filter.cpp:39
itpp::sum
T sum(const Vec< T > &v)
Sum of all elements in the vector.
Definition matfunc.h:59
itpp::length
int length(const Vec< T > &v)
Length of vector.
Definition matfunc.h:51
itpp::sinc
double sinc(double x)
Sinc function: sinc(x) = sin(pi*x)/pi*x.
Definition trig_hyp.h:42
itpp::hamming
vec hamming(int n)
Hamming window.
Definition window.cpp:43
matfunc.h
Various functions on vectors and matrices - header file.
itpp
itpp namespace
Definition itmex.h:37
trig_hyp.h
Trigonometric and hyperbolic functions - header file.
window.h
Definitions of window functions.

Generated on for IT++ by Doxygen 1.15.0