1 #ifndef NPSTAT_HISTOND_HH_
2 #define NPSTAT_HISTOND_HH_
42 template <
typename Numeric,
class Axis = HistoAxis>
44 template <
typename Num2,
class Axis2>
55 const char*
title =
nullptr,
64 const char*
title =
nullptr,
71 const char*
title =
nullptr,
79 const char*
title =
nullptr,
88 const char*
title =
nullptr,
98 const char*
title =
nullptr,
107 template <
typename Num2,
class Functor>
110 const char*
title =
nullptr,
120 template <
typename Num2>
132 template <
typename Num2>
152 template <
typename Num2>
155 const unsigned* newBinCounts,
156 unsigned lenNewBinCounts,
157 const double* shifts =
nullptr,
158 const char*
title =
nullptr);
188 inline const std::vector<Axis>&
axes()
const {
return axes_; }
191 inline const Axis&
axis(
const unsigned i)
const {
return axes_.at(
i); }
213 title_ = newtitle ? newtitle :
"";
224 inline void setAxisLabel(
const unsigned axisNum,
const char* newlabel) {
225 axes_.at(axisNum).setLabel(newlabel);
249 template <
class Po
int>
295 template <
typename Num2>
296 void fill(
const double* coords,
unsigned coordLength,
const Num2&
weight);
303 template <
typename Num2>
306 template <
typename Num2>
309 template <
typename Num2>
312 template <
typename Num2>
315 template <
typename Num2>
316 void fill(
double x0,
double x1,
double x2,
double x3,
const Num2&
weight);
318 template <
typename Num2>
319 void fill(
double x0,
double x1,
double x2,
double x3,
double x4,
const Num2&
weight);
321 template <
typename Num2>
322 void fill(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
const Num2&
weight);
324 template <
typename Num2>
325 void fill(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
const Num2&
weight);
327 template <
typename Num2>
329 double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
double x7,
const Num2&
weight);
331 template <
typename Num2>
343 template <
typename Num2>
370 template <
typename Num2,
class Functor>
371 void dispatch(
const double* coords,
unsigned coordLength, Num2&
weight, Functor&
f);
378 template <
typename Num2,
class Functor>
381 template <
typename Num2,
class Functor>
384 template <
typename Num2,
class Functor>
387 template <
typename Num2,
class Functor>
390 template <
typename Num2,
class Functor>
393 template <
typename Num2,
class Functor>
394 void dispatch(
double x0,
double x1,
double x2,
double x3,
double x4, Num2&
weight, Functor&
f);
396 template <
typename Num2,
class Functor>
397 void dispatch(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5, Num2&
weight, Functor&
f);
399 template <
typename Num2,
class Functor>
400 void dispatch(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6, Num2&
weight, Functor&
f);
402 template <
typename Num2,
class Functor>
414 template <
typename Num2,
class Functor>
427 template <
typename Num2,
class Functor>
448 const Numeric&
examine(
const double* coords,
unsigned coordLength)
const;
455 const Numeric&
examine()
const;
457 const Numeric&
examine(
double x0)
const;
459 const Numeric&
examine(
double x0,
double x1)
const;
461 const Numeric&
examine(
double x0,
double x1,
double x2)
const;
463 const Numeric&
examine(
double x0,
double x1,
double x2,
double x3)
const;
465 const Numeric&
examine(
double x0,
double x1,
double x2,
double x3,
double x4)
const;
467 const Numeric&
examine(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5)
const;
469 const Numeric&
examine(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6)
const;
471 const Numeric&
examine(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
double x7)
const;
474 double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
double x7,
double x8)
const;
477 double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
double x7,
double x8,
double x9)
487 const Numeric&
closestBin(
const double* coords,
unsigned coordLength)
const;
502 const Numeric&
closestBin(
double x0,
double x1,
double x2,
double x3)
const;
504 const Numeric&
closestBin(
double x0,
double x1,
double x2,
double x3,
double x4)
const;
506 const Numeric&
closestBin(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5)
const;
508 const Numeric&
closestBin(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6)
const;
511 double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
double x7)
const;
514 double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
double x7,
double x8)
const;
517 double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
double x7,
double x8,
double x9)
543 template <
typename Num2>
544 void fillC(
const double* coords,
unsigned coordLength,
const Num2&
weight);
551 template <
typename Num2>
554 template <
typename Num2>
557 template <
typename Num2>
560 template <
typename Num2>
563 template <
typename Num2>
564 void fillC(
double x0,
double x1,
double x2,
double x3,
const Num2&
weight);
566 template <
typename Num2>
567 void fillC(
double x0,
double x1,
double x2,
double x3,
double x4,
const Num2&
weight);
569 template <
typename Num2>
570 void fillC(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
const Num2&
weight);
572 template <
typename Num2>
573 void fillC(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
const Num2&
weight);
575 template <
typename Num2>
577 double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
double x7,
const Num2&
weight);
579 template <
typename Num2>
580 void fillC(
double x0,
591 template <
typename Num2>
592 void fillC(
double x0,
609 template <
typename Num2>
621 template <
typename Num2>
626 template <
typename Num2>
627 void setBin(
const unsigned*
index,
unsigned indexLen,
const Num2&
v);
629 template <
typename Num2>
632 template <
typename Num2>
633 void setBin(
unsigned i0,
const Num2&
v);
635 template <
typename Num2>
636 void setBin(
unsigned i0,
unsigned i1,
const Num2&
v);
638 template <
typename Num2>
639 void setBin(
unsigned i0,
unsigned i1,
unsigned i2,
const Num2&
v);
641 template <
typename Num2>
642 void setBin(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
const Num2&
v);
644 template <
typename Num2>
645 void setBin(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
unsigned i4,
const Num2&
v);
647 template <
typename Num2>
648 void setBin(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
unsigned i4,
unsigned i5,
const Num2&
v);
650 template <
typename Num2>
652 unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
unsigned i4,
unsigned i5,
unsigned i6,
const Num2&
v);
654 template <
typename Num2>
665 template <
typename Num2>
677 template <
typename Num2>
690 template <
typename Num2>
699 template <
typename Num2>
700 void setBinAt(
const unsigned*
index,
unsigned indexLen,
const Num2&
v);
702 template <
typename Num2>
705 template <
typename Num2>
706 void setBinAt(
unsigned i0,
const Num2&
v);
708 template <
typename Num2>
709 void setBinAt(
unsigned i0,
unsigned i1,
const Num2&
v);
711 template <
typename Num2>
712 void setBinAt(
unsigned i0,
unsigned i1,
unsigned i2,
const Num2&
v);
714 template <
typename Num2>
715 void setBinAt(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
const Num2&
v);
717 template <
typename Num2>
718 void setBinAt(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
unsigned i4,
const Num2&
v);
720 template <
typename Num2>
721 void setBinAt(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
unsigned i4,
unsigned i5,
const Num2&
v);
723 template <
typename Num2>
725 unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
unsigned i4,
unsigned i5,
unsigned i6,
const Num2&
v);
727 template <
typename Num2>
738 template <
typename Num2>
750 template <
typename Num2>
763 template <
typename Num2>
771 template <
typename Num2>
775 template <
typename Num2>
782 template <
typename Num2>
792 template <
typename Num2>
822 template <
typename Num2>
826 template <
typename Num2>
831 template <
typename Num2>
834 template <
typename Num2>
843 template <
typename Num2>
846 template <
typename Num2>
856 template <
typename Num2>
859 template <
typename Num2>
871 template <
typename Acc>
885 template <
typename Num2,
typename Num3>
888 const unsigned* projectedIndices,
889 unsigned nProjectedIndices)
const;
891 template <
typename Num2,
typename Num3>
894 const unsigned* projectedIndices,
895 unsigned nProjectedIndices)
const;
924 inline gs::ClassId
classId()
const {
return gs::ClassId(*
this); }
925 bool write(std::ostream& of)
const;
929 static inline unsigned version() {
return 1; }
930 static HistoND*
read(
const gs::ClassId&
id, std::istream&
in);
937 template <
typename Num2>
940 template <
typename Acc>
945 double overlapFraction,
946 long double* wsum)
const;
974 template <
typename Histo>
982 template <
typename Histo>
995 template <
typename Histo>
1003 #include <algorithm>
1005 #include "Alignment/Geners/interface/CPP11_auto_ptr.hh"
1006 #include "Alignment/Geners/interface/binaryIO.hh"
1010 template <
class Axis>
1012 const unsigned n = axes.size();
1015 for (
unsigned i = 0;
i <
n; ++
i)
1016 result.push_back(axes[
i].nBins());
1020 template <
class Axis>
1028 template <
class Axis>
1037 template <
class Axis>
1047 template <
class Axis>
1054 result.push_back(tAxis.nBins());
1058 template <
class Axis>
1060 const Axis&
xAxis,
const Axis&
yAxis,
const Axis&
zAxis,
const Axis& tAxis,
const Axis& vAxis) {
1066 result.push_back(tAxis.nBins());
1067 result.push_back(vAxis.nBins());
1071 template <
class Axis>
1072 std::vector<Axis>
rebinAxes(
const std::vector<Axis>& axes,
const unsigned* newBins,
const unsigned lenNewBins) {
1073 const unsigned dim = axes.size();
1074 if (lenNewBins != dim)
1076 "In npstat::Private::rebinAxes: invalid length "
1077 "of the new bins array");
1079 std::vector<Axis> newAxes;
1080 newAxes.reserve(dim);
1081 for (
unsigned i = 0;
i < dim; ++
i)
1082 newAxes.push_back(axes[
i].rebin(newBins[
i]));
1086 template <
class Axis>
1088 const unsigned* fixedIndices,
1089 const unsigned nFixedIndices) {
1090 const unsigned dim = axes.size();
1091 std::vector<Axis> newAxes;
1092 if (nFixedIndices == 0
U)
1094 "In npstat::Private::axesOfASlice: "
1095 "at least one fixed index must be specified");
1096 if (nFixedIndices > dim)
1099 for (
unsigned i = 0;
i < nFixedIndices; ++
i)
1100 if (fixedIndices[
i] >= dim)
1102 newAxes.reserve(dim - nFixedIndices);
1103 for (
unsigned i = 0;
i < dim; ++
i) {
1105 for (
unsigned j = 0;
j < nFixedIndices; ++
j)
1106 if (fixedIndices[
j] ==
i) {
1111 newAxes.push_back(axes[
i]);
1113 if (newAxes.size() != dim - nFixedIndices)
1118 template <
class Axis>
1120 const unsigned* fixedIndices,
1121 const unsigned nFixedIndices) {
1122 const unsigned dim = axes.size();
1123 if (nFixedIndices == 0
U)
1125 "In npstat::Private::shapeOfASlice: "
1126 "at least one fixed index must be specified");
1127 if (nFixedIndices > dim)
1132 for (
unsigned j = 0;
j < nFixedIndices; ++
j)
1133 if (fixedIndices[
j] >= dim)
1138 if (nFixedIndices < dim)
1139 sh.reserve(dim - nFixedIndices);
1140 for (
unsigned i = 0;
i < dim; ++
i) {
1142 for (
unsigned j = 0;
j < nFixedIndices; ++
j)
1143 if (fixedIndices[
j] ==
i) {
1148 sh.push_back(axes[
i].
nBins());
1150 if (sh.size() != dim - nFixedIndices)
1155 template <
class Axis>
1156 std::vector<Axis>
addAxis(
const std::vector<Axis>& axes,
const Axis& newAxis,
const unsigned newAxisNumber) {
1157 const unsigned dim = axes.size();
1158 std::vector<Axis> newAxes;
1159 newAxes.reserve(dim + 1
U);
1161 for (
unsigned i = 0;
i < dim; ++
i) {
1162 if (newAxisNumber ==
i)
1163 newAxes.push_back(newAxis);
1165 newAxes.push_back(axes[iadd++]);
1168 newAxes.push_back(newAxis);
1170 newAxes.push_back(axes[iadd]);
1174 template <
class Axis>
1176 const unsigned dim = axes.size();
1180 for (
unsigned i = 0;
i < dim; ++
i) {
1181 if (newAxisNumber ==
i)
1182 result.push_back(newAxis.nBins());
1187 result.push_back(newAxis.nBins());
1194 std::ostringstream os;
1195 os <<
"In npstat::HistoND::" <<
method <<
": number of arguments"
1196 <<
" is incompatible with histogram dimensionality";
1201 template <
typename Numeric,
class Axis>
1202 template <
typename Acc>
1207 const double overlapFraction,
1208 long double* wsum)
const {
1210 const Axis& axis(axes_[
level]);
1211 const unsigned nbins = axis.nBins();
1212 const bool lastLevel =
level == dim_ - 1
U;
1213 for (
unsigned i = 0;
i <
nbins; ++
i) {
1214 const double over = overlapFraction * axis.binInterval(
i).overlapFraction(boxSide);
1226 template <
typename Numeric,
class Axis>
1227 template <
typename Acc>
1230 const bool calculateAverage)
const {
1231 if (box.size() != dim_)
1233 "In npstat::HistoND::accumulateBinsInBox: "
1234 "incompatible box dimensionality");
1237 long double wsum = 0.0L;
1238 for (
unsigned i = 0;
i < dim_; ++
i)
1240 accumulateBinsLoop(0
U, box, &indexBuf_[0],
accumulator, 1.0, &wsum);
1241 if (calculateAverage && wsum > 0.0
L)
1247 template <
typename Numeric,
class Axis>
1254 template <
typename Numeric,
class Axis>
1261 template <
typename Numeric,
class Axis>
1268 template <
typename Numeric,
class Axis>
1275 weightBuf_(axesIn.
size()),
1276 indexBuf_(2
U * axesIn.
size()),
1278 dim_(axesIn.
size()) {
1279 if (
dim_ >= CHAR_BIT *
sizeof(
unsigned long))
1281 "In npstat::HistoND constructor: requested histogram "
1282 "dimensionality is not supported (too large)");
1286 template <
typename Numeric,
class Axis>
1301 template <
typename Numeric,
class Axis>
1317 template <
typename Numeric,
class Axis>
1335 template <
typename Numeric,
class Axis>
1350 axes_.push_back(tAxis);
1354 template <
typename Numeric,
class Axis>
1374 axes_.push_back(tAxis);
1375 axes_.push_back(vAxis);
1379 template <
typename Numeric,
class Axis>
1388 weightBuf_(shape.
size()),
1389 indexBuf_(2
U * shape.
size()),
1391 dim_(shape.
size()) {
1394 "In npstat::HistoND constructor: "
1395 "incompatible bounding box dimensionality");
1396 if (
dim_ >= CHAR_BIT *
sizeof(
unsigned long))
1398 "In npstat::HistoND constructor: requested histogram "
1399 "dimensionality is not supported (too large)");
1401 for (
unsigned i = 0;
i <
dim_; ++
i)
1406 template <
typename Numeric,
class Axis>
1407 template <
typename Num2,
class Functor>
1412 overflow_(
r.overflow_,
f),
1415 indexBuf_(2
U *
r.dim_),
1416 fillCount_(
r.fillCount_),
1417 overCount_(
r.overCount_),
1421 template <
typename Numeric,
class Axis>
1422 template <
typename Num2>
1425 const unsigned nIndices,
1428 accumulatedDataLabel_(
h.accumulatedDataLabel_),
1432 weightBuf_(data_.rank()),
1433 indexBuf_(2
U * data_.rank()),
1435 dim_(data_.rank()) {
1439 template <
typename Numeric,
class Axis>
1440 template <
typename Num2>
1442 const Axis& newAxis,
1443 const unsigned newAxisNumber,
1446 accumulatedDataLabel_(
h.accumulatedDataLabel_),
1448 overflow_(data_.rank(), 3
U),
1449 axes_(Private::
addAxis(
h.axes_, newAxis, newAxisNumber)),
1450 weightBuf_(data_.rank()),
1451 indexBuf_(2
U * data_.rank()),
1453 dim_(data_.rank()) {
1454 if (
dim_ >= CHAR_BIT *
sizeof(
unsigned long))
1456 "In npstat::HistoND constructor: requested histogram "
1457 "dimensionality is not supported (too large)");
1461 template <
typename Numeric,
class Axis>
1462 template <
typename Num2>
1465 const unsigned* newBinCounts,
1466 const unsigned lenNewBinCounts,
1467 const double* shifts,
1470 accumulatedDataLabel_(
h.accumulatedDataLabel_),
1471 data_(newBinCounts, lenNewBinCounts),
1472 overflow_(
h.overflow_),
1473 axes_(Private::
rebinAxes(
h.axes_, newBinCounts, lenNewBinCounts)),
1475 indexBuf_(2
U *
h.dim_),
1476 fillCount_(
h.fillCount_),
1477 overCount_(
h.overCount_),
1481 const Axis* ax = &
axes_[0];
1487 for (
unsigned long ibin = 0; ibin < newBins; ++ibin) {
1490 for (
unsigned i = 0;
i <
dim_; ++
i)
1493 for (
unsigned i = 0;
i <
dim_; ++
i)
1498 const Numeric
zero = Numeric();
1500 for (
unsigned long ibin = 0; ibin < newBins; ++ibin) {
1502 for (
unsigned i = 0;
i <
dim_; ++
i)
1503 binLimits[
i] = ax[
i].binInterval(ubuf[
i]);
1506 h.accumulateBinsInBox(binLimits, &thisBin, rType ==
AVERAGE);
1511 template <
typename Numeric,
class Axis>
1513 for (
unsigned i = 0;
i < dim_; ++
i)
1514 if (!axes_[
i].isUniform())
1519 template <
typename Numeric,
class Axis>
1525 if (isUniformlyBinned()) {
1526 Precise sum = data_.template sum<Precise>();
1527 return static_cast<double>(sum) * binVolume();
1529 Precise sum = Precise();
1530 const Numeric*
data = data_.data();
1531 const unsigned long len = data_.length();
1532 for (
unsigned long i = 0;
i < len; ++
i)
1533 sum +=
data[
i] * binVolume(
i);
1534 return static_cast<double>(sum);
1538 template <
typename Numeric,
class Axis>
1543 const Axis* ax = &axes_[0];
1544 for (
unsigned i = 0;
i < dim_; ++
i)
1545 box.push_back(ax[
i].interval());
1550 template <
typename Numeric,
class Axis>
1553 const unsigned lenCoords)
const {
1554 if (dim_ != lenCoords)
1556 "In npstat::HistoND::binCenter: "
1557 "incompatible input point dimensionality");
1560 data_.convertLinearIndex(
binNumber, &indexBuf_[0], dim_);
1561 const Axis* ax = &axes_[0];
1562 for (
unsigned i = 0;
i < dim_; ++
i)
1563 coords[
i] = ax[
i].binCenter(indexBuf_[
i]);
1567 template <
typename Numeric,
class Axis>
1568 template <
class Po
int>
1572 const unsigned long len = data_.length();
1573 centers->reserve(len);
1574 unsigned* ibuf = &indexBuf_[0];
1575 const Axis* ax = &axes_[0];
1577 if (center.size() < dim_)
1579 "In npstat::HistoND::allBinCenters: "
1580 "incompatible point dimensionality (too small)");
1583 for (
unsigned long i = 0;
i < len; ++
i) {
1584 data_.convertLinearIndex(
i, ibuf, dim_);
1585 for (
unsigned idim = 0; idim < dim_; ++idim)
1586 cdat[idim] = ax[idim].binCenter(ibuf[idim]);
1587 centers->push_back(center);
1591 template <
typename Numeric,
class Axis>
1597 data_.convertLinearIndex(
binNumber, &indexBuf_[0], dim_);
1598 const Axis* ax = &axes_[0];
1599 for (
unsigned i = 0;
i < dim_; ++
i)
1600 box->push_back(ax[
i].binInterval(indexBuf_[
i]));
1604 template <
typename Numeric,
class Axis>
1606 return dim_ ==
r.dim_ && overflow_ ==
r.overflow_ && data_ ==
r.data_;
1609 template <
typename Numeric,
class Axis>
1611 return dim_ ==
r.dim_ && fillCount_ ==
r.fillCount_ && overCount_ ==
r.overCount_ && title_ ==
r.title_ &&
1612 accumulatedDataLabel_ ==
r.accumulatedDataLabel_ && axes_ ==
r.axes_ && overflow_ ==
r.overflow_ &&
1616 template <
typename Numeric,
class Axis>
1618 return !(*
this ==
r);
1621 template <
typename Numeric,
class Axis>
1625 data_.convertLinearIndex(
binNumber, &indexBuf_[0], dim_);
1626 const Axis* ax = &axes_[0];
1627 for (
unsigned i = 0;
i < dim_; ++
i)
1628 v *= ax[
i].binWidth(indexBuf_[
i]);
1633 template <
typename Numeric,
class Axis>
1637 const Axis* ax = &axes_[0];
1638 for (
unsigned i = 0;
i < dim_; ++
i)
1644 template <
typename Numeric,
class Axis>
1645 template <
typename Num2>
1647 if (coordLength != dim_)
1649 "In npstat::HistoND::fill: "
1650 "incompatible input point dimensionality");
1653 unsigned*
idx = &indexBuf_[0];
1654 unsigned* over =
idx + dim_;
1655 const Axis* ax = &axes_[0];
1656 unsigned overflown = 0
U;
1657 for (
unsigned i = 0;
i < dim_; ++
i) {
1658 over[
i] = ax[
i].overflowIndex(coords[
i],
idx +
i);
1659 overflown |= (over[
i] - 1
U);
1662 overflow_.value(over, dim_) +=
w;
1665 data_.value(
idx, dim_) +=
w;
1672 template <
typename Numeric,
class Axis>
1673 template <
typename Num2,
class Functor>
1675 if (coordLength != dim_)
1677 "In npstat::HistoND::dispatch: "
1678 "incompatible input point dimensionality");
1681 unsigned*
idx = &indexBuf_[0];
1682 unsigned* over =
idx + dim_;
1683 const Axis* ax = &axes_[0];
1684 unsigned overflown = 0
U;
1685 for (
unsigned i = 0;
i < dim_; ++
i) {
1686 over[
i] = ax[
i].overflowIndex(coords[
i],
idx +
i);
1687 overflown |= (over[
i] - 1
U);
1690 f(overflow_.value(over, dim_),
w);
1692 f(data_.value(
idx, dim_),
w);
1698 template <
typename Numeric,
class Axis>
1700 if (coordLength != dim_)
1702 "In npstat::HistoND::examine: "
1703 "incompatible input point dimensionality");
1706 unsigned*
idx = &indexBuf_[0];
1707 unsigned* over =
idx + dim_;
1708 const Axis* ax = &axes_[0];
1709 unsigned overflown = 0
U;
1710 for (
unsigned i = 0;
i < dim_; ++
i) {
1711 over[
i] = ax[
i].overflowIndex(coords[
i],
idx +
i);
1712 overflown |= (over[
i] - 1
U);
1715 return overflow_.value(over, dim_);
1717 return data_.value(
idx, dim_);
1722 template <
typename Numeric,
class Axis>
1724 if (coordLength != dim_)
1726 "In npstat::HistoND::closestBin: "
1727 "incompatible input point dimensionality");
1730 unsigned*
idx = &indexBuf_[0];
1731 const Axis* ax = &axes_[0];
1732 for (
unsigned i = 0;
i < dim_; ++
i)
1733 idx[
i] = ax[
i].closestValidBin(coords[
i]);
1734 return data_.value(
idx, dim_);
1739 template <
typename Numeric,
class Axis>
1740 template <
typename Num2>
1742 const double*
weights = &weightBuf_[0];
1743 const unsigned* cell = &indexBuf_[0];
1744 const unsigned long* strides = data_.strides();
1745 const unsigned long maxcycle = 1UL << dim_;
1746 for (
unsigned long icycle = 0; icycle < maxcycle; ++icycle) {
1748 unsigned long icell = 0UL;
1749 for (
unsigned i = 0;
i < dim_; ++
i) {
1750 if (icycle & (1UL <<
i)) {
1752 icell += strides[
i] * (cell[
i] + 1
U);
1755 icell += strides[
i] * cell[
i];
1758 data_.linearValue(icell) += (
value *
w);
1762 template <
typename Numeric,
class Axis>
1763 template <
typename Num2>
1765 if (coordLength != dim_)
1767 "In npstat::HistoND::fillC: "
1768 "incompatible input point dimensionality");
1771 double* wg = &weightBuf_[0];
1772 unsigned*
idx = &indexBuf_[0];
1773 unsigned* over =
idx + dim_;
1774 const Axis* ax = &axes_[0];
1775 unsigned overflown = 0
U;
1776 for (
unsigned i = 0;
i < dim_; ++
i) {
1777 over[
i] = ax[
i].overflowIndexWeighted(coords[
i],
idx +
i, wg +
i);
1778 overflown |= (over[
i] - 1
U);
1781 overflow_.value(over, dim_) +=
w;
1784 fillPreservingCentroid(
w);
1791 template <
typename Numeric,
class Axis>
1792 template <
typename Num2>
1801 template <
typename Numeric,
class Axis>
1802 template <
typename Num2,
class Functor>
1810 template <
typename Numeric,
class Axis>
1811 template <
typename Num2>
1820 template <
typename Numeric,
class Axis>
1827 template <
typename Numeric,
class Axis>
1834 template <
typename Numeric,
class Axis>
1835 template <
typename Num2>
1840 const unsigned ov0 = axes_[0].overflowIndex(x0, &i0);
1844 overflow_(ov0) +=
w;
1851 template <
typename Numeric,
class Axis>
1852 template <
typename Num2,
class Functor>
1857 const unsigned ov0 = axes_[0].overflowIndex(x0, &i0);
1861 f(overflow_(ov0),
w);
1865 template <
typename Numeric,
class Axis>
1866 template <
typename Num2>
1870 double* wg = &weightBuf_[0];
1871 unsigned*
idx = &indexBuf_[0];
1872 const unsigned ov0 = axes_[0].overflowIndexWeighted(x0,
idx, wg);
1874 fillPreservingCentroid(
w);
1876 overflow_(ov0) +=
w;
1883 template <
typename Numeric,
class Axis>
1888 const unsigned ov0 = axes_[0].overflowIndex(x0, &i0);
1892 return overflow_(ov0);
1895 template <
typename Numeric,
class Axis>
1899 const unsigned i0 = axes_[0].closestValidBin(x0);
1903 template <
typename Numeric,
class Axis>
1904 template <
typename Num2>
1908 unsigned i0 = 0,
i1 = 0;
1909 const Axis* ax = &axes_[0];
1910 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1911 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
1912 if (o0 == 1
U &&
o1 == 1
U)
1915 overflow_(o0,
o1) +=
w;
1922 template <
typename Numeric,
class Axis>
1923 template <
typename Num2,
class Functor>
1927 unsigned i0 = 0,
i1 = 0;
1928 const Axis* ax = &axes_[0];
1929 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1930 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
1931 if (o0 == 1
U &&
o1 == 1
U)
1932 f(data_(i0,
i1),
w);
1934 f(overflow_(o0,
o1),
w);
1938 template <
typename Numeric,
class Axis>
1939 template <
typename Num2>
1943 double* wg = &weightBuf_[0];
1944 unsigned*
idx = &indexBuf_[0];
1945 const Axis* ax = &axes_[0];
1946 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
1947 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
1948 if (o0 == 1
U &&
o1 == 1
U)
1949 fillPreservingCentroid(
w);
1951 overflow_(o0,
o1) +=
w;
1958 template <
typename Numeric,
class Axis>
1962 unsigned i0 = 0,
i1 = 0;
1963 const Axis* ax = &axes_[0];
1964 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1965 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
1966 if (o0 == 1
U &&
o1 == 1
U)
1967 return data_(i0,
i1);
1969 return overflow_(o0,
o1);
1972 template <
typename Numeric,
class Axis>
1976 const Axis* ax = &axes_[0];
1977 const unsigned i0 = ax[0].closestValidBin(x0);
1978 const unsigned i1 = ax[1].closestValidBin(
x1);
1979 return data_(i0,
i1);
1982 template <
typename Numeric,
class Axis>
1983 template <
typename Num2>
1987 unsigned i0 = 0,
i1 = 0,
i2 = 0;
1988 const Axis* ax = &axes_[0];
1989 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1990 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
1991 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
1992 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U)
1993 data_(i0,
i1,
i2) +=
w;
1995 overflow_(o0,
o1, o2) +=
w;
2002 template <
typename Numeric,
class Axis>
2003 template <
typename Num2,
class Functor>
2007 unsigned i0 = 0,
i1 = 0,
i2 = 0;
2008 const Axis* ax = &axes_[0];
2009 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2010 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2011 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2012 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U)
2015 f(overflow_(o0,
o1, o2),
w);
2019 template <
typename Numeric,
class Axis>
2020 template <
typename Num2>
2024 double* wg = &weightBuf_[0];
2025 unsigned*
idx = &indexBuf_[0];
2026 const Axis* ax = &axes_[0];
2027 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
2028 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
2029 const unsigned o2 = ax[2].overflowIndexWeighted(
x2,
idx + 2, wg + 2);
2030 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U)
2031 fillPreservingCentroid(
w);
2033 overflow_(o0,
o1, o2) +=
w;
2040 template <
typename Numeric,
class Axis>
2044 unsigned i0 = 0,
i1 = 0,
i2 = 0;
2045 const Axis* ax = &axes_[0];
2046 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2047 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2048 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2049 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U)
2050 return data_(i0,
i1,
i2);
2052 return overflow_(o0,
o1, o2);
2055 template <
typename Numeric,
class Axis>
2059 const Axis* ax = &axes_[0];
2060 const unsigned i0 = ax[0].closestValidBin(x0);
2061 const unsigned i1 = ax[1].closestValidBin(
x1);
2062 const unsigned i2 = ax[2].closestValidBin(
x2);
2063 return data_(i0,
i1,
i2);
2066 template <
typename Numeric,
class Axis>
2067 template <
typename Num2>
2071 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0;
2072 const Axis* ax = &axes_[0];
2073 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2074 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2075 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2076 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2077 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U)
2080 overflow_(o0,
o1, o2, o3) +=
w;
2087 template <
typename Numeric,
class Axis>
2088 template <
typename Num2,
class Functor>
2090 const double x0,
const double x1,
const double x2,
const double x3, Num2&
w, Functor&
f) {
2093 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0;
2094 const Axis* ax = &axes_[0];
2095 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2096 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2097 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2098 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2099 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U)
2102 f(overflow_(o0,
o1, o2, o3),
w);
2106 template <
typename Numeric,
class Axis>
2107 template <
typename Num2>
2111 double* wg = &weightBuf_[0];
2112 unsigned*
idx = &indexBuf_[0];
2113 const Axis* ax = &axes_[0];
2114 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
2115 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
2116 const unsigned o2 = ax[2].overflowIndexWeighted(
x2,
idx + 2, wg + 2);
2117 const unsigned o3 = ax[3].overflowIndexWeighted(x3,
idx + 3, wg + 3);
2118 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U)
2119 fillPreservingCentroid(
w);
2121 overflow_(o0,
o1, o2, o3) +=
w;
2128 template <
typename Numeric,
class Axis>
2132 const double x3)
const {
2135 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0;
2136 const Axis* ax = &axes_[0];
2137 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2138 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2139 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2140 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2141 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U)
2142 return data_(i0,
i1,
i2,
i3);
2144 return overflow_(o0,
o1, o2, o3);
2147 template <
typename Numeric,
class Axis>
2151 const double x3)
const {
2154 const Axis* ax = &axes_[0];
2155 const unsigned i0 = ax[0].closestValidBin(x0);
2156 const unsigned i1 = ax[1].closestValidBin(
x1);
2157 const unsigned i2 = ax[2].closestValidBin(
x2);
2158 const unsigned i3 = ax[3].closestValidBin(x3);
2159 return data_(i0,
i1,
i2,
i3);
2162 template <
typename Numeric,
class Axis>
2163 template <
typename Num2>
2165 const double x0,
const double x1,
const double x2,
const double x3,
const double x4,
const Num2&
w) {
2168 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0;
2169 const Axis* ax = &axes_[0];
2170 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2171 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2172 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2173 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2174 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2175 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U)
2176 data_(i0,
i1,
i2,
i3, i4) +=
w;
2178 overflow_(o0,
o1, o2, o3, o4) +=
w;
2185 template <
typename Numeric,
class Axis>
2186 template <
typename Num2,
class Functor>
2188 const double x0,
const double x1,
const double x2,
const double x3,
const double x4, Num2&
w, Functor&
f) {
2191 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0;
2192 const Axis* ax = &axes_[0];
2193 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2194 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2195 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2196 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2197 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2198 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U)
2201 f(overflow_(o0,
o1, o2, o3, o4),
w);
2205 template <
typename Numeric,
class Axis>
2206 template <
typename Num2>
2208 const double x0,
const double x1,
const double x2,
const double x3,
const double x4,
const Num2&
w) {
2211 double* wg = &weightBuf_[0];
2212 unsigned*
idx = &indexBuf_[0];
2213 const Axis* ax = &axes_[0];
2214 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
2215 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
2216 const unsigned o2 = ax[2].overflowIndexWeighted(
x2,
idx + 2, wg + 2);
2217 const unsigned o3 = ax[3].overflowIndexWeighted(x3,
idx + 3, wg + 3);
2218 const unsigned o4 = ax[4].overflowIndexWeighted(x4,
idx + 4, wg + 4);
2219 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U)
2220 fillPreservingCentroid(
w);
2222 overflow_(o0,
o1, o2, o3, o4) +=
w;
2229 template <
typename Numeric,
class Axis>
2231 const double x0,
const double x1,
const double x2,
const double x3,
const double x4)
const {
2234 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0;
2235 const Axis* ax = &axes_[0];
2236 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2237 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2238 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2239 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2240 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2241 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U)
2242 return data_(i0,
i1,
i2,
i3, i4);
2244 return overflow_(o0,
o1, o2, o3, o4);
2247 template <
typename Numeric,
class Axis>
2249 const double x0,
const double x1,
const double x2,
const double x3,
const double x4)
const {
2252 const Axis* ax = &axes_[0];
2253 const unsigned i0 = ax[0].closestValidBin(x0);
2254 const unsigned i1 = ax[1].closestValidBin(
x1);
2255 const unsigned i2 = ax[2].closestValidBin(
x2);
2256 const unsigned i3 = ax[3].closestValidBin(x3);
2257 const unsigned i4 = ax[4].closestValidBin(x4);
2258 return data_(i0,
i1,
i2,
i3, i4);
2261 template <
typename Numeric,
class Axis>
2262 template <
typename Num2>
2272 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0;
2273 const Axis* ax = &axes_[0];
2274 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2275 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2276 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2277 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2278 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2279 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2280 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U)
2281 data_(i0,
i1,
i2,
i3, i4, i5) +=
w;
2283 overflow_(o0,
o1, o2, o3, o4, o5) +=
w;
2290 template <
typename Numeric,
class Axis>
2291 template <
typename Num2,
class Functor>
2302 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0;
2303 const Axis* ax = &axes_[0];
2304 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2305 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2306 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2307 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2308 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2309 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2310 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U)
2311 f(data_(i0,
i1,
i2,
i3, i4, i5),
w);
2313 f(overflow_(o0,
o1, o2, o3, o4, o5),
w);
2317 template <
typename Numeric,
class Axis>
2318 template <
typename Num2>
2328 double* wg = &weightBuf_[0];
2329 unsigned*
idx = &indexBuf_[0];
2330 const Axis* ax = &axes_[0];
2331 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
2332 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
2333 const unsigned o2 = ax[2].overflowIndexWeighted(
x2,
idx + 2, wg + 2);
2334 const unsigned o3 = ax[3].overflowIndexWeighted(x3,
idx + 3, wg + 3);
2335 const unsigned o4 = ax[4].overflowIndexWeighted(x4,
idx + 4, wg + 4);
2336 const unsigned o5 = ax[5].overflowIndexWeighted(x5,
idx + 5, wg + 5);
2337 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U)
2338 fillPreservingCentroid(
w);
2340 overflow_(o0,
o1, o2, o3, o4, o5) +=
w;
2347 template <
typename Numeric,
class Axis>
2349 const double x0,
const double x1,
const double x2,
const double x3,
const double x4,
const double x5)
const {
2352 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0;
2353 const Axis* ax = &axes_[0];
2354 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2355 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2356 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2357 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2358 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2359 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2360 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U)
2361 return data_(i0,
i1,
i2,
i3, i4, i5);
2363 return overflow_(o0,
o1, o2, o3, o4, o5);
2366 template <
typename Numeric,
class Axis>
2368 const double x0,
const double x1,
const double x2,
const double x3,
const double x4,
const double x5)
const {
2371 const Axis* ax = &axes_[0];
2372 const unsigned i0 = ax[0].closestValidBin(x0);
2373 const unsigned i1 = ax[1].closestValidBin(
x1);
2374 const unsigned i2 = ax[2].closestValidBin(
x2);
2375 const unsigned i3 = ax[3].closestValidBin(x3);
2376 const unsigned i4 = ax[4].closestValidBin(x4);
2377 const unsigned i5 = ax[5].closestValidBin(x5);
2378 return data_(i0,
i1,
i2,
i3, i4, i5);
2381 template <
typename Numeric,
class Axis>
2382 template <
typename Num2>
2393 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0;
2394 const Axis* ax = &axes_[0];
2395 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2396 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2397 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2398 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2399 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2400 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2401 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2402 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U)
2403 data_(i0,
i1,
i2,
i3, i4, i5, i6) +=
w;
2405 overflow_(o0,
o1, o2, o3, o4, o5, o6) +=
w;
2412 template <
typename Numeric,
class Axis>
2413 template <
typename Num2,
class Functor>
2425 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0;
2426 const Axis* ax = &axes_[0];
2427 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2428 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2429 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2430 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2431 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2432 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2433 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2434 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U)
2435 f(data_(i0,
i1,
i2,
i3, i4, i5, i6),
w);
2437 f(overflow_(o0,
o1, o2, o3, o4, o5, o6),
w);
2441 template <
typename Numeric,
class Axis>
2442 template <
typename Num2>
2453 double* wg = &weightBuf_[0];
2454 unsigned*
idx = &indexBuf_[0];
2455 const Axis* ax = &axes_[0];
2456 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
2457 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
2458 const unsigned o2 = ax[2].overflowIndexWeighted(
x2,
idx + 2, wg + 2);
2459 const unsigned o3 = ax[3].overflowIndexWeighted(x3,
idx + 3, wg + 3);
2460 const unsigned o4 = ax[4].overflowIndexWeighted(x4,
idx + 4, wg + 4);
2461 const unsigned o5 = ax[5].overflowIndexWeighted(x5,
idx + 5, wg + 5);
2462 const unsigned o6 = ax[6].overflowIndexWeighted(x6,
idx + 6, wg + 6);
2463 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U)
2464 fillPreservingCentroid(
w);
2466 overflow_(o0,
o1, o2, o3, o4, o5, o6) +=
w;
2473 template <
typename Numeric,
class Axis>
2480 const double x6)
const {
2483 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0;
2484 const Axis* ax = &axes_[0];
2485 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2486 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2487 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2488 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2489 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2490 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2491 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2492 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U)
2493 return data_(i0,
i1,
i2,
i3, i4, i5, i6);
2495 return overflow_(o0,
o1, o2, o3, o4, o5, o6);
2498 template <
typename Numeric,
class Axis>
2505 const double x6)
const {
2508 const Axis* ax = &axes_[0];
2509 const unsigned i0 = ax[0].closestValidBin(x0);
2510 const unsigned i1 = ax[1].closestValidBin(
x1);
2511 const unsigned i2 = ax[2].closestValidBin(
x2);
2512 const unsigned i3 = ax[3].closestValidBin(x3);
2513 const unsigned i4 = ax[4].closestValidBin(x4);
2514 const unsigned i5 = ax[5].closestValidBin(x5);
2515 const unsigned i6 = ax[6].closestValidBin(x6);
2516 return data_(i0,
i1,
i2,
i3, i4, i5, i6);
2519 template <
typename Numeric,
class Axis>
2520 template <
typename Num2>
2532 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
2533 const Axis* ax = &axes_[0];
2534 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2535 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2536 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2537 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2538 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2539 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2540 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2541 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2542 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U && o7 == 1
U)
2543 data_(i0,
i1,
i2,
i3, i4, i5, i6, i7) +=
w;
2545 overflow_(o0,
o1, o2, o3, o4, o5, o6, o7) +=
w;
2552 template <
typename Numeric,
class Axis>
2553 template <
typename Num2,
class Functor>
2566 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
2567 const Axis* ax = &axes_[0];
2568 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2569 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2570 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2571 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2572 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2573 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2574 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2575 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2576 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U && o7 == 1
U)
2577 f(data_(i0,
i1,
i2,
i3, i4, i5, i6, i7),
w);
2579 f(overflow_(o0,
o1, o2, o3, o4, o5, o6, o7),
w);
2583 template <
typename Numeric,
class Axis>
2584 template <
typename Num2>
2596 double* wg = &weightBuf_[0];
2597 unsigned*
idx = &indexBuf_[0];
2598 const Axis* ax = &axes_[0];
2599 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
2600 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
2601 const unsigned o2 = ax[2].overflowIndexWeighted(
x2,
idx + 2, wg + 2);
2602 const unsigned o3 = ax[3].overflowIndexWeighted(x3,
idx + 3, wg + 3);
2603 const unsigned o4 = ax[4].overflowIndexWeighted(x4,
idx + 4, wg + 4);
2604 const unsigned o5 = ax[5].overflowIndexWeighted(x5,
idx + 5, wg + 5);
2605 const unsigned o6 = ax[6].overflowIndexWeighted(x6,
idx + 6, wg + 6);
2606 const unsigned o7 = ax[7].overflowIndexWeighted(x7,
idx + 7, wg + 7);
2607 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U && o7 == 1
U)
2608 fillPreservingCentroid(
w);
2610 overflow_(o0,
o1, o2, o3, o4, o5, o6, o7) +=
w;
2617 template <
typename Numeric,
class Axis>
2625 const double x7)
const {
2628 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
2629 const Axis* ax = &axes_[0];
2630 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2631 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2632 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2633 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2634 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2635 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2636 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2637 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2638 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U && o7 == 1
U)
2639 return data_(i0,
i1,
i2,
i3, i4, i5, i6, i7);
2641 return overflow_(o0,
o1, o2, o3, o4, o5, o6, o7);
2644 template <
typename Numeric,
class Axis>
2652 const double x7)
const {
2655 const Axis* ax = &axes_[0];
2656 const unsigned i0 = ax[0].closestValidBin(x0);
2657 const unsigned i1 = ax[1].closestValidBin(
x1);
2658 const unsigned i2 = ax[2].closestValidBin(
x2);
2659 const unsigned i3 = ax[3].closestValidBin(x3);
2660 const unsigned i4 = ax[4].closestValidBin(x4);
2661 const unsigned i5 = ax[5].closestValidBin(x5);
2662 const unsigned i6 = ax[6].closestValidBin(x6);
2663 const unsigned i7 = ax[7].closestValidBin(x7);
2664 return data_(i0,
i1,
i2,
i3, i4, i5, i6, i7);
2667 template <
typename Numeric,
class Axis>
2668 template <
typename Num2>
2681 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
2682 const Axis* ax = &axes_[0];
2683 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2684 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2685 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2686 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2687 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2688 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2689 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2690 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2691 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2692 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U && o7 == 1
U && o8 == 1
U)
2693 data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8) +=
w;
2695 overflow_(o0,
o1, o2, o3, o4, o5, o6, o7, o8) +=
w;
2702 template <
typename Numeric,
class Axis>
2703 template <
typename Num2,
class Functor>
2717 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
2718 const Axis* ax = &axes_[0];
2719 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2720 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2721 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2722 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2723 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2724 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2725 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2726 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2727 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2728 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U && o7 == 1
U && o8 == 1
U)
2729 f(data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8),
w);
2731 f(overflow_(o0,
o1, o2, o3, o4, o5, o6, o7, o8),
w);
2735 template <
typename Numeric,
class Axis>
2736 template <
typename Num2>
2749 double* wg = &weightBuf_[0];
2750 unsigned*
idx = &indexBuf_[0];
2751 const Axis* ax = &axes_[0];
2752 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
2753 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
2754 const unsigned o2 = ax[2].overflowIndexWeighted(
x2,
idx + 2, wg + 2);
2755 const unsigned o3 = ax[3].overflowIndexWeighted(x3,
idx + 3, wg + 3);
2756 const unsigned o4 = ax[4].overflowIndexWeighted(x4,
idx + 4, wg + 4);
2757 const unsigned o5 = ax[5].overflowIndexWeighted(x5,
idx + 5, wg + 5);
2758 const unsigned o6 = ax[6].overflowIndexWeighted(x6,
idx + 6, wg + 6);
2759 const unsigned o7 = ax[7].overflowIndexWeighted(x7,
idx + 7, wg + 7);
2760 const unsigned o8 = ax[8].overflowIndexWeighted(x8,
idx + 8, wg + 8);
2761 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U && o7 == 1
U && o8 == 1
U)
2762 fillPreservingCentroid(
w);
2764 overflow_(o0,
o1, o2, o3, o4, o5, o6, o7, o8) +=
w;
2771 template <
typename Numeric,
class Axis>
2780 const double x8)
const {
2783 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
2784 const Axis* ax = &axes_[0];
2785 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2786 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2787 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2788 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2789 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2790 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2791 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2792 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2793 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2794 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U && o7 == 1
U && o8 == 1
U)
2795 return data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8);
2797 return overflow_(o0,
o1, o2, o3, o4, o5, o6, o7, o8);
2800 template <
typename Numeric,
class Axis>
2809 const double x8)
const {
2812 const Axis* ax = &axes_[0];
2813 const unsigned i0 = ax[0].closestValidBin(x0);
2814 const unsigned i1 = ax[1].closestValidBin(
x1);
2815 const unsigned i2 = ax[2].closestValidBin(
x2);
2816 const unsigned i3 = ax[3].closestValidBin(x3);
2817 const unsigned i4 = ax[4].closestValidBin(x4);
2818 const unsigned i5 = ax[5].closestValidBin(x5);
2819 const unsigned i6 = ax[6].closestValidBin(x6);
2820 const unsigned i7 = ax[7].closestValidBin(x7);
2821 const unsigned i8 = ax[8].closestValidBin(x8);
2822 return data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8);
2825 template <
typename Numeric,
class Axis>
2826 template <
typename Num2>
2840 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
2841 const Axis* ax = &axes_[0];
2842 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2843 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2844 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2845 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2846 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2847 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2848 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2849 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2850 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2851 const unsigned o9 = ax[9].overflowIndex(x9, &i9);
2852 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U && o7 == 1
U && o8 == 1
U &&
2854 data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8, i9) +=
w;
2856 overflow_(o0,
o1, o2, o3, o4, o5, o6, o7, o8, o9) +=
w;
2863 template <
typename Numeric,
class Axis>
2864 template <
typename Num2,
class Functor>
2879 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
2880 const Axis* ax = &axes_[0];
2881 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2882 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2883 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2884 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2885 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2886 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2887 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2888 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2889 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2890 const unsigned o9 = ax[9].overflowIndex(x9, &i9);
2891 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U && o7 == 1
U && o8 == 1
U &&
2893 f(data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8, i9),
w);
2895 f(overflow_(o0,
o1, o2, o3, o4, o5, o6, o7, o8, o9),
w);
2899 template <
typename Numeric,
class Axis>
2900 template <
typename Num2>
2914 double* wg = &weightBuf_[0];
2915 unsigned*
idx = &indexBuf_[0];
2916 const Axis* ax = &axes_[0];
2917 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
2918 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
2919 const unsigned o2 = ax[2].overflowIndexWeighted(
x2,
idx + 2, wg + 2);
2920 const unsigned o3 = ax[3].overflowIndexWeighted(x3,
idx + 3, wg + 3);
2921 const unsigned o4 = ax[4].overflowIndexWeighted(x4,
idx + 4, wg + 4);
2922 const unsigned o5 = ax[5].overflowIndexWeighted(x5,
idx + 5, wg + 5);
2923 const unsigned o6 = ax[6].overflowIndexWeighted(x6,
idx + 6, wg + 6);
2924 const unsigned o7 = ax[7].overflowIndexWeighted(x7,
idx + 7, wg + 7);
2925 const unsigned o8 = ax[8].overflowIndexWeighted(x8,
idx + 8, wg + 8);
2926 const unsigned o9 = ax[9].overflowIndexWeighted(x9,
idx + 9, wg + 9);
2927 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U && o7 == 1
U && o8 == 1
U &&
2929 fillPreservingCentroid(
w);
2931 overflow_(o0,
o1, o2, o3, o4, o5, o6, o7, o8, o9) +=
w;
2938 template <
typename Numeric,
class Axis>
2948 const double x9)
const {
2951 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
2952 const Axis* ax = &axes_[0];
2953 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2954 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2955 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2956 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2957 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2958 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2959 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2960 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2961 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2962 const unsigned o9 = ax[9].overflowIndex(x9, &i9);
2963 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U && o7 == 1
U && o8 == 1
U &&
2965 return data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8, i9);
2967 return overflow_(o0,
o1, o2, o3, o4, o5, o6, o7, o8, o9);
2970 template <
typename Numeric,
class Axis>
2980 const double x9)
const {
2983 const Axis* ax = &axes_[0];
2984 const unsigned i0 = ax[0].closestValidBin(x0);
2985 const unsigned i1 = ax[1].closestValidBin(
x1);
2986 const unsigned i2 = ax[2].closestValidBin(
x2);
2987 const unsigned i3 = ax[3].closestValidBin(x3);
2988 const unsigned i4 = ax[4].closestValidBin(x4);
2989 const unsigned i5 = ax[5].closestValidBin(x5);
2990 const unsigned i6 = ax[6].closestValidBin(x6);
2991 const unsigned i7 = ax[7].closestValidBin(x7);
2992 const unsigned i8 = ax[8].closestValidBin(x8);
2993 const unsigned i9 = ax[9].closestValidBin(x9);
2994 return data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8, i9);
2997 template <
typename Numeric,
class Axis>
2998 template <
typename Num2>
3000 data_.value(
index, indexLen) =
v;
3004 template <
typename Numeric,
class Axis>
3005 template <
typename Num2>
3007 data_.valueAt(
index, indexLen) =
v;
3011 template <
typename Numeric,
class Axis>
3012 template <
typename Num2>
3018 template <
typename Numeric,
class Axis>
3019 template <
typename Num2>
3025 template <
typename Numeric,
class Axis>
3026 template <
typename Num2>
3032 template <
typename Numeric,
class Axis>
3033 template <
typename Num2>
3039 template <
typename Numeric,
class Axis>
3040 template <
typename Num2>
3046 template <
typename Numeric,
class Axis>
3047 template <
typename Num2>
3049 data_.at(i0,
i1) =
v;
3053 template <
typename Numeric,
class Axis>
3054 template <
typename Num2>
3056 data_(i0,
i1,
i2) =
v;
3060 template <
typename Numeric,
class Axis>
3061 template <
typename Num2>
3063 const unsigned i0,
const unsigned i1,
const unsigned i2,
const unsigned i3,
const Num2&
v) {
3068 template <
typename Numeric,
class Axis>
3069 template <
typename Num2>
3071 const unsigned i0,
const unsigned i1,
const unsigned i2,
const unsigned i3,
const unsigned i4,
const Num2&
v) {
3072 data_(i0,
i1,
i2,
i3, i4) =
v;
3076 template <
typename Numeric,
class Axis>
3077 template <
typename Num2>
3085 data_(i0,
i1,
i2,
i3, i4, i5) =
v;
3089 template <
typename Numeric,
class Axis>
3090 template <
typename Num2>
3099 data_(i0,
i1,
i2,
i3, i4, i5, i6) =
v;
3103 template <
typename Numeric,
class Axis>
3104 template <
typename Num2>
3114 data_(i0,
i1,
i2,
i3, i4, i5, i6, i7) =
v;
3118 template <
typename Numeric,
class Axis>
3119 template <
typename Num2>
3130 data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8) =
v;
3134 template <
typename Numeric,
class Axis>
3135 template <
typename Num2>
3147 data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8, i9) =
v;
3151 template <
typename Numeric,
class Axis>
3152 template <
typename Num2>
3154 data_.at(i0,
i1,
i2) =
v;
3158 template <
typename Numeric,
class Axis>
3159 template <
typename Num2>
3161 const unsigned i0,
const unsigned i1,
const unsigned i2,
const unsigned i3,
const Num2&
v) {
3166 template <
typename Numeric,
class Axis>
3167 template <
typename Num2>
3169 const unsigned i0,
const unsigned i1,
const unsigned i2,
const unsigned i3,
const unsigned i4,
const Num2&
v) {
3170 data_.at(i0,
i1,
i2,
i3, i4) =
v;
3174 template <
typename Numeric,
class Axis>
3175 template <
typename Num2>
3183 data_.at(i0,
i1,
i2,
i3, i4, i5) =
v;
3187 template <
typename Numeric,
class Axis>
3188 template <
typename Num2>
3197 data_.at(i0,
i1,
i2,
i3, i4, i5, i6) =
v;
3201 template <
typename Numeric,
class Axis>
3202 template <
typename Num2>
3212 data_.at(i0,
i1,
i2,
i3, i4, i5, i6, i7) =
v;
3216 template <
typename Numeric,
class Axis>
3217 template <
typename Num2>
3228 data_.at(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8) =
v;
3232 template <
typename Numeric,
class Axis>
3233 template <
typename Num2>
3245 data_.at(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8, i9) =
v;
3249 template <
typename Numeric,
class Axis>
3250 template <
typename Num2>
3253 overflow_ +=
r.overflow_;
3254 fillCount_ +=
r.fillCount_;
3255 overCount_ +=
r.overCount_;
3260 template <
typename Numeric,
class Axis>
3261 template <
typename Num2>
3264 overflow_ -=
r.overflow_;
3271 fillCount_ +=
r.fillCount_;
3272 overCount_ +=
r.overCount_;
3278 template <
typename Numeric,
class Axis>
3279 template <
typename Num2>
3287 template <
typename Numeric,
class Axis>
3288 template <
typename Num2>
3296 template <
typename Numeric,
class Axis>
3299 accumulatedDataLabel_(
r.accumulatedDataLabel_),
3303 weightBuf_(
r.weightBuf_),
3304 indexBuf_(
r.indexBuf_),
3305 fillCount_(
r.fillCount_),
3306 overCount_(
r.overCount_),
3312 template <
typename Numeric,
class Axis>
3315 accumulatedDataLabel_(
r.accumulatedDataLabel_),
3317 overflow_(
r.overflow_),
3319 weightBuf_(
r.weightBuf_),
3320 indexBuf_(
r.indexBuf_),
3321 fillCount_(
r.fillCount_),
3322 overCount_(
r.overCount_),
3326 template <
typename Numeric,
class Axis>
3330 accumulatedDataLabel_ =
r.accumulatedDataLabel_;
3331 data_.uninitialize();
3333 overflow_.uninitialize();
3334 overflow_ =
r.overflow_;
3336 weightBuf_ =
r.weightBuf_;
3337 indexBuf_ =
r.indexBuf_;
3338 fillCount_ =
r.fillCount_;
3339 overCount_ =
r.overCount_;
3346 template <
typename Numeric,
class Axis>
3348 if (axisNum1 >= dim_ || axisNum2 >= dim_)
3350 "In npstat::HistoND::transpose: "
3351 "axis number is out of range");
3352 if (axisNum1 == axisNum2)
3356 return HistoND(*
this, axisNum1, axisNum2);
3359 template <
typename Numeric,
class Axis>
3360 template <
typename Num2>
3362 const unsigned long nDat = data_.length();
3363 Numeric*
data = const_cast<Numeric*>(data_.data());
3364 for (
unsigned long i = 0;
i < nDat; ++
i)
3370 template <
typename Numeric,
class Axis>
3371 template <
typename Num2>
3373 const unsigned long nOver = overflow_.length();
3374 Numeric*
data = const_cast<Numeric*>(overflow_.data());
3375 for (
unsigned long i = 0;
i < nOver; ++
i)
3377 overCount_ += nOver;
3378 fillCount_ += nOver;
3382 template <
typename Numeric,
class Axis>
3383 template <
typename Num2>
3385 if (dataLength != data_.length())
3388 Numeric* dat = const_cast<Numeric*>(data_.data());
3389 for (
unsigned long i = 0;
i < dataLength; ++
i)
3391 fillCount_ += dataLength;
3395 template <
typename Numeric,
class Axis>
3396 template <
typename Num2>
3398 if (dataLength != overflow_.length())
3401 Numeric* dat = const_cast<Numeric*>(overflow_.data());
3402 for (
unsigned long i = 0;
i < dataLength; ++
i)
3404 overCount_ += dataLength;
3405 fillCount_ += dataLength;
3409 template <
typename Numeric,
class Axis>
3410 template <
typename Num2>
3412 if (dataLength != data_.length())
3415 Numeric* dat = const_cast<Numeric*>(data_.data());
3416 for (
unsigned long i = 0;
i < dataLength; ++
i)
3421 template <
typename Numeric,
class Axis>
3422 template <
typename Num2>
3424 if (dataLength != overflow_.length())
3427 Numeric* dat = const_cast<Numeric*>(overflow_.data());
3428 for (
unsigned long i = 0;
i < dataLength; ++
i)
3433 template <
typename Numeric,
class Axis>
3434 template <
typename Num2>
3436 const unsigned long dataLength,
3437 const bool clearOverflowsNow) {
3438 data_.setData(
data, dataLength);
3439 if (clearOverflowsNow)
3444 template <
typename Numeric,
class Axis>
3445 template <
typename Num2>
3447 overflow_.setData(
data, dataLength);
3451 template <
typename Numeric,
class Axis>
3453 const long double nOver = overflow_.template sum<long double>();
3454 const long double nData = data_.template sum<long double>();
3455 overCount_ = static_cast<unsigned long>(nOver);
3456 fillCount_ = static_cast<unsigned long>(nData + nOver);
3460 template <
typename Numeric,
class Axis>
3461 template <
typename Num2,
typename Num3>
3464 const unsigned* projectedIndices,
3465 const unsigned nProjectedIndices)
const {
3467 data_.addToProjection(&projection->data_, projector, projectedIndices, nProjectedIndices);
3468 projection->fillCount_ += projection->nBins();
3469 projection->modCount_++;
3472 template <
typename Numeric,
class Axis>
3473 template <
typename Num2,
typename Num3>
3476 const unsigned* projectedIndices,
3477 const unsigned nProjectedIndices)
const {
3479 data_.addToProjection(&projection->data_, projector, projectedIndices, nProjectedIndices);
3480 projection->fillCount_ += projection->nBins();
3481 projection->modCount_++;
3484 template <
typename Numeric,
class Axis>
3486 static const std::string myClass(gs::template_class_name<Numeric, Axis>(
"npstat::HistoND"));
3487 return myClass.c_str();
3490 template <
typename Numeric,
class Axis>
3492 gs::write_pod(of, title_);
3493 gs::write_pod(of, accumulatedDataLabel_);
3494 gs::write_pod(of, fillCount_);
3495 gs::write_pod(of, overCount_);
3497 return !of.fail() && gs::write_obj_vector(of, axes_) && data_.classId().write(of) && data_.write(of) &&
3498 overflow_.write(of);
3501 template <
typename Numeric,
class Axis>
3504 current.ensureSameId(
id);
3510 gs::read_pod(
in, &accumulatedDataLabel);
3512 unsigned long fillCount = 0, overCount = 0;
3513 gs::read_pod(
in, &fillCount);
3514 gs::read_pod(
in, &overCount);
3516 throw gs::IOReadFailure(
"In npstat::HistoND::read: input stream failure");
3518 std::vector<Axis> axes;
3519 gs::read_heap_obj_vector_as_placed(
in, &axes);
3520 gs::ClassId ida(
in, 1);
3524 CPP11_auto_ptr<HistoND<Numeric, Axis> >
result(
3527 result->overflow_ = over;
3528 result->fillCount_ = fillCount;
3529 result->overCount_ = overCount;
3533 template <
typename Histo>
3536 if (!knownNonNegative)
3538 const double integ =
h->integral();
3542 template <
typename Histo>
3544 std::vector<LinearMapper1d>
result;
3545 const unsigned d =
histo.dim();
3547 for (
unsigned i = 0;
i <
d; ++
i) {
3549 result.push_back(
m.inverse());
3554 template <
typename Histo>
3556 std::vector<CircularMapper1d>
result;
3557 const unsigned d =
histo.dim();
3559 for (
unsigned i = 0;
i <
d; ++
i)
3560 result.push_back(
histo.axis(
i).kernelScanMapper(doubleRange));
3565 #endif // NPSTAT_HISTOND_HH_