16 namespace GAUSS_LEGENDRE {
37 namespace GAUSS_LAGUERRE {
46 const double xmax = +1.0e10;
51 inline double f1(
const double x)
59 inline double F1(
const double x)
63 return -0.5 *
exp(-x) * (x*
sin(x) + (x + 1.0)*cos(x));
67 namespace GAUSS_HERMITE {
74 const double sigma[] = { 4.0, 0.5 };
97 int main(
int argc,
char **argv)
107 JParser<> zap(
"Example program to test JTOOLS::JQuadrature.");
114 catch(
const exception &error) {
115 FATAL(error.what() << endl);
119 using namespace GAUSS_LEGENDRE;
125 const double x0 = 0.5 * (
xmax +
xmin);
126 const double x1 = 0.5 * (
xmax -
xmin);
132 const double x = x0 + i->getX() * x1;
134 W +=
f1(x) * i->getY() * x1;
137 DEBUG(
"integral analytical " <<
FIXED(9,5) <<
V << endl);
138 DEBUG(
"integral numerical " <<
FIXED(9,5) << W << endl);
140 ASSERT(fabs(
V - W) <= precision,
"Test Gauss-Legendre integration.");
143 using namespace GAUSS_LAGUERRE;
153 const double x = i->getX();
155 W +=
f1(x) * i->getY();
158 DEBUG(
"integral analytical " <<
FIXED(9,5) <<
V << endl);
159 DEBUG(
"integral numerical " <<
FIXED(9,5) << W << endl);
161 ASSERT(fabs(
V - W) <= precision,
"Test Gauss-Laguerre integration.");
164 using namespace GAUSS_HERMITE;
170 const double V =
F1(
x);
176 const double u = i->getX() *
sigma[1] * sqrt(2.0);
177 const double v = i->getY() / sqrt(
PI);
184 ASSERT(fabs(V - W) <= precision * V,
"Test Gauss-Hermite integration.");
const JPolynome F1
Integral.
Utility class to parse command line options.
int main(int argc, char *argv[])
Auxiliary data structure for floating point format specification.
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
const JPolynome f1(1.0, 2.0, 3.0)
Function.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
static const double PI
Mathematical constants.
General purpose messaging.
double getIntegral(const double x) const
Integral value.
Auxiliary classes for numerical integration.
Utility class to parse command line options.
Polynome function object.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable STRING $argv[2] set_array QUANTILES set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))" set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"` source JAcousticsToolkit.sh typeset -A TRIPODS get_tripods $WORKDIR/tripod.txt TRIPODS XMEAN
#define DEBUG(A)
Message macros.