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

iir_df.h

Go to the documentation of this file.
00001 // 
00002 // Copyright(c) 1993-1996 Tony Kirke
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 IIR_DF
00022 #define IIR_DF
00023 #include <fir.h>
00024 namespace SPUC {
00033 
00034 
00035 
00036 
00037 
00038 template <class Numeric> class iir_df
00039 {
00040  public: 
00041         fir<Numeric> poles;
00042         fir<Numeric> zeros;
00043         Numeric output;
00044         int err;
00045   
00046  public: 
00048   void reset() {        
00049           poles.reset();
00050           zeros.reset();
00051           output = 0;
00052   }
00054   Numeric out() { return(output); }
00055   ~iir_df(void) {  }
00057   iir_df(const char* filep, const char* filez) { 
00058           err = 0;
00059           err  = poles.read_taps(filep);
00060           err += zeros.read_taps(filez);
00061   };               
00062   iir_df<Numeric>(const iir_df<Numeric>& cp) : poles(cp.poles.num_taps), zeros(cp.zeros.num_taps) {
00063           int i;
00064           for (i=0;i<cp.poles.num_taps;i++) poles.coeff[i] = cp.poles.coeff[i];
00065           for (i=0;i<cp.zeros.num_taps;i++) zeros.coeff[i] = cp.zeros.coeff[i];
00066   };               
00067           //  iir_df(void) : poles(NULL), zeros(NULL) {; }
00068   Numeric clock(Numeric in) { return(update(in)); }
00069   Numeric update(Numeric in) {
00070           if (err) return(0);
00071           else {
00072                   output = zeros.update(in);
00073                   output = poles.iir(output);
00074                   return(output);
00075           }
00076   }
00077   void print(void) {
00078           poles.print();
00079           zeros.print();
00080   }
00081 };    
00082 } // namespace SPUC 
00083 #endif      

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