33#ifndef MADNESS_MRA_ADQUAD_H__INCLUDED
34#define MADNESS_MRA_ADQUAD_H__INCLUDED
52 template <
typename funcT>
53 typename funcT::returnT
do_adq(
double lo,
double hi,
const funcT&
func,
54 int n,
const double* x,
const double*
w) {
56 double range = (hi-
lo);
57 typename funcT::returnT
sum =
func(
lo + range*x[0])*
w[0];
58 for (
int i=1; i<n; ++i)
sum +=
func(
lo + range*x[i])*
w[i];
63 template <
typename funcT>
65 int n,
const double* x,
const double*
w,
int level) {
66 static const int MAX_LEVEL=14;
70 typename funcT::returnT half =
do_adq(
lo,
lo+
d,
func, n, x,
w) +
do_adq(
lo+
d, hi,
func, n, x,
w);
74 double relerr = (
norm==0.0) ? 0.0 : abserr/
norm;
78 bool converged = (relerr < 1
e-14) || (abserr<
thresh && relerr<0.01);
83 if (level == MAX_LEVEL) {
94 template <
typename funcT>
95 typename funcT::returnT
adq(
double lo,
double hi,
const funcT&
func,
double thresh) {
108 return exp(-x*x)*cos(3*x);
112 const double pi = 3.1415926535897932384;
113 return sqrt(
pi)*exp(-9.0/4.0);
double w(double t, double eps)
Definition DKops.h:22
A tensor is a multidimension array.
Definition tensor.h:317
float_scalar_type normf() const
Returns the Frobenius norm of the tensor.
Definition tensor.h:1726
static double lo
Definition dirac-hatom.cc:23
auto T(World &world, response_space &f) -> response_space
Definition global_functions.cc:34
double norm(const T &t)
Definition adquad.h:42
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
funcT::returnT adq(double lo, double hi, const funcT &func, double thresh)
Definition adquad.h:95
funcT::returnT do_adq(double lo, double hi, const funcT &func, int n, const double *x, const double *w)
Definition adquad.h:53
std::shared_ptr< FunctionFunctorInterface< double, 3 > > func(new opT(g))
bool gauss_legendre(int n, double xlo, double xhi, double *x, double *w)
Definition legendre.cc:226
funcT::returnT adq1(double lo, double hi, const funcT &func, double thresh, int n, const double *x, const double *w, int level)
Definition adquad.h:64
static long abs(long a)
Definition tensor.h:218
static const double d
Definition nonlinschro.cc:121
static const double thresh
Definition rk.cc:45
double operator()(double x) const
Definition adquad.h:106
static bool runtest()
Definition adquad.h:116
static double exact()
Definition adquad.h:111
double returnT
Definition adquad.h:105
AtomicInt sum
Definition test_atomicint.cc:46
double norm(const T i1)
Definition test_cloud.cc:72
void e()
Definition test_sig.cc:75
static const double pi
Definition testcosine.cc:6
void test()
Definition y.cc:696