Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef MOVING_AVERAGE_H_
00013 #define MOVING_AVERAGE_H_
00014
00015 #include "stdafx.h"
00016 #include "settings_type.h"
00017 #include "core/math_func.hpp"
00018
00026 template<class Tvalue>
00027 class MovingAverage {
00028 protected:
00029 uint length;
00030
00031 public:
00036 FORCEINLINE MovingAverage(uint length) : length(length)
00037 {
00038 assert(this->length > 0);
00039 }
00040
00045 FORCEINLINE uint Length() const
00046 {
00047 return this->length;
00048 }
00049
00060 FORCEINLINE Tvalue Monthly(const Tvalue &value) const
00061 {
00062 return (value * 30) / (this->length);
00063 }
00064
00070 FORCEINLINE Tvalue &Decrease(Tvalue &value) const
00071 {
00072 return value = (value * this->length) / (this->length + 1);
00073 }
00074 };
00075
00076 template<class Titem> void RunAverages();
00077
00078 #endif