Commit 65467bbb authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

proceeding

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 2188
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent b7f67280
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: firfilters.h,v 1.1 2006-11-21 16:36:55 tforb Exp $
* $Id: firfilters.h,v 1.2 2006-11-21 16:51:16 tforb Exp $
* \author Thomas Forbriger
* \date 21/11/2006
*
......@@ -39,7 +39,10 @@
#define TF_FIRFILTERS_H_VERSION \
"TF_FIRFILTERS_H V1.0 "
#define TF_FIRFILTERS_H_CVSID \
"$Id: firfilters.h,v 1.1 2006-11-21 16:36:55 tforb Exp $"
"$Id: firfilters.h,v 1.2 2006-11-21 16:51:16 tforb Exp $"
#include<aff/series.h>
#include<aff/iterator.h>
namespace ts {
......@@ -62,6 +65,57 @@ namespace ts {
extern const FIR SeisCompLP;
extern const FIR SeisCompVLP;
/*! Class to evaluate a FIR filter
*
* Add new sample through member function push().
* Member function pop() returns result.
*
* \note
* This class highly depends on the property of AFF container iterators to
* by cyclic.
*/
template<class T>
class FIRfilter {
public:
typedef T Tvalue;
typedef aff::Series<Tvalue> Tseries;
typedef aff::Iterator<Tseries> Titerator;
FIRfilter(FIR* fir): Mfir(fir), Ms(fir.points), Mi(Ms)
{ this->clear(); }
void push(const Tvalue& v)
{
*Mi = v;
++Mi;
}
Tvalue pop() const
{
Titerator Ml=Mi;
Tvalue sum=0;
if (Mfir->symmetric)
{
for (int i=0; i<Mfir->points / 2; ++i)
{ sum += *(Ml--) * Mfir->c[i] * Mfir->gain; }
for (int i= Mfir->points/2 -1; i>=0; --i)
{ sum += *(Ml--) * Mfir->c[i] * Mfir->gain; }
}
else
{
for (int i=0; i<Mfir->points; ++i)
{ sum += *(Ml--) * Mfir->c[i] * Mfir->gain; }
}
}
void clear()
{
Mi.tofirst();
while (Mi.valid()) *(Mi++)=0;
Mi.tofirst();
}
private:
FIR* Mfir;
Tseries Ms;
Titerator Mi;
};
} // namespace fir
} // namespace ts
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment