Skip to content
Snippets Groups Projects
Commit 18e62203 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

testMaths is now less verbose when everything is fine.

parent 8a7620ec
No related branches found
No related tags found
No related merge requests found
......@@ -39,24 +39,29 @@ int main() {
const float rel =
0.5f * fabs(exp_correct - exp_approx) / fabs(exp_correct + exp_approx);
printf("%2d: x= %f exp(x)= %e approx_exp(x)=%e abs=%e rel=%e\n", i, x,
exp_correct, exp_approx, abs, rel);
int error = 0;
if (abs > 3e-6 && fabsf(x) <= 0.2) {
printf("Absolute difference too large !\n");
return 1;
error = 1;
}
if (abs > 1.2e-7 && fabsf(x) <= 0.1) {
printf("Absolute difference too large !\n");
return 1;
error = 1;
}
if (rel > 1e-6 && fabsf(x) <= 0.2) {
printf("Relative difference too large !\n");
return 1;
error = 1;
}
if (rel > 4e-8 && fabsf(x) <= 0.1) {
printf("Relative difference too large !\n");
error = 1;
}
if(error) {
printf("%2d: x= %f exp(x)= %e approx_exp(x)=%e abs=%e rel=%e\n", i, x,
exp_correct, exp_approx, abs, rel);
return 1;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment