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

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


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

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

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


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