Fixing bug in check_cdd
This commit is contained in:
@@ -29,29 +29,37 @@ using namespace std;
|
|||||||
// Custom test to check the minimum number of correct decimal digits between
|
// Custom test to check the minimum number of correct decimal digits between
|
||||||
// the test and the ref vectors.
|
// the test and the ref vectors.
|
||||||
boost::test_tools::predicate_result check_cdd(std::vector<float>& test,
|
boost::test_tools::predicate_result check_cdd(std::vector<float>& test,
|
||||||
std::vector<float>& ref, long cdd_tol)
|
std::vector<float>& ref, long cdd_tol){
|
||||||
{
|
float tmp, min_cdd = 10.0;
|
||||||
float tmp, min_cdd = 100.0;
|
|
||||||
|
|
||||||
// TODO: What is the vectors aren't the same length?
|
// TODO: What if the vectors aren't the same length?
|
||||||
|
|
||||||
std::vector<float>::iterator test_it;
|
std::vector<float>::iterator test_it;
|
||||||
std::vector<float>::iterator ref_it;
|
std::vector<float>::iterator ref_it;
|
||||||
|
|
||||||
for (test_it = test.begin(); test_it < test.end(); ++test_it) {
|
for (test_it = test.begin(), ref_it = ref.begin();
|
||||||
for (ref_it = ref.begin(); ref_it < ref.end(); ++ref_it) {
|
(test_it < test.end()) && (ref_it < ref.end());
|
||||||
|
++test_it, ++ref_it)
|
||||||
|
{
|
||||||
|
if (*test_it != *ref_it) {
|
||||||
|
// Compute log absolute error
|
||||||
|
tmp = abs(*test_it - *ref_it);
|
||||||
|
if (tmp < 1.0e-7f)
|
||||||
|
tmp = 1.0e-7f;
|
||||||
|
|
||||||
if (*test_it != *ref_it) {
|
else if (tmp > 2.0f)
|
||||||
tmp = - log10f(abs(*test_it - *ref_it));
|
tmp = 1.0f;
|
||||||
if (tmp < min_cdd) min_cdd = tmp;
|
|
||||||
}
|
tmp = -log10(tmp);
|
||||||
|
if (tmp < 0.0f)
|
||||||
|
tmp = 0.0f;
|
||||||
|
|
||||||
|
if (tmp < min_cdd)
|
||||||
|
min_cdd = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (min_cdd == 100.0)
|
return floor(min_cdd) >= cdd_tol;
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return floor(min_cdd) <= cdd_tol;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::test_tools::predicate_result check_string(std::string test, std::string ref)
|
boost::test_tools::predicate_result check_string(std::string test, std::string ref)
|
||||||
|
|||||||
Reference in New Issue
Block a user