TS++ library: time series library

◆ innerproduct()

template<class T >
T ts::innerproduct ( const aff::ConstSeries< T > &  a,
const aff::ConstSeries< T > &  b 
)

Calculate inner product of two series.

If both series are of unequal index range, they are padded with zeros.

The function evaluates

\[ c_k = \sum\limits_{l=F}^{L} a_l b_l, \]

where the index ranges of the input series are $ a_l: l \in [F_a,L_a] $ and $ b_l: l \in [F_b,L_b]. $ and $F=\textrm{max}(F_a,F_b)$ as well as $L=\textrm{min}(L_a,L_b).$

Parameters
a$ a_l $
b$ b_l $
Returns
c $ c_l $

Definition at line 66 of file innerproduct.h.

References ts::seife::first().

Referenced by rms().

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
void first(const Tseries &s)
Definition: seifexx.cc:117
Here is the call graph for this function:
Here is the caller graph for this function: