IIRFilter.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno    
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00026 
00030 
00031 #ifndef __IIR_FILTER_H_
00032 #define __IIR_FILTER_H_
00033 
00034 #ifdef MIP_HOST_APPLE
00035 #include <applePatch.h>
00036 #endif
00037 
00038 #include <vector>
00039 #include <list>
00040 
00041 #include<baselib.h>
00042 
00043 
00044 using namespace MipBaselib;
00045 
00047 /* @{ */
00048 
00049 
00050 // esempio per order = 3
00051 // implementa la funzione di trasferimento:
00052 // _inCoeff[0]  +  _inCoeff[1] z +  _inCoeff[2] z^2 + _inCoeff[3] z^3
00053 // ------------------------------------------------------------------
00054 //      _outCoeff[0] + _outCoeff[1] z + _outCoeff[2] z^2 + z^3
00055 //
00056 // ossia
00057 //
00058 //y[t] =  _inCoeff[0] * u[t-3] +  _inCoeff[1] * u[t-2] +  _inCoeff[2] * u[t-1] + _inCoeff[3] * u[t]
00059 //   - _outCoeff[0] * y[t-3] - _outCoeff[1] * y[t-2] - _outCoeff[2] * y[t-1]
00060 
00067 class IIRFilter{
00068  private:
00069   vector< vector<Decimal> > _inCoeff;
00070   vector<Decimal> _outCoeff;
00071   vector< list<Decimal> > _pastIns;
00072   list<Decimal> _pastOuts;
00073   int _order;
00074   int _inNum;
00075   list<Decimal>::iterator outIt,inIt;
00076   int iCo,iIn;
00077   
00078   void _kernelConstructor(vector< vector<Decimal> > &inputCoeff,vector<Decimal> &outputCoeff);
00079  public:
00080   
00091   IIRFilter(vector<Decimal> &inputCoeff,vector<Decimal> &outputCoef);
00092   
00103   IIRFilter(vector< vector<Decimal> > &inputCoeff,vector<Decimal> &outputCoef);
00104   
00105   
00106   
00107   
00108   ~IIRFilter();
00109 
00111   IIRFilter(const IIRFilter& t);
00112   
00114   IIRFilter& operator=(const IIRFilter& t);
00115   
00120   void step(const Decimal &in,Decimal& out);
00121   
00125   void step(const vector<Decimal>& in,Decimal& out);
00126 };
00127 
00128 /* @} */
00129 
00130 #endif
00131 
00132 
00133 
00134 

Generated on Mon Feb 20 07:01:06 2017 for MIP by  doxygen 1.5.6