Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

fir_adapt.h

Go to the documentation of this file.
00001 // Copyright (c) 1993-1996 Tony Kirke
00002 // 
00003 // author="Tony Kirke"
00004 /*
00005  * SPUC - Signal processing using C++ - A DSP library
00006  * 
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2, or (at your option)
00010  * any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 */
00021 #ifndef FIRA
00022 #define FIRA
00023 #include <fir.h>
00024 namespace SPUC {
00028 
00029 
00030 
00031 
00032 template <class Numeric> class fir_adapt : public fir<Numeric>
00033 {
00034  public: 
00036   double u;
00037     
00038  public: 
00040   fir_adapt<Numeric>(void) { u=0.01;    };
00042   fir_adapt<Numeric>(long n, double gain=0.01) : u(gain), fir<Numeric>(n) {     };
00044   void reset() {
00045         fir<Numeric>::reset();
00046         for (int i=0;i<fir<Numeric>::num_taps;i++) fir<Numeric>::coeff[i] = 0;
00047   }
00049   void set_gain(double gain) { u = gain;}
00051   void update_lms(Numeric err) {
00052         for (int i=0;i<fir<Numeric>::num_taps;i++) fir<Numeric>::coeff[i] += u*err*conj(fir<Numeric>::z[i]);
00053   }
00055   void update_lms_sign_coeff(Numeric err) {
00056         for (int i=0;i<fir<Numeric>::num_taps;i++) fir<Numeric>::coeff[i] += u*err*signbit(conj(fir<Numeric>::z[i]));
00057   }
00058 };      
00059 } // namespace SPUC 
00060 #endif

Generated on Fri Sep 16 11:02:26 2005 for spuc by  doxygen 1.4.4