24int main(
int argc,
char **argv)
34 JParser<> zap(
"Example program to test JTOOLS::JQuadrature.");
41 catch(
const exception &error) {
47 const double epsilon = 1.0e-12;
49 const double xmin = -5.0;
50 const double xmax = +3.0;
62 double V =
F1(xmax) -
F1(xmin);
66 const double x0 = 0.5 * (xmax + xmin);
67 const double x1 = 0.5 * (xmax - xmin);
73 const double x = x0 + i->getX() * x1;
75 W += f1(x) * i->getY() * x1;
81 ASSERT(fabs(V - W) <= precision,
"Test Gauss-Legendre integration.");
86 const double epsilon = 1.0e-12;
88 const double xmin = 0.0;
89 const double xmax = +1.0e10;
95 inline double operator()(
const double x)
const
105 inline double operator()(
const double x)
const
109 return -0.5 *
exp(-x) * (x*
sin(x) + (x + 1.0)*
cos(x));
113 const double V =
F1(xmax) -
F1(xmin);
121 const double x = i->getX();
123 W += f1(x) * i->getY();
129 ASSERT(fabs(V - W) <= precision,
"Test Gauss-Laguerre integration.");
133 const double epsilon = 1.0e-12;
135 const double sigma[] = { 4.0, 0.5 };
137 const double xmin = -3.0 * sigma[0];
138 const double xmax = +3.0 * sigma[0];
143 const JGauss f1(0.0, sigma[0]);
148 const JGauss
F1(0.0,
hypot(sigma[0], sigma[1]));
152 for (
double x = xmin; x <= xmax; x += 0.05*(xmax - xmin)) {
154 const double V =
F1(x);
160 const double u = i->getX() * sigma[1] * sqrt(2.0);
161 const double v = i->getY() / sqrt(PI);
168 ASSERT(fabs(V - W) <= precision * V,
"Test Gauss-Hermite integration.");
174 const double a = -1.5;
175 const double g = 0.924;
177 const double V = 1.0;
185 const double x = i->getX();
187 W += henyey_greenstein(g,x) * i->getY() * 2*PI;
193 ASSERT(fabs(V - W) <= precision,
"Test Henyey-Greenstein integration.");
198 const double a = 0.835;
200 const double V = 1.0;
208 const double x = i->getX();
210 W += rayleigh(a,x) * i->getY() * 2*PI;
216 ASSERT(fabs(V - W) <= precision,
"Test Rayleigh integration.");
General purpose messaging.
#define DEBUG(A)
Message macros.
#define ASSERT(A,...)
Assert macro.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
int main(int argc, char **argv)
Auxiliary classes for numerical integration.
Template definition of a multi-dimensional oscillation probability interpolation table.
Utility class to parse command line options.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Recursive template class for polynomial function.
double getIntegral(const double x) const
Integral value.