Skip to content

Commit 44980ef

Browse files
committed
fix some bugs
1 parent c76747f commit 44980ef

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

c++/triqs_ctseg/measures/four_point.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ namespace triqs_ctseg::measures {
2929

3030
auto g3w_vec = [&]() {
3131
std::vector<gf<prod<imfreq, imfreq, imfreq>, tensor_valued<4>>> green_v;
32-
for (auto const &[bl1_name, bl1_size] : p.gf_struct)
33-
for (auto const &[bl2_name, bl2_size] : p.gf_struct)
32+
for (auto const &[bl1_name, bl1_size] : wdata.gf_struct)
33+
for (auto const &[bl2_name, bl2_size] : wdata.gf_struct)
3434
green_v.emplace_back(gf<prod<imfreq, imfreq, imfreq>, tensor_valued<4>>(
3535
{{beta, Fermion, p.n_iw_chi4_f, imfreq::option::all_frequencies},
3636
{beta, Fermion, p.n_iw_chi4_f, imfreq::option::all_frequencies},
@@ -40,30 +40,26 @@ namespace triqs_ctseg::measures {
4040
};
4141

4242
std::vector<std::string> block_names;
43-
for (auto const &[bl_name, bl_size] : p.gf_struct) block_names.push_back(bl_name);
43+
for (auto const &[bl_name, bl_size] : wdata.gf_struct) block_names.push_back(bl_name);
4444
auto bosonic_block_names = std::vector<std::string>{};
4545
for (auto const &str1 : block_names)
4646
for (auto const &str2 : block_names)
4747
bosonic_block_names.push_back(str1 + "|" + str2);
4848

4949
g3w = make_block_gf<prod<imfreq, imfreq, imfreq>, tensor_valued<4>>(bosonic_block_names, g3w_vec());
5050
f3w = make_block_gf<prod<imfreq, imfreq, imfreq>, tensor_valued<4>>(bosonic_block_names, g3w_vec());
51-
52-
for (auto &g : g3w)
53-
g() = 0;
54-
for (auto &f : f3w)
55-
f() = 0;
5651

5752
LOG("\n ====================== COMPUTING M-MATRIX ====================== \n");
58-
if (measure_g3w) Mw_vector = compute_Mw(false);
59-
if (measure_f3w) nMw_vector = compute_Mw(true);
6053

6154
n_w_fermionic = std::get<0>(g3w[0].mesh().components()).last_index() + 1;
6255
n_w_bosonic = std::get<2>(g3w[0].mesh().components()).last_index() + 1;
6356

6457
w_ini = (2 * (-n_w_fermionic) + 1) * M_PI / beta;
6558
w_inc = 2 * M_PI / beta;
6659

60+
Mw_vector = compute_Mw(false);
61+
if (measure_f3w) nMw_vector = compute_Mw(true);
62+
6763
}
6864

6965
// -------------------------------------
@@ -106,7 +102,7 @@ namespace triqs_ctseg::measures {
106102
for (int m = 0; m < n_w_bosonic; m++) {
107103
int n2 = n1 + m;
108104
int n3 = n4 + m;
109-
g3w[bl](n1, n4, m)(a, b, c, d) += s * Mw(b1, a, b, n1, n2) * Mw(b2, c, d, n3, n4);
105+
g3w[bl](n1, n4, m)(a, b, c, d) = s * Mw(b1, a, b, n1, n2) * Mw(b2, c, d, n3, n4);
110106
if (b1 == b2)
111107
g3w[bl](n1, n4, m)(a, b, c, d) -= s * Mw(b1, a, d, n1, n4) * Mw(b2, c, b, n3, n2);
112108
} // m
@@ -132,7 +128,7 @@ namespace triqs_ctseg::measures {
132128
for (int m = 0; m < n_w_bosonic; m++) {
133129
int n2 = n1 + m;
134130
int n3 = n4 + m;
135-
f3w[bl](n1, n4, m)(a, b, c, d) += s * nMw(b1, a, b, n1, n2) * Mw(b2, c, d, n3, n4);
131+
f3w[bl](n1, n4, m)(a, b, c, d) = s * nMw(b1, a, b, n1, n2) * Mw(b2, c, d, n3, n4);
136132
if (b1 == b2)
137133
f3w[bl](n1, n4, m)(a, b, c, d) -= s * nMw(b1, a, d, n1, n4) * Mw(b2, c, b, n3, n2);
138134
} // m
@@ -143,7 +139,7 @@ namespace triqs_ctseg::measures {
143139
} // b
144140
} // a
145141
} // bl
146-
}
142+
} // measure_f3w
147143

148144
}
149145

@@ -169,6 +165,7 @@ namespace triqs_ctseg::measures {
169165

170166
double four_point::fprefactor(long const &block, std::pair<tau_t, long> const &y) {
171167

168+
// Copied from G_F_tau.cpp
172169
int color = wdata.block_to_color(block, y.second);
173170
double I_tau = 0;
174171
for (auto const &[c, sl] : itertools::enumerate(config.seglists)) {
@@ -189,9 +186,10 @@ namespace triqs_ctseg::measures {
189186

190187
// -------------------------------------
191188

192-
vector<array<dcomplex, 4>> four_point::compute_Mw(bool is_nMw) {
189+
std::vector<array<dcomplex, 4>> four_point::compute_Mw(bool is_nMw) {
190+
193191
int n_w_aux = 2 * n_w_fermionic + n_w_bosonic > 1 ? 2 * n_w_fermionic + n_w_bosonic - 1 : 0;
194-
vector<array<dcomplex, 4>> result;
192+
std::vector<array<dcomplex, 4>> result;
195193
result.resize(wdata.gf_struct.size());
196194

197195
for (auto const &[bl, bl_pair] : itertools::enumerate(wdata.gf_struct)) {
@@ -241,8 +239,8 @@ namespace triqs_ctseg::measures {
241239
}
242240
}
243241
}
244-
245242
return result;
243+
246244
}
247245

248246
} // namespace triqs_ctseg::measures

c++/triqs_ctseg/measures/four_point.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ namespace triqs_ctseg::measures {
3333
bool measure_f3w;
3434
int n_w_fermionic;
3535
int n_w_bosonic;
36-
vector<array<dcomplex, 4>> Mw_vector;
37-
vector<array<dcomplex, 4>> nMw_vector;
36+
std::vector<array<dcomplex, 4>> Mw_vector, nMw_vector;
3837
vector<dcomplex> y_exp_ini, y_exp_inc, x_exp_ini, x_exp_inc;
3938
vector<int> y_inner_index, x_inner_index;
4039

@@ -49,7 +48,7 @@ namespace triqs_ctseg::measures {
4948
void collect_results(mpi::communicator const &c);
5049
double fprefactor(long const &block, std::pair<tau_t, long> const &y);
5150

52-
vector<array<dcomplex, 4>> compute_Mw(bool is_nMw);
51+
std::vector<array<dcomplex, 4>> compute_Mw(bool is_nMw);
5352

5453
dcomplex Mw(long const &block, int const &i, int const &j, int const &n1, int const &n2) {
5554
return Mw_vector[block](i, j, n1 + n_w_fermionic, n2 + n_w_fermionic);

0 commit comments

Comments
 (0)