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

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

Made the project to compile on my Intel Mac running Leopard.

  • 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 1260 2008-04-08 06:16:53Z jari $
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
30#include <sys/types.h>
31
32namespace theplu {
33namespace yat {
34namespace statistics {
35
36  ///
37  /// \brief Interface Class for vector functors.
38  ///
39  struct VectorFunction
40  {
41    /**
42       \brief Destructor
43     */
44    virtual ~VectorFunction();
45
46    /**
47       \brief abstract interface
48     */
49    virtual double operator()(const std::vector<double>&) const=0;
50  };
51
52
53  ///
54  /// @brief Larget element
55  ///
56  struct Max : public VectorFunction
57  {
58    ///
59    /// \return Largest element
60    ///
61    double operator()(const std::vector<double>&) const;
62  };
63
64
65  ///
66  /// @brief Median element
67  ///
68  struct Median : public VectorFunction
69  {
70    ///
71    /// \see statistics::median(std::vector<double>, bool)
72    ///
73    /// \return Median
74    ///
75    double operator()(const std::vector<double>&) const;
76  };
77
78  ///
79  /// \brief Mean element
80  ///
81  struct Mean : public VectorFunction
82  {
83    ///
84    /// \return Mean
85    ///
86    double operator()(const std::vector<double>&) const;
87  };
88
89
90  ///
91  /// \brief Smallest element
92  ///
93  struct Min : public VectorFunction
94  {
95    ///
96    /// \return Smallest element
97    ///
98    double operator()(const std::vector<double>&) const;
99  };
100
101  /**
102     Functor that picks Nth smalles element in a vector.
103   */
104  class Nth_Element : public VectorFunction
105  {
106  public:
107    ///
108    /// \param N equal to 1 gives identical object as Min (but less
109    /// efficient)
110    ///
111    Nth_Element(u_int N);
112
113    ///
114    /// \return Nth smallest element
115    ///
116    double operator()(const std::vector<double>&) const;
117
118  private:
119    u_int N_;
120  };
121
122}}} // of namespace statistics, yat, and theplu
123
124#endif
Note: See TracBrowser for help on using the repository browser.