running_stat_vec_proto.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2009 NICTA
00002 // 
00003 // Authors:
00004 // - Conrad Sanderson (conradsand at ieee dot org)
00005 // 
00006 // This file is part of the Armadillo C++ library.
00007 // It is provided without any warranty of fitness
00008 // for any purpose. You can redistribute this file
00009 // and/or modify it under the terms of the GNU
00010 // Lesser General Public License (LGPL) as published
00011 // by the Free Software Foundation, either version 3
00012 // of the License or (at your option) any later version.
00013 // (see http://www.opensource.org/licenses for more info)
00014 
00015 
00016 //! \addtogroup running_stat_vec
00017 //! @{
00018 
00019 
00020 
00021 //! Class for keeping statistics of a continuously sampled process / signal.
00022 //! Useful if the storage of individual samples is not necessary or desired.
00023 //! Also useful if the number of samples is not known beforehand or exceeds 
00024 //! available memory.
00025 template<typename eT>
00026 class running_stat_vec
00027   {
00028   public:
00029   
00030   typedef typename get_pod_type<eT>::pod_type T;
00031   
00032   inline ~running_stat_vec();
00033   inline  running_stat_vec(const bool in_calc_cov = false);
00034   
00035   template<typename T1> inline void operator() (const Base<               T,  T1>& X);
00036   template<typename T1> inline void operator() (const Base< std::complex<T>,  T1>& X);
00037   
00038   inline void reset();
00039   
00040   inline Mat<eT>  mean() const;
00041   
00042   inline Mat< T>  var   (const u32 norm_type = 0) const;
00043   inline Mat< T>  stddev(const u32 norm_type = 0) const;
00044   inline Mat<eT>  cov   (const u32 norm_type = 0) const;
00045   
00046   inline Mat<eT> min() const;
00047   inline Mat<eT> max() const;
00048   
00049   //
00050   //
00051   
00052   private:
00053   
00054   const bool calc_cov;
00055   
00056   arma_aligned arma_counter<T> counter;
00057   
00058   arma_aligned Mat<eT> r_mean;
00059   arma_aligned Mat< T> r_var;
00060   arma_aligned Mat<eT> r_cov;
00061   
00062   arma_aligned Mat<eT> min_val;
00063   arma_aligned Mat<eT> max_val;
00064   
00065   arma_aligned Mat< T> min_val_norm;
00066   arma_aligned Mat< T> max_val_norm;
00067   
00068   friend class running_stat_vec_aux;
00069   };
00070 
00071 
00072 
00073 class running_stat_vec_aux
00074   {
00075   public:
00076   
00077   template<typename eT>
00078   inline static void update_stats(running_stat_vec< eT >&              x, const Mat<eT>&                sample);
00079   
00080   template<typename T>
00081   inline static void update_stats(running_stat_vec< std::complex<T> >& x, const Mat< T>&                sample);
00082   
00083   template<typename T>
00084   inline static void update_stats(running_stat_vec< std::complex<T> >& x, const Mat< std::complex<T> >& sample);
00085   
00086   //
00087   
00088   template<typename eT>
00089   inline static Mat<eT> var(const running_stat_vec< eT >&              x, const u32 norm_type = 0);
00090   
00091   template<typename T>
00092   inline static Mat< T> var(const running_stat_vec< std::complex<T> >& x, const u32 norm_type = 0);
00093   
00094   //
00095   
00096   template<typename eT>
00097   inline static Mat<              eT > cov(const running_stat_vec< eT >&              x, const u32 norm_type = 0);
00098   
00099   template<typename T>
00100   inline static Mat< std::complex<T> > cov(const running_stat_vec< std::complex<T> >& x, const u32 norm_type = 0);
00101   };
00102 
00103 
00104 
00105 //! @}