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

Function dist_gfor1

examples/getting_started/vectorize.cpp:54–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54static array dist_gfor1(array a, array b) {
55 array dist_mat = constant(0, (int)a.dims(1), (int)b.dims(1));
56
57 // GFOR along columns of a
58 gfor(seq ii, (int)a.dims(1)) {
59 array avec = a(span, ii);
60
61 // Itere through columns of b
62 for (int jj = 0; jj < (int)b.dims(1); jj++) {
63 array bvec = b(span, jj);
64
65 // get SAD using sum on the vector
66 dist_mat(ii, jj) = sum(abs(avec - bvec));
67 }
68 }
69
70 return dist_mat;
71}
72
73static array dist_gfor2(array a, array b) {
74 array dist_mat = constant(0, (int)a.dims(1), (int)b.dims(1));

Callers 2

bench_gfor1Function · 0.85
mainFunction · 0.85

Calls 4

constantFunction · 0.85
sumFunction · 0.50
absFunction · 0.50
dimsMethod · 0.45

Tested by

no test coverage detected