TS++ library: time series library
convolve.h
Go to the documentation of this file.
1 
35 // include guard
36 #ifndef TF_CONVOLVE_H_VERSION
37 
38 #define TF_CONVOLVE_H_VERSION \
39  "TF_CONVOLVE_H V1.0"
40 
41 #include<aff/series.h>
42 
43 namespace ts {
44 
102  template<class T>
103  aff::Series<T> convolve(const aff::ConstSeries<T>& a,
104  const aff::ConstSeries<T>& b)
105  {
106  aff::Series<T> retval(a.first()+b.first(),b.last()+a.last());
107  for (long int k=retval.first(); k<=retval.last(); ++k)
108  {
109  retval(k)=T(0);
110  long int lmin=a.first() > (k-b.last()) ? a.first() : (k-b.last());
111  long int lmax=a.last() < (k-b.first()) ? a.last() : (k-b.first());
112  for(long int l=lmin; l<=lmax; ++l)
113  {
114  retval(k)+=a(l)*b(k-l);
115  }
116  }
117  return(retval);
118  } // convolve
119 
120 } // namespace ts
121 
122 #endif // TF_CONVOLVE_H_VERSION (includeguard)
123 
124 /* ----- END OF convolve.h ----- */
aff::Series< T > convolve(const aff::ConstSeries< T > &a, const aff::ConstSeries< T > &b)
Calculate convolution of two series.
Definition: convolve.h:103
All stuff in this library will be placed within namespace ts.
Definition: anyfilter.cc:43