00001 #ifndef LSSOFILTER_H_ 00002 #define LSSOFILTER_H_ 00003 00004 #include "AdaptiveFilter.h" 00005 00006 namespace gplib 00007 { 00008 /** \addtogroup sigproc Signal processing methods */ 00009 /* @{ */ 00010 00011 //! Base class for least squares filter with a single output value 00012 /*!***************************************************** 00013 * Base class for Least-Square filters with a single output value 00014 * currently used for LMS and RLS filters, implements all virtual 00015 * functions from AdaptiveFilters apart from AdaptFilter, which 00016 * depends on the functionality of the individual filter 00017 * 00018 * 00019 * *****************************************************/ 00020 class LSSOFilter: public AdaptiveFilter 00021 { 00022 private: 00023 //! For single output values the weights can be stored in a vector 00024 gplib::rvec Weights; 00025 protected: 00026 gplib::rvec &SetWeights() 00027 { 00028 return Weights; 00029 } 00030 public: 00031 //! The way to calculate the output is the same for all single output filters, we implement it here 00032 virtual void CalcOutput(const gplib::rvec &Input, gplib::rvec &Output); 00033 //! For single channel output we can also just return the output as a double 00034 double CalcOutput(const gplib::rvec &Input) 00035 { 00036 gplib::rvec temp; 00037 CalcOutput(Input, temp); 00038 return temp(0); 00039 } 00040 //! Return the current set of weights 00041 const gplib::rvec &GetWeights() 00042 { 00043 return Weights; 00044 } 00045 //! Implement the abstract function from adaptive filter, in this case just another name for GetWeights 00046 virtual const gplib::rvec &GetWeightsAsVector() 00047 { 00048 return Weights; 00049 } 00050 //! Print the weights to output stream 00051 virtual void PrintWeights(std::ostream &output); 00052 //! The constructor only needs the filter length, outputsize for Adaptive filter is 1 00053 LSSOFilter(const int filterlength); 00054 virtual ~LSSOFilter(); 00055 //! We declare friend classes for easier access to the Weight vector 00056 }; 00057 /* @} */ 00058 } 00059 #endif /*CLSSOFILTER_H_*/
1.5.8