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

Function gaussian1D

src/backend/cpu/utility.hpp:36–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35template<typename T>
36void gaussian1D(T* out, int const dim, double sigma = 0.0) {
37 if (!(sigma > 0)) sigma = 0.25 * dim;
38
39 T sum = (T)0;
40 for (int i = 0; i < dim; i++) {
41 int x = i - (dim - 1) / 2;
42 T el = 1. / std::sqrt(2 * af::Pi * sigma * sigma) *
43 std::exp(-((x * x) / (2 * (sigma * sigma))));
44 out[i] = el;
45 sum += el;
46 }
47
48 for (int k = 0; k < dim; k++) out[k] /= sum;
49}
50} // namespace cpu
51} // namespace arrayfire

Callers 1

orbFunction · 0.70

Calls 2

sqrtFunction · 0.85
expFunction · 0.85

Tested by

no test coverage detected