TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
arrays.hpp
Go to the documentation of this file.
1// Copyright (c) 2015-2018 Commissariat à l'énergie atomique et aux énergies alternatives (CEA)
2// Copyright (c) 2015-2018 Centre national de la recherche scientifique (CNRS)
3// Copyright (c) 2018-2021 Simons Foundation
4// Copyright (c) 2016 Igor Krivenko
5//
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You may obtain a copy of the License at
17// https://www.gnu.org/licenses/gpl-3.0.txt
18//
19// Authors: Igor Krivenko, Olivier Parcollet, Nils Wentzell
20
25
26#pragma once
27
28#ifndef TRIQS_DEBUG
29#define TRIQS_DEBUG
30#endif
31
32#include "../arrays.hpp"
33
34#include <gtest/gtest.h>
35#include <h5/h5.hpp>
36#include <mpi/mpi.hpp>
37#include <nda/nda.hpp>
38#include <nda/gtest_tools.hpp>
39
40#include <sstream>
41#include <string>
42
43using dcomplex = std::complex<double>;
44using triqs::clef::placeholder;
45
50
60#define EXPECT_PRINT(X, Y) \
61 { \
62 std::stringstream ss; \
63 ss << (Y); \
64 EXPECT_EQ(X, ss.str()); \
65 }
66
76#define ASSERT_PRINT(X, Y) \
77 { \
78 std::stringstream ss; \
79 ss << (Y); \
80 ASSERT_EQ(X, ss.str()); \
81 }
82
89#define MAKE_MAIN \
90 int main(int argc, char **argv) { \
91 ::testing::InitGoogleTest(&argc, argv); \
92 if (mpi::has_env) { \
93 mpi::environment env(argc, argv); \
94 std::cout << "MPI environment detected\n"; \
95 return RUN_ALL_TESTS(); \
96 } else \
97 return RUN_ALL_TESTS(); \
98 }
99
112template <typename T> T rw_h5(T const &x, std::string filename = "ess", std::string name = "x") {
113 T y; // must be default constructible
114 {
115 h5::file file(filename + ".h5", 'w');
116 h5_write(file, name, x);
117 }
118 {
119 h5::file file(filename + ".h5", 'r');
120 h5_read(file, name, y);
121 }
122 return y;
123}
124
friend void h5_read(h5::group fg, std::string const &subgroup_name, this_t &g)
Read a block Green's function from HDF5.
friend void h5_write(h5::group fg, std::string const &subgroup_name, this_t const &g)
Write a block Green's function to HDF5.
Backward-compatibility umbrella header pulling in the nda array library.
T rw_h5(T const &x, std::string filename="ess", std::string name="x")
Write an object to an HDF5 file and read it back.
Definition arrays.hpp:112