source: trunk/yat/statistics/VectorFunction.h @ 2986

Last change on this file since 2986 was 2986, checked in by Peter, 9 years ago

merge 0.10-stable branch into trunk

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1#ifndef _theplu_yat_statistics_vector_function_
2#define _theplu_yat_statistics_vector_function_
3
4// $Id: VectorFunction.h 2986 2013-02-18 08:07:44Z peter $
5
6/*
7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2013 Jari Häkkinen
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 <cstddef>
27#include <vector>
28
29namespace theplu {
30namespace yat {
31namespace statistics {
32
33  ///
34  /// \brief Interface Class for vector functors.
35  ///
36  struct VectorFunction
37  {
38    /**
39       \brief Destructor
40     */
41    virtual ~VectorFunction();
42
43    /**
44       \brief abstract interface
45     */
46    virtual double operator()(const std::vector<double>&) const=0;
47  };
48
49
50  ///
51  /// @brief Larget element
52  ///
53  struct Max : public VectorFunction
54  {
55    ///
56    /// \return Largest element
57    ///
58    double operator()(const std::vector<double>&) const;
59  };
60
61
62  ///
63  /// @brief Median element
64  ///
65  struct Median : public VectorFunction
66  {
67    ///
68    /// \see statistics::median(std::vector<double>, bool)
69    ///
70    /// \return Median
71    ///
72    double operator()(const std::vector<double>&) const;
73  };
74
75  ///
76  /// \brief Mean element
77  ///
78  struct Mean : public VectorFunction
79  {
80    ///
81    /// \return Mean
82    ///
83    double operator()(const std::vector<double>&) const;
84  };
85
86
87  ///
88  /// \brief Smallest element
89  ///
90  struct Min : public VectorFunction
91  {
92    ///
93    /// \return Smallest element
94    ///
95    double operator()(const std::vector<double>&) const;
96  };
97
98  /**
99     Functor that picks Nth smalles element in a vector.
100   */
101  class Nth_Element : public VectorFunction
102  {
103  public:
104    ///
105    /// \param N equal to 1 gives identical object as Min (but less
106    /// efficient)
107    ///
108    Nth_Element(size_t N);
109
110    ///
111    /// \return Nth smallest element
112    ///
113    double operator()(const std::vector<double>&) const;
114
115  private:
116    size_t N_;
117  };
118
119}}} // of namespace statistics, yat, and theplu
120
121#endif
Note: See TracBrowser for help on using the repository browser.