7#include "./state_hist.hpp"
10namespace triqs_ctseg::measures {
12 state_hist::state_hist(params_t
const &p, work_data_t
const &wdata, configuration_t
const &config, results_t &results)
13 : wdata{wdata}, config{config}, results{results} {
16 H = nda::zeros<double>(ipow(2, config.n_color()));
21 void state_hist::accumulate(
double s) {
23 LOG(
"\n =================== MEASURE STATE HISTOGRAM ================ \n");
38 double tau_prev = beta;
39 nda::vector<bool> state = nda::zeros<bool>(config.n_color());
40 for (
auto const &op : colored_ordered_ops(config.seglists)) {
42 for (
auto c : range(config.n_color()))
43 if (state(c)) state_idx += ipow(2, c);
44 H(state_idx) += (tau_prev - op.tau);
45 tau_prev = (double)op.tau;
46 ALWAYS_EXPECTS((state(op.color) == op.is_cdag),
"Operator error at color {}", op.color);
47 state(op.color) = !op.is_cdag;
51 ALWAYS_EXPECTS((state == nda::zeros<bool>(config.n_color())),
"Operator error");
56 void state_hist::collect_results(mpi::communicator
const &c) {
58 Z = mpi::all_reduce(Z, c);
59 H = mpi::all_reduce(H, c);
63 results.state_hist = std::move(H);