source: trunk/yat/statistics/Average.h

Last change on this file was 3550, checked in by Peter, 5 years ago

Update copyright years. Happy New Year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
1#ifndef _theplu_yat_statistics_average_
2#define _theplu_yat_statistics_average_
3
4// $Id: Average.h 3550 2017-01-03 05:41:02Z peter $
5
6/*
7  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2016 Peter Johansson
9
10  This file is part of the yat library, http://dev.thep.lu.se/yat
11
12  The yat library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU General Public License as
14  published by the Free Software Foundation; either version 3 of the
15  License, or (at your option) any later version.
16
17  The yat library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  General Public License for more details.
21
22  You should have received a copy of the GNU General Public License
23  along with yat. If not, see <http://www.gnu.org/licenses/>.
24*/
25
26#include "averager_traits.h"
27#include "utility.h"
28
29namespace theplu {
30namespace yat {
31namespace statistics {
32
33  /**
34     \brief Functor to take average of a range.
35
36     \since New in yat 0.5
37   */
38  struct Average
39  {
40    /**
41       If range is weighted an AveragerWeighted is used else a Averager.
42
43       \return average of range
44
45       Type Requirements:
46       - \c InputIterator is a \readable_iterator
47       - \c InputIterator is \single_pass_iterator
48     */
49    template<typename InputIterator>
50    inline double operator()(InputIterator first, InputIterator last) const
51    {
52      typename averager<InputIterator>::type a;
53      add(a, first, last);
54      return a.mean();
55    }
56  };
57
58}}} // of namespace statistics, yat, and theplu
59
60#endif
Note: See TracBrowser for help on using the repository browser.