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

Function dist_gfor2

examples/getting_started/vectorize.cpp:73–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73static array dist_gfor2(array a, array b) {
74 array dist_mat = constant(0, (int)a.dims(1), (int)b.dims(1));
75
76 // GFOR along columns of b
77 gfor(seq jj, (int)b.dims(1)) {
78 array bvec = b(span, jj);
79
80 // Iterate through columns of A
81 for (int ii = 0; ii < (int)a.dims(1); ii++) {
82 array avec = a(span, ii);
83
84 // get SAD using sum on the vector
85 dist_mat(ii, jj) = sum(abs(avec - bvec));
86 }
87 }
88
89 return dist_mat;
90}
91
92static array dist_tile1(array a, array b) {
93 // int feat_len = (int)a.dims(0); // Same as (int)b.dims(0);

Callers 2

bench_gfor2Function · 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