iLand
floatingaverage.h
Go to the documentation of this file.
1/********************************************************************************************
2** iLand - an individual based forest landscape and disturbance model
3** http://iland-model.org
4** Copyright (C) 2009- Werner Rammer, Rupert Seidl
5**
6** This program is free software: you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation, either version 3 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program. If not, see <http://www.gnu.org/licenses/>.
18********************************************************************************************/
19
20#ifndef FLOATINGAVERAGE_H
21#define FLOATINGAVERAGE_H
22#include <QVector>
27{
28public:
30 FloatingAverage(int size) { setup(size); }
31 void setup(const int size, const double InitValue = 0.);
32 double add(double add_value);
33
34 double average() const {return mCurrentAverage; }
35 double sum() const;
36private:
37 double mCurrentAverage;
38 QVector<double> mData;
39 int mSize;
40 int mPos;
41 bool mFilled;
42 double mInitValue;
43
44};
45#endif // FLOATINGAVERAGE_H
Helper class for floating averages.
Definition: floatingaverage.h:27
double sum() const
retrieve total sum of values.
Definition: floatingaverage.cpp:67
void setup(const int size, const double InitValue=0.)
Definition: floatingaverage.cpp:31
double add(double add_value)
add a value and return current average
Definition: floatingaverage.cpp:44
FloatingAverage(int size)
Definition: floatingaverage.h:30
FloatingAverage()
Definition: floatingaverage.cpp:23
double average() const
retrieve current average
Definition: floatingaverage.h:34