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
void test(World &world, bool doloadbal=false)
Definition: dataloadbal.cc:224
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
double norm(const Tensor< T > &t)
Definition: adquad.h:47
File holds all helper structures necessary for the CC_Operator and CC2 class.
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
Function< T, NDIM > sum(World &world, const std::vector< Function< T, NDIM > > &f, bool fence=true)
Returns new function — q = sum_i f[i].
Definition: vmra.h:1421
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 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
void d()
Definition: test_sig.cc:79
void e()
Definition: test_sig.cc:75
static const double pi
Definition: testcosine.cc:6