44 result_type(
const double __f,
60 operator double()
const
97 inline result_type operator()(
const double x,
101 return result_type(f (x) * f (y) * f (z),
102 fp(x) * f (y) * f (z),
103 f (x) * fp(y) * f (z),
104 f (x) * f (y) * fp(z));
119 inline double operator()(
const double xmin,
const double xmax,
120 const double ymin,
const double ymax,
121 const double zmin,
const double zmax)
const
123 return ((__f1.getIntegral(xmax) - __f1.getIntegral(xmin)) *
124 (__f1.getIntegral(ymax) - __f1.getIntegral(ymin)) *
125 (__f1.getIntegral(zmax) - __f1.getIntegral(zmin)));
136 inline double f(
const double x)
const
138 return __f1.getValue(x);
148 inline double fp(
const double x)
const
150 return __f1.getDerivative(x);
160 template<
class JMultiFunction_t>
161 int do_main(
int argc,
char **argv,
const char* title)
170 precision[
"spline"] = 1.0e-3;
171 precision[
"polint"] = 1.0e-10;
175 JParser<> zap(
"Example program to test multi-dimensional integration.");
184 catch(
const exception &error) {
185 FATAL(error.what() << endl);
189 if (numberOfBins <= 2) {
190 FATAL(
"Number of bins " << numberOfBins << endl);
196 const JFunction3D
f3(f1);
198 const double xmin = -1.0;
199 const double xmax = +1.0;
200 const double dx = (xmax - xmin) / (numberOfBins - 1);
205 for (
double x = xmin; x < xmax + 0.5*dx; x += dx) {
206 for (
double y = xmin; y < xmax + 0.5*dx; y += dx) {
207 for (
double z = xmin; z < xmax + 0.5*dx; z += dx) {
208 g3[x][y][z] =
f3(x,y,z);
218 << setw(8) << left << title <<
' '
219 << setw(12) << right <<
"real" <<
' '
220 << setw(12) << right <<
"calculated" << endl;
221 cout << setw(8) << left <<
"integral";
222 cout <<
' ' <<
SCIENTIFIC(12,4) <<
f3(xmin, xmax, xmin, xmax, xmin, xmax);
227 ASSERT(fabs(
f3(xmin, xmax, xmin, xmax, xmin, xmax) -
getIntegral(g3)) <= precision[title] *
f3(xmin, xmax, xmin, xmax, xmin, xmax));
240 int main(
int argc,
char **argv)
248 JPolint3FunctionalGridMap>::maplist JMaplist_t;
251 if (do_main<JMultiFunction_t>(argc, argv,
"polint") != 0)
return 1;
257 JSplineFunctionalGridMap>::maplist JMaplist_t;
260 if (do_main<JMultiFunction_t>(argc, argv,
"spline") != 0)
return 1;
Utility class to parse command line options.
Polynome function object.
Empty structure for specification of parser element that is initialised (i.e.
Various implementations of functional maps.
I/O formatting auxiliaries.
#define ASSERT(A)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
General purpose messaging.
Utility class to parse command line options.
double f3(const double x, const double y, const double z)
3D function.
Auxiliary data structure for floating point format specification.
int main(int argc, char *argv[])