// Copyright (C) 2014 National ICT Australia (NICTA) // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. // ------------------------------------------------------------------- // // Written by Conrad Sanderson - http://conradsanderson.id.au //! \addtogroup gmm_diag //! @{ namespace gmm_priv { template inline running_mean_scalar::running_mean_scalar() : counter(uword(0)) , r_mean ( eT(0)) { arma_extra_debug_sigprint_this(this); } template inline running_mean_scalar::running_mean_scalar(const running_mean_scalar& in) : counter(in.counter) , r_mean (in.r_mean ) { arma_extra_debug_sigprint_this(this); } template inline const running_mean_scalar& running_mean_scalar::operator=(const running_mean_scalar& in) { arma_extra_debug_sigprint(); counter = in.counter; r_mean = in.r_mean; return *this; } template arma_hot inline void running_mean_scalar::operator() (const eT X) { arma_extra_debug_sigprint(); counter++; if(counter > 1) { const eT old_r_mean = r_mean; r_mean = old_r_mean + (X - old_r_mean)/counter; } else { r_mean = X; } } template inline void running_mean_scalar::reset() { arma_extra_debug_sigprint(); counter = 0; r_mean = eT(0); } template inline uword running_mean_scalar::count() const { return counter; } template inline eT running_mean_scalar::mean() const { return r_mean; } // // // template inline running_mean_vec::running_mean_vec() : last_i (0) , counter(0) { arma_extra_debug_sigprint_this(this); } template inline running_mean_vec::running_mean_vec(const running_mean_vec& in) : last_i (in.last_i ) , counter(in.counter) , r_mean (in.r_mean ) { arma_extra_debug_sigprint_this(this); } template inline const running_mean_vec& running_mean_vec::operator=(const running_mean_vec& in) { arma_extra_debug_sigprint(); last_i = in.last_i; counter = in.counter; r_mean = in.r_mean; return *this; } template arma_hot inline void running_mean_vec::operator() (const Col& X, const uword index) { arma_extra_debug_sigprint(); last_i = index; counter++; if(counter > 1) { const uword n_elem = r_mean.n_elem; eT* r_mean_mem = r_mean.memptr(); const eT* X_mem = X.memptr(); for(uword i=0; i inline void running_mean_vec::reset() { arma_extra_debug_sigprint(); last_i = 0; counter = 0; r_mean.reset(); } template inline uword running_mean_vec::last_index() const { return last_i; } template inline uword running_mean_vec::count() const { return counter; } template inline const Col& running_mean_vec::mean() const { return r_mean; } // // // template arma_inline arma_hot eT distance::eval(const uword N, const eT* A, const eT* B, const eT*) { eT acc1 = eT(0); eT acc2 = eT(0); uword i,j; for(i=0, j=1; j arma_inline arma_hot eT distance::eval(const uword N, const eT* A, const eT* B, const eT* C) { eT acc1 = eT(0); eT acc2 = eT(0); uword i,j; for(i=0, j=1; j