MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / stdev

Function stdev

src/api/c/stdev.cpp:48–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47template<typename inType, typename outType>
48static 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
64template<typename inType, typename outType>
65static af_array stdev(const af_array& in, int dim, const af_var_bias bias) {

Callers 3

stdevDimTestFunction · 0.50
TESTFunction · 0.50
stdevDimIndexTestFunction · 0.50

Calls 4

sqrtFunction · 0.85
divisionFunction · 0.50
dimsMethod · 0.45
elementsMethod · 0.45

Tested by

no test coverage detected