TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
mc_measure_set.cpp
Go to the documentation of this file.
1// Copyright (c) 2013-2018 Commissariat à l'énergie atomique et aux énergies alternatives (CEA)
2// Copyright (c) 2013-2018 Centre national de la recherche scientifique (CNRS)
3// Copyright (c) 2018-2022 Simons Foundation
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You may obtain a copy of the License at
16// https://www.gnu.org/licenses/gpl-3.0.txt
17//
18// Authors: Michel Ferrero, Olivier Parcollet, Nils Wentzell
19
24
25#include "./concepts.hpp"
26#include "./mc_measure_set.hpp"
27
28#include <fmt/format.h>
29#include <mpi/communicator.hpp>
30
31#include <complex>
32#include <string>
33#include <vector>
34
35namespace triqs::mc_tools {
36
37 template <DoubleOrComplex MCSignType> std::vector<std::string> measure_set<MCSignType>::names() const {
38 std::vector<std::string> res;
39 for (auto &[name, m] : measures_) {
40 res.push_back(name);
41 auto tmp_vec = m.names();
42 res.insert(res.end(), tmp_vec.begin(), tmp_vec.end());
43 }
44 return res;
45 }
46
47 template <DoubleOrComplex MCSignType> void measure_set<MCSignType>::collect_results(const mpi::communicator &c) {
48 for (auto &[name, m] : measures_) m.collect_results(c);
49 }
50
51 template <DoubleOrComplex MCSignType> std::string measure_set<MCSignType>::report() const {
52 std::string res;
53 for (auto &[name, m] : measures_) {
54 auto str = m.report();
55 if (!str.empty()) res += " " + str + "\n";
56 }
57 return res;
58 }
59
60 template <DoubleOrComplex MCSignType> std::string measure_set<MCSignType>::get_timings(std::string const &prefix) const {
61 std::string res;
62 for (auto const &[name, m] : measures_) { res += m.get_timings(name, prefix); }
63 return res;
64 }
65
66 // Explicit template instantiations.
67 template class measure_set<double>;
69
70} // namespace triqs::mc_tools
std::vector< std::string > names() const
Get a vector of all the measure names.
void collect_results(const mpi::communicator &c)
Collect results from all the measures in the measure set from multiple MPI processes.
std::string get_timings(std::string const &prefix="") const
Get a formatted string with the timings of all measures.
std::string report() const
Report information about the measures in the set.
Provides a set of MC measurements.
Provides concepts for the MC tools.