50 template <
int N = 0, nda::MemoryArray A>
auto flatten_2d(A
const &v) {
51 long nrows = v.extent(N);
52 long ncols = v.size() / nrows;
53 return reshape(
typename A::regular_type{nda::transposed_view<0, N>(v)}, nrows, ncols);
65 template <
int N = 0>
void unflatten_2d(nda::MemoryArray
auto &&out, nda::MemoryArray
auto const &afl) {
66 auto sh_fl = out.shape();
67 std::swap(sh_fl[0], sh_fl[N]);
68 auto data_fl = reshape(afl, sh_fl);
69 out() = nda::transposed_view<0, N>(data_fl);
The owning Green's function container.
Concept checking that a type behaves like an in-memory Green's function.
Provides the Green's function class.
auto flatten_2d(A const &v)
Flatten an array into two dimensions, keeping one dimension and collapsing the rest.
void unflatten_2d(nda::MemoryArray auto &&out, nda::MemoryArray auto const &afl)
Inverse of triqs::gfs::flatten_2d: scatter a two-dimensional array back into a higher-rank array.
void unflatten_gf_2d(MemoryGf auto &g, Gfl const &gfl)
Inverse of triqs::gfs::flatten_gf_2d: scatter a flattened Green's function back into a higher-rank on...
auto flatten_gf_2d(G const &g)
Flatten a Green's function into a single-mesh, tensor-valued Green's function.
auto const & get_mesh(BG const &bg)
Get the mesh of a block Green's function, or its N-th component for a product mesh.
static constexpr bool is_product
Constexpr bool that is true if the given triqs::mesh::Mesh type is a product of meshes,...
Common macros used in TRIQS.