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

Function compareArraysRMSD

test/arrayfire_test.cpp:1128–1154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1126
1127template<typename T>
1128bool compareArraysRMSD(dim_t data_size, T *gold, T *data, double tolerance) {
1129 double accum = 0.0;
1130 double maxion = -FLT_MAX; //(double)std::numeric_limits<T>::lowest();
1131 double minion = FLT_MAX; //(double)std::numeric_limits<T>::max();
1132
1133 for (dim_t i = 0; i < data_size; i++) {
1134 double dTemp = (double)data[i];
1135 double gTemp = (double)gold[i];
1136 double diff = gTemp - dTemp;
1137 double err =
1138 (std::isfinite(diff) && (std::abs(diff) > 1.0e-4)) ? diff : 0.0f;
1139 accum += std::pow(err, 2.0);
1140 maxion = std::max(maxion, dTemp);
1141 minion = std::min(minion, dTemp);
1142 }
1143 accum /= data_size;
1144 double NRMSD = std::sqrt(accum) / (maxion - minion);
1145
1146 if (std::isnan(NRMSD) || NRMSD > tolerance) {
1147#ifndef NDEBUG
1148 printf("Comparison failed, NRMSD value: %lf\n", NRMSD);
1149#endif
1150 return false;
1151 }
1152
1153 return true;
1154}
1155
1156#define INSTANTIATE(TYPE) \
1157 template double computeArraysRMSD<TYPE>(dim_t data_size, TYPE * gold, \

Callers 3

bilateralDataTestFunction · 0.85
TESTFunction · 0.85
cppMorphImageTestFunction · 0.85

Calls 7

isfiniteFunction · 0.85
powFunction · 0.85
sqrtFunction · 0.85
absFunction · 0.70
maxFunction · 0.70
minFunction · 0.70
isnanFunction · 0.50

Tested by

no test coverage detected