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

Last change on this file since 1261 was 1261, checked in by Peter, 13 years ago

changing some u_int to size_t

  • 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 1261 2008-04-08 14:01:33Z peter $
5
6/*
7  Copyright (C) 2007 Peter Johansson
8  Copyright (C) 2008 Jari Häkkinen
9
10  This file is part of the yat library, http://trac.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 2 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 this program; if not, write to the Free Software
24  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25  02111-1307, USA.
26*/
27
28#include <vector>
29
30namespace theplu {
31namespace yat {
32namespace statistics {
33
34  ///
35  /// \brief Interface Class for vector functors.
36  ///
37  struct VectorFunction
38  {
39    /**
40       \brief Destructor
41     */
42    virtual ~VectorFunction();
43
44    /**
45       \brief abstract interface
46     */
47    virtual double operator()(const std::vector<double>&) const=0;
48  };
49
50
51  ///
52  /// @brief Larget element
53  ///
54  struct Max : public VectorFunction
55  {
56    ///
57    /// \return Largest element
58    ///
59    double operator()(const std::vector<double>&) const;
60  };
61
62
63  ///
64  /// @brief Median element
65  ///
66  struct Median : public VectorFunction
67  {
68    ///
69    /// \see statistics::median(std::vector<double>, bool)
70    ///
71    /// \return Median
72    ///
73    double operator()(const std::vector<double>&) const;
74  };
75
76  ///
77  /// \brief Mean element
78  ///
79  struct Mean : public VectorFunction
80  {
81    ///
82    /// \return Mean
83    ///
84    double operator()(const std::vector<double>&) const;
85  };
86
87
88  ///
89  /// \brief Smallest element
90  ///
91  struct Min : public VectorFunction
92  {
93    ///
94    /// \return Smallest element
95    ///
96    double operator()(const std::vector<double>&) const;
97  };
98
99  /**
100     Functor that picks Nth smalles element in a vector.
101   */
102  class Nth_Element : public VectorFunction
103  {
104  public:
105    ///
106    /// \param N equal to 1 gives identical object as Min (but less
107    /// efficient)
108    ///
109    Nth_Element(size_t N);
110
111    ///
112    /// \return Nth smallest element
113    ///
114    double operator()(const std::vector<double>&) const;
115
116  private:
117    size_t N_;
118  };
119
120}}} // of namespace statistics, yat, and theplu
121
122#endif
Note: See TracBrowser for help on using the repository browser.