27 template <
typename Mesh>
30 auto n_mesh = Gimp[0].mesh().size();
31 auto n_blocks = Gimp.size();
33 std::vector<std::vector<long>> groups;
34 std::vector<bool> used(n_blocks,
false);
36 auto are_matrices_equal = [threshold, n_mesh](
auto const &A,
auto const &B) {
37 if (A.target_shape() != B.target_shape())
return false;
38 long n0 = A.target_shape()[0];
39 for (
auto mesh_idx : range(n_mesh)) {
40 auto const &Am = A(mesh_idx);
41 auto const &Bm = B(mesh_idx);
42 for (
size_t i = 0; i < n0; ++i) {
43 for (
size_t j = i + 1; j < n0; ++j) {
44 if (std::abs(Am(i, j) - Bm(i, j)) > threshold)
return false;
51 for (
auto i = 0; i < n_blocks; ++i) {
53 std::vector<long> current_group = {i};
55 for (
auto j = i + 1; j < n_blocks; ++j) {
56 if (!used[j] && are_matrices_equal(Gimp[i], Gimp[j])) {
57 current_group.push_back(j);
61 groups.push_back(std::move(current_group));
78 template <
typename Mesh>
79 block_gf<Mesh, matrix_valued>
symmetrize_gf(block_gf<Mesh, matrix_valued>
const &g, std::vector<std::vector<long>> deg_bls) {
81 auto const &mesh = gsymm[0].mesh();
83 for (
auto const °_bl : deg_bls) {
84 auto n_deg = deg_bl.size();
85 auto dim = g[deg_bl[0]].target_shape()[0];
87 auto gtmp = gf{mesh, {dim, dim}};
88 for (
auto bl : deg_bl) { gtmp += g[bl]; }
92 for (
auto bl : deg_bl) { gsymm[bl] = gtmp; }
103 template block_gf<imfreq, matrix_valued>
symmetrize_gf(block_gf<imfreq, matrix_valued>
const &g, std::vector<std::vector<long>> deg_bls);
104 template block_gf<imtime, matrix_valued>
symmetrize_gf(block_gf<imtime, matrix_valued>
const &g, std::vector<std::vector<long>> deg_bls);
105 template block_gf<dlr_imfreq, matrix_valued>
symmetrize_gf(block_gf<dlr_imfreq, matrix_valued>
const &g, std::vector<std::vector<long>> deg_bls);
106 template block_gf<dlr_imtime, matrix_valued>
symmetrize_gf(block_gf<dlr_imtime, matrix_valued>
const &g, std::vector<std::vector<long>> deg_bls);
block_gf< Mesh, matrix_valued > symmetrize_gf(block_gf< Mesh, matrix_valued > const &g, std::vector< std::vector< long > > deg_bls)
Symmetrize the blocks of a Green's function given a list of it's degenerate blocks.
std::vector< std::vector< long > > analyze_degenerate_blocks(block_gf< Mesh, matrix_valued > const &Gimp, double threshold=1.e-5)
Find the generate blocks of a block GF by analyzing or using the union-find algorithm.