max@0: // Copyright (C) 2009-2011 NICTA (www.nicta.com.au) max@0: // Copyright (C) 2009-2011 Conrad Sanderson max@0: // max@0: // This file is part of the Armadillo C++ library. max@0: // It is provided without any warranty of fitness max@0: // for any purpose. You can redistribute this file max@0: // and/or modify it under the terms of the GNU max@0: // Lesser General Public License (LGPL) as published max@0: // by the Free Software Foundation, either version 3 max@0: // of the License or (at your option) any later version. max@0: // (see http://www.opensource.org/licenses for more info) max@0: max@0: max@0: //! \addtogroup running_stat max@0: //! @{ max@0: max@0: max@0: max@0: template max@0: class arma_counter max@0: { max@0: public: max@0: max@0: inline ~arma_counter(); max@0: inline arma_counter(); max@0: max@0: inline const arma_counter& operator++(); max@0: inline void operator++(int); max@0: max@0: inline void reset(); max@0: inline eT value() const; max@0: inline eT value_plus_1() const; max@0: inline eT value_minus_1() const; max@0: max@0: max@0: private: max@0: max@0: arma_aligned eT d_count; max@0: arma_aligned uword i_count; max@0: }; max@0: max@0: max@0: max@0: //! Class for keeping statistics of a continuously sampled process / signal. max@0: //! Useful if the storage of individual samples is not necessary or desired. max@0: //! Also useful if the number of samples is not known beforehand or exceeds max@0: //! available memory. max@0: template max@0: class running_stat max@0: { max@0: public: max@0: max@0: typedef typename get_pod_type::result T; max@0: max@0: max@0: inline ~running_stat(); max@0: inline running_stat(); max@0: max@0: inline void operator() (const T sample); max@0: inline void operator() (const std::complex& sample); max@0: max@0: inline void reset(); max@0: max@0: inline eT mean() const; max@0: max@0: inline T var (const uword norm_type = 0) const; max@0: inline T stddev(const uword norm_type = 0) const; max@0: max@0: inline eT min() const; max@0: inline eT max() const; max@0: max@0: inline T count() const; max@0: max@0: // max@0: // max@0: max@0: private: max@0: max@0: arma_aligned arma_counter counter; max@0: max@0: arma_aligned eT r_mean; max@0: arma_aligned T r_var; max@0: max@0: arma_aligned eT min_val; max@0: arma_aligned eT max_val; max@0: max@0: arma_aligned T min_val_norm; max@0: arma_aligned T max_val_norm; max@0: max@0: max@0: friend class running_stat_aux; max@0: }; max@0: max@0: max@0: max@0: class running_stat_aux max@0: { max@0: public: max@0: max@0: template max@0: inline static void update_stats(running_stat& x, const eT sample); max@0: max@0: template max@0: inline static void update_stats(running_stat< std::complex >& x, const T sample); max@0: max@0: template max@0: inline static void update_stats(running_stat< std::complex >& x, const std::complex& sample); max@0: max@0: }; max@0: max@0: max@0: max@0: //! @}