// senf::StatisticAccumulator<T>
template <class T>
-prefix_ senf::StatisticAccumulator<T>::StatisticAccumulator( T defaultvalue)
- : defaultvalue_(defaultvalue),
- sum_squared_(defaultvalue*defaultvalue),
- sum_(defaultvalue),
- min_(defaultvalue),
- max_(defaultvalue),
- last_avg_(float(defaultvalue)),
+prefix_ senf::StatisticAccumulator<T>::StatisticAccumulator( )
+ : sum_squared_(0),
+ sum_(0),
+ min_(0),
+ max_(0),
+ last_avg_(0),
count_(0)
{
}
{
last_avg_ = avg();
count_ = 0;
- sum_squared_ = defaultvalue_*defaultvalue_;
- sum_ = min_ = max_ = defaultvalue_;
+ sum_squared_ = 0;
+ sum_ = min_ = max_ = 0;
}
class StatisticAccumulator
{
public:
- StatisticAccumulator( T defaultvalue = 0);
+ StatisticAccumulator();
// virtual ~StatisticAccumulator();
void clear();
///< Reset accumulated values.
- /**< This member reset all avg/min/max values to the given \a
- defaultvalue and the count to zero. */
+ /**< This member reset all values. */
void accumulate(T value);
///< Gather value to be accumulated.
/**< This method accumulate a value.
/**< This method returns count of accumulated values of the current accumulation.*/
private:
- T defaultvalue_;
T sum_squared_;
T sum_;
T min_;
#include "Statistics.hh"
#include "auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
-#include <boost/math/special_functions/fpclassify.hpp>
+#include <math.h>
+//#include <boost/math/special_functions/fpclassify.hpp>
#define prefix_
///////////////////////////////ct.p////////////////////////////////////////
BOOST_CHECK_EQUAL( sa.max(), 0);
BOOST_CHECK_EQUAL( sa.min(), 0);
- BOOST_CHECK( (boost::math::isnan)( sa.avg()));
+// BOOST_CHECK( (boost::math::isnan)( sa.avg()));
+ BOOST_CHECK( ::isnan( sa.avg()) != 0);
BOOST_CHECK_EQUAL( sa.last_avg(), 5.0);
- BOOST_CHECK( (boost::math::isnan)( sa.stddev()));
+ BOOST_CHECK( ::isnan( sa.stddev()));
BOOST_CHECK_EQUAL( sa.count(), 0);