6#include "./histogram.hpp"
8namespace triqs_ctint::measures {
10 histogram::histogram(params_t
const &, qmc_config_t
const &qmc_config_, container_set *results)
11 : qmc_config(qmc_config_), histogram_(results->histogram) {
12 results->histogram = std::vector<double>(4);
15 void histogram::accumulate(mc_weight_t) {
16 int k = qmc_config.perturbation_order();
17 while (k >= histogram_->size()) histogram_->resize(2 * histogram_->size());
18 histogram_.value()[k] += 1.;
22 void histogram::collect_results(mpi::communicator
const &comm) {
23 N = mpi::all_reduce(N, comm);
26 auto max_size = mpi::all_reduce(histogram_->size(), comm, MPI_MAX);
27 histogram_->resize(max_size, 0.0);
30 histogram_ = mpi::all_reduce(histogram_.value(), comm);
31 for (
auto &h_k : histogram_.value()) h_k = h_k / N;