Commit 69b728dc authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

concentrate on failing tests; improve test output

parent e96489da
......@@ -35,16 +35,32 @@ double hwhm0(double sigma, double gamma)
return .5*(1.06868*gamma+sqrt(0.86743*gamma*gamma+4*2*log(2)*sigma*sigma));
}
void widtest(result_t* result, double limit, double sigma, double gamma)
{
++result->total;
const double expected = hwhm0(sigma, gamma);
const double computed = voigt_hwhm(sigma, gamma);
const double re = relerr(computed, expected);
if (re > limit) {
printf("failure in subtest %i: sigma=%14.9e, gamma=%14.9e\n", result->total, sigma, gamma);
printf("- fct value %20.15g\n", computed);
printf("- expected %20.15g\n", expected);
printf("=> error %6.2g above limit %6.2g\n", re, limit);
++result->failed;
}
}
int main()
{
result_t result;
const int N = 30;
const int M = 30000;
for (int i = 0; i<N; ++i ) {
const int N = 37;
const int M = 2;
for (int i = 0; i<=N; ++i ) {
const double sigma = pow(10., 180*(i-N/2)/(N/2));
for (int j = 0; j<M; ++j ) {
for (int j = 0; j<=M; ++j ) {
const double gamma = sigma * pow(10., 17*(j-M/2)/(M/2));
RTEST(result, 1e-2, voigt_hwhm(sigma, gamma), hwhm0(sigma,gamma));
widtest(&result, 1e-2, sigma, gamma);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment