
* mln/accu/rms.hh: rename attributes and add a hook to the underlying values. --- milena/ChangeLog | 7 +++++++ milena/mln/accu/rms.hh | 26 +++++++++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 205f6d9..5debdb3 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,4 +1,11 @@ 2009-02-05 Guillaume Lazzara <z@lrde.epita.fr> + + Cleanup accu::rms. + + * mln/accu/rms.hh: rename attributes and add a hook to the underlying + values. + +2009-02-05 Guillaume Lazzara <z@lrde.epita.fr> Add debug::histo. diff --git a/milena/mln/accu/rms.hh b/milena/mln/accu/rms.hh index 339eabc..35709eb 100644 --- a/milena/mln/accu/rms.hh +++ b/milena/mln/accu/rms.hh @@ -66,13 +66,17 @@ namespace mln /// Get the value of the accumulator. V to_result() const; + /// Return the underlying value used to compute the result. + /// v = sum(t * t); + V hook_value_() const; + /// Check whether this accu is able to return a result. /// Always true here. bool is_valid() const; protected: - V t_; + V v_; unsigned count_; }; @@ -107,7 +111,7 @@ namespace mln void rms<T,V>::init() { - t_ = literal::zero; + v_ = literal::zero; count_ = 0; } @@ -116,7 +120,7 @@ namespace mln void rms<T,V>::take_as_init(const T& t) { - t_ += t * t; + v_ += t * t; ++count_; } @@ -125,7 +129,7 @@ namespace mln void rms<T,V>::take(const T& t) { - t_ += t * t; + v_ += t * t; ++count_; } @@ -134,7 +138,7 @@ namespace mln void rms<T,V>::take(const rms<T,V>& other) { - t_ += other.t_; + v_ += other.v_; count_ += other.count_; } @@ -144,8 +148,16 @@ namespace mln rms<T,V>::to_result() const { if (count_ == 0) - return literal::zero; - return math::sqrt<V>(t_ / count_); + return V(0); + return math::sqrt<V>(v_ / count_); + } + + template <typename T, typename V> + inline + V + rms<T,V>::hook_value_() const + { + return v_; } template <typename T, typename V> -- 1.5.6.5
participants (1)
-
Guillaume Lazzara