#include <gpk_std.h>
#include <assert.h>
#include <math.h>
#include "romberg.h"

/* good for a function going as x.   Not (x-a)!!! */


struct xx_s     {void *cc; integrand_function ff;};
LOCAL double funclog(double x, void *q, int nc);

method_fr mid_prop(integrand_function func, double a, double b,
				int n, void *c, int nc)
{
 struct xx_s q;

 assert(a>=0.0 && b>=0.0);
 q.cc = (void *)c;
 q.ff = func;
 return midpnt(funclog, a*a/2, b*b/2, n, (void *)(&q), nc);
}

LOCAL double funclog(double x, void *qq, int nc)
{
 struct xx_s *q = (struct xx_s *)qq;
 C double xu = sqrt(2*x);
 return (*q->ff)(xu, q->cc, nc)/xu;
}
