TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
defs.hpp
Go to the documentation of this file.
1// Copyright (c) 2016-2018 Commissariat à l'énergie atomique et aux énergies alternatives (CEA)
2// Copyright (c) 2016-2018 Centre national de la recherche scientifique (CNRS)
3// Copyright (c) 2018-2023 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#pragma once
26
27#include "../../arrays.hpp"
30#include "../../mesh/prod.hpp"
31#include "../../mesh/utils.hpp"
33
34#include <array>
35#include <complex>
36#include <cstddef>
37#include <utility>
38
39namespace triqs::gfs {
40
41 // Alias for std::complex<double>.
42 using dcomplex = std::complex<double>;
43
44 // Elevate certain types into the triqs::gfs namespace.
45 using mesh::all_t;
46 using mesh::Boson;
48 using mesh::Fermion;
49 using mesh::matsubara_freq;
50 using mesh::Mesh;
53 using nda::array;
54 using nda::array_view;
55 using nda::ellipsis;
56 using nda::matrix;
57 using nda::matrix_const_view;
58 using nda::matrix_view;
59 using triqs::arrays::make_shape;
60 using utility::factory;
61
66
75 template <Mesh M> struct gf_evaluator;
76
84 template <typename Mesh> using evaluator_t = gf_evaluator<Mesh>;
85 };
86
88
99 template <typename Mesh, typename Target> struct gf_h5_rw;
100
101 namespace detail {
102
103 // Build a sub-mesh from a product mesh by keeping the components at the given positions.
104 template <auto Positions, Mesh M> auto filter_mesh(M const &m) {
105 static_assert(Positions.size() > 0);
106 if constexpr (Positions.size() == 1) {
107 return std::get<Positions[0]>(m);
108 } else {
109 return [&]<size_t... Is>(std::index_sequence<Is...>) {
110 return mesh::prod{std::get<Positions[Is]>(m)...};
111 }(std::make_index_sequence<Positions.size()>{});
112 }
113 }
114
115 // Compute the positions of the first L set entries of a boolean filter.
116 template <size_t L> constexpr std::array<int, L> compute_position(auto const &filter) {
117 std::array<int, L> r{};
118 int ii = 0;
119 for (int i = 0; i < filter.size() and ii < L; ++i) {
120 r[ii] = i;
121 ii += int(filter[i]);
122 }
123 return r;
124 }
125
126 // Check whether a Green's function evaluation is known to vanish at the given arguments.
127 template <Mesh M, typename... XS> bool eval_to_zero(M const &m, XS const &...xs) {
128 if constexpr (sizeof...(XS) > 1) {
129 return [&]<std::size_t... Is>(std::index_sequence<Is...>) {
130 return (eval_to_zero(std::get<Is>(m), xs) or ... or false);
131 }(std::make_index_sequence<sizeof...(XS)>());
132 } else if constexpr (requires { m.eval_to_zero(xs...); }) {
133 return m.eval_to_zero(xs...);
134 }
135 return false;
136 }
137
138 } // namespace detail
139
140} // namespace triqs::gfs
Backward-compatibility umbrella header pulling in the nda array library.
Product mesh type for combining multiple meshes.
Definition prod.hpp:138
Generic factory for constructing objects of a given type.
auto closest_mesh_pt(Ts &&...ts)
Construct a triqs::mesh::closest_mesh_point_t object for a single value or a std::tuple of triqs::mes...
Definition utils.hpp:199
statistic_enum
Enum to specify particle statistics.
Definition utils.hpp:163
static constexpr int n_variables
Constexpr variable that holds the number of meshes in a triqs::mesh::Mesh type ( for non-product mes...
Definition utils.hpp:154
T factory(U &&...x)
Generic factory to construct an object of a given type from an arbitrary parameter pack of arguments.
Definition factory.hpp:95
filter_t< T, Is... > filter(T &&t)
Keep only the elements of a tuple at the given positions.
Provides a struct to represent Matsubara frequencies.
Provides concepts for mesh points and meshes.
Provides various utilities used with Meshes.
Provides a product mesh type.
Default evaluator policy.
Definition defs.hpp:82
gf_evaluator< Mesh > evaluator_t
The evaluator functor associated with the mesh type Mesh.
Definition defs.hpp:84
Default evaluator of a Green's function at arbitrary points of its mesh.
Definition evaluator.hpp:52
Traits class for reading/writing a Green's function from/to HDF5.
Definition h5.hpp:95