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);
185 inline const std::vector<Axis>&
axes()
const {
return axes_; }
188 inline const Axis&
axis(
const unsigned i)
const {
return axes_.at(
i); }
210 title_ = newtitle ? newtitle :
"";
221 inline void setAxisLabel(
const unsigned axisNum,
const char* newlabel) {
222 axes_.at(axisNum).setLabel(newlabel);
246 template <
class Po
int>
292 template <
typename Num2>
293 void fill(
const double* coords,
unsigned coordLength,
const Num2&
weight);
300 template <
typename Num2>
303 template <
typename Num2>
306 template <
typename Num2>
309 template <
typename Num2>
312 template <
typename Num2>
313 void fill(
double x0,
double x1,
double x2,
double x3,
const Num2&
weight);
315 template <
typename Num2>
316 void fill(
double x0,
double x1,
double x2,
double x3,
double x4,
const Num2&
weight);
318 template <
typename Num2>
319 void fill(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
const Num2&
weight);
321 template <
typename Num2>
322 void fill(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
const Num2&
weight);
324 template <
typename Num2>
326 double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
double x7,
const Num2&
weight);
328 template <
typename Num2>
340 template <
typename Num2>
367 template <
typename Num2,
class Functor>
368 void dispatch(
const double* coords,
unsigned coordLength, Num2&
weight, Functor&
f);
375 template <
typename Num2,
class Functor>
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>
391 void dispatch(
double x0,
double x1,
double x2,
double x3,
double x4, Num2&
weight, Functor&
f);
393 template <
typename Num2,
class Functor>
394 void dispatch(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5, 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,
double x6, Num2&
weight, Functor&
f);
399 template <
typename Num2,
class Functor>
411 template <
typename Num2,
class Functor>
424 template <
typename Num2,
class Functor>
445 const Numeric&
examine(
const double* coords,
unsigned coordLength)
const;
452 const Numeric&
examine()
const;
454 const Numeric&
examine(
double x0)
const;
456 const Numeric&
examine(
double x0,
double x1)
const;
458 const Numeric&
examine(
double x0,
double x1,
double x2)
const;
460 const Numeric&
examine(
double x0,
double x1,
double x2,
double x3)
const;
462 const Numeric&
examine(
double x0,
double x1,
double x2,
double x3,
double x4)
const;
464 const Numeric&
examine(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5)
const;
466 const Numeric&
examine(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6)
const;
468 const Numeric&
examine(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
double x7)
const;
471 double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
double x7,
double x8)
const;
474 double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
double x7,
double x8,
double x9)
484 const Numeric&
closestBin(
const double* coords,
unsigned coordLength)
const;
499 const Numeric&
closestBin(
double x0,
double x1,
double x2,
double x3)
const;
501 const Numeric&
closestBin(
double x0,
double x1,
double x2,
double x3,
double x4)
const;
503 const Numeric&
closestBin(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5)
const;
505 const Numeric&
closestBin(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6)
const;
508 double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
double x7)
const;
511 double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
double x7,
double x8)
const;
514 double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
double x7,
double x8,
double x9)
540 template <
typename Num2>
541 void fillC(
const double* coords,
unsigned coordLength,
const Num2&
weight);
548 template <
typename Num2>
551 template <
typename Num2>
554 template <
typename Num2>
557 template <
typename Num2>
560 template <
typename Num2>
561 void fillC(
double x0,
double x1,
double x2,
double x3,
const Num2&
weight);
563 template <
typename Num2>
564 void fillC(
double x0,
double x1,
double x2,
double x3,
double x4,
const Num2&
weight);
566 template <
typename Num2>
567 void fillC(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
const Num2&
weight);
569 template <
typename Num2>
570 void fillC(
double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
const Num2&
weight);
572 template <
typename Num2>
574 double x0,
double x1,
double x2,
double x3,
double x4,
double x5,
double x6,
double x7,
const Num2&
weight);
576 template <
typename Num2>
577 void fillC(
double x0,
588 template <
typename Num2>
589 void fillC(
double x0,
606 template <
typename Num2>
618 template <
typename Num2>
623 template <
typename Num2>
624 void setBin(
const unsigned*
index,
unsigned indexLen,
const Num2&
v);
626 template <
typename Num2>
629 template <
typename Num2>
630 void setBin(
unsigned i0,
const Num2&
v);
632 template <
typename Num2>
633 void setBin(
unsigned i0,
unsigned i1,
const Num2&
v);
635 template <
typename Num2>
636 void setBin(
unsigned i0,
unsigned i1,
unsigned i2,
const Num2&
v);
638 template <
typename Num2>
639 void setBin(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
const Num2&
v);
641 template <
typename Num2>
642 void setBin(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
unsigned i4,
const Num2&
v);
644 template <
typename Num2>
645 void setBin(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
unsigned i4,
unsigned i5,
const Num2&
v);
647 template <
typename Num2>
649 unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
unsigned i4,
unsigned i5,
unsigned i6,
const Num2&
v);
651 template <
typename Num2>
662 template <
typename Num2>
674 template <
typename Num2>
687 template <
typename Num2>
696 template <
typename Num2>
697 void setBinAt(
const unsigned*
index,
unsigned indexLen,
const Num2&
v);
699 template <
typename Num2>
702 template <
typename Num2>
703 void setBinAt(
unsigned i0,
const Num2&
v);
705 template <
typename Num2>
706 void setBinAt(
unsigned i0,
unsigned i1,
const Num2&
v);
708 template <
typename Num2>
709 void setBinAt(
unsigned i0,
unsigned i1,
unsigned i2,
const Num2&
v);
711 template <
typename Num2>
712 void setBinAt(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
const Num2&
v);
714 template <
typename Num2>
715 void setBinAt(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
unsigned i4,
const Num2&
v);
717 template <
typename Num2>
718 void setBinAt(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
unsigned i4,
unsigned i5,
const Num2&
v);
720 template <
typename Num2>
722 unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
unsigned i4,
unsigned i5,
unsigned i6,
const Num2&
v);
724 template <
typename Num2>
735 template <
typename Num2>
747 template <
typename Num2>
760 template <
typename Num2>
768 template <
typename Num2>
772 template <
typename Num2>
779 template <
typename Num2>
789 template <
typename Num2>
819 template <
typename Num2>
823 template <
typename Num2>
828 template <
typename Num2>
831 template <
typename Num2>
840 template <
typename Num2>
843 template <
typename Num2>
853 template <
typename Num2>
856 template <
typename Num2>
868 template <
typename Acc>
882 template <
typename Num2,
typename Num3>
885 const unsigned* projectedIndices,
886 unsigned nProjectedIndices)
const;
888 template <
typename Num2,
typename Num3>
891 const unsigned* projectedIndices,
892 unsigned nProjectedIndices)
const;
921 inline gs::ClassId
classId()
const {
return gs::ClassId(*
this); }
922 bool write(std::ostream& of)
const;
926 static inline unsigned version() {
return 1; }
927 static HistoND*
read(
const gs::ClassId&
id, std::istream&
in);
936 template <
typename Num2>
939 template <
typename Acc>
944 double overlapFraction,
945 long double* wsum)
const;
973 template <
typename Histo>
981 template <
typename Histo>
994 template <
typename Histo>
1002 #include <algorithm>
1004 #include "Alignment/Geners/interface/CPP11_auto_ptr.hh"
1005 #include "Alignment/Geners/interface/binaryIO.hh"
1009 template <
class Axis>
1011 const unsigned n = axes.size();
1014 for (
unsigned i = 0;
i <
n; ++
i)
1015 result.push_back(axes[
i].nBins());
1019 template <
class Axis>
1027 template <
class Axis>
1036 template <
class Axis>
1046 template <
class Axis>
1053 result.push_back(tAxis.nBins());
1057 template <
class Axis>
1059 const Axis&
xAxis,
const Axis&
yAxis,
const Axis&
zAxis,
const Axis& tAxis,
const Axis& vAxis) {
1065 result.push_back(tAxis.nBins());
1066 result.push_back(vAxis.nBins());
1070 template <
class Axis>
1071 std::vector<Axis>
rebinAxes(
const std::vector<Axis>& axes,
const unsigned* newBins,
const unsigned lenNewBins) {
1072 const unsigned dim = axes.size();
1073 if (lenNewBins != dim)
1075 "In npstat::Private::rebinAxes: invalid length "
1076 "of the new bins array");
1078 std::vector<Axis> newAxes;
1079 newAxes.reserve(dim);
1080 for (
unsigned i = 0;
i < dim; ++
i)
1081 newAxes.push_back(axes[
i].rebin(newBins[
i]));
1085 template <
class Axis>
1087 const unsigned* fixedIndices,
1088 const unsigned nFixedIndices) {
1089 const unsigned dim = axes.size();
1090 std::vector<Axis> newAxes;
1091 if (nFixedIndices == 0
U)
1093 "In npstat::Private::axesOfASlice: "
1094 "at least one fixed index must be specified");
1095 if (nFixedIndices > dim)
1098 for (
unsigned i = 0;
i < nFixedIndices; ++
i)
1099 if (fixedIndices[
i] >= dim)
1101 newAxes.reserve(dim - nFixedIndices);
1102 for (
unsigned i = 0;
i < dim; ++
i) {
1104 for (
unsigned j = 0;
j < nFixedIndices; ++
j)
1105 if (fixedIndices[
j] ==
i) {
1110 newAxes.push_back(axes[
i]);
1112 if (newAxes.size() != dim - nFixedIndices)
1117 template <
class Axis>
1119 const unsigned* fixedIndices,
1120 const unsigned nFixedIndices) {
1121 const unsigned dim = axes.size();
1122 if (nFixedIndices == 0
U)
1124 "In npstat::Private::shapeOfASlice: "
1125 "at least one fixed index must be specified");
1126 if (nFixedIndices > dim)
1131 for (
unsigned j = 0;
j < nFixedIndices; ++
j)
1132 if (fixedIndices[
j] >= dim)
1137 if (nFixedIndices < dim)
1138 sh.reserve(dim - nFixedIndices);
1139 for (
unsigned i = 0;
i < dim; ++
i) {
1141 for (
unsigned j = 0;
j < nFixedIndices; ++
j)
1142 if (fixedIndices[
j] ==
i) {
1147 sh.push_back(axes[
i].
nBins());
1149 if (sh.size() != dim - nFixedIndices)
1154 template <
class Axis>
1155 std::vector<Axis>
addAxis(
const std::vector<Axis>& axes,
const Axis& newAxis,
const unsigned newAxisNumber) {
1156 const unsigned dim = axes.size();
1157 std::vector<Axis> newAxes;
1158 newAxes.reserve(dim + 1
U);
1160 for (
unsigned i = 0;
i < dim; ++
i) {
1161 if (newAxisNumber ==
i)
1162 newAxes.push_back(newAxis);
1164 newAxes.push_back(axes[iadd++]);
1167 newAxes.push_back(newAxis);
1169 newAxes.push_back(axes[iadd]);
1173 template <
class Axis>
1175 const unsigned dim = axes.size();
1179 for (
unsigned i = 0;
i < dim; ++
i) {
1180 if (newAxisNumber ==
i)
1181 result.push_back(newAxis.nBins());
1186 result.push_back(newAxis.nBins());
1193 std::ostringstream os;
1194 os <<
"In npstat::HistoND::" <<
method <<
": number of arguments"
1195 <<
" is incompatible with histogram dimensionality";
1200 template <
typename Numeric,
class Axis>
1201 template <
typename Acc>
1206 const double overlapFraction,
1207 long double* wsum)
const {
1209 const Axis& axis(axes_[
level]);
1210 const unsigned nbins = axis.nBins();
1211 const bool lastLevel =
level == dim_ - 1
U;
1212 for (
unsigned i = 0;
i <
nbins; ++
i) {
1213 const double over = overlapFraction * axis.binInterval(
i).overlapFraction(boxSide);
1225 template <
typename Numeric,
class Axis>
1226 template <
typename Acc>
1229 const bool calculateAverage)
const {
1230 if (box.size() != dim_)
1232 "In npstat::HistoND::accumulateBinsInBox: "
1233 "incompatible box dimensionality");
1236 long double wsum = 0.0L;
1237 for (
unsigned i = 0;
i < dim_; ++
i)
1239 accumulateBinsLoop(0
U, box, &indexBuf_[0],
accumulator, 1.0, &wsum);
1240 if (calculateAverage && wsum > 0.0
L)
1246 template <
typename Numeric,
class Axis>
1253 template <
typename Numeric,
class Axis>
1260 template <
typename Numeric,
class Axis>
1267 template <
typename Numeric,
class Axis>
1274 weightBuf_(axesIn.
size()),
1275 indexBuf_(2
U * axesIn.
size()),
1277 dim_(axesIn.
size()) {
1278 if (
dim_ >= CHAR_BIT *
sizeof(
unsigned long))
1280 "In npstat::HistoND constructor: requested histogram "
1281 "dimensionality is not supported (too large)");
1285 template <
typename Numeric,
class Axis>
1300 template <
typename Numeric,
class Axis>
1316 template <
typename Numeric,
class Axis>
1334 template <
typename Numeric,
class Axis>
1349 axes_.push_back(tAxis);
1353 template <
typename Numeric,
class Axis>
1373 axes_.push_back(tAxis);
1374 axes_.push_back(vAxis);
1378 template <
typename Numeric,
class Axis>
1387 weightBuf_(shape.
size()),
1388 indexBuf_(2
U * shape.
size()),
1390 dim_(shape.
size()) {
1393 "In npstat::HistoND constructor: "
1394 "incompatible bounding box dimensionality");
1395 if (
dim_ >= CHAR_BIT *
sizeof(
unsigned long))
1397 "In npstat::HistoND constructor: requested histogram "
1398 "dimensionality is not supported (too large)");
1400 for (
unsigned i = 0;
i <
dim_; ++
i)
1405 template <
typename Numeric,
class Axis>
1406 template <
typename Num2,
class Functor>
1411 overflow_(
r.overflow_,
f),
1414 indexBuf_(2
U *
r.dim_),
1415 fillCount_(
r.fillCount_),
1416 overCount_(
r.overCount_),
1420 template <
typename Numeric,
class Axis>
1421 template <
typename Num2>
1424 const unsigned nIndices,
1427 accumulatedDataLabel_(
h.accumulatedDataLabel_),
1431 weightBuf_(data_.rank()),
1432 indexBuf_(2
U * data_.rank()),
1434 dim_(data_.rank()) {
1438 template <
typename Numeric,
class Axis>
1439 template <
typename Num2>
1441 const Axis& newAxis,
1442 const unsigned newAxisNumber,
1445 accumulatedDataLabel_(
h.accumulatedDataLabel_),
1447 overflow_(data_.rank(), 3
U),
1448 axes_(Private::
addAxis(
h.axes_, newAxis, newAxisNumber)),
1449 weightBuf_(data_.rank()),
1450 indexBuf_(2
U * data_.rank()),
1452 dim_(data_.rank()) {
1453 if (
dim_ >= CHAR_BIT *
sizeof(
unsigned long))
1455 "In npstat::HistoND constructor: requested histogram "
1456 "dimensionality is not supported (too large)");
1460 template <
typename Numeric,
class Axis>
1461 template <
typename Num2>
1464 const unsigned* newBinCounts,
1465 const unsigned lenNewBinCounts,
1466 const double* shifts,
1469 accumulatedDataLabel_(
h.accumulatedDataLabel_),
1470 data_(newBinCounts, lenNewBinCounts),
1471 overflow_(
h.overflow_),
1472 axes_(Private::
rebinAxes(
h.axes_, newBinCounts, lenNewBinCounts)),
1474 indexBuf_(2
U *
h.dim_),
1475 fillCount_(
h.fillCount_),
1476 overCount_(
h.overCount_),
1480 const Axis* ax = &
axes_[0];
1486 for (
unsigned long ibin = 0; ibin < newBins; ++ibin) {
1489 for (
unsigned i = 0;
i <
dim_; ++
i)
1492 for (
unsigned i = 0;
i <
dim_; ++
i)
1497 const Numeric
zero = Numeric();
1499 for (
unsigned long ibin = 0; ibin < newBins; ++ibin) {
1501 for (
unsigned i = 0;
i <
dim_; ++
i)
1502 binLimits[
i] = ax[
i].binInterval(ubuf[
i]);
1505 h.accumulateBinsInBox(binLimits, &thisBin, rType ==
AVERAGE);
1510 template <
typename Numeric,
class Axis>
1512 for (
unsigned i = 0;
i < dim_; ++
i)
1513 if (!axes_[
i].isUniform())
1518 template <
typename Numeric,
class Axis>
1524 if (isUniformlyBinned()) {
1525 Precise sum = data_.template sum<Precise>();
1526 return static_cast<double>(sum) * binVolume();
1528 Precise sum = Precise();
1529 const Numeric*
data = data_.data();
1530 const unsigned long len = data_.length();
1531 for (
unsigned long i = 0;
i < len; ++
i)
1532 sum +=
data[
i] * binVolume(
i);
1533 return static_cast<double>(sum);
1537 template <
typename Numeric,
class Axis>
1542 const Axis* ax = &axes_[0];
1543 for (
unsigned i = 0;
i < dim_; ++
i)
1544 box.push_back(ax[
i].interval());
1549 template <
typename Numeric,
class Axis>
1552 const unsigned lenCoords)
const {
1553 if (dim_ != lenCoords)
1555 "In npstat::HistoND::binCenter: "
1556 "incompatible input point dimensionality");
1559 data_.convertLinearIndex(
binNumber, &indexBuf_[0], dim_);
1560 const Axis* ax = &axes_[0];
1561 for (
unsigned i = 0;
i < dim_; ++
i)
1562 coords[
i] = ax[
i].binCenter(indexBuf_[
i]);
1566 template <
typename Numeric,
class Axis>
1567 template <
class Po
int>
1571 const unsigned long len = data_.length();
1572 centers->reserve(len);
1573 unsigned* ibuf = &indexBuf_[0];
1574 const Axis* ax = &axes_[0];
1576 if (center.size() < dim_)
1578 "In npstat::HistoND::allBinCenters: "
1579 "incompatible point dimensionality (too small)");
1582 for (
unsigned long i = 0;
i < len; ++
i) {
1583 data_.convertLinearIndex(
i, ibuf, dim_);
1584 for (
unsigned idim = 0; idim < dim_; ++idim)
1585 cdat[idim] = ax[idim].binCenter(ibuf[idim]);
1586 centers->push_back(center);
1590 template <
typename Numeric,
class Axis>
1596 data_.convertLinearIndex(
binNumber, &indexBuf_[0], dim_);
1597 const Axis* ax = &axes_[0];
1598 for (
unsigned i = 0;
i < dim_; ++
i)
1599 box->push_back(ax[
i].binInterval(indexBuf_[
i]));
1603 template <
typename Numeric,
class Axis>
1605 return dim_ ==
r.dim_ && overflow_ ==
r.overflow_ && data_ ==
r.data_;
1608 template <
typename Numeric,
class Axis>
1610 return dim_ ==
r.dim_ && fillCount_ ==
r.fillCount_ && overCount_ ==
r.overCount_ && title_ ==
r.title_ &&
1611 accumulatedDataLabel_ ==
r.accumulatedDataLabel_ && axes_ ==
r.axes_ && overflow_ ==
r.overflow_ &&
1615 template <
typename Numeric,
class Axis>
1617 return !(*
this ==
r);
1620 template <
typename Numeric,
class Axis>
1624 data_.convertLinearIndex(
binNumber, &indexBuf_[0], dim_);
1625 const Axis* ax = &axes_[0];
1626 for (
unsigned i = 0;
i < dim_; ++
i)
1627 v *= ax[
i].binWidth(indexBuf_[
i]);
1632 template <
typename Numeric,
class Axis>
1636 const Axis* ax = &axes_[0];
1637 for (
unsigned i = 0;
i < dim_; ++
i)
1643 template <
typename Numeric,
class Axis>
1644 template <
typename Num2>
1646 if (coordLength != dim_)
1648 "In npstat::HistoND::fill: "
1649 "incompatible input point dimensionality");
1652 unsigned*
idx = &indexBuf_[0];
1653 unsigned* over =
idx + dim_;
1654 const Axis* ax = &axes_[0];
1655 unsigned overflown = 0
U;
1656 for (
unsigned i = 0;
i < dim_; ++
i) {
1657 over[
i] = ax[
i].overflowIndex(coords[
i],
idx +
i);
1658 overflown |= (over[
i] - 1
U);
1661 overflow_.value(over, dim_) +=
w;
1664 data_.value(
idx, dim_) +=
w;
1671 template <
typename Numeric,
class Axis>
1672 template <
typename Num2,
class Functor>
1674 if (coordLength != dim_)
1676 "In npstat::HistoND::dispatch: "
1677 "incompatible input point dimensionality");
1680 unsigned*
idx = &indexBuf_[0];
1681 unsigned* over =
idx + dim_;
1682 const Axis* ax = &axes_[0];
1683 unsigned overflown = 0
U;
1684 for (
unsigned i = 0;
i < dim_; ++
i) {
1685 over[
i] = ax[
i].overflowIndex(coords[
i],
idx +
i);
1686 overflown |= (over[
i] - 1
U);
1689 f(overflow_.value(over, dim_),
w);
1691 f(data_.value(
idx, dim_),
w);
1697 template <
typename Numeric,
class Axis>
1699 if (coordLength != dim_)
1701 "In npstat::HistoND::examine: "
1702 "incompatible input point dimensionality");
1705 unsigned*
idx = &indexBuf_[0];
1706 unsigned* over =
idx + dim_;
1707 const Axis* ax = &axes_[0];
1708 unsigned overflown = 0
U;
1709 for (
unsigned i = 0;
i < dim_; ++
i) {
1710 over[
i] = ax[
i].overflowIndex(coords[
i],
idx +
i);
1711 overflown |= (over[
i] - 1
U);
1714 return overflow_.value(over, dim_);
1716 return data_.value(
idx, dim_);
1721 template <
typename Numeric,
class Axis>
1723 if (coordLength != dim_)
1725 "In npstat::HistoND::closestBin: "
1726 "incompatible input point dimensionality");
1729 unsigned*
idx = &indexBuf_[0];
1730 const Axis* ax = &axes_[0];
1731 for (
unsigned i = 0;
i < dim_; ++
i)
1732 idx[
i] = ax[
i].closestValidBin(coords[
i]);
1733 return data_.value(
idx, dim_);
1738 template <
typename Numeric,
class Axis>
1739 template <
typename Num2>
1741 const double*
weights = &weightBuf_[0];
1742 const unsigned* cell = &indexBuf_[0];
1743 const unsigned long* strides = data_.strides();
1744 const unsigned long maxcycle = 1UL << dim_;
1745 for (
unsigned long icycle = 0; icycle < maxcycle; ++icycle) {
1747 unsigned long icell = 0UL;
1748 for (
unsigned i = 0;
i < dim_; ++
i) {
1749 if (icycle & (1UL <<
i)) {
1751 icell += strides[
i] * (cell[
i] + 1
U);
1754 icell += strides[
i] * cell[
i];
1757 data_.linearValue(icell) += (
value *
w);
1761 template <
typename Numeric,
class Axis>
1762 template <
typename Num2>
1764 if (coordLength != dim_)
1766 "In npstat::HistoND::fillC: "
1767 "incompatible input point dimensionality");
1770 double* wg = &weightBuf_[0];
1771 unsigned*
idx = &indexBuf_[0];
1772 unsigned* over =
idx + dim_;
1773 const Axis* ax = &axes_[0];
1774 unsigned overflown = 0
U;
1775 for (
unsigned i = 0;
i < dim_; ++
i) {
1776 over[
i] = ax[
i].overflowIndexWeighted(coords[
i],
idx +
i, wg +
i);
1777 overflown |= (over[
i] - 1
U);
1780 overflow_.value(over, dim_) +=
w;
1783 fillPreservingCentroid(
w);
1790 template <
typename Numeric,
class Axis>
1791 template <
typename Num2>
1800 template <
typename Numeric,
class Axis>
1801 template <
typename Num2,
class Functor>
1809 template <
typename Numeric,
class Axis>
1810 template <
typename Num2>
1819 template <
typename Numeric,
class Axis>
1826 template <
typename Numeric,
class Axis>
1833 template <
typename Numeric,
class Axis>
1834 template <
typename Num2>
1839 const unsigned ov0 = axes_[0].overflowIndex(x0, &i0);
1843 overflow_(ov0) +=
w;
1850 template <
typename Numeric,
class Axis>
1851 template <
typename Num2,
class Functor>
1856 const unsigned ov0 = axes_[0].overflowIndex(x0, &i0);
1860 f(overflow_(ov0),
w);
1864 template <
typename Numeric,
class Axis>
1865 template <
typename Num2>
1869 double* wg = &weightBuf_[0];
1870 unsigned*
idx = &indexBuf_[0];
1871 const unsigned ov0 = axes_[0].overflowIndexWeighted(x0,
idx, wg);
1873 fillPreservingCentroid(
w);
1875 overflow_(ov0) +=
w;
1882 template <
typename Numeric,
class Axis>
1887 const unsigned ov0 = axes_[0].overflowIndex(x0, &i0);
1891 return overflow_(ov0);
1894 template <
typename Numeric,
class Axis>
1898 const unsigned i0 = axes_[0].closestValidBin(x0);
1902 template <
typename Numeric,
class Axis>
1903 template <
typename Num2>
1907 unsigned i0 = 0,
i1 = 0;
1908 const Axis* ax = &axes_[0];
1909 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1910 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
1911 if (o0 == 1
U &&
o1 == 1
U)
1914 overflow_(o0,
o1) +=
w;
1921 template <
typename Numeric,
class Axis>
1922 template <
typename Num2,
class Functor>
1926 unsigned i0 = 0,
i1 = 0;
1927 const Axis* ax = &axes_[0];
1928 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1929 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
1930 if (o0 == 1
U &&
o1 == 1
U)
1931 f(data_(i0,
i1),
w);
1933 f(overflow_(o0,
o1),
w);
1937 template <
typename Numeric,
class Axis>
1938 template <
typename Num2>
1942 double* wg = &weightBuf_[0];
1943 unsigned*
idx = &indexBuf_[0];
1944 const Axis* ax = &axes_[0];
1945 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
1946 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
1947 if (o0 == 1
U &&
o1 == 1
U)
1948 fillPreservingCentroid(
w);
1950 overflow_(o0,
o1) +=
w;
1957 template <
typename Numeric,
class Axis>
1961 unsigned i0 = 0,
i1 = 0;
1962 const Axis* ax = &axes_[0];
1963 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1964 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
1965 if (o0 == 1
U &&
o1 == 1
U)
1966 return data_(i0,
i1);
1968 return overflow_(o0,
o1);
1971 template <
typename Numeric,
class Axis>
1975 const Axis* ax = &axes_[0];
1976 const unsigned i0 = ax[0].closestValidBin(x0);
1977 const unsigned i1 = ax[1].closestValidBin(
x1);
1978 return data_(i0,
i1);
1981 template <
typename Numeric,
class Axis>
1982 template <
typename Num2>
1986 unsigned i0 = 0,
i1 = 0,
i2 = 0;
1987 const Axis* ax = &axes_[0];
1988 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1989 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
1990 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
1991 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U)
1992 data_(i0,
i1,
i2) +=
w;
1994 overflow_(o0,
o1, o2) +=
w;
2001 template <
typename Numeric,
class Axis>
2002 template <
typename Num2,
class Functor>
2006 unsigned i0 = 0,
i1 = 0,
i2 = 0;
2007 const Axis* ax = &axes_[0];
2008 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2009 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2010 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2011 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U)
2014 f(overflow_(o0,
o1, o2),
w);
2018 template <
typename Numeric,
class Axis>
2019 template <
typename Num2>
2023 double* wg = &weightBuf_[0];
2024 unsigned*
idx = &indexBuf_[0];
2025 const Axis* ax = &axes_[0];
2026 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
2027 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
2028 const unsigned o2 = ax[2].overflowIndexWeighted(
x2,
idx + 2, wg + 2);
2029 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U)
2030 fillPreservingCentroid(
w);
2032 overflow_(o0,
o1, o2) +=
w;
2039 template <
typename Numeric,
class Axis>
2043 unsigned i0 = 0,
i1 = 0,
i2 = 0;
2044 const Axis* ax = &axes_[0];
2045 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2046 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2047 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2048 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U)
2049 return data_(i0,
i1,
i2);
2051 return overflow_(o0,
o1, o2);
2054 template <
typename Numeric,
class Axis>
2058 const Axis* ax = &axes_[0];
2059 const unsigned i0 = ax[0].closestValidBin(x0);
2060 const unsigned i1 = ax[1].closestValidBin(
x1);
2061 const unsigned i2 = ax[2].closestValidBin(
x2);
2062 return data_(i0,
i1,
i2);
2065 template <
typename Numeric,
class Axis>
2066 template <
typename Num2>
2070 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0;
2071 const Axis* ax = &axes_[0];
2072 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2073 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2074 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2075 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2076 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U)
2079 overflow_(o0,
o1, o2, o3) +=
w;
2086 template <
typename Numeric,
class Axis>
2087 template <
typename Num2,
class Functor>
2089 const double x0,
const double x1,
const double x2,
const double x3, Num2&
w, Functor&
f) {
2092 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0;
2093 const Axis* ax = &axes_[0];
2094 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2095 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2096 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2097 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2098 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U)
2101 f(overflow_(o0,
o1, o2, o3),
w);
2105 template <
typename Numeric,
class Axis>
2106 template <
typename Num2>
2110 double* wg = &weightBuf_[0];
2111 unsigned*
idx = &indexBuf_[0];
2112 const Axis* ax = &axes_[0];
2113 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
2114 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
2115 const unsigned o2 = ax[2].overflowIndexWeighted(
x2,
idx + 2, wg + 2);
2116 const unsigned o3 = ax[3].overflowIndexWeighted(x3,
idx + 3, wg + 3);
2117 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U)
2118 fillPreservingCentroid(
w);
2120 overflow_(o0,
o1, o2, o3) +=
w;
2127 template <
typename Numeric,
class Axis>
2131 const double x3)
const {
2134 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0;
2135 const Axis* ax = &axes_[0];
2136 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2137 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2138 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2139 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2140 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U)
2141 return data_(i0,
i1,
i2,
i3);
2143 return overflow_(o0,
o1, o2, o3);
2146 template <
typename Numeric,
class Axis>
2150 const double x3)
const {
2153 const Axis* ax = &axes_[0];
2154 const unsigned i0 = ax[0].closestValidBin(x0);
2155 const unsigned i1 = ax[1].closestValidBin(
x1);
2156 const unsigned i2 = ax[2].closestValidBin(
x2);
2157 const unsigned i3 = ax[3].closestValidBin(x3);
2158 return data_(i0,
i1,
i2,
i3);
2161 template <
typename Numeric,
class Axis>
2162 template <
typename Num2>
2164 const double x0,
const double x1,
const double x2,
const double x3,
const double x4,
const Num2&
w) {
2167 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0;
2168 const Axis* ax = &axes_[0];
2169 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2170 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2171 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2172 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2173 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2174 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U)
2175 data_(i0,
i1,
i2,
i3, i4) +=
w;
2177 overflow_(o0,
o1, o2, o3, o4) +=
w;
2184 template <
typename Numeric,
class Axis>
2185 template <
typename Num2,
class Functor>
2187 const double x0,
const double x1,
const double x2,
const double x3,
const double x4, Num2&
w, Functor&
f) {
2190 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0;
2191 const Axis* ax = &axes_[0];
2192 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2193 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2194 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2195 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2196 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2197 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U)
2200 f(overflow_(o0,
o1, o2, o3, o4),
w);
2204 template <
typename Numeric,
class Axis>
2205 template <
typename Num2>
2207 const double x0,
const double x1,
const double x2,
const double x3,
const double x4,
const Num2&
w) {
2210 double* wg = &weightBuf_[0];
2211 unsigned*
idx = &indexBuf_[0];
2212 const Axis* ax = &axes_[0];
2213 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
2214 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
2215 const unsigned o2 = ax[2].overflowIndexWeighted(
x2,
idx + 2, wg + 2);
2216 const unsigned o3 = ax[3].overflowIndexWeighted(x3,
idx + 3, wg + 3);
2217 const unsigned o4 = ax[4].overflowIndexWeighted(x4,
idx + 4, wg + 4);
2218 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U)
2219 fillPreservingCentroid(
w);
2221 overflow_(o0,
o1, o2, o3, o4) +=
w;
2228 template <
typename Numeric,
class Axis>
2230 const double x0,
const double x1,
const double x2,
const double x3,
const double x4)
const {
2233 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0;
2234 const Axis* ax = &axes_[0];
2235 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2236 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2237 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2238 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2239 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2240 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U)
2241 return data_(i0,
i1,
i2,
i3, i4);
2243 return overflow_(o0,
o1, o2, o3, o4);
2246 template <
typename Numeric,
class Axis>
2248 const double x0,
const double x1,
const double x2,
const double x3,
const double x4)
const {
2251 const Axis* ax = &axes_[0];
2252 const unsigned i0 = ax[0].closestValidBin(x0);
2253 const unsigned i1 = ax[1].closestValidBin(
x1);
2254 const unsigned i2 = ax[2].closestValidBin(
x2);
2255 const unsigned i3 = ax[3].closestValidBin(x3);
2256 const unsigned i4 = ax[4].closestValidBin(x4);
2257 return data_(i0,
i1,
i2,
i3, i4);
2260 template <
typename Numeric,
class Axis>
2261 template <
typename Num2>
2271 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0;
2272 const Axis* ax = &axes_[0];
2273 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2274 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2275 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2276 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2277 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2278 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2279 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U)
2280 data_(i0,
i1,
i2,
i3, i4, i5) +=
w;
2282 overflow_(o0,
o1, o2, o3, o4, o5) +=
w;
2289 template <
typename Numeric,
class Axis>
2290 template <
typename Num2,
class Functor>
2301 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0;
2302 const Axis* ax = &axes_[0];
2303 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2304 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2305 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2306 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2307 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2308 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2309 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U)
2310 f(data_(i0,
i1,
i2,
i3, i4, i5),
w);
2312 f(overflow_(o0,
o1, o2, o3, o4, o5),
w);
2316 template <
typename Numeric,
class Axis>
2317 template <
typename Num2>
2327 double* wg = &weightBuf_[0];
2328 unsigned*
idx = &indexBuf_[0];
2329 const Axis* ax = &axes_[0];
2330 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
2331 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
2332 const unsigned o2 = ax[2].overflowIndexWeighted(
x2,
idx + 2, wg + 2);
2333 const unsigned o3 = ax[3].overflowIndexWeighted(x3,
idx + 3, wg + 3);
2334 const unsigned o4 = ax[4].overflowIndexWeighted(x4,
idx + 4, wg + 4);
2335 const unsigned o5 = ax[5].overflowIndexWeighted(x5,
idx + 5, wg + 5);
2336 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U)
2337 fillPreservingCentroid(
w);
2339 overflow_(o0,
o1, o2, o3, o4, o5) +=
w;
2346 template <
typename Numeric,
class Axis>
2348 const double x0,
const double x1,
const double x2,
const double x3,
const double x4,
const double x5)
const {
2351 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0;
2352 const Axis* ax = &axes_[0];
2353 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2354 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2355 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2356 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2357 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2358 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2359 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U)
2360 return data_(i0,
i1,
i2,
i3, i4, i5);
2362 return overflow_(o0,
o1, o2, o3, o4, o5);
2365 template <
typename Numeric,
class Axis>
2367 const double x0,
const double x1,
const double x2,
const double x3,
const double x4,
const double x5)
const {
2370 const Axis* ax = &axes_[0];
2371 const unsigned i0 = ax[0].closestValidBin(x0);
2372 const unsigned i1 = ax[1].closestValidBin(
x1);
2373 const unsigned i2 = ax[2].closestValidBin(
x2);
2374 const unsigned i3 = ax[3].closestValidBin(x3);
2375 const unsigned i4 = ax[4].closestValidBin(x4);
2376 const unsigned i5 = ax[5].closestValidBin(x5);
2377 return data_(i0,
i1,
i2,
i3, i4, i5);
2380 template <
typename Numeric,
class Axis>
2381 template <
typename Num2>
2392 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0;
2393 const Axis* ax = &axes_[0];
2394 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2395 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2396 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2397 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2398 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2399 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2400 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2401 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U)
2402 data_(i0,
i1,
i2,
i3, i4, i5, i6) +=
w;
2404 overflow_(o0,
o1, o2, o3, o4, o5, o6) +=
w;
2411 template <
typename Numeric,
class Axis>
2412 template <
typename Num2,
class Functor>
2424 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0;
2425 const Axis* ax = &axes_[0];
2426 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2427 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2428 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2429 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2430 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2431 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2432 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2433 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U)
2434 f(data_(i0,
i1,
i2,
i3, i4, i5, i6),
w);
2436 f(overflow_(o0,
o1, o2, o3, o4, o5, o6),
w);
2440 template <
typename Numeric,
class Axis>
2441 template <
typename Num2>
2452 double* wg = &weightBuf_[0];
2453 unsigned*
idx = &indexBuf_[0];
2454 const Axis* ax = &axes_[0];
2455 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
2456 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
2457 const unsigned o2 = ax[2].overflowIndexWeighted(
x2,
idx + 2, wg + 2);
2458 const unsigned o3 = ax[3].overflowIndexWeighted(x3,
idx + 3, wg + 3);
2459 const unsigned o4 = ax[4].overflowIndexWeighted(x4,
idx + 4, wg + 4);
2460 const unsigned o5 = ax[5].overflowIndexWeighted(x5,
idx + 5, wg + 5);
2461 const unsigned o6 = ax[6].overflowIndexWeighted(x6,
idx + 6, wg + 6);
2462 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U)
2463 fillPreservingCentroid(
w);
2465 overflow_(o0,
o1, o2, o3, o4, o5, o6) +=
w;
2472 template <
typename Numeric,
class Axis>
2479 const double x6)
const {
2482 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0;
2483 const Axis* ax = &axes_[0];
2484 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2485 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2486 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2487 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2488 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2489 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2490 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2491 if (o0 == 1
U &&
o1 == 1
U && o2 == 1
U && o3 == 1
U && o4 == 1
U && o5 == 1
U && o6 == 1
U)
2492 return data_(i0,
i1,
i2,
i3, i4, i5, i6);
2494 return overflow_(o0,
o1, o2, o3, o4, o5, o6);
2497 template <
typename Numeric,
class Axis>
2504 const double x6)
const {
2507 const Axis* ax = &axes_[0];
2508 const unsigned i0 = ax[0].closestValidBin(x0);
2509 const unsigned i1 = ax[1].closestValidBin(
x1);
2510 const unsigned i2 = ax[2].closestValidBin(
x2);
2511 const unsigned i3 = ax[3].closestValidBin(x3);
2512 const unsigned i4 = ax[4].closestValidBin(x4);
2513 const unsigned i5 = ax[5].closestValidBin(x5);
2514 const unsigned i6 = ax[6].closestValidBin(x6);
2515 return data_(i0,
i1,
i2,
i3, i4, i5, i6);
2518 template <
typename Numeric,
class Axis>
2519 template <
typename Num2>
2531 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
2532 const Axis* ax = &axes_[0];
2533 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2534 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2535 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2536 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2537 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2538 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2539 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2540 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2541 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)
2542 data_(i0,
i1,
i2,
i3, i4, i5, i6, i7) +=
w;
2544 overflow_(o0,
o1, o2, o3, o4, o5, o6, o7) +=
w;
2551 template <
typename Numeric,
class Axis>
2552 template <
typename Num2,
class Functor>
2565 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
2566 const Axis* ax = &axes_[0];
2567 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2568 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2569 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2570 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2571 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2572 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2573 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2574 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2575 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)
2576 f(data_(i0,
i1,
i2,
i3, i4, i5, i6, i7),
w);
2578 f(overflow_(o0,
o1, o2, o3, o4, o5, o6, o7),
w);
2582 template <
typename Numeric,
class Axis>
2583 template <
typename Num2>
2595 double* wg = &weightBuf_[0];
2596 unsigned*
idx = &indexBuf_[0];
2597 const Axis* ax = &axes_[0];
2598 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
2599 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
2600 const unsigned o2 = ax[2].overflowIndexWeighted(
x2,
idx + 2, wg + 2);
2601 const unsigned o3 = ax[3].overflowIndexWeighted(x3,
idx + 3, wg + 3);
2602 const unsigned o4 = ax[4].overflowIndexWeighted(x4,
idx + 4, wg + 4);
2603 const unsigned o5 = ax[5].overflowIndexWeighted(x5,
idx + 5, wg + 5);
2604 const unsigned o6 = ax[6].overflowIndexWeighted(x6,
idx + 6, wg + 6);
2605 const unsigned o7 = ax[7].overflowIndexWeighted(x7,
idx + 7, wg + 7);
2606 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)
2607 fillPreservingCentroid(
w);
2609 overflow_(o0,
o1, o2, o3, o4, o5, o6, o7) +=
w;
2616 template <
typename Numeric,
class Axis>
2624 const double x7)
const {
2627 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
2628 const Axis* ax = &axes_[0];
2629 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2630 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2631 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2632 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2633 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2634 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2635 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2636 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2637 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)
2638 return data_(i0,
i1,
i2,
i3, i4, i5, i6, i7);
2640 return overflow_(o0,
o1, o2, o3, o4, o5, o6, o7);
2643 template <
typename Numeric,
class Axis>
2651 const double x7)
const {
2654 const Axis* ax = &axes_[0];
2655 const unsigned i0 = ax[0].closestValidBin(x0);
2656 const unsigned i1 = ax[1].closestValidBin(
x1);
2657 const unsigned i2 = ax[2].closestValidBin(
x2);
2658 const unsigned i3 = ax[3].closestValidBin(x3);
2659 const unsigned i4 = ax[4].closestValidBin(x4);
2660 const unsigned i5 = ax[5].closestValidBin(x5);
2661 const unsigned i6 = ax[6].closestValidBin(x6);
2662 const unsigned i7 = ax[7].closestValidBin(x7);
2663 return data_(i0,
i1,
i2,
i3, i4, i5, i6, i7);
2666 template <
typename Numeric,
class Axis>
2667 template <
typename Num2>
2680 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
2681 const Axis* ax = &axes_[0];
2682 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2683 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2684 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2685 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2686 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2687 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2688 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2689 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2690 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2691 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)
2692 data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8) +=
w;
2694 overflow_(o0,
o1, o2, o3, o4, o5, o6, o7, o8) +=
w;
2701 template <
typename Numeric,
class Axis>
2702 template <
typename Num2,
class Functor>
2716 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
2717 const Axis* ax = &axes_[0];
2718 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2719 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2720 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2721 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2722 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2723 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2724 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2725 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2726 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2727 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)
2728 f(data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8),
w);
2730 f(overflow_(o0,
o1, o2, o3, o4, o5, o6, o7, o8),
w);
2734 template <
typename Numeric,
class Axis>
2735 template <
typename Num2>
2748 double* wg = &weightBuf_[0];
2749 unsigned*
idx = &indexBuf_[0];
2750 const Axis* ax = &axes_[0];
2751 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
2752 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
2753 const unsigned o2 = ax[2].overflowIndexWeighted(
x2,
idx + 2, wg + 2);
2754 const unsigned o3 = ax[3].overflowIndexWeighted(x3,
idx + 3, wg + 3);
2755 const unsigned o4 = ax[4].overflowIndexWeighted(x4,
idx + 4, wg + 4);
2756 const unsigned o5 = ax[5].overflowIndexWeighted(x5,
idx + 5, wg + 5);
2757 const unsigned o6 = ax[6].overflowIndexWeighted(x6,
idx + 6, wg + 6);
2758 const unsigned o7 = ax[7].overflowIndexWeighted(x7,
idx + 7, wg + 7);
2759 const unsigned o8 = ax[8].overflowIndexWeighted(x8,
idx + 8, wg + 8);
2760 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)
2761 fillPreservingCentroid(
w);
2763 overflow_(o0,
o1, o2, o3, o4, o5, o6, o7, o8) +=
w;
2770 template <
typename Numeric,
class Axis>
2779 const double x8)
const {
2782 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
2783 const Axis* ax = &axes_[0];
2784 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2785 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2786 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2787 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2788 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2789 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2790 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2791 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2792 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2793 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)
2794 return data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8);
2796 return overflow_(o0,
o1, o2, o3, o4, o5, o6, o7, o8);
2799 template <
typename Numeric,
class Axis>
2808 const double x8)
const {
2811 const Axis* ax = &axes_[0];
2812 const unsigned i0 = ax[0].closestValidBin(x0);
2813 const unsigned i1 = ax[1].closestValidBin(
x1);
2814 const unsigned i2 = ax[2].closestValidBin(
x2);
2815 const unsigned i3 = ax[3].closestValidBin(x3);
2816 const unsigned i4 = ax[4].closestValidBin(x4);
2817 const unsigned i5 = ax[5].closestValidBin(x5);
2818 const unsigned i6 = ax[6].closestValidBin(x6);
2819 const unsigned i7 = ax[7].closestValidBin(x7);
2820 const unsigned i8 = ax[8].closestValidBin(x8);
2821 return data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8);
2824 template <
typename Numeric,
class Axis>
2825 template <
typename Num2>
2839 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
2840 const Axis* ax = &axes_[0];
2841 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2842 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2843 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2844 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2845 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2846 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2847 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2848 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2849 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2850 const unsigned o9 = ax[9].overflowIndex(x9, &i9);
2851 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 &&
2853 data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8, i9) +=
w;
2855 overflow_(o0,
o1, o2, o3, o4, o5, o6, o7, o8, o9) +=
w;
2862 template <
typename Numeric,
class Axis>
2863 template <
typename Num2,
class Functor>
2878 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
2879 const Axis* ax = &axes_[0];
2880 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2881 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2882 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2883 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2884 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2885 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2886 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2887 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2888 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2889 const unsigned o9 = ax[9].overflowIndex(x9, &i9);
2890 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 &&
2892 f(data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8, i9),
w);
2894 f(overflow_(o0,
o1, o2, o3, o4, o5, o6, o7, o8, o9),
w);
2898 template <
typename Numeric,
class Axis>
2899 template <
typename Num2>
2913 double* wg = &weightBuf_[0];
2914 unsigned*
idx = &indexBuf_[0];
2915 const Axis* ax = &axes_[0];
2916 const unsigned o0 = ax[0].overflowIndexWeighted(x0,
idx + 0, wg + 0);
2917 const unsigned o1 = ax[1].overflowIndexWeighted(
x1,
idx + 1, wg + 1);
2918 const unsigned o2 = ax[2].overflowIndexWeighted(
x2,
idx + 2, wg + 2);
2919 const unsigned o3 = ax[3].overflowIndexWeighted(x3,
idx + 3, wg + 3);
2920 const unsigned o4 = ax[4].overflowIndexWeighted(x4,
idx + 4, wg + 4);
2921 const unsigned o5 = ax[5].overflowIndexWeighted(x5,
idx + 5, wg + 5);
2922 const unsigned o6 = ax[6].overflowIndexWeighted(x6,
idx + 6, wg + 6);
2923 const unsigned o7 = ax[7].overflowIndexWeighted(x7,
idx + 7, wg + 7);
2924 const unsigned o8 = ax[8].overflowIndexWeighted(x8,
idx + 8, wg + 8);
2925 const unsigned o9 = ax[9].overflowIndexWeighted(x9,
idx + 9, wg + 9);
2926 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 &&
2928 fillPreservingCentroid(
w);
2930 overflow_(o0,
o1, o2, o3, o4, o5, o6, o7, o8, o9) +=
w;
2937 template <
typename Numeric,
class Axis>
2947 const double x9)
const {
2950 unsigned i0 = 0,
i1 = 0,
i2 = 0,
i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
2951 const Axis* ax = &axes_[0];
2952 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2953 const unsigned o1 = ax[1].overflowIndex(
x1, &
i1);
2954 const unsigned o2 = ax[2].overflowIndex(
x2, &
i2);
2955 const unsigned o3 = ax[3].overflowIndex(x3, &
i3);
2956 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2957 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2958 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2959 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2960 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2961 const unsigned o9 = ax[9].overflowIndex(x9, &i9);
2962 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 &&
2964 return data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8, i9);
2966 return overflow_(o0,
o1, o2, o3, o4, o5, o6, o7, o8, o9);
2969 template <
typename Numeric,
class Axis>
2979 const double x9)
const {
2982 const Axis* ax = &axes_[0];
2983 const unsigned i0 = ax[0].closestValidBin(x0);
2984 const unsigned i1 = ax[1].closestValidBin(
x1);
2985 const unsigned i2 = ax[2].closestValidBin(
x2);
2986 const unsigned i3 = ax[3].closestValidBin(x3);
2987 const unsigned i4 = ax[4].closestValidBin(x4);
2988 const unsigned i5 = ax[5].closestValidBin(x5);
2989 const unsigned i6 = ax[6].closestValidBin(x6);
2990 const unsigned i7 = ax[7].closestValidBin(x7);
2991 const unsigned i8 = ax[8].closestValidBin(x8);
2992 const unsigned i9 = ax[9].closestValidBin(x9);
2993 return data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8, i9);
2996 template <
typename Numeric,
class Axis>
2997 template <
typename Num2>
2999 data_.value(
index, indexLen) =
v;
3003 template <
typename Numeric,
class Axis>
3004 template <
typename Num2>
3006 data_.valueAt(
index, indexLen) =
v;
3010 template <
typename Numeric,
class Axis>
3011 template <
typename Num2>
3017 template <
typename Numeric,
class Axis>
3018 template <
typename Num2>
3024 template <
typename Numeric,
class Axis>
3025 template <
typename Num2>
3031 template <
typename Numeric,
class Axis>
3032 template <
typename Num2>
3038 template <
typename Numeric,
class Axis>
3039 template <
typename Num2>
3045 template <
typename Numeric,
class Axis>
3046 template <
typename Num2>
3048 data_.at(i0,
i1) =
v;
3052 template <
typename Numeric,
class Axis>
3053 template <
typename Num2>
3055 data_(i0,
i1,
i2) =
v;
3059 template <
typename Numeric,
class Axis>
3060 template <
typename Num2>
3062 const unsigned i0,
const unsigned i1,
const unsigned i2,
const unsigned i3,
const Num2&
v) {
3067 template <
typename Numeric,
class Axis>
3068 template <
typename Num2>
3070 const unsigned i0,
const unsigned i1,
const unsigned i2,
const unsigned i3,
const unsigned i4,
const Num2&
v) {
3071 data_(i0,
i1,
i2,
i3, i4) =
v;
3075 template <
typename Numeric,
class Axis>
3076 template <
typename Num2>
3084 data_(i0,
i1,
i2,
i3, i4, i5) =
v;
3088 template <
typename Numeric,
class Axis>
3089 template <
typename Num2>
3098 data_(i0,
i1,
i2,
i3, i4, i5, i6) =
v;
3102 template <
typename Numeric,
class Axis>
3103 template <
typename Num2>
3113 data_(i0,
i1,
i2,
i3, i4, i5, i6, i7) =
v;
3117 template <
typename Numeric,
class Axis>
3118 template <
typename Num2>
3129 data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8) =
v;
3133 template <
typename Numeric,
class Axis>
3134 template <
typename Num2>
3146 data_(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8, i9) =
v;
3150 template <
typename Numeric,
class Axis>
3151 template <
typename Num2>
3153 data_.at(i0,
i1,
i2) =
v;
3157 template <
typename Numeric,
class Axis>
3158 template <
typename Num2>
3160 const unsigned i0,
const unsigned i1,
const unsigned i2,
const unsigned i3,
const Num2&
v) {
3165 template <
typename Numeric,
class Axis>
3166 template <
typename Num2>
3168 const unsigned i0,
const unsigned i1,
const unsigned i2,
const unsigned i3,
const unsigned i4,
const Num2&
v) {
3169 data_.at(i0,
i1,
i2,
i3, i4) =
v;
3173 template <
typename Numeric,
class Axis>
3174 template <
typename Num2>
3182 data_.at(i0,
i1,
i2,
i3, i4, i5) =
v;
3186 template <
typename Numeric,
class Axis>
3187 template <
typename Num2>
3196 data_.at(i0,
i1,
i2,
i3, i4, i5, i6) =
v;
3200 template <
typename Numeric,
class Axis>
3201 template <
typename Num2>
3211 data_.at(i0,
i1,
i2,
i3, i4, i5, i6, i7) =
v;
3215 template <
typename Numeric,
class Axis>
3216 template <
typename Num2>
3227 data_.at(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8) =
v;
3231 template <
typename Numeric,
class Axis>
3232 template <
typename Num2>
3244 data_.at(i0,
i1,
i2,
i3, i4, i5, i6, i7, i8, i9) =
v;
3248 template <
typename Numeric,
class Axis>
3249 template <
typename Num2>
3252 overflow_ +=
r.overflow_;
3253 fillCount_ +=
r.fillCount_;
3254 overCount_ +=
r.overCount_;
3259 template <
typename Numeric,
class Axis>
3260 template <
typename Num2>
3263 overflow_ -=
r.overflow_;
3270 fillCount_ +=
r.fillCount_;
3271 overCount_ +=
r.overCount_;
3277 template <
typename Numeric,
class Axis>
3278 template <
typename Num2>
3286 template <
typename Numeric,
class Axis>
3287 template <
typename Num2>
3295 template <
typename Numeric,
class Axis>
3298 accumulatedDataLabel_(
r.accumulatedDataLabel_),
3302 weightBuf_(
r.weightBuf_),
3303 indexBuf_(
r.indexBuf_),
3304 fillCount_(
r.fillCount_),
3305 overCount_(
r.overCount_),
3311 template <
typename Numeric,
class Axis>
3314 accumulatedDataLabel_(
r.accumulatedDataLabel_),
3316 overflow_(
r.overflow_),
3318 weightBuf_(
r.weightBuf_),
3319 indexBuf_(
r.indexBuf_),
3320 fillCount_(
r.fillCount_),
3321 overCount_(
r.overCount_),
3325 template <
typename Numeric,
class Axis>
3329 accumulatedDataLabel_ =
r.accumulatedDataLabel_;
3330 data_.uninitialize();
3332 overflow_.uninitialize();
3333 overflow_ =
r.overflow_;
3335 weightBuf_ =
r.weightBuf_;
3336 indexBuf_ =
r.indexBuf_;
3337 fillCount_ =
r.fillCount_;
3338 overCount_ =
r.overCount_;
3345 template <
typename Numeric,
class Axis>
3347 if (axisNum1 >= dim_ || axisNum2 >= dim_)
3349 "In npstat::HistoND::transpose: "
3350 "axis number is out of range");
3351 if (axisNum1 == axisNum2)
3355 return HistoND(*
this, axisNum1, axisNum2);
3358 template <
typename Numeric,
class Axis>
3359 template <
typename Num2>
3361 const unsigned long nDat = data_.length();
3362 Numeric*
data = const_cast<Numeric*>(data_.data());
3363 for (
unsigned long i = 0;
i < nDat; ++
i)
3369 template <
typename Numeric,
class Axis>
3370 template <
typename Num2>
3372 const unsigned long nOver = overflow_.length();
3373 Numeric*
data = const_cast<Numeric*>(overflow_.data());
3374 for (
unsigned long i = 0;
i < nOver; ++
i)
3376 overCount_ += nOver;
3377 fillCount_ += nOver;
3381 template <
typename Numeric,
class Axis>
3382 template <
typename Num2>
3384 if (dataLength != data_.length())
3387 Numeric* dat = const_cast<Numeric*>(data_.data());
3388 for (
unsigned long i = 0;
i < dataLength; ++
i)
3390 fillCount_ += dataLength;
3394 template <
typename Numeric,
class Axis>
3395 template <
typename Num2>
3397 if (dataLength != overflow_.length())
3400 Numeric* dat = const_cast<Numeric*>(overflow_.data());
3401 for (
unsigned long i = 0;
i < dataLength; ++
i)
3403 overCount_ += dataLength;
3404 fillCount_ += dataLength;
3408 template <
typename Numeric,
class Axis>
3409 template <
typename Num2>
3411 if (dataLength != data_.length())
3414 Numeric* dat = const_cast<Numeric*>(data_.data());
3415 for (
unsigned long i = 0;
i < dataLength; ++
i)
3420 template <
typename Numeric,
class Axis>
3421 template <
typename Num2>
3423 if (dataLength != overflow_.length())
3426 Numeric* dat = const_cast<Numeric*>(overflow_.data());
3427 for (
unsigned long i = 0;
i < dataLength; ++
i)
3432 template <
typename Numeric,
class Axis>
3433 template <
typename Num2>
3435 const unsigned long dataLength,
3436 const bool clearOverflowsNow) {
3437 data_.setData(
data, dataLength);
3438 if (clearOverflowsNow)
3443 template <
typename Numeric,
class Axis>
3444 template <
typename Num2>
3446 overflow_.setData(
data, dataLength);
3450 template <
typename Numeric,
class Axis>
3452 const long double nOver = overflow_.template sum<long double>();
3453 const long double nData = data_.template sum<long double>();
3454 overCount_ = static_cast<unsigned long>(nOver);
3455 fillCount_ = static_cast<unsigned long>(nData + nOver);
3459 template <
typename Numeric,
class Axis>
3460 template <
typename Num2,
typename Num3>
3463 const unsigned* projectedIndices,
3464 const unsigned nProjectedIndices)
const {
3466 data_.addToProjection(&projection->data_, projector, projectedIndices, nProjectedIndices);
3467 projection->fillCount_ += projection->nBins();
3468 projection->modCount_++;
3471 template <
typename Numeric,
class Axis>
3472 template <
typename Num2,
typename Num3>
3475 const unsigned* projectedIndices,
3476 const unsigned nProjectedIndices)
const {
3478 data_.addToProjection(&projection->data_, projector, projectedIndices, nProjectedIndices);
3479 projection->fillCount_ += projection->nBins();
3480 projection->modCount_++;
3483 template <
typename Numeric,
class Axis>
3485 static const std::string myClass(gs::template_class_name<Numeric, Axis>(
"npstat::HistoND"));
3486 return myClass.c_str();
3489 template <
typename Numeric,
class Axis>
3491 gs::write_pod(of, title_);
3492 gs::write_pod(of, accumulatedDataLabel_);
3493 gs::write_pod(of, fillCount_);
3494 gs::write_pod(of, overCount_);
3496 return !of.fail() && gs::write_obj_vector(of, axes_) && data_.classId().write(of) && data_.write(of) &&
3497 overflow_.write(of);
3500 template <
typename Numeric,
class Axis>
3503 current.ensureSameId(
id);
3509 gs::read_pod(
in, &accumulatedDataLabel);
3511 unsigned long fillCount = 0, overCount = 0;
3512 gs::read_pod(
in, &fillCount);
3513 gs::read_pod(
in, &overCount);
3515 throw gs::IOReadFailure(
"In npstat::HistoND::read: input stream failure");
3517 std::vector<Axis> axes;
3518 gs::read_heap_obj_vector_as_placed(
in, &axes);
3519 gs::ClassId ida(
in, 1);
3523 CPP11_auto_ptr<HistoND<Numeric, Axis> >
result(
3526 result->overflow_ = over;
3527 result->fillCount_ = fillCount;
3528 result->overCount_ = overCount;
3532 template <
typename Histo>
3535 if (!knownNonNegative)
3537 const double integ =
h->integral();
3541 template <
typename Histo>
3543 std::vector<LinearMapper1d>
result;
3544 const unsigned d =
histo.dim();
3546 for (
unsigned i = 0;
i <
d; ++
i) {
3548 result.push_back(
m.inverse());
3553 template <
typename Histo>
3555 std::vector<CircularMapper1d>
result;
3556 const unsigned d =
histo.dim();
3558 for (
unsigned i = 0;
i <
d; ++
i)
3559 result.push_back(
histo.axis(
i).kernelScanMapper(doubleRange));
3564 #endif // NPSTAT_HISTOND_HH_