TS++ library: time series library
innerproduct.h
Go to the documentation of this file.
1 
35 // include guard
36 #ifndef TF_INNERPRODUCT_H_VERSION
37 
38 #define TF_INNERPRODUCT_H_VERSION \
39  "TF_INNERPRODUCT_H V1.0 "
40 
41 #include<aff/series.h>
42 
43 namespace ts {
44 
65  template<class T>
66  T innerproduct(const aff::ConstSeries<T>& a,
67  const aff::ConstSeries<T>& b)
68  {
69  T retval=0;
70  long int first=(a.first() > b.first() ? a.first() : b.first());
71  long int last=(a.last() < b.last() ? a.last() : b.last());
72  if (last >= first)
73  {
74  for (int i=first; i<=last; i++)
75  {
76  retval += a(i)*b(i);
77  }
78  }
79  return(retval);
80  } // innerproduct
81 
92  template<class T>
93  T rms(const aff::ConstSeries<T>& a)
94  { return(sqrt(innerproduct(a,a)/a.size())); }
95 
96 } // namespace ts
97 
98 #endif // TF_INNERPRODUCT_H_VERSION (includeguard)
99 
100 /* ----- END OF innerproduct.h ----- */
void first(const Tseries &s)
Definition: seifexx.cc:117
T innerproduct(const aff::ConstSeries< T > &a, const aff::ConstSeries< T > &b)
Calculate inner product of two series.
Definition: innerproduct.h:66
All stuff in this library will be placed within namespace ts.
Definition: anyfilter.cc:43
T rms(const aff::ConstSeries< T > &a)
Calculate rms value.
Definition: innerproduct.h:93