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

struct xx_xs     {void *cc; integrand_function ff; double b;};
LOCAL double funcroot(double x, void *q, int nc);

/* for function that has a sqrt(b-x) singularity */
method_fr mid2sqrt(integrand_function func, double a, double b,
				int n, void *c, int nc)
{
 struct xx_xs q;
 q.cc = c;	q.ff = func; q.b = b;
 return midsqrt(funcroot, 0, b-a, n, &q, nc);
}

LOCAL double funcroot(double x, void *q, int nc)
{
 C struct xx_xs *C qq = (C struct xx_xs *)q;
 return (*qq->ff)(qq->b-x, qq->cc, nc);
}
