00001 #ifndef ADAPTIVEFILTER_H 00002 #define ADAPTIVEFILTER_H 00003 00004 #include "types.h" 00005 #include "VecMat.h" 00006 00007 namespace gplib 00008 { 00009 /** \addtogroup sigproc Signal processing methods */ 00010 /* @{ */ 00011 00012 /*! 00013 * \file Basic class for adaptive filtering of time series data 00014 * \author Max Moorkamp 00015 * $Id: AdaptiveFilter.h 1816 2009-09-07 11:28:35Z mmoorkamp $ 00016 * 00017 * The class AdaptiveFilter provides the generic interface for all types of adaptive Filters 00018 */ 00019 00020 namespace ublas = boost::numeric::ublas; 00021 //! A generic base class for all types of adaptive filters 00022 /*! The class AdaptiveFilter provides a unified interface for various types 00023 * of adaptive filters and storage for some quantities that are common to all 00024 * of them. Ideally this should facilitate transparent use of all filters in 00025 * any program or routine. See, for example, mtuadaptive.cpp. We assume that the filter length 00026 * and number of output points is constant for the life of the object. 00027 */ 00028 class AdaptiveFilter 00029 { 00030 private: 00031 //! The vector holding the last filter output calculated 00032 gplib::rvec FilterOutput; 00033 //! The vector holding the last estimation error 00034 gplib::rvec Epsilon; 00035 //! length of the input vector to the filter, this is not the time-series length, but the segment the filter operates on 00036 const unsigned int inputlength; 00037 //! length of the filter output 00038 const unsigned int outputlength; 00039 protected: 00040 //! Access function for derived classes for the inputlength 00041 unsigned int GetInputLength() 00042 { 00043 return inputlength; 00044 } 00045 //! Access function for derived classes for the outputlength 00046 unsigned int GetOutputLength() 00047 { 00048 return outputlength; 00049 } 00050 //! Possibility for derived classes to set estimation error 00051 void SetEpsilon(const gplib::rvec &MyEps) 00052 { 00053 Epsilon = MyEps; 00054 } 00055 //! Possibility for derived classes to set output 00056 void SetOutput(const gplib::rvec &Out) 00057 { 00058 FilterOutput = Out; 00059 } 00060 public: 00061 //! Access to the last calculated output (not sure if needed) 00062 const gplib::rvec &GetFilterOutput() const 00063 { 00064 return FilterOutput; 00065 } 00066 //! Return the last estimation error 00067 const gplib::rvec &GetEpsilon() const 00068 { 00069 return Epsilon; 00070 } 00071 //! Print the current set of weights to the output stream, has to be implemented in derived class 00072 virtual void PrintWeights(std::ostream &output) =0; 00073 //! We can always convert the weights to some sort of vector, the details have to be implemented in the derived class 00074 virtual const gplib::rvec &GetWeightsAsVector() = 0; 00075 //! Adapt the filter weights given the Input and Desired vectors 00076 virtual void 00077 AdaptFilter(const gplib::rvec &Input, const gplib::rvec &Desired) = 0; 00078 //! Calculate the filter output given Input 00079 virtual void CalcOutput(const gplib::rvec &Input, gplib::rvec &Output) = 0; 00080 //! The constructor needs to know the length of the input and output vectors for memory allocation 00081 AdaptiveFilter(const int inputsize, const int outputsize); 00082 virtual ~AdaptiveFilter(); 00083 friend class ApplyFilter; 00084 }; 00085 /* @} */ 00086 } 00087 #endif // ADAPTIVEFILTER_H
1.5.8