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

Function gaussian1D

src/backend/cuda/kernel/orb.hpp:35–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34template<typename T>
35void gaussian1D(T* out, const int dim, double sigma = 0.0) {
36 if (!(sigma > 0)) sigma = 0.25 * dim;
37
38 T sum = (T)0;
39 for (int i = 0; i < dim; i++) {
40 int x = i - (dim - 1) / 2;
41 T el = 1. / sqrt(2 * PI_VAL * sigma * sigma) *
42 exp(-((x * x) / (2 * (sigma * sigma))));
43 out[i] = el;
44 sum += el;
45 }
46
47 for (int k = 0; k < dim; k++) out[k] /= sum;
48}
49
50inline __device__ float block_reduce_sum(float val) {
51 __shared__ float data[THREADS_X * THREADS_Y];

Callers 1

orbFunction · 0.70

Calls 2

sqrtFunction · 0.85
expFunction · 0.85

Tested by

no test coverage detected