TRIQS/triqs_ctseg 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
average_sign.cpp
1// Copyright (c) 2023--present, The Simons Foundation
2// Copyright (c) 2023--present, Max Planck Institute for Polymer Research, Mainz, Germany
3// This file is part of TRIQS/ctseg and is licensed under the terms of GPLv3 or later.
4// SPDX-License-Identifier: GPL-3.0-or-later
5// See LICENSE in the root of this distribution for details.
6
7#include "average_sign.hpp"
8#include <itertools/itertools.hpp>
9#include "../logs.hpp"
10
11namespace triqs_ctseg::measures {
12
13 average_sign::average_sign(params_t const &, work_data_t const &wdata, configuration_t const &config,
14 results_t &results)
15 : wdata{wdata}, config{config}, results{results} {
16 Z = 0.0;
17 N = 0.0;
18 }
19
20 // -------------------------------------
21
22 void average_sign::accumulate(double s) {
23 Z += s;
24 N += 1.0;
25 }
26
27 // -------------------------------------
28
29 void average_sign::collect_results(mpi::communicator const &c) {
30 Z = mpi::all_reduce(Z, c);
31 N = mpi::all_reduce(N, c);
32
33 results.average_sign = Z / N;
34 }
35
36} // namespace triqs_ctseg::measures