Fourier library: Operations in the Fourier domain
filters.cc
Go to the documentation of this file.
1 
35 #define TF_FILTER_CC_VERSION \
36  "TF_FILTER_CC V1.0"
37 
38 #include <fourier/filters.h>
39 #include <fourier/error.h>
40 #include <cmath>
41 
42 namespace fourier {
43 
44  const double Filter::pi=M_PI;
45  const Filter::Tcvalue Filter::ime=Tcvalue(0.,1.);
46 
47  /*----------------------------------------------------------------------*/
48 
50  {
51  Tcvalue retval;
52  if (isfreqmod()) { retval=2.*pi*par; } else { retval=2.*pi/par; }
53  return(retval);
54  }
55 
56  /*----------------------------------------------------------------------*/
57 
59  {
60  this->Tbase::setpole(Tcvalue(0.,0.));
61  this->Tbase::denfactor(Tcvalue(0.,1.));
62  }
63 
64  /*----------------------------------------------------------------------*/
65 
67  {
68  this->Tbase::setzero(Tcvalue(0.,0.));
69  this->Tbase::numfactor(Tcvalue(0.,1.));
70  }
71 
72  /*----------------------------------------------------------------------*/
73 
74  void Filter::sethpb(const Filter::Tcvalue& par, const int& ord)
75  {
76  Tcvalue om=omega(par);
77  FOURIER_assert((ord>0), "ERROR (Filter hpb): illegal order!");
78  for (int i=1; i<=ord; ++i)
79  {
80  this->Tbase::setzero(Tcvalue(0.,0.));
81  Tcvalue pole=om*std::exp(ime*pi*(2.*i-1.)/(2.*ord));
82  this->Tbase::setpole(pole);
83  }
84  }
85 
86  /*----------------------------------------------------------------------*/
87 
88  void Filter::setlpb(const Filter::Tcvalue& par, const int& ord)
89  {
90  Tcvalue om=omega(par);
91  FOURIER_assert((ord>0), "ERROR (Filter lpb): illegal order!");
92  for (int i=1; i<=ord; ++i)
93  {
94  this->Tbase::numfactor(-ime*om);
95  Tcvalue pole=om*std::exp(ime*pi*(2.*i-1.)/(2.*ord));
96  this->Tbase::setpole(pole);
97  }
98  }
99 
100  /*----------------------------------------------------------------------*/
101 
102  void Filter::sethp2(const Filter::Tcvalue& par, const double& h)
103  {
104  Tcvalue om=omega(par);
105  this->Tbase::setzero(Tcvalue(0.,0.));
106  this->Tbase::setzero(Tcvalue(0.,0.));
107  Tcvalue pole=om*(ime*h+std::sqrt(1.-h*h));
108  this->Tbase::setpole(pole);
109  pole=om*(ime*h-std::sqrt(1.-h*h));
110  this->Tbase::setpole(pole);
111  }
112 
113  /*----------------------------------------------------------------------*/
114 
115  void Filter::setlp2(const Filter::Tcvalue& par, const double& h)
116  {
117  Tcvalue om=omega(par);
118  this->Tbase::numfactor(-ime*om);
119  this->Tbase::numfactor(-ime*om);
120  Tcvalue pole=om*(ime*h+std::sqrt(1.-h*h));
121  this->Tbase::setpole(pole);
122  pole=om*(ime*h-std::sqrt(1.-h*h));
123  this->Tbase::setpole(pole);
124  }
125 
126 } // namespace fourier
127 
128 /* ----- END OF filter.cc ----- */
void setint()
Definition: filters.cc:58
#define FOURIER_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:141
static const Tcvalue ime
Definition: filters.h:54
void setlpb(const Tcvalue &par, const int &ord)
Definition: filters.cc:88
void setdif()
Definition: filters.cc:66
void sethp2(const Tcvalue &par, const double &h)
Definition: filters.cc:102
void numfactor(const Tcvalue &factor)
Definition: polesnzeroes.cc:72
error handling for libfourier (prototypes)
void setlp2(const Tcvalue &par, const double &h)
Definition: filters.cc:115
Tbase::Tcvalue Tcvalue
Definition: filters.h:51
static const double pi
Definition: filters.h:53
Definition: error.cc:44
void denfactor(const Tcvalue &factor)
Definition: polesnzeroes.cc:82
provides specific filters (prototypes)
Tcvalue omega(const Tcvalue &par) const
Definition: filters.cc:49
void setpole(const Tcvalue &pole)
Definition: polesnzeroes.cc:52
void setzero(const Tcvalue &zero)
Definition: polesnzeroes.cc:62
void sethpb(const Tcvalue &par, const int &ord)
Definition: filters.cc:74
bool isfreqmod() const
Definition: filters.h:62