rearrange
This commit is contained in:
@@ -49,10 +49,10 @@ struct op_mean
|
||||
inline static eT direct_mean(const eT* X_mem, const uword N);
|
||||
|
||||
template<typename eT>
|
||||
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<typename eT>
|
||||
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<typename eT>
|
||||
inline static eT direct_mean_robust_promote(const eT old_mean, const eT* X_mem, const uword N);
|
||||
|
||||
@@ -325,6 +325,31 @@ op_mean::direct_mean(const eT* X_mem, const uword N)
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
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<eT>::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<typename eT>
|
||||
inline
|
||||
eT
|
||||
@@ -352,31 +377,6 @@ op_mean::direct_mean_promote(const eT* X_mem, const uword N)
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
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<eT>::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<typename eT>
|
||||
inline
|
||||
eT
|
||||
|
||||
Reference in New Issue
Block a user