00001 // Copyright (C) 2009-2011 NICTA (www.nicta.com.au) 00002 // Copyright (C) 2009-2011 Conrad Sanderson 00003 // 00004 // This file is part of the Armadillo C++ library. 00005 // It is provided without any warranty of fitness 00006 // for any purpose. You can redistribute this file 00007 // and/or modify it under the terms of the GNU 00008 // Lesser General Public License (LGPL) as published 00009 // by the Free Software Foundation, either version 3 00010 // of the License or (at your option) any later version. 00011 // (see http://www.opensource.org/licenses for more info) 00012 00013 00016 00017 00018 00023 template<typename eT> 00024 class running_stat_vec 00025 { 00026 public: 00027 00028 typedef typename get_pod_type<eT>::result T; 00029 00030 inline ~running_stat_vec(); 00031 inline running_stat_vec(const bool in_calc_cov = false); 00032 00033 inline running_stat_vec(const running_stat_vec& in_rsv); 00034 00035 inline const running_stat_vec& operator=(const running_stat_vec& in_rsv); 00036 00037 template<typename T1> arma_hot inline void operator() (const Base< T, T1>& X); 00038 template<typename T1> arma_hot inline void operator() (const Base< std::complex<T>, T1>& X); 00039 00040 inline void reset(); 00041 00042 inline const Mat<eT>& mean() const; 00043 00044 inline const Mat< T>& var (const uword norm_type = 0); 00045 inline Mat< T> stddev(const uword norm_type = 0) const; 00046 inline const Mat<eT>& cov (const uword norm_type = 0); 00047 00048 inline const Mat<eT>& min() const; 00049 inline const Mat<eT>& max() const; 00050 00051 inline T count() const; 00052 00053 // 00054 // 00055 00056 private: 00057 00058 const bool calc_cov; 00059 00060 arma_aligned arma_counter<T> counter; 00061 00062 arma_aligned Mat<eT> r_mean; 00063 arma_aligned Mat< T> r_var; 00064 arma_aligned Mat<eT> r_cov; 00065 00066 arma_aligned Mat<eT> min_val; 00067 arma_aligned Mat<eT> max_val; 00068 00069 arma_aligned Mat< T> min_val_norm; 00070 arma_aligned Mat< T> max_val_norm; 00071 00072 arma_aligned Mat< T> r_var_dummy; 00073 arma_aligned Mat<eT> r_cov_dummy; 00074 00075 arma_aligned Mat<eT> tmp1; 00076 arma_aligned Mat<eT> tmp2; 00077 00078 friend class running_stat_vec_aux; 00079 }; 00080 00081 00082 00083 class running_stat_vec_aux 00084 { 00085 public: 00086 00087 template<typename eT> 00088 inline static void update_stats(running_stat_vec< eT >& x, const Mat<eT>& sample); 00089 00090 template<typename T> 00091 inline static void update_stats(running_stat_vec< std::complex<T> >& x, const Mat< T>& sample); 00092 00093 template<typename T> 00094 inline static void update_stats(running_stat_vec< std::complex<T> >& x, const Mat< std::complex<T> >& sample); 00095 00096 // 00097 00098 template<typename eT> 00099 inline static Mat<eT> var(const running_stat_vec< eT >& x, const uword norm_type = 0); 00100 00101 template<typename T> 00102 inline static Mat< T> var(const running_stat_vec< std::complex<T> >& x, const uword norm_type = 0); 00103 00104 // 00105 00106 template<typename eT> 00107 inline static Mat< eT > cov(const running_stat_vec< eT >& x, const uword norm_type = 0); 00108 00109 template<typename T> 00110 inline static Mat< std::complex<T> > cov(const running_stat_vec< std::complex<T> >& x, const uword norm_type = 0); 00111 }; 00112 00113 00114