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)};
51 template <
typename Mesh> gf_struct_t
get_struct(block_gf<Mesh>
const &g) {
53 for (
auto [name, size] : zip(g.block_names(), g.block_sizes())) result.emplace_back(name, size);
59 auto res = nda::zeros<long>(g.size1(), g.size2());
60 for (
auto [alpha, sigma] : res.indices()) res(alpha, sigma) = g(alpha, sigma).target_shape()[0];
61 return {g.block_names(), std::move(res)};
65 if (g.size1() != 1)
throw std::runtime_error{
"decomposition_view: not implemented if g.size1 !=1"};
68 auto n_sigma = g.size2();
70 for (
auto sigma : range(n_sigma)) { Gout(alpha, sigma).data() = g(0, sigma).data()(
r_all, Ralpha, Ralpha); }
78 auto n_sigma = g.size();
80 for (
auto sigma : range(n_sigma)) { Gout(alpha, sigma).data() = g(0, sigma).data()(
r_all, Ralpha, Ralpha); }
85 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) {
86 auto &in_mesh = g(0, 0).mesh();
87 auto beta = in_mesh.beta();
88 auto dlr_mesh = mesh::dlr_imfreq(beta, mesh::statistic_enum::Fermion, w_max, eps);
90 auto n_alpha = g.size1();
91 auto n_sigma = g.size2();
92 for (
auto a : range(n_alpha))
93 for (
auto s : range(n_sigma))
94 for (
auto [iw, wdlr] : enumerate(dlr_mesh)) {
95 if (wdlr.n > g(0, 0).mesh().last_index())
96 throw std::runtime_error{
97 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)};
99 gdlr(a, s).data()(iw,
r_all,
r_all) = g(a, s)(wdlr);
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)
gf_struct_t get_struct(block_gf< Mesh > const &g)
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