1 #ifndef NPSTAT_INTERPOLATEHISTOND_HH_ 2 #define NPSTAT_INTERPOLATEHISTOND_HH_ 34 template <
typename Float,
class Axis>
36 const double *coords,
unsigned coordsDim,
37 unsigned interpolationDegree);
43 template <
typename Float,
class Axis>
45 double x0,
unsigned interpolationDegree);
47 template <
typename Float,
class Axis>
50 unsigned interpolationDegree);
52 template <
typename Float,
class Axis>
54 double x0,
double x1,
double x2,
55 unsigned interpolationDegree);
57 template <
typename Float,
class Axis>
59 double x0,
double x1,
double x2,
double x3,
60 unsigned interpolationDegree);
62 template <
typename Float,
class Axis>
64 double x0,
double x1,
double x2,
double x3,
65 double x4,
unsigned interpolationDegree);
67 template <
typename Float,
class Axis>
69 double x0,
double x1,
double x2,
double x3,
71 unsigned interpolationDegree);
73 template <
typename Float,
class Axis>
75 double x0,
double x1,
double x2,
double x3,
76 double x4,
double x5,
double x6,
77 unsigned interpolationDegree);
79 template <
typename Float,
class Axis>
81 double x0,
double x1,
double x2,
double x3,
82 double x4,
double x5,
double x6,
double x7,
83 unsigned interpolationDegree);
85 template <
typename Float,
class Axis>
87 double x0,
double x1,
double x2,
double x3,
88 double x4,
double x5,
double x6,
double x7,
89 double x8,
unsigned interpolationDegree);
91 template <
typename Float,
class Axis>
93 double x0,
double x1,
double x2,
double x3,
94 double x4,
double x5,
double x6,
double x7,
96 unsigned interpolationDegree);
105 template <
typename Float,
class Axis>
108 const unsigned interpolationDegree)
111 "In npstat::interpolateHistoND: incompatible " 112 "dimensionality of input coordinates");
114 "In npstat::interpolateHistoND: can not interpolate " 115 "zero-dimensional histograms");
116 if (!(interpolationDegree == 0
U ||
117 interpolationDegree == 1
U ||
119 "In npstat::interpolateHistoND: " 120 "unsupported interpolation degree");
123 "In npstat::interpolateHistoND: unsupported " 124 "interpolation degree for non-uniform binning");
128 template <
typename Float,
class Axis>
130 const double *x,
const unsigned xDim,
131 const unsigned interpolationDegree)
135 const Axis*
ax = &histo.
axes()[0];
136 double coords[CHAR_BIT*
sizeof(
unsigned long)];
137 for (
unsigned i=0;
i<xDim; ++
i)
138 coords[
i] = ax[
i].fltBinNumber(x[
i],
false);
140 switch (interpolationDegree)
143 return bins.interpolate1(coords, xDim);
145 return bins.interpolate3(coords, xDim);
147 return bins.closest(coords, xDim);
151 template <
typename Float,
class Axis>
154 const unsigned interpolationDegree)
156 const unsigned expDim = 1
U;
158 const double coords = histo.
axis(0).fltBinNumber(x0,
false);
160 switch (interpolationDegree)
163 return bins.interpolate1(&coords, expDim);
165 return bins.interpolate3(&coords, expDim);
167 return bins.closest(&coords, expDim);
171 template <
typename Float,
class Axis>
175 const unsigned interpolationDegree)
177 const unsigned expDim = 2
U;
179 const Axis*
ax = &histo.
axes()[0];
180 double coords[expDim];
181 coords[0] = ax[0].fltBinNumber(x0,
false);
182 coords[1] = ax[1].fltBinNumber(x1,
false);
184 switch (interpolationDegree)
187 return bins.interpolate1(coords, expDim);
189 return bins.interpolate3(coords, expDim);
191 return bins.closest(coords, expDim);
195 template <
typename Float,
class Axis>
200 const unsigned interpolationDegree)
202 const unsigned expDim = 3
U;
204 const Axis*
ax = &histo.
axes()[0];
205 double coords[expDim];
206 coords[0] = ax[0].fltBinNumber(x0,
false);
207 coords[1] = ax[1].fltBinNumber(x1,
false);
208 coords[2] = ax[2].fltBinNumber(x2,
false);
210 switch (interpolationDegree)
213 return bins.interpolate1(coords, expDim);
215 return bins.interpolate3(coords, expDim);
217 return bins.closest(coords, expDim);
221 template <
typename Float,
class Axis>
227 const unsigned interpolationDegree)
229 const unsigned expDim = 4
U;
231 const Axis*
ax = &histo.
axes()[0];
232 double coords[expDim];
233 coords[0] = ax[0].fltBinNumber(x0,
false);
234 coords[1] = ax[1].fltBinNumber(x1,
false);
235 coords[2] = ax[2].fltBinNumber(x2,
false);
236 coords[3] = ax[3].fltBinNumber(x3,
false);
238 switch (interpolationDegree)
241 return bins.interpolate1(coords, expDim);
243 return bins.interpolate3(coords, expDim);
245 return bins.closest(coords, expDim);
249 template <
typename Float,
class Axis>
256 const unsigned interpolationDegree)
258 const unsigned expDim = 5
U;
260 const Axis*
ax = &histo.
axes()[0];
261 double coords[expDim];
262 coords[0] = ax[0].fltBinNumber(x0,
false);
263 coords[1] = ax[1].fltBinNumber(x1,
false);
264 coords[2] = ax[2].fltBinNumber(x2,
false);
265 coords[3] = ax[3].fltBinNumber(x3,
false);
266 coords[4] = ax[4].fltBinNumber(x4,
false);
268 switch (interpolationDegree)
271 return bins.interpolate1(coords, expDim);
273 return bins.interpolate3(coords, expDim);
275 return bins.closest(coords, expDim);
279 template <
typename Float,
class Axis>
287 const unsigned interpolationDegree)
289 const unsigned expDim = 6
U;
291 const Axis*
ax = &histo.
axes()[0];
292 double coords[expDim];
293 coords[0] = ax[0].fltBinNumber(x0,
false);
294 coords[1] = ax[1].fltBinNumber(x1,
false);
295 coords[2] = ax[2].fltBinNumber(x2,
false);
296 coords[3] = ax[3].fltBinNumber(x3,
false);
297 coords[4] = ax[4].fltBinNumber(x4,
false);
298 coords[5] = ax[5].fltBinNumber(x5,
false);
300 switch (interpolationDegree)
303 return bins.interpolate1(coords, expDim);
305 return bins.interpolate3(coords, expDim);
307 return bins.closest(coords, expDim);
311 template <
typename Float,
class Axis>
320 const unsigned interpolationDegree)
322 const unsigned expDim = 7
U;
324 const Axis*
ax = &histo.
axes()[0];
325 double coords[expDim];
326 coords[0] = ax[0].fltBinNumber(x0,
false);
327 coords[1] = ax[1].fltBinNumber(x1,
false);
328 coords[2] = ax[2].fltBinNumber(x2,
false);
329 coords[3] = ax[3].fltBinNumber(x3,
false);
330 coords[4] = ax[4].fltBinNumber(x4,
false);
331 coords[5] = ax[5].fltBinNumber(x5,
false);
332 coords[6] = ax[6].fltBinNumber(x6,
false);
334 switch (interpolationDegree)
337 return bins.interpolate1(coords, expDim);
339 return bins.interpolate3(coords, expDim);
341 return bins.closest(coords, expDim);
345 template <
typename Float,
class Axis>
355 const unsigned interpolationDegree)
357 const unsigned expDim = 8
U;
359 const Axis*
ax = &histo.
axes()[0];
360 double coords[expDim];
361 coords[0] = ax[0].fltBinNumber(x0,
false);
362 coords[1] = ax[1].fltBinNumber(x1,
false);
363 coords[2] = ax[2].fltBinNumber(x2,
false);
364 coords[3] = ax[3].fltBinNumber(x3,
false);
365 coords[4] = ax[4].fltBinNumber(x4,
false);
366 coords[5] = ax[5].fltBinNumber(x5,
false);
367 coords[6] = ax[6].fltBinNumber(x6,
false);
368 coords[7] = ax[7].fltBinNumber(x7,
false);
370 switch (interpolationDegree)
373 return bins.interpolate1(coords, expDim);
375 return bins.interpolate3(coords, expDim);
377 return bins.closest(coords, expDim);
381 template <
typename Float,
class Axis>
392 const unsigned interpolationDegree)
394 const unsigned expDim = 9
U;
396 const Axis*
ax = &histo.
axes()[0];
397 double coords[expDim];
398 coords[0] = ax[0].fltBinNumber(x0,
false);
399 coords[1] = ax[1].fltBinNumber(x1,
false);
400 coords[2] = ax[2].fltBinNumber(x2,
false);
401 coords[3] = ax[3].fltBinNumber(x3,
false);
402 coords[4] = ax[4].fltBinNumber(x4,
false);
403 coords[5] = ax[5].fltBinNumber(x5,
false);
404 coords[6] = ax[6].fltBinNumber(x6,
false);
405 coords[7] = ax[7].fltBinNumber(x7,
false);
406 coords[8] = ax[8].fltBinNumber(x8,
false);
408 switch (interpolationDegree)
411 return bins.interpolate1(coords, expDim);
413 return bins.interpolate3(coords, expDim);
415 return bins.closest(coords, expDim);
419 template <
typename Float,
class Axis>
431 const unsigned interpolationDegree)
433 const unsigned expDim = 10
U;
435 const Axis*
ax = &histo.
axes()[0];
436 double coords[expDim];
437 coords[0] = ax[0].fltBinNumber(x0,
false);
438 coords[1] = ax[1].fltBinNumber(x1,
false);
439 coords[2] = ax[2].fltBinNumber(x2,
false);
440 coords[3] = ax[3].fltBinNumber(x3,
false);
441 coords[4] = ax[4].fltBinNumber(x4,
false);
442 coords[5] = ax[5].fltBinNumber(x5,
false);
443 coords[6] = ax[6].fltBinNumber(x6,
false);
444 coords[7] = ax[7].fltBinNumber(x7,
false);
445 coords[8] = ax[8].fltBinNumber(x8,
false);
446 coords[9] = ax[9].fltBinNumber(x9,
false);
448 switch (interpolationDegree)
451 return bins.interpolate1(coords, expDim);
453 return bins.interpolate3(coords, expDim);
455 return bins.closest(coords, expDim);
461 #endif // NPSTAT_INTERPOLATEHISTOND_HH_ void iHND_checkArgs(const HistoND< Float, Axis > &histo, const unsigned xDim, const unsigned interpolationDegree)
const Axis & axis(const unsigned i) const
Arbitrary-dimensional histogram template.
const ArrayND< Numeric > & binContents() const
Exceptions for the npstat namespace.
bool isUniformlyBinned() const
const std::vector< Axis > & axes() const
Float interpolateHistoND(const HistoND< Float, Axis > &histo, const double *coords, unsigned coordsDim, unsigned interpolationDegree)