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_vec 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_vec max@0: { max@0: public: max@0: max@0: typedef typename get_pod_type::result T; max@0: max@0: inline ~running_stat_vec(); max@0: inline running_stat_vec(const bool in_calc_cov = false); max@0: max@0: inline running_stat_vec(const running_stat_vec& in_rsv); max@0: max@0: inline const running_stat_vec& operator=(const running_stat_vec& in_rsv); max@0: max@0: template arma_hot inline void operator() (const Base< T, T1>& X); max@0: template arma_hot inline void operator() (const Base< std::complex, T1>& X); max@0: max@0: inline void reset(); max@0: max@0: inline const Mat& mean() const; max@0: max@0: inline const Mat< T>& var (const uword norm_type = 0); max@0: inline Mat< T> stddev(const uword norm_type = 0) const; max@0: inline const Mat& cov (const uword norm_type = 0); max@0: max@0: inline const Mat& min() const; max@0: inline const Mat& 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: const bool calc_cov; max@0: max@0: arma_aligned arma_counter counter; max@0: max@0: arma_aligned Mat r_mean; max@0: arma_aligned Mat< T> r_var; max@0: arma_aligned Mat r_cov; max@0: max@0: arma_aligned Mat min_val; max@0: arma_aligned Mat max_val; max@0: max@0: arma_aligned Mat< T> min_val_norm; max@0: arma_aligned Mat< T> max_val_norm; max@0: max@0: arma_aligned Mat< T> r_var_dummy; max@0: arma_aligned Mat r_cov_dummy; max@0: max@0: arma_aligned Mat tmp1; max@0: arma_aligned Mat tmp2; max@0: max@0: friend class running_stat_vec_aux; max@0: }; max@0: max@0: max@0: max@0: class running_stat_vec_aux max@0: { max@0: public: max@0: max@0: template max@0: inline static void update_stats(running_stat_vec< eT >& x, const Mat& sample); max@0: max@0: template max@0: inline static void update_stats(running_stat_vec< std::complex >& x, const Mat< T>& sample); max@0: max@0: template max@0: inline static void update_stats(running_stat_vec< std::complex >& x, const Mat< std::complex >& sample); max@0: max@0: // max@0: max@0: template max@0: inline static Mat var(const running_stat_vec< eT >& x, const uword norm_type = 0); max@0: max@0: template max@0: inline static Mat< T> var(const running_stat_vec< std::complex >& x, const uword norm_type = 0); max@0: max@0: // max@0: max@0: template max@0: inline static Mat< eT > cov(const running_stat_vec< eT >& x, const uword norm_type = 0); max@0: max@0: template max@0: inline static Mat< std::complex > cov(const running_stat_vec< std::complex >& x, const uword norm_type = 0); max@0: }; max@0: max@0: max@0: max@0: //! @}