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

Last change on this file since 827 was 827, checked in by Peter, 16 years ago

added Functors to be used in CIR. Refs #151

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1#ifndef _theplu_yat_statistics_vector_function_
2#define _theplu_yat_statistics_vector_function_
3
4// $Id: VectorFunction.h 827 2007-03-19 18:52:36Z peter $
5
6/*
7  Copyright (C) The authors contributing to this file.
8
9  This file is part of the yat library, http://lev.thep.lu.se/trac/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 2 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 this program; if not, write to the Free Software
23  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24  02111-1307, USA.
25*/
26
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    virtual ~VectorFunction();
39    virtual double operator()(const std::vector<double>&) const=0;
40  };
41
42
43  struct Max : public VectorFunction
44  {
45    ///
46    /// \return Largest element
47    ///
48    double operator()(const std::vector<double>&) const;
49  };
50
51
52  struct Median : public VectorFunction
53  {
54    ///
55    /// \return Median
56    ///
57    double operator()(const std::vector<double>&) const;
58  };
59
60
61  struct Mean : public VectorFunction
62  {
63    ///
64    /// \return Mean
65    ///
66    double operator()(const std::vector<double>&) const;
67  };
68
69
70  struct Min : public VectorFunction
71  {
72    ///
73    /// \return Smallest element
74    ///
75    double operator()(const std::vector<double>&) const;
76  };
77
78
79  class Nth_Element : public VectorFunction
80  {
81  public:
82    ///
83    /// \param N equal to 1 gives identical object as Min (but less
84    /// efficient)
85    ///
86    Nth_Element(u_int N);
87
88    ///
89    /// \return Nth smallest element
90    ///
91    double operator()(const std::vector<double>&) const;
92
93  private:
94    u_int N_;
95  };
96
97}}} // of namespace statistics, yat, and theplu
98
99#endif
Note: See TracBrowser for help on using the repository browser.