1 #ifndef NPSTAT_INTERPOLATEHISTOND_HH_ 2 #define NPSTAT_INTERPOLATEHISTOND_HH_ 34 template <
typename Float,
class Axis>
38 unsigned interpolationDegree);
44 template <
typename Float,
class Axis>
47 template <
typename Float,
class Axis>
50 template <
typename Float,
class Axis>
52 const HistoND<Float, Axis>&
histo,
double x0,
double x1,
double x2,
unsigned interpolationDegree);
54 template <
typename Float,
class Axis>
56 const HistoND<Float, Axis>&
histo,
double x0,
double x1,
double x2,
double x3,
unsigned interpolationDegree);
58 template <
typename Float,
class Axis>
65 unsigned interpolationDegree);
67 template <
typename Float,
class Axis>
75 unsigned interpolationDegree);
77 template <
typename Float,
class Axis>
86 unsigned interpolationDegree);
88 template <
typename Float,
class Axis>
98 unsigned interpolationDegree);
100 template <
typename Float,
class Axis>
111 unsigned interpolationDegree);
113 template <
typename Float,
class Axis>
125 unsigned interpolationDegree);
134 template <
typename Float,
class Axis>
136 if (xDim !=
histo.dim())
138 "In npstat::interpolateHistoND: incompatible " 139 "dimensionality of input coordinates");
142 "In npstat::interpolateHistoND: can not interpolate " 143 "zero-dimensional histograms");
144 if (!(interpolationDegree == 0
U || interpolationDegree == 1
U || interpolationDegree == 3
U))
146 "In npstat::interpolateHistoND: " 147 "unsupported interpolation degree");
148 if (interpolationDegree == 3
U && !
histo.isUniformlyBinned())
150 "In npstat::interpolateHistoND: unsupported " 151 "interpolation degree for non-uniform binning");
155 template <
typename Float,
class Axis>
159 const unsigned interpolationDegree) {
162 const Axis* ax = &
histo.axes()[0];
163 double coords[CHAR_BIT *
sizeof(
unsigned long)];
164 for (
unsigned i = 0;
i < xDim; ++
i)
165 coords[
i] = ax[
i].fltBinNumber(
x[
i],
false);
167 switch (interpolationDegree) {
169 return bins.interpolate1(coords, xDim);
171 return bins.interpolate3(coords, xDim);
173 return bins.closest(coords, xDim);
177 template <
typename Float,
class Axis>
179 const unsigned expDim = 1
U;
181 const double coords =
histo.axis(0).fltBinNumber(x0,
false);
183 switch (interpolationDegree) {
185 return bins.interpolate1(&coords, expDim);
187 return bins.interpolate3(&coords, expDim);
189 return bins.closest(&coords, expDim);
193 template <
typename Float,
class Axis>
197 const unsigned interpolationDegree) {
198 const unsigned expDim = 2
U;
200 const Axis* ax = &
histo.axes()[0];
201 double coords[expDim];
202 coords[0] = ax[0].fltBinNumber(x0,
false);
203 coords[1] = ax[1].fltBinNumber(x1,
false);
205 switch (interpolationDegree) {
207 return bins.interpolate1(coords, expDim);
209 return bins.interpolate3(coords, expDim);
211 return bins.closest(coords, expDim);
215 template <
typename Float,
class Axis>
220 const unsigned interpolationDegree) {
221 const unsigned expDim = 3
U;
223 const Axis* ax = &
histo.axes()[0];
224 double coords[expDim];
225 coords[0] = ax[0].fltBinNumber(x0,
false);
226 coords[1] = ax[1].fltBinNumber(x1,
false);
227 coords[2] = ax[2].fltBinNumber(x2,
false);
229 switch (interpolationDegree) {
231 return bins.interpolate1(coords, expDim);
233 return bins.interpolate3(coords, expDim);
235 return bins.closest(coords, expDim);
239 template <
typename Float,
class Axis>
245 const unsigned interpolationDegree) {
246 const unsigned expDim = 4
U;
248 const Axis* ax = &
histo.axes()[0];
249 double coords[expDim];
250 coords[0] = ax[0].fltBinNumber(x0,
false);
251 coords[1] = ax[1].fltBinNumber(x1,
false);
252 coords[2] = ax[2].fltBinNumber(x2,
false);
253 coords[3] = ax[3].fltBinNumber(x3,
false);
255 switch (interpolationDegree) {
257 return bins.interpolate1(coords, expDim);
259 return bins.interpolate3(coords, expDim);
261 return bins.closest(coords, expDim);
265 template <
typename Float,
class Axis>
272 const unsigned interpolationDegree) {
273 const unsigned expDim = 5
U;
275 const Axis* ax = &
histo.axes()[0];
276 double coords[expDim];
277 coords[0] = ax[0].fltBinNumber(x0,
false);
278 coords[1] = ax[1].fltBinNumber(x1,
false);
279 coords[2] = ax[2].fltBinNumber(x2,
false);
280 coords[3] = ax[3].fltBinNumber(x3,
false);
281 coords[4] = ax[4].fltBinNumber(x4,
false);
283 switch (interpolationDegree) {
285 return bins.interpolate1(coords, expDim);
287 return bins.interpolate3(coords, expDim);
289 return bins.closest(coords, expDim);
293 template <
typename Float,
class Axis>
301 const unsigned interpolationDegree) {
302 const unsigned expDim = 6
U;
304 const Axis* ax = &
histo.axes()[0];
305 double coords[expDim];
306 coords[0] = ax[0].fltBinNumber(x0,
false);
307 coords[1] = ax[1].fltBinNumber(x1,
false);
308 coords[2] = ax[2].fltBinNumber(x2,
false);
309 coords[3] = ax[3].fltBinNumber(x3,
false);
310 coords[4] = ax[4].fltBinNumber(x4,
false);
311 coords[5] = ax[5].fltBinNumber(x5,
false);
313 switch (interpolationDegree) {
315 return bins.interpolate1(coords, expDim);
317 return bins.interpolate3(coords, expDim);
319 return bins.closest(coords, expDim);
323 template <
typename Float,
class Axis>
332 const unsigned interpolationDegree) {
333 const unsigned expDim = 7
U;
335 const Axis* ax = &
histo.axes()[0];
336 double coords[expDim];
337 coords[0] = ax[0].fltBinNumber(x0,
false);
338 coords[1] = ax[1].fltBinNumber(x1,
false);
339 coords[2] = ax[2].fltBinNumber(x2,
false);
340 coords[3] = ax[3].fltBinNumber(x3,
false);
341 coords[4] = ax[4].fltBinNumber(x4,
false);
342 coords[5] = ax[5].fltBinNumber(x5,
false);
343 coords[6] = ax[6].fltBinNumber(x6,
false);
345 switch (interpolationDegree) {
347 return bins.interpolate1(coords, expDim);
349 return bins.interpolate3(coords, expDim);
351 return bins.closest(coords, expDim);
355 template <
typename Float,
class Axis>
365 const unsigned interpolationDegree) {
366 const unsigned expDim = 8
U;
368 const Axis* ax = &
histo.axes()[0];
369 double coords[expDim];
370 coords[0] = ax[0].fltBinNumber(x0,
false);
371 coords[1] = ax[1].fltBinNumber(x1,
false);
372 coords[2] = ax[2].fltBinNumber(x2,
false);
373 coords[3] = ax[3].fltBinNumber(x3,
false);
374 coords[4] = ax[4].fltBinNumber(x4,
false);
375 coords[5] = ax[5].fltBinNumber(x5,
false);
376 coords[6] = ax[6].fltBinNumber(x6,
false);
377 coords[7] = ax[7].fltBinNumber(x7,
false);
379 switch (interpolationDegree) {
381 return bins.interpolate1(coords, expDim);
383 return bins.interpolate3(coords, expDim);
385 return bins.closest(coords, expDim);
389 template <
typename Float,
class Axis>
400 const unsigned interpolationDegree) {
401 const unsigned expDim = 9
U;
403 const Axis* ax = &
histo.axes()[0];
404 double coords[expDim];
405 coords[0] = ax[0].fltBinNumber(x0,
false);
406 coords[1] = ax[1].fltBinNumber(x1,
false);
407 coords[2] = ax[2].fltBinNumber(x2,
false);
408 coords[3] = ax[3].fltBinNumber(x3,
false);
409 coords[4] = ax[4].fltBinNumber(x4,
false);
410 coords[5] = ax[5].fltBinNumber(x5,
false);
411 coords[6] = ax[6].fltBinNumber(x6,
false);
412 coords[7] = ax[7].fltBinNumber(x7,
false);
413 coords[8] = ax[8].fltBinNumber(x8,
false);
415 switch (interpolationDegree) {
417 return bins.interpolate1(coords, expDim);
419 return bins.interpolate3(coords, expDim);
421 return bins.closest(coords, expDim);
425 template <
typename Float,
class Axis>
437 const unsigned interpolationDegree) {
438 const unsigned expDim = 10
U;
440 const Axis* ax = &
histo.axes()[0];
441 double coords[expDim];
442 coords[0] = ax[0].fltBinNumber(x0,
false);
443 coords[1] = ax[1].fltBinNumber(x1,
false);
444 coords[2] = ax[2].fltBinNumber(x2,
false);
445 coords[3] = ax[3].fltBinNumber(x3,
false);
446 coords[4] = ax[4].fltBinNumber(x4,
false);
447 coords[5] = ax[5].fltBinNumber(x5,
false);
448 coords[6] = ax[6].fltBinNumber(x6,
false);
449 coords[7] = ax[7].fltBinNumber(x7,
false);
450 coords[8] = ax[8].fltBinNumber(x8,
false);
451 coords[9] = ax[9].fltBinNumber(x9,
false);
453 switch (interpolationDegree) {
455 return bins.interpolate1(coords, expDim);
457 return bins.interpolate3(coords, expDim);
459 return bins.closest(coords, expDim);
464 #endif // NPSTAT_INTERPOLATEHISTOND_HH_ void iHND_checkArgs(const HistoND< Float, Axis > &histo, const unsigned xDim, const unsigned interpolationDegree)
Arbitrary-dimensional histogram template.
Exceptions for the npstat namespace.
Float interpolateHistoND(const HistoND< Float, Axis > &histo, const double *coords, unsigned coordsDim, unsigned interpolationDegree)