47{
50
51 int numberOfEvents;
53 double precision;
55
56 try {
57
58 JParser<> zap(
"Example program to test multi-dimensional interpolation.");
59
64
65 zap(argc, argv);
66 }
67 catch(const exception &error) {
68 FATAL(error.what() << endl);
69 }
70
71
72 const double xmin = -1.0;
73 const double xmax = +1.0;
75
76
78
83
85
86
87 JMultiFunction_t g5;
88
89
90 for (
double x0 = xmin; x0 <=
xmax + 0.5*dx; x0 += dx) {
91 for (
double x1 = xmin; x1 <=
xmax + 0.5*dx; x1 += dx) {
92 for (
double x2 = xmin; x2 <=
xmax + 0.5*dx; x2 += dx) {
93 for (
double x3 = xmin; x3 <=
xmax + 0.5*dx; x3 += dx) {
94 for (
double x4 = xmin; x4 <=
xmax + 0.5*dx; x4 += dx) {
95 g5[x0][x1][x2][x3][x4] =
f5(x0, x1, x2, x3, x4);
96 }
97 }
98 }
99 }
100 }
101
103 g5.setExceptionHandler(
new JFunction1D_t::JDefaultResult(
JMATH::zero));
104
105 ASSERT(numberOfEvents > 0);
106
107 {
108 const double x =
xmin - dx;
109
110 ASSERT(fabs(g5(x, 0.0, 0.0, 0.0, 0.0)) <= precision);
111 ASSERT(fabs(g5(0.0, x, 0.0, 0.0, 0.0)) <= precision);
112 ASSERT(fabs(g5(0.0, 0.0, x, 0.0, 0.0)) <= precision);
113 ASSERT(fabs(g5(0.0, 0.0, 0.0, x, 0.0)) <= precision);
114 ASSERT(fabs(g5(0.0, 0.0, 0.0, 0.0, x)) <= precision);
115 }
116
118
120
121 for (int i = 0; i != numberOfEvents; ++i) {
122
123 const double x0 = gRandom->Uniform(xmin, xmax);
124 const double x1 = gRandom->Uniform(xmin, xmax);
125 const double x2 = gRandom->Uniform(xmin, xmax);
126 const double x3 = gRandom->Uniform(xmin, xmax);
127 const double x4 = gRandom->Uniform(xmin, xmax);
128
129 const double v =
f5(x0,x1,x2,x3,x4);
130
132
133 const double w = g5(x0,x1,x2,x3,x4);
134
136
138 }
139
140 if (
debug >- debug_t) {
141
143
144 timer.
print(cout, 1.0 / numberOfEvents);
145 }
146
149
150 return 0;
151}
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
double f5(const double x0, const double x1, const double x2, const double x3, const double x4)
5D function.
int numberOfBins
number of bins for average CDF integral of optical module
Auxiliary class for CPU timing and usage.
void print(std::ostream &out, const JScale_t scale=milli_t) const
Print timer data.
Utility class to parse command line options.
static const JZero zero
Function object to assign zero value.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).