source: mmcs/armadillo_bits/running_stat_bones.hpp @ 8daa049

matrices
Last change on this file since 8daa049 was 9dd61b1, checked in by rboet <rboet@…>, 9 years ago

Avance del proyecto 60%

  • Property mode set to 100644
File size: 2.5 KB
Line 
1// Copyright (C) 2009-2013 Conrad Sanderson
2// Copyright (C) 2009-2013 NICTA (www.nicta.com.au)
3//
4// This Source Code Form is subject to the terms of the Mozilla Public
5// License, v. 2.0. If a copy of the MPL was not distributed with this
6// file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
8
9//! \addtogroup running_stat
10//! @{
11
12
13
14template<typename eT>
15class arma_counter
16  {
17  public:
18 
19  inline ~arma_counter();
20  inline  arma_counter();
21 
22  inline const arma_counter& operator++();
23  inline void                operator++(int);
24 
25  inline void reset();
26  inline eT   value()         const;
27  inline eT   value_plus_1()  const;
28  inline eT   value_minus_1() const;
29 
30 
31  private:
32 
33  arma_aligned eT    d_count;
34  arma_aligned uword i_count;
35  };
36
37
38
39//! Class for keeping statistics of a continuously sampled process / signal.
40//! Useful if the storage of individual samples is not necessary or desired.
41//! Also useful if the number of samples is not known beforehand or exceeds
42//! available memory.
43template<typename eT>
44class running_stat
45  {
46  public:
47 
48  typedef typename get_pod_type<eT>::result T;
49 
50 
51  inline ~running_stat();
52  inline  running_stat();
53 
54  inline void operator() (const T sample);
55  inline void operator() (const std::complex<T>& sample);
56 
57  inline void reset();
58 
59  inline eT mean() const;
60 
61  inline  T var   (const uword norm_type = 0) const;
62  inline  T stddev(const uword norm_type = 0) const;
63 
64  inline eT min()  const;
65  inline eT max()  const;
66 
67  inline T count() const;
68 
69  //
70  //
71 
72  private:
73 
74  arma_aligned arma_counter<T> counter;
75 
76  arma_aligned eT r_mean;
77  arma_aligned  T r_var;
78 
79  arma_aligned eT min_val;
80  arma_aligned eT max_val;
81 
82  arma_aligned  T min_val_norm;
83  arma_aligned  T max_val_norm;
84 
85 
86  friend class running_stat_aux;
87  };
88
89
90
91class running_stat_aux
92  {
93  public:
94 
95  template<typename eT>
96  inline static void update_stats(running_stat<eT>& x, const eT sample, const typename arma_not_cx<eT>::result* junk = 0);
97 
98  template<typename eT>
99  inline static void update_stats(running_stat<eT>& x, const std::complex<eT>& sample, const typename arma_not_cx<eT>::result* junk = 0);
100 
101  template<typename eT>
102  inline static void update_stats(running_stat<eT>& x, const typename eT::value_type sample, const typename arma_cx_only<eT>::result* junk = 0);
103 
104  template<typename eT>
105  inline static void update_stats(running_stat<eT>& x, const eT& sample, const typename arma_cx_only<eT>::result* junk = 0);
106  };
107
108
109
110//! @}
Note: See TracBrowser for help on using the repository browser.