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