51{
54
55 int numberOfEvents;
57
58 try {
59
60 JParser<> zap(
"Example program to test JTab1D & interpolation between 1D tables.");
61
64
65 zap(argc, argv);
66 }
67 catch(const exception &error) {
68 FATAL(error.what() << endl);
69 }
70
71
72 const int NX = 21;
73 const int NY = 11;
74
77
81
82
83 JFunction1D_t buffer;
84
85 for (int i = 0; i != X.getSize(); ++i) {
86
87 DEBUG(
"table[" << i <<
"]" << endl);
88
89 const double x = X.getX(i);
90
91 JTable1D_t& table = buffer[
x];
92
93 for (int __i = 0; __i != NY; ++__i) {
94
95 const double y = Y.getX(__i);
96
97 table[__i] = f2(x,y);
98
99 DEBUG(
' ' <<
FIXED(5,3) << table[__i] << endl);
100
101 }
102 }
103
104
105 const int NT = 3;
107 tab1[0] = 1; tab1[1] = 2; tab1[2] = 3;
109 tab2[0] = 4; tab2[1] = 5; tab2[2] = 6;
110
112 ASSERT(tab2[1] == 5,
"GetEntry");
114 ASSERT((tab2.
add(tab1))[0] == -3,
"Add");
115 ASSERT((tab2.
sub(tab1))[0] == -4,
"Subtract");
116 ASSERT(tab1.
mul(5)[1] == 10,
"Multiply");
118
119
121
122 g2.configure(Y);
123
126
129
130
131 for (int i = 0; i != numberOfEvents; ++i) {
132
133 const double x = gRandom->Uniform(X.getXmin(), X.getXmax());
134 const double y = gRandom->Uniform(Y.getXmin(), Y.getXmax());
135
136 const double v = f2(x,y);
137
138
139
140
141 t1.start();
142
143 const int __i = (int) (Y.getSize() * (y - Y.getXmin()) / (Y.getXmax() - Y.getXmin()));
144
145 const double w1 = buffer(x)[__i];
146
147 t1.stop();
148
149
150
151
152 t2.start();
153
154 const JTable1D_t& table = buffer(x);
155
156 for (int __i = 0; __i != Y.getSize(); ++__i) {
157 g2.getY(__i) = table[__i];
158
159 }
160
161 g2.compile();
162
163 const double w2 = g2(y);
164 t2.stop();
165
166 fa.put(v - w1);
167 fb.put(v - w2);
168 }
169
170
172
173 cout << i->getTitle() << endl;
174 cout <<
"mean " <<
SCIENTIFIC(10,2) << i->getMean() << endl;
175 cout <<
"RMS " <<
SCIENTIFIC(10,2) << i->getSTDev() << endl;
176 }
177
179 i->print(cout, true, micro_t);
180 }
181}
#define DEBUG(A)
Message macros.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
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.
Auxiliary data structure for floating point format specification.