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

Last change on this file since 1703 was 1487, checked in by Jari Häkkinen, 13 years ago

Addresses #436. GPL license copy reference should also be updated.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1#ifndef _theplu_yat_statistics_vector_function_
2#define _theplu_yat_statistics_vector_function_
3
4// $Id: VectorFunction.h 1487 2008-09-10 08:41:36Z jari $
5
6/*
7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
8
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include <vector>
26
27namespace theplu {
28namespace yat {
29namespace statistics {
30
31  ///
32  /// \brief Interface Class for vector functors.
33  ///
34  struct VectorFunction
35  {
36    /**
37       \brief Destructor
38     */
39    virtual ~VectorFunction();
40
41    /**
42       \brief abstract interface
43     */
44    virtual double operator()(const std::vector<double>&) const=0;
45  };
46
47
48  ///
49  /// @brief Larget element
50  ///
51  struct Max : public VectorFunction
52  {
53    ///
54    /// \return Largest element
55    ///
56    double operator()(const std::vector<double>&) const;
57  };
58
59
60  ///
61  /// @brief Median element
62  ///
63  struct Median : public VectorFunction
64  {
65    ///
66    /// \see statistics::median(std::vector<double>, bool)
67    ///
68    /// \return Median
69    ///
70    double operator()(const std::vector<double>&) const;
71  };
72
73  ///
74  /// \brief Mean element
75  ///
76  struct Mean : public VectorFunction
77  {
78    ///
79    /// \return Mean
80    ///
81    double operator()(const std::vector<double>&) const;
82  };
83
84
85  ///
86  /// \brief Smallest element
87  ///
88  struct Min : public VectorFunction
89  {
90    ///
91    /// \return Smallest element
92    ///
93    double operator()(const std::vector<double>&) const;
94  };
95
96  /**
97     Functor that picks Nth smalles element in a vector.
98   */
99  class Nth_Element : public VectorFunction
100  {
101  public:
102    ///
103    /// \param N equal to 1 gives identical object as Min (but less
104    /// efficient)
105    ///
106    Nth_Element(size_t N);
107
108    ///
109    /// \return Nth smallest element
110    ///
111    double operator()(const std::vector<double>&) const;
112
113  private:
114    size_t N_;
115  };
116
117}}} // of namespace statistics, yat, and theplu
118
119#endif
Note: See TracBrowser for help on using the repository browser.