A class to histogram in 4 dimensions.
More...
#include <Histo4d.h>
|
| SparseHisto4d () |
|
| SparseHisto4d (const int n1, double min1, double max1, const int n2, double min2, double max2, const int n3, double min3, double max3, const int n4, double min4, double max4, const int nEntries) |
|
void | fill (const double x[4]) |
|
void | fill (const double x1, const double x2, const double x3, const double x4) |
|
int | maxBin (double x[4]) |
|
void | zeroBin (double x[4]) |
|
void | binLimits (const double x[4], const int idim, double &xMin, double &xMax) const |
| return the bin limits of dimension idim (0<=idim<4), around point X. More...
|
|
int | getNEntries () const |
|
| ~SparseHisto4d () |
|
int | code_value (const double x[4]) const |
|
void | inverse_code (const int code, double x[4]) const |
|
void | sort () |
|
void | print () const |
|
A class to histogram in 4 dimensions.
Uses Sparse storage. The number of bin is limited to 256 per dimension. Used in ListMatch.cc
Definition at line 33 of file Histo4d.h.
◆ SparseHisto4d() [1/2]
lsst::jointcal::SparseHisto4d::SparseHisto4d |
( |
| ) |
|
|
inline |
◆ SparseHisto4d() [2/2]
lsst::jointcal::SparseHisto4d::SparseHisto4d |
( |
const int |
n1, |
|
|
double |
min1, |
|
|
double |
max1, |
|
|
const int |
n2, |
|
|
double |
min2, |
|
|
double |
max2, |
|
|
const int |
n3, |
|
|
double |
min3, |
|
|
double |
max3, |
|
|
const int |
n4, |
|
|
double |
min4, |
|
|
double |
max4, |
|
|
const int |
nEntries |
|
) |
| |
Definition at line 41 of file Histo4d.cc.
44 double indexMax = n1 * n2 * n3 * n4;
46 if (indexMax >
double(INT_MAX))
47 LOGLS_WARN(_log,
"Cannot hold a 4D histo with more than " << INT_MAX <<
" values.");
61 for (
int i = 0; i < 4; ++i) _scale[i] = _n[i] / (_maxVal[i] - _minVal[i]);
62 _data.
reset(
new int[nEntries]);
◆ ~SparseHisto4d()
lsst::jointcal::SparseHisto4d::~SparseHisto4d |
( |
| ) |
|
|
inline |
◆ binLimits()
void lsst::jointcal::SparseHisto4d::binLimits |
( |
const double |
x[4], |
|
|
const int |
idim, |
|
|
double & |
xMin, |
|
|
double & |
xMax |
|
) |
| const |
return the bin limits of dimension idim (0<=idim<4), around point X.
Definition at line 154 of file Histo4d.cc.
158 xMin = xCenter[iDim] - 0.5 / _scale[iDim];
159 xMax = xCenter[iDim] + 0.5 / _scale[iDim];
◆ code_value()
int lsst::jointcal::SparseHisto4d::code_value |
( |
const double |
x[4] | ) |
const |
Definition at line 68 of file Histo4d.cc.
70 for (
int idim = 0; idim < 4; ++idim) {
71 int i = (int)
std::floor((
x[idim] - _minVal[idim]) * _scale[idim]);
72 if (i < 0 || i >= _n[idim])
return -1;
73 index = index * _n[idim] + i;
◆ fill() [1/2]
void lsst::jointcal::SparseHisto4d::fill |
( |
const double |
x1, |
|
|
const double |
x2, |
|
|
const double |
x3, |
|
|
const double |
x4 |
|
) |
| |
◆ fill() [2/2]
void lsst::jointcal::SparseHisto4d::fill |
( |
const double |
x[4] | ) |
|
Definition at line 93 of file Histo4d.cc.
98 if (_ndata == _dataSize) {
100 memcpy(newData.get(), _data.
get(), _dataSize *
sizeof(_data[0]));
104 _data[_ndata++] = code;
◆ getNEntries()
int lsst::jointcal::SparseHisto4d::getNEntries |
( |
| ) |
const |
|
inline |
◆ inverse_code()
void lsst::jointcal::SparseHisto4d::inverse_code |
( |
const int |
code, |
|
|
double |
x[4] |
|
) |
| const |
Definition at line 78 of file Histo4d.cc.
79 for (
int i = 3; i >= 0; --i) {
80 int bin = code % _n[i];
82 x[i] = _minVal[i] + ((double)bin + 0.5) / _scale[i];
◆ maxBin()
int lsst::jointcal::SparseHisto4d::maxBin |
( |
double |
x[4] | ) |
|
Definition at line 117 of file Histo4d.cc.
119 if (_ndata == 0)
return 0;
120 int maxval = _data[0];
122 int oldval = _data[0];
123 int currentCount = 1;
124 for (
int i = 1; i < _ndata; ++i) {
125 if (_data[i] == oldval)
129 if (currentCount > maxCount) {
130 maxCount = currentCount;
◆ print()
void lsst::jointcal::SparseHisto4d::print |
( |
| ) |
const |
Definition at line 162 of file Histo4d.cc.
163 for (
int i = 0; i < _ndata; ++i)
◆ sort()
void lsst::jointcal::SparseHisto4d::sort |
( |
| ) |
|
◆ zeroBin()
void lsst::jointcal::SparseHisto4d::zeroBin |
( |
double |
x[4] | ) |
|
Definition at line 139 of file Histo4d.cc.
144 while ((_data[start] < code) && start < _ndata) start++;
147 while (
end < _ndata && _data[start] == _data[
end])
end++;
148 int shift =
end - start;
149 int lastShift = _ndata - (
end - start);
150 for (
int i = start; i < lastShift; ++i) _data[i] = _data[i + shift];
The documentation for this class was generated from the following files:
- /j/snowflake/release/lsstsw/stack/1a1d771/Linux64/jointcal/20.0.0/include/lsst/jointcal/Histo4d.h
- /j/snowflake/release/lsstsw/stack/1a1d771/Linux64/jointcal/20.0.0/src/Histo4d.cc