File sliding_window.hpp

Functions

template<typename NT>
NT relativeError(NT approx, NT exact)

Computes the relative error

Template Parameters:

NT – Numeric type

Parameters:
  • approx[in] The approximated value

  • exact[in] The exact value

Returns:

The relative error

template<typename NT>
class SlidingWindow
#include <sliding_window.hpp>

A sliding window, which allows to get the relative error of approximations

Template Parameters:

NT – Numeric type

Public Functions

inline SlidingWindow(int windowSize)

Constructor

Parameters:

windowSize[in] The size of the window

inline void push(NT approximation)

Adds an approximation in the window

Parameters:

approximation[in] The new approximation

inline double getRelativeError()
Returns:

The relative error between the youngest and oldest approximations

Public Members

std::list<NT> approximations

The stored approximations.

int windowSize

The size of the window.

int numEntries

The number of entries in list approximations.