diff --git a/include/armadillo_bits/op_mean_bones.hpp b/include/armadillo_bits/op_mean_bones.hpp index 9e3bee18..77fdf809 100644 --- a/include/armadillo_bits/op_mean_bones.hpp +++ b/include/armadillo_bits/op_mean_bones.hpp @@ -49,10 +49,10 @@ struct op_mean inline static eT direct_mean(const eT* X_mem, const uword N); template - inline static eT direct_mean_promote(const eT* X_mem, const uword N); + inline static eT direct_mean_robust(const eT old_mean, const eT* X_mem, const uword N); template - inline static eT direct_mean_robust(const eT old_mean, const eT* X_mem, const uword N); + inline static eT direct_mean_promote(const eT* X_mem, const uword N); template inline static eT direct_mean_robust_promote(const eT old_mean, const eT* X_mem, const uword N); diff --git a/include/armadillo_bits/op_mean_meat.hpp b/include/armadillo_bits/op_mean_meat.hpp index 19053904..f8df0793 100644 --- a/include/armadillo_bits/op_mean_meat.hpp +++ b/include/armadillo_bits/op_mean_meat.hpp @@ -325,6 +325,31 @@ op_mean::direct_mean(const eT* X_mem, const uword N) +template +inline +eT +op_mean::direct_mean_robust(const eT old_mean, const eT* X_mem, const uword N) + { + arma_debug_sigprint(); + + // use an adapted form of the mean finding algorithm from the running_stat class + + typedef typename get_pod_type::result T; + + if(arrayops::is_finite(X_mem, N) == false) { return old_mean; } + + eT r_mean = eT(0); + + for(uword i=0; i < N; ++i) + { + r_mean = r_mean + (X_mem[i] - r_mean) / T(i+1); + } + + return r_mean; + } + + + template inline eT @@ -352,31 +377,6 @@ op_mean::direct_mean_promote(const eT* X_mem, const uword N) -template -inline -eT -op_mean::direct_mean_robust(const eT old_mean, const eT* X_mem, const uword N) - { - arma_debug_sigprint(); - - // use an adapted form of the mean finding algorithm from the running_stat class - - typedef typename get_pod_type::result T; - - if(arrayops::is_finite(X_mem, N) == false) { return old_mean; } - - eT r_mean = eT(0); - - for(uword i=0; i < N; ++i) - { - r_mean = r_mean + (X_mem[i] - r_mean) / T(i+1); - } - - return r_mean; - } - - - template inline eT