| 46 | |
| 47 | template<typename inType, typename outType> |
| 48 | static outType stdev(const af_array& in, const af_var_bias bias) { |
| 49 | using weightType = typename baseOutType<outType>::type; |
| 50 | const Array<inType> _in = getArray<inType>(in); |
| 51 | Array<outType> input = cast<outType>(_in); |
| 52 | Array<outType> meanCnst = createValueArray<outType>( |
| 53 | input.dims(), mean<inType, weightType, outType>(_in)); |
| 54 | Array<outType> diff = |
| 55 | detail::arithOp<outType, af_sub_t>(input, meanCnst, input.dims()); |
| 56 | Array<outType> diffSq = |
| 57 | detail::arithOp<outType, af_mul_t>(diff, diff, diff.dims()); |
| 58 | outType result = division( |
| 59 | getScalar<outType>(reduce_all<af_add_t, outType, outType>(diffSq)), |
| 60 | (input.elements() - (bias == AF_VARIANCE_SAMPLE))); |
| 61 | return sqrt(result); |
| 62 | } |
| 63 | |
| 64 | template<typename inType, typename outType> |
| 65 | static af_array stdev(const af_array& in, int dim, const af_var_bias bias) { |
no test coverage detected