GPLIB++
AdaptiveFilter.h
Go to the documentation of this file.
1 #ifndef ADAPTIVEFILTER_H
2 #define ADAPTIVEFILTER_H
3 
4 #include "types.h"
5 #include "VecMat.h"
6 
7 namespace gplib
8  {
9  /** \addtogroup sigproc Signal processing methods */
10  /* @{ */
11 
12  /*!
13  * \file AdaptiveFilter.h
14  * Basic class for adaptive filtering of time series data
15  * \author Max Moorkamp
16  * $Id: AdaptiveFilter.h 1845 2010-04-12 11:55:22Z mmoorkamp $
17  *
18  * The class AdaptiveFilter provides the generic interface for all types of adaptive Filters
19  */
20 
21  namespace ublas = boost::numeric::ublas;
22  //! A generic base class for all types of adaptive filters
23  /*! The class AdaptiveFilter provides a unified interface for various types
24  * of adaptive filters and storage for some quantities that are common to all
25  * of them. Ideally this should facilitate transparent use of all filters in
26  * any program or routine. See, for example, mtuadaptive.cpp. We assume that the filter length
27  * and number of output points is constant for the life of the object.
28  */
30  {
31  private:
32  //! The vector holding the last filter output calculated
33  gplib::rvec FilterOutput;
34  //! The vector holding the last estimation error
35  gplib::rvec Epsilon;
36  //! length of the input vector to the filter, this is not the time-series length, but the segment the filter operates on
37  const unsigned int inputlength;
38  //! length of the filter output
39  const unsigned int outputlength;
40  protected:
41  //! Access function for derived classes for the inputlength
42  unsigned int GetInputLength()
43  {
44  return inputlength;
45  }
46  //! Access function for derived classes for the outputlength
47  unsigned int GetOutputLength()
48  {
49  return outputlength;
50  }
51  //! Possibility for derived classes to set estimation error
52  void SetEpsilon(const gplib::rvec &MyEps)
53  {
54  Epsilon = MyEps;
55  }
56  //! Possibility for derived classes to set output
57  void SetOutput(const gplib::rvec &Out)
58  {
59  FilterOutput = Out;
60  }
61  public:
62  //! Access to the last calculated output (not sure if needed)
63  const gplib::rvec &GetFilterOutput() const
64  {
65  return FilterOutput;
66  }
67  //! Return the last estimation error
68  const gplib::rvec &GetEpsilon() const
69  {
70  return Epsilon;
71  }
72  //! Print the current set of weights to the output stream, has to be implemented in derived class
73  virtual void PrintWeights(std::ostream &output) =0;
74  //! We can always convert the weights to some sort of vector, the details have to be implemented in the derived class
75  virtual const gplib::rvec &GetWeightsAsVector() = 0;
76  //! Adapt the filter weights given the Input and Desired vectors
77  virtual void
78  AdaptFilter(const gplib::rvec &Input, const gplib::rvec &Desired) = 0;
79  //! Calculate the filter output given Input
80  virtual void CalcOutput(const gplib::rvec &Input, gplib::rvec &Output) = 0;
81  //! The constructor needs to know the length of the input and output vectors for memory allocation
82  AdaptiveFilter(const int inputsize, const int outputsize);
83  virtual ~AdaptiveFilter();
84  friend class ApplyFilter;
85  };
86  /* @} */
87  }
88 #endif // ADAPTIVEFILTER_H
const gplib::rvec & GetEpsilon() const
Return the last estimation error.
Apply an adaptive filter to a time-series.
Definition: ApplyFilter.h:15
void SetEpsilon(const gplib::rvec &MyEps)
Possibility for derived classes to set estimation error.
virtual const gplib::rvec & GetWeightsAsVector()=0
We can always convert the weights to some sort of vector, the details have to be implemented in the d...
unsigned int GetInputLength()
Access function for derived classes for the inputlength.
A generic base class for all types of adaptive filters.
const gplib::rvec & GetFilterOutput() const
Access to the last calculated output (not sure if needed)
virtual void CalcOutput(const gplib::rvec &Input, gplib::rvec &Output)=0
Calculate the filter output given Input.
virtual void AdaptFilter(const gplib::rvec &Input, const gplib::rvec &Desired)=0
Adapt the filter weights given the Input and Desired vectors.
AdaptiveFilter(const int inputsize, const int outputsize)
The constructor needs to know the length of the input and output vectors for memory allocation...
void SetOutput(const gplib::rvec &Out)
Possibility for derived classes to set output.
unsigned int GetOutputLength()
Access function for derived classes for the outputlength.
virtual void PrintWeights(std::ostream &output)=0
Print the current set of weights to the output stream, has to be implemented in derived class...