52{
55
56 int numberOfEvents;
58 double precision;
59
60 try {
61
62 JParser<> zap(
"Example program to test interpolation between 1D tables on 2D grid.");
63
67
68 zap(argc, argv);
69 }
70 catch(const exception &error) {
71 FATAL(error.what() << endl);
72 }
73
74
75 const int NX = 19;
76 const int NY = 35;
77 const int NZ = 16384;
78
82
83
84
90
91 JMultiFunction_t g3;
92
93 for (int ix = 0; ix != X.getSize(); ++ix) {
94 for (int iy = 0; iy != Y.getSize(); ++iy) {
95
96 DEBUG(
"table[" << ix <<
", " << iy <<
"]" << endl);
97
98 const double x = X.getX(ix);
99 const double y = Y.getX(iy);
100
101 JTable1D_t& table = g3[
x][
y];
102
103 for (int iz = 0; iz != Z.getSize(); ++iz) {
104
105 const double z = Z.getX(iz);
106 table[iz] =
f3(x,y,z);
107
109
110 }
112 }
113 }
114
116
117
118 JTimer t1(
"JTable1D interpolant");
119
120 for (int i = 0; i != numberOfEvents; ++i) {
121
122 const double x = gRandom->Uniform(X.getXmin(), X.getXmax());
123 const double y = gRandom->Uniform(Y.getXmin(), Y.getXmax());
124 DEBUG(
"x = " << x <<
" y = " << y << endl);
125
126 t1.start();
127 JTable1D_t res = g3(x,y);
128 t1.stop();
129
130 int valid = 1;
131
133
134 for (int iz = 0; iz != Z.getSize(); ++iz) {
135 const double z = Z.getX(iz);
136 double val_f3 =
f3(x,y,z);
137
139 if (fabs((val_f3 - res[iz]) / res[iz]) > precision) {valid = 0;}
140
141 }
142
144
145 }
146
148 i->print(cout, true, micro_t);
149 }
150
151}
#define DEBUG(A)
Message macros.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
double f3(const double x, const double y, const double z)
3D function.
Auxiliary class for CPU timing and usage.
const std::string & getTitle() const
Get title.
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.