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 "./block_gf.hpp"
28
29#include <utility>
30
31namespace triqs::gfs {
32
37
38 // auto assignment of the gf (gf(om_) << expression fills the functions by evaluation of expression)
39
52 template <typename RHS, typename M, typename T> void clef_auto_assign(block_gf_view<M, T> g, RHS const &rhs) {
53 for (int i = 0; i < g.size(); ++i) triqs_bgf_clef_auto_assign_impl_aux_assign(g[i], rhs(i));
54 }
55
65 template <typename RHS, typename M, typename T> void clef_auto_assign(block2_gf_view<M, T> g, RHS const &rhs) {
66 for (int i = 0; i < g.size1(); ++i)
67 for (int j = 0; j < g.size2(); ++j) triqs_bgf_clef_auto_assign_impl_aux_assign(g(i, j), rhs(i, j));
68 }
69
79 template <typename RHS, typename M, typename T> void clef_auto_assign(block_gf<M, T> &g, RHS const &rhs) { clef_auto_assign(g(), rhs); }
80
90 template <typename RHS, typename M, typename T> void clef_auto_assign(block2_gf<M, T> &g, RHS const &rhs) { clef_auto_assign(g(), rhs); }
91
101 template <typename RHS, typename M, typename T> void clef_auto_assign_subscript(block_gf_view<M, T> g, RHS const &rhs) { clef_auto_assign(g, rhs); }
102
112 template <typename RHS, typename M, typename T> void clef_auto_assign_subscript(block_gf<M, T> &g, RHS const &rhs) { clef_auto_assign(g(), rhs); }
113
114 // Helper that assigns a (non-CLEF) right hand side to a block element.
115 template <typename G, typename RHS> void triqs_bgf_clef_auto_assign_impl_aux_assign(G &&g, RHS &&rhs) {
116 std::forward<G>(g) = std::forward<RHS>(rhs);
117 }
118
119 // Helper overload that recurses into a CLEF function object right hand side.
120 template <typename G, typename Expr, int... Is> void triqs_bgf_clef_auto_assign_impl_aux_assign(G &&g, clef::make_fun_impl<Expr, Is...> &&rhs) {
121 clef_auto_assign(std::forward<G>(g), std::move(rhs));
122 }
123
125
126} // namespace triqs::gfs
Provides the block Green's function container.
A non-owning view of a block Green's function.
int size() const
Get the total number of blocks.
int size2() const
Get the number of blocks along the second index (block2_gf only).
int size1() const
Get the number of blocks along the first index (block2_gf only).
The owning block Green's function container.
Definition block_gf.hpp:259
block_gf_view< Mesh, Target, Layout, 2, false > block2_gf_view
Mutable view of a two-index block Green's function.
Definition block_gf.hpp:81
block_gf< Mesh, Target, Layout, 2 > block2_gf
Owning two-index block Green's function (a matrix of blocks).
Definition block_gf.hpp:70
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.