6 #if __cplusplus >= 202002L 21 using map_type = std::map<int, unsigned int>;
26 : resolution(resolution)
30 const T getResolution()
const {
return resolution; }
32 void add(
const T value)
34 if (std::isfinite(value)) {
35 const auto index =
static_cast<map_type::key_type
>(std::round(value / resolution));
39 faunus_logger->warn(
"histogram: skipping inf/nan number");
43 friend auto& operator<<(std::ostream& stream,
const SparseHistogram& histogram)
45 std::for_each(histogram.data.begin(), histogram.data.end(), [&](
const auto& sample) {
46 stream << std::format(
47 "{:.6E} {}\n", static_cast<T>(sample.first) * histogram.resolution, sample.second);
double T
floating point size
Definition: units.h:73
Cell list class templates.
Definition: actions.cpp:11
Histogram for an arbitrary set of values using a sparse memory layout (map)
Definition: sparsehistogram.h:18