All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions
GpCoreTools::MovingStatistics Class Reference

Brief description of class still missing. More...

#include <MovingStatistics.h>

Inheritance diagram for GpCoreTools::MovingStatistics:
GpCoreTools::Statistics

List of all members.

Public Member Functions

void add (double val)
void addMinMax (double val)
 MovingStatistics ()
 MovingStatistics (int size)
void reset (int size)
void set (double val)
 ~MovingStatistics ()

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

Description of constructor still missing

References TRACE.

    : Statistics()
  {
    TRACE;
    _values=0;
    _currentIndex=0;
    _size=0;
  }

Description of constructor still missing

References TRACE.

    : Statistics()
  {
    TRACE;
    _values=new double[size];
    _currentIndex=0;
    _size=size;
  }

Description of destructor still missing

References TRACE.

  {
    TRACE;
    delete [] _values;
  }

Member Function Documentation

void GpCoreTools::MovingStatistics::add ( double  val)

Add a new value. Minimum and maximum are not calculated.

Reimplemented from GpCoreTools::Statistics.

References GpCoreTools::Statistics::_count, GpCoreTools::Statistics::_sum, and GpCoreTools::Statistics::_sum2.

Referenced by addMinMax().

  {
    if(_count<_size) {
      _sum+=val;
      _sum2+=val*val;
      _count++;
    } else {
      if(_currentIndex==_size) {
        _currentIndex=0;
      }
      double oldVal=_values[_currentIndex];
      _sum+=val-oldVal;
      _sum2+=val*val-oldVal*oldVal;
    }
    _values[_currentIndex]=val;
    _currentIndex++;
  }

Add a new value. Minimum and maximum are calculated.

References GpCoreTools::Statistics::_count, GpCoreTools::Statistics::_maximum, GpCoreTools::Statistics::_minimum, GpCoreTools::Statistics::_sum, GpCoreTools::Statistics::_sum2, and add().

  {
    if(_count<_size) {
      Statistics::add(val);
      _values[_currentIndex]=val;
    } else {
      if(_currentIndex==_size) {
        _currentIndex=0;
      }
      double oldVal=_values[_currentIndex];
      _sum+=val-oldVal;
      _sum2+=val*val-oldVal*oldVal;
      _values[_currentIndex]=val;
      if(oldVal==_minimum || oldVal==_maximum) {
        for(int i=0; i<_size; i++) {
          val=_values[i];
          if(val<_minimum) _minimum=val;
          if(val>_maximum) _maximum=val;
        }
      } else {
        if(val<_minimum) _minimum=val;
        if(val>_maximum) _maximum=val;
      }
    }
    _currentIndex++;
  }

References GpCoreTools::Statistics::reset().

Referenced by CubeBuffer::CubeBuffer().

  {
    if(size>_size) {
      delete [] _values;
      if(size>0) {
        _values=new double[size];
      } else {
        _values=0;
      }
    }
    _size=size;
    Statistics::reset();
    _currentIndex=0;
  }
void GpCoreTools::MovingStatistics::set ( double  val)

Reimplemented from GpCoreTools::Statistics.

  {
    Statistics::set(val);
    _currentIndex=1;
  }

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines