Public Member Functions | Private Attributes | List of all members
dune::SlidingAverage< T > Class Template Reference

#include <SlidingAverage.hh>

Public Member Functions

 SlidingAverage (unsigned _length)
 
void add_value (T value)
 
sum ()
 
avg ()
 

Private Attributes

const unsigned length
 
unsigned pt
 
std::vector< T > values
 
current_sum
 

Detailed Description

template<typename T>
class dune::SlidingAverage< T >

Definition at line 17 of file SlidingAverage.hh.

Constructor & Destructor Documentation

template<typename T >
dune::SlidingAverage< T >::SlidingAverage ( unsigned  _length)
inline

Definition at line 19 of file SlidingAverage.hh.

19 : length(_length), pt(0), values(_length), current_sum(0) {};
std::vector< T > values
const unsigned length

Member Function Documentation

template<typename T >
void dune::SlidingAverage< T >::add_value ( value)
inline

Definition at line 21 of file SlidingAverage.hh.

21  {
22  current_sum -= values[pt];
23  current_sum += value;
24  values[pt] = value;
25  pt = (pt + 1) % length;
26  }
std::vector< T > values
const unsigned length
template<typename T >
T dune::SlidingAverage< T >::avg ( )
inline

Definition at line 32 of file SlidingAverage.hh.

template<typename T >
T dune::SlidingAverage< T >::sum ( )
inline

Definition at line 28 of file SlidingAverage.hh.

28  {
29  return current_sum;
30  }

Member Data Documentation

template<typename T >
T dune::SlidingAverage< T >::current_sum
private

Definition at line 40 of file SlidingAverage.hh.

template<typename T >
const unsigned dune::SlidingAverage< T >::length
private

Definition at line 37 of file SlidingAverage.hh.

template<typename T >
unsigned dune::SlidingAverage< T >::pt
private

Definition at line 38 of file SlidingAverage.hh.

template<typename T >
std::vector<T> dune::SlidingAverage< T >::values
private

Definition at line 39 of file SlidingAverage.hh.


The documentation for this class was generated from the following file: