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

Function dist_naive

examples/getting_started/vectorize.cpp:18–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16array A, B;
17
18static array dist_naive(array a, array b) {
19 array dist_mat = constant(0, a.dims(1), (int)b.dims(1));
20
21 // Iterate through columns a
22 for (int ii = 0; ii < (int)a.dims(1); ii++) {
23 // Iterate through columns of b
24 for (int jj = 0; jj < (int)b.dims(1); jj++) {
25 // Get the sum of absolute differences
26 for (int kk = 0; kk < (int)a.dims(0); kk++) {
27 dist_mat(ii, jj) += abs(a(kk, ii) - b(kk, jj));
28 }
29 }
30 }
31
32 return dist_mat;
33}
34
35static array dist_vec(array a, array b) {
36 array dist_mat = constant(0, (int)a.dims(1), (int)b.dims(1));

Callers 2

bench_naiveFunction · 0.85
mainFunction · 0.85

Calls 3

constantFunction · 0.85
absFunction · 0.50
dimsMethod · 0.45

Tested by

no test coverage detected