5 #ifndef FML_CPU_INTERNALS_VECOPS_H
6 #define FML_CPU_INTERNALS_VECOPS_H
12 #include "../../_internals/types.hh"
21 template <
typename REAL>
22 static inline void sum(
const len_t len,
const REAL *x, REAL &s)
26 #pragma omp simd reduction(+:s)
27 for (len_t i=0; i<len; i++)
33 template <
typename REAL>
34 static inline void sweep_add(
const REAL c,
const len_t len, REAL *x)
37 for (len_t i=0; i<len; i++)
43 template <
typename REAL>
44 static inline void sweep_mul(
const REAL c,
const len_t len, REAL *x)
47 for (len_t i=0; i<len; i++)
53 template <
typename REAL>
54 static inline void var(
const len_t n,
const REAL *x, REAL &mean, REAL &var)
59 for (len_t i=0; i<n; i++)
61 REAL dt = x[i] - mean;
62 mean += dt/((REAL) i+1);
63 var += dt * (x[i] - mean);
66 var = sqrt(var / ((REAL) n-1));