Commit 287985cd authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

return early if y values agree within 2 espilon

parent 69b728dc
......@@ -32,6 +32,7 @@
#include "cerf.h"
#include <math.h>
#include <assert.h>
#include <stdio.h>
#ifndef DBL_EPSILON
#define DBL_EPSILON 2.2204460492503131E-16
......@@ -73,8 +74,12 @@ voigt_hwhm(double sigma, double gamma)
* and <10 iterations to converge to DBL_EPSILON.
* I have never seen convergence worse than k = 15.
*/
printf("START %25.16e %25.16e -> HM=%25.16e, approx=%25.16e\n", sigma, gamma, HM, fwhm);
for (k=0; k<30; k++) {
if (fabs(del_a-del_b) < 2 * DBL_EPSILON * HM)
return a/2+b/2;
c = (b*del_a - a*del_b) / (del_a - del_b);
printf("%25.16e %25.16e %25.16e -> %25.16e %25.16e\n", a, c, b, del_a, del_b);
if (fabs(b-a) < 2 * DBL_EPSILON * fabs(b+a))
return c;
del_c = voigt(c, sigma, gamma) - HM;
......
......@@ -54,7 +54,7 @@ void widtest(result_t* result, double limit, double sigma, double gamma)
int main()
{
result_t result;
const int N = 37;
const int N = 5;
const int M = 2;
for (int i = 0; i<=N; ++i ) {
const double sigma = pow(10., 180*(i-N/2)/(N/2));
......
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