comparison armadillo-2.4.4/include/armadillo_bits/running_stat_bones.hpp @ 0:8b6102e2a9b0

Armadillo Library
author maxzanoni76 <max.zanoni@eecs.qmul.ac.uk>
date Wed, 11 Apr 2012 09:27:06 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8b6102e2a9b0
1 // Copyright (C) 2009-2011 NICTA (www.nicta.com.au)
2 // Copyright (C) 2009-2011 Conrad Sanderson
3 //
4 // This file is part of the Armadillo C++ library.
5 // It is provided without any warranty of fitness
6 // for any purpose. You can redistribute this file
7 // and/or modify it under the terms of the GNU
8 // Lesser General Public License (LGPL) as published
9 // by the Free Software Foundation, either version 3
10 // of the License or (at your option) any later version.
11 // (see http://www.opensource.org/licenses for more info)
12
13
14 //! \addtogroup running_stat
15 //! @{
16
17
18
19 template<typename eT>
20 class arma_counter
21 {
22 public:
23
24 inline ~arma_counter();
25 inline arma_counter();
26
27 inline const arma_counter& operator++();
28 inline void operator++(int);
29
30 inline void reset();
31 inline eT value() const;
32 inline eT value_plus_1() const;
33 inline eT value_minus_1() const;
34
35
36 private:
37
38 arma_aligned eT d_count;
39 arma_aligned uword i_count;
40 };
41
42
43
44 //! Class for keeping statistics of a continuously sampled process / signal.
45 //! Useful if the storage of individual samples is not necessary or desired.
46 //! Also useful if the number of samples is not known beforehand or exceeds
47 //! available memory.
48 template<typename eT>
49 class running_stat
50 {
51 public:
52
53 typedef typename get_pod_type<eT>::result T;
54
55
56 inline ~running_stat();
57 inline running_stat();
58
59 inline void operator() (const T sample);
60 inline void operator() (const std::complex<T>& sample);
61
62 inline void reset();
63
64 inline eT mean() const;
65
66 inline T var (const uword norm_type = 0) const;
67 inline T stddev(const uword norm_type = 0) const;
68
69 inline eT min() const;
70 inline eT max() const;
71
72 inline T count() const;
73
74 //
75 //
76
77 private:
78
79 arma_aligned arma_counter<T> counter;
80
81 arma_aligned eT r_mean;
82 arma_aligned T r_var;
83
84 arma_aligned eT min_val;
85 arma_aligned eT max_val;
86
87 arma_aligned T min_val_norm;
88 arma_aligned T max_val_norm;
89
90
91 friend class running_stat_aux;
92 };
93
94
95
96 class running_stat_aux
97 {
98 public:
99
100 template<typename eT>
101 inline static void update_stats(running_stat<eT>& x, const eT sample);
102
103 template<typename T>
104 inline static void update_stats(running_stat< std::complex<T> >& x, const T sample);
105
106 template<typename T>
107 inline static void update_stats(running_stat< std::complex<T> >& x, const std::complex<T>& sample);
108
109 };
110
111
112
113 //! @}