ACT-CV - Machine Vision for Cognitive Modeling
DynamicsHelpers.h
Go to the documentation of this file.
1 // -*- mode: c++; indent-tabs-mode: nil; c-basic-offset: 4; coding: iso-8859-1; -*-
2 
3 /*
4 ACT-CV - Machine Vision for Cognitive Modeling
5 Copyright (c) 2008 Marc Halbruegge
6 
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11 
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21 
22 
30 #ifndef __DYNAMICS_HELPERS_H
31 #define __DYNAMICS_HELPERS_H
32 
33 
44 template<class _t> class ExpGlaett {
45  _t x;
46  float anteil;
47  public:
48  ExpGlaett() {}
49  ExpGlaett(const _t &f, float a) : x(f), anteil(a){}
50  void setNeuAnteil(float f) {
51  anteil=f;
52  }
53  void add(const _t &f) {
54  x = x *(1-anteil) + f*anteil;
55  }
56  void set(const _t &f) {
57  x=f;
58  }
59  _t get() const {
60  return x;
61  }
62  operator _t() const {
63  return get();
64  }
65 };
66 
71 template<class _t> class Mittelwert {
72  _t summe;
73  int N;
74  public:
75  Mittelwert(const _t &start) : summe(start), N(1) {}
76  Mittelwert() : summe(0), N(0) {};
77  operator _t () const {
78  return getMittel();
79  }
80  _t getMittel() const {
81  return static_cast<_t>(summe / N);
82  }
83  void add(const _t &x) {
84  summe += x;
85  N++;
86  }
87  _t getSumme() const {
88  return summe;
89  }
90  int getNumberOfCases() const {
91  return N;
92  }
93 };
94 
99 template<class _t> class Veraenderung {
102  public:
104  void Set(const _t &x) {
105  differenz -= differenz;
106  aktuell = x;
107  }
108  void Add(const _t &x) {
109  differenz = x - aktuell;
110  aktuell = x;
111  }
112  const _t& GetCurrent() const {
113  return aktuell;
114  }
115  const _t& GetDiff() const {
116  return differenz;
117  }
118 };
119 
120 
121 
122 #endif // __DYNAMICS_HELPERS_H


ACT-CV - Machine Vision for Cognitive Modeling
© 2015 Marc Halbruegge (actcvlibrary@googlemail.com)