#ifndef _theplu_yat_statistics_average_
#define _theplu_yat_statistics_average_
// $Id: Average.h 1487 2008-09-10 08:41:36Z jari $
/*
Copyright (C) 2008 Peter Johansson
This file is part of the yat library, http://dev.thep.lu.se/yat
The yat library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.
The yat library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with yat. If not, see .
*/
#include "averager_traits.h"
#include "utility.h"
namespace theplu {
namespace yat {
namespace statistics {
/**
\brief Functor to take average of a range.
\since New in yat 0.5
*/
struct Average
{
/**
If range is weighted an AveragerWeighted is used else a Averager.
\return average of range
*/
template
inline double operator()(InputIterator first, InputIterator last) const
{
typename averager::type a;
add(a, first, last);
return a.mean();
}
};
}}} // of namespace statistics, yat, and theplu
#endif