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

Function compareEuclidean

test/gloh.cpp:94–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94static bool compareEuclidean(dim_t desc_len, dim_t ndesc, float* cpu,
95 float* gpu, float unit_thr = 1.f,
96 float euc_thr = 1.f) {
97 bool ret = true;
98 float sum = 0.0f;
99
100 for (dim_t i = 0; i < ndesc; i++) {
101 sum = 0.0f;
102 for (dim_t l = 0; l < desc_len; l++) {
103 dim_t idx = i * desc_len + l;
104 float x = (cpu[idx] - gpu[idx]);
105 sum += x * x;
106 if (abs(x) > (float)unit_thr) {
107 ret = false;
108 cout << endl << "@compareEuclidean: unit mismatch." << endl;
109 cout << "(cpu,gpu,cpu-gpu)[" << i << "," << l << "] : {"
110 << cpu[idx] << "," << gpu[idx] << ","
111 << cpu[idx] - gpu[idx] << "}" << endl;
112 cout << endl;
113 break;
114 }
115 }
116 if (sqrt(sum) > euc_thr) {
117 ret = false;
118 cout << endl << "@compareEuclidean: distance mismatch." << endl;
119 cout << "Euclidean distance: " << sqrt(sum) << endl;
120 }
121 if (ret == false) return ret;
122 }
123
124 return ret;
125}
126
127template<typename T>
128class GLOH : public ::testing::Test {

Callers 2

glohTestFunction · 0.70
TESTFunction · 0.70

Calls 2

sqrtFunction · 0.85
absFunction · 0.70

Tested by

no test coverage detected