9#include <triqs/mesh/dlr_imfreq.hpp>
10#include <triqs/mesh/utils.hpp>
12#include <fmt/ostream.h>
19 { os << t } -> std::same_as<std::ostream &>;
23struct fmt::formatter<M> : fmt::ostream_formatter {};
36 std::vector<std::vector<std::string>>
names;
42 using g_t = gf<Mesh, matrix_valued>;
43 auto g = std::vector<std::vector<g_t>>(gf_s.
names[0].size(), std::vector<g_t>(gf_s.
names[1].size()));
44 for (
auto [alpha, sigma] : gf_s.
dims().indices()) {
45 auto dim = gf_s.
dims()(alpha, sigma);
46 g[alpha][sigma] = g_t{mesh, {dim, dim}};
48 return {gf_s.
names, std::move(g)};
53 auto res = nda::zeros<long>(g.size1(), g.size2());
54 for (
auto [alpha, sigma] : res.indices()) res(alpha, sigma) = g(alpha, sigma).target_shape()[0];
55 return {g.block_names(), std::move(res)};
59 if (g.size1() != 1)
throw std::runtime_error{
"decomposition_view: not implemented if g.size1 !=1"};
62 auto n_sigma = g.size2();
64 for (
auto sigma : range(n_sigma)) { Gout(alpha, sigma).data() = g(0, sigma).data()(
r_all, Ralpha, Ralpha); }
72 auto n_sigma = g.size();
74 for (
auto sigma : range(n_sigma)) { Gout(alpha, sigma).data() = g(0, sigma).data()(
r_all, Ralpha, Ralpha); }
79 inline block2_gf<mesh::dlr_imfreq, matrix_valued>
make_block2_dlr_gf(block2_gf<mesh::imfreq, matrix_valued>
const &g,
double w_max,
double eps) {
80 auto &in_mesh = g(0, 0).mesh();
81 auto beta = in_mesh.beta();
82 auto dlr_mesh = mesh::dlr_imfreq(beta, mesh::statistic_enum::Fermion, w_max, eps);
84 auto n_alpha = g.size1();
85 auto n_sigma = g.size2();
86 for (
auto a : range(n_alpha))
87 for (
auto s : range(n_sigma))
88 for (
auto [iw, wdlr] : enumerate(dlr_mesh)) {
89 if (wdlr.n > g(0, 0).mesh().last_index())
90 throw std::runtime_error{
91 fmt::format(
"make_block2_dlr_gf: the imfreq mesh \n{}\n is too short to extract the dlr_mesh \n{}\n", in_mesh, dlr_mesh)};
93 gdlr(a, s).data()(iw,
r_all,
r_all) = g(a, s)(wdlr);
gf_struct2_t get_struct(block2_gf< Mesh, matrix_valued > const &g)
block2_gf< Mesh, matrix_valued > make_block2_gf(Mesh const &mesh, gf_struct2_t const &gf_s)
block2_gf< Mesh > decomposition_view(block2_gf< Mesh > const &g, gf_struct2_t const &stru)
block2_gf< mesh::dlr_imfreq, matrix_valued > make_block2_dlr_gf(block2_gf< mesh::imfreq, matrix_valued > const &g, double w_max, double eps)
static constexpr auto r_all
generator< std::pair< long, nda::range > > enumerated_sub_slices(auto sub_div)
nda::array< long, 2 > dims
std::vector< std::vector< std::string > > names