// SPDX-License-Identifier: Apache-2.0 // // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au) // Copyright 2008-2016 National ICT Australia (NICTA) // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ------------------------------------------------------------------------ //! \addtogroup gmm_misc //! @{ 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 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 arma_inline 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 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