TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
auto_assign.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 "./gf.hpp"
28
31
32#include <utility>
33
34namespace triqs::gfs {
35
40
41 // auto assignment of the gf (gf(om_) << expression fills the functions by evaluation of expression)
42
43 // Helper that assigns a (non-CLEF) right hand side to a Green's function element.
44 template <typename G, typename RHS> FORCEINLINE void triqs_gf_clef_auto_assign_impl_aux_assign(G &&g, RHS &&rhs) {
45 std::forward<G>(g) = std::forward<RHS>(rhs);
46 }
47
48 // Helper overload that recurses into a CLEF function object right hand side.
49 template <typename G, typename Expr, int... Is>
50 FORCEINLINE void triqs_gf_clef_auto_assign_impl_aux_assign(G &&g, clef::make_fun_impl<Expr, Is...> &&rhs) {
51 clef_auto_assign(std::forward<G>(g), std::move(rhs));
52 }
53
67 template <typename RHS, typename M, typename T, typename L> FORCEINLINE void clef_auto_assign(gf_view<M, T, L> g, RHS const &rhs) {
68 if constexpr (mesh::is_product<M>) {
69 for (auto w : g.mesh()) { triqs_gf_clef_auto_assign_impl_aux_assign(g[w], triqs::tuple::apply(rhs, w)); }
70 } else {
71 for (auto w : g.mesh()) { triqs_gf_clef_auto_assign_impl_aux_assign(g[w], rhs(w)); }
72 }
73 }
74
85 template <typename RHS, typename M, typename T, typename L> FORCEINLINE void clef_auto_assign(gf<M, T, L> &g, RHS const &rhs) {
86 clef_auto_assign(g(), rhs);
87 }
88
99 template <typename RHS, typename M, typename T, typename L> FORCEINLINE void clef_auto_assign_subscript(gf_view<M, T, L> g, RHS const &rhs) {
100 clef_auto_assign(g, rhs);
101 }
102
103 /* template <typename RHS, typename M, typename T, typename L>*/
104 /*FORCEINLINE void clef_auto_assign_subscript(gf<M, T, L> const &g, RHS const &rhs) { return 1;} // = delete;*/
105
116 template <typename RHS, typename M, typename T, typename L> FORCEINLINE void clef_auto_assign_subscript(gf<M, T, L> &g, RHS const &rhs) {
117 clef_auto_assign(g, rhs);
118 }
119
121
122} // namespace triqs::gfs
A mutable, non-owning view of a Green's function.
Definition gf_view.hpp:48
mesh_t const & mesh() const
Get the mesh of the Green's function.
Definition gf_view.hpp:125
The owning Green's function container.
Definition gf.hpp:194
Provides the Green's function class.
void clef_auto_assign(block_gf_view< M, T > g, RHS const &rhs)
CLEF auto-assignment into a block Green's function view, i.e. g(om_) << expr.
void clef_auto_assign_subscript(block_gf_view< M, T > g, RHS const &rhs)
CLEF auto-assignment via subscript into a block Green's function view, i.e. g[om_] << expr.
static constexpr bool is_product
Constexpr bool that is true if the given triqs::mesh::Mesh type is a product of meshes,...
Definition utils.hpp:151
#define FORCEINLINE
Force-inline attribute portable across GCC and Clang.
Definition macros.hpp:64
decltype(auto) apply(F &&f, T &&t)
Call a function with the elements of a tuple as its arguments.
Common macros used in TRIQS.
Generic tuple manipulation tools.