AdaptiveFilter.h

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

Generated on Tue May 4 16:52:14 2010 for GPLIB++ by  doxygen 1.5.8