Skip to content

Commit 67dfec7

Browse files
committed
Clang-format all source files
1 parent ba83a58 commit 67dfec7

21 files changed

+80
-89
lines changed

c++/triqs_ctseg-J/configuration.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ double K_overlap(std::vector<segment_t> const &seglist, tau_t const &tau, bool i
226226
// List of operators containing all colors.
227227
// Time are ordered in decreasing order, in agreement with the whole physic literature.
228228
std::vector<colored_ops_t> colored_ordered_ops(std::vector<std::vector<segment_t>> const &seglists) {
229-
int c = 0; // index of color
229+
int c = 0; // index of color
230230
std::vector<colored_ops_t> ops_list; // list of all the operators
231231
for (auto const &seglist : seglists) {
232232
for (auto const &s : seglist) {
@@ -275,7 +275,7 @@ std::ostream &operator<<(std::ostream &out, configuration_t const &config) {
275275

276276
std::ostream &operator<<(std::ostream &out, std::vector<colored_ops_t> const &col) {
277277
for (auto const &[i, co] : itertools::enumerate(col))
278-
out << "\n" << "i: " << i << ", tau: " << co.tau << ", color: " << co.color
279-
<< ", " << (co.is_cdag ? "cdag" : "c");
278+
out << "\n"
279+
<< "i: " << i << ", tau: " << co.tau << ", color: " << co.color << ", " << (co.is_cdag ? "cdag" : "c");
280280
return out;
281281
}

c++/triqs_ctseg-J/configuration.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
// ================= Data structures =================
1212

1313
// The configuration is made of n_color ordered lists of segments
14-
// and (if needed) a list of J_perp lines.
14+
// and (if needed) a list of J_perp lines.
1515

1616
// --------------- Segment -------------------
1717
//
1818
// A segment represents a couple (c, cdag), at given tau_t times in [0, beta]
19-
// Segment is cyclic if tau_c < tau_cdag, non-cyclic otherwise.
19+
// Segment is cyclic if tau_c < tau_cdag, non-cyclic otherwise.
2020
//
2121
// Some segments are aligned between 2 colors, corresponding to a S^+, S^- operators
2222
// The S operators will not be linked to Delta, the hybridization, but to Jperp lines.
23-
// The segment stores two booleans (J_c, J_cdag) that indicate whether its operators are
24-
// linked to J_perp lines.
23+
// The segment stores two booleans (J_c, J_cdag) that indicate whether its operators are
24+
// linked to J_perp lines.
2525
//
2626
// Special case : full lines.
2727
// When a line has no operator, we need to take into account 2 states : empty or full.
@@ -45,8 +45,8 @@ using vec_seg_iter_t = std::vector<segment_t>::const_iterator;
4545

4646
// ----------------- J_perp line -------------------
4747
// Stores the times of a couple (S+, S-)
48-
// Note: J_perp expansion only implemented for single orbital
49-
// (two colors, spin up and spin down).
48+
// Note: J_perp expansion only implemented for single orbital
49+
// (two colors, spin up and spin down).
5050
struct jperp_line_t {
5151
tau_t tau_Sminus, tau_Splus; // times of the S-, S+
5252
};
@@ -60,7 +60,7 @@ struct colored_ops_t {
6060
};
6161

6262
// --------------- Configuration ----------------------
63-
// The configuration is a list of of segments for each color,
63+
// The configuration is a list of of segments for each color,
6464
// and a list of J_perp lines.
6565
struct configuration_t {
6666
// A list of segments for each color.

c++/triqs_ctseg-J/dets.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using namespace triqs::mesh;
99

1010
/// A lambda to adapt Delta(tau) for the call by det_manip.
1111
struct delta_block_adaptor {
12-
gf<imtime, matrix_real_valued> delta;
12+
gf<imtime, matrix_real_valued> delta;
1313

1414
double operator()(std::pair<tau_t, int> const &x, std::pair<tau_t, int> const &y) const {
1515
double res = delta(double(x.first - y.first))(x.second, y.second);

c++/triqs_ctseg-J/invariants.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void check_segments(configuration_t const &config) {
2828

2929
void check_dets(configuration_t const &config, work_data_t const &wdata) {
3030
for (auto bl : range(wdata.dets.size())) {
31-
auto const &D = wdata.dets[bl];
31+
auto const &D = wdata.dets[bl];
3232
auto const n_orb = wdata.gf_struct[bl].second;
3333
// Times in det must be ordered
3434
if (D.size() != 0) {
@@ -47,21 +47,21 @@ void check_dets(configuration_t const &config, work_data_t const &wdata) {
4747
long det_index_c = 0, det_index_cdag = 0;
4848
for (auto const &seg : sl) {
4949
if (not seg.J_c and !is_full_line(seg)) {
50-
ALWAYS_EXPECTS(D.size() != 0, "Det error, block {}: there is a hybridized c but det is empty. Config: {}", bl,
51-
config);
50+
ALWAYS_EXPECTS(D.size() != 0, "Det error, block {}: there is a hybridized c but det is empty. Config: {}",
51+
bl, config);
5252
auto det_c_time = [&](long i) { return D.get_y(i).first; };
5353
det_index_c = lower_bound(det_c_time, D.size(), seg.tau_c);
5454
ALWAYS_EXPECTS(det_c_time(det_index_c) == seg.tau_c,
55-
"Det error, block {}: tau_c = {} is not in det! Config: {}", bl, seg.tau_c, config);
55+
"Det error, block {}: tau_c = {} is not in det! Config: {}", bl, seg.tau_c, config);
5656
++n_hyb_c;
5757
}
5858
if (not seg.J_cdag and !is_full_line(seg)) {
59-
ALWAYS_EXPECTS(D.size() != 0, "Det error, block {}: there is a hybridized cdag but det is empty. Config: {}",
60-
bl, config);
59+
ALWAYS_EXPECTS(D.size() != 0,
60+
"Det error, block {}: there is a hybridized cdag but det is empty. Config: {}", bl, config);
6161
auto det_cdag_time = [&](long i) { return D.get_x(i).first; };
6262
det_index_cdag = lower_bound(det_cdag_time, D.size(), seg.tau_cdag);
6363
ALWAYS_EXPECTS(det_cdag_time(det_index_cdag) == seg.tau_cdag,
64-
"Det error, block {}: tau_cdag = {} is not in det! Config: {}", bl, seg.tau_cdag, config);
64+
"Det error, block {}: tau_cdag = {} is not in det! Config: {}", bl, seg.tau_cdag, config);
6565
++n_hyb_cdag;
6666
}
6767
}

c++/triqs_ctseg-J/logs.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static constexpr bool ctseg_debug = false;
1111
#ifdef PRINT_LOGS
1212
static constexpr bool print_logs = true;
1313
#else
14-
static constexpr bool print_logs = false;
14+
static constexpr bool print_logs = false;
1515
#endif
1616

1717
#include <fmt/format.h>

c++/triqs_ctseg-J/measures/g_f_tau.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace measures {
4040
auto val = (y.first >= x.first ? s : -s) * Minv;
4141
auto dtau = double(y.first - x.first);
4242
g[closest_mesh_pt(dtau)](y.second, x.second) += val;
43-
if (measure_ft) f[closest_mesh_pt(dtau)](y.second, x.second) += val * f_fact;
43+
if (measure_ft) f[closest_mesh_pt(dtau)](y.second, x.second) += val * f_fact;
4444
}
4545
}
4646
}

c++/triqs_ctseg-J/measures/perturbation_order_histo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ namespace measures {
77
configuration_t const &config, results_t &results)
88
: wdata{wdata}, config{config}, results{results} {
99

10-
histo_delta = triqs::stat::histogram{0, p.histogram_max_order};
11-
histo_Jperp = triqs::stat::histogram{0, p.histogram_max_order};
10+
histo_delta = triqs::stat::histogram{0, p.histogram_max_order};
11+
histo_Jperp = triqs::stat::histogram{0, p.histogram_max_order};
1212
}
1313

1414
// -------------------------------------

c++/triqs_ctseg-J/measures/sign.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ namespace measures {
77
sign::sign(params_t const &, work_data_t const &wdata, configuration_t const &config, results_t &results)
88
: wdata{wdata}, config{config}, results{results} {
99
Z = 0.0;
10-
N = 0.0;
10+
N = 0.0;
1111
}
1212

1313
// -------------------------------------
1414

1515
void sign::accumulate(double s) {
1616
Z += s;
17-
N += 1.0;
17+
N += 1.0;
1818
}
1919

2020
// -------------------------------------
2121

2222
void sign::collect_results(mpi::communicator const &c) {
23-
Z = mpi::all_reduce(Z, c);
24-
N = mpi::all_reduce(N, c);
23+
Z = mpi::all_reduce(Z, c);
24+
N = mpi::all_reduce(N, c);
2525
results.sign = Z / N;
2626
}
2727
} // namespace measures

c++/triqs_ctseg-J/measures/sign.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace measures {
1111
configuration_t const &config;
1212
results_t &results;
1313

14-
double N = 0;
14+
double N = 0;
1515
double Z = 0;
1616

1717
sign(params_t const &params, work_data_t const &wdata, configuration_t const &config, results_t &results);

c++/triqs_ctseg-J/measures/state_hist.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace measures {
66
state_hist::state_hist(params_t const &p, work_data_t const &wdata, configuration_t const &config, results_t &results)
77
: wdata{wdata}, config{config}, results{results} {
88

9-
beta = p.beta;
10-
H = nda::zeros<double>(ipow(2, config.n_color()));
9+
beta = p.beta;
10+
H = nda::zeros<double>(ipow(2, config.n_color()));
1111
}
1212

1313
// -------------------------------------
@@ -26,19 +26,19 @@ namespace measures {
2626
*
2727
* - the length of the histogram is 2^n_colors
2828
*/
29-
29+
3030
Z += s;
3131

32-
double tau_prev = beta; // time of prevous operator; start with beta
32+
double tau_prev = beta; // time of prevous operator; start with beta
3333
nda::vector<bool> state = nda::zeros<bool>(config.n_color());
3434
for (auto const &op : colored_ordered_ops(config.seglists)) {
35-
int state_idx = 0;
36-
for (auto c : range(config.n_color()))
37-
if (state(c)) state_idx += ipow(2, c); // get the index of the impurity state
38-
H(state_idx) += (tau_prev - op.tau);
39-
tau_prev = (double)op.tau;
40-
ALWAYS_EXPECTS((state(op.color) == op.is_cdag), "Operator error at color {}", op.color);
41-
state(op.color) = !op.is_cdag;
35+
int state_idx = 0;
36+
for (auto c : range(config.n_color()))
37+
if (state(c)) state_idx += ipow(2, c); // get the index of the impurity state
38+
H(state_idx) += (tau_prev - op.tau);
39+
tau_prev = (double)op.tau;
40+
ALWAYS_EXPECTS((state(op.color) == op.is_cdag), "Operator error at color {}", op.color);
41+
state(op.color) = !op.is_cdag;
4242
}
4343

4444
// get edge state contribution; tau_prev has time of last operator

c++/triqs_ctseg-J/params.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ void h5_write(h5::group h5group, std::string subgroup_name, solve_params_t const
6262
h5_write(grp, "det_precision_error", c.det_precision_error);
6363
h5_write(grp, "det_singular_threshold", c.det_singular_threshold);
6464
h5_write(grp, "histogram_max_order", c.histogram_max_order);
65-
6665
}
6766

6867
//------------------------------------
@@ -105,6 +104,4 @@ void h5_read(h5::group h5group, std::string subgroup_name, solve_params_t &c) {
105104
h5_read(grp, "det_precision_error", c.det_precision_error);
106105
h5_read(grp, "det_singular_threshold", c.det_singular_threshold);
107106
h5_read(grp, "histogram_max_order", c.histogram_max_order);
108-
109107
}
110-

c++/triqs_ctseg-J/params.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ struct solve_params_t {
131131
/// Bound for the determinant matrix being singular, abs(det) > singular_threshold. If <0, it is !isnormal(abs(det))
132132
double det_singular_threshold = -1;
133133

134-
/// Maximum order for the perturbation order histograms
135-
int histogram_max_order = 1000;
134+
/// Maximum order for the perturbation order histograms
135+
int histogram_max_order = 1000;
136136
};
137137

138138
/// A struct combining both constr_params_t and solve_params_t

c++/triqs_ctseg-J/results.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ struct results_t {
1414
/// Self-energy improved estimator :math:`F(\tau)`.
1515
std::optional<block_gf<imtime>> F_tau;
1616

17-
/// Density-density time correlation function :math:`\langle n_a(\tau) n_b(0) \rangle`.
17+
/// Density-density time correlation function :math:`\langle n_a(\tau) n_b(0) \rangle`.
1818
std::optional<gf<imtime>> nn_tau;
1919

2020
/// Perpendicular spin-spin correlation function :math:`\langle s_x(\tau) s_x(0) \rangle`.
2121
std::optional<gf<imtime>> sperp_tau;
2222

23-
/// Density-density static correlation function :math:`\langle n_a(0) n_b(0) \rangle`.
23+
/// Density-density static correlation function :math:`\langle n_a(0) n_b(0) \rangle`.
2424
std::optional<nda::matrix<double>> nn_static;
2525

26-
/// Density per color.
26+
/// Density per color.
2727
nda::array<double, 1> densities;
2828

2929
/// Delta perturbation order histogram
@@ -35,7 +35,7 @@ struct results_t {
3535
/// State histogram
3636
std::optional<nda::vector<double>> state_hist;
3737

38-
/// Average sign
38+
/// Average sign
3939
double sign;
4040
};
4141

c++/triqs_ctseg-J/solver_core.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,10 @@ void solver_core::solve(solve_params_t const &solve_params) {
4646

4747
// Initialize work data
4848
work_data_t wdata{p, inputs, c};
49-
// Initialize configuration
49+
// Initialize configuration
5050
configuration_t config{wdata.n_color};
5151
// Start from a non-empty configuration when Delta(tau) = 0
52-
if (not wdata.has_delta) {
53-
config.seglists[0].push_back(segment_t::full_line());
54-
}
52+
if (not wdata.has_delta) { config.seglists[0].push_back(segment_t::full_line()); }
5553

5654
// ................ QMC ...................
5755

c++/triqs_ctseg-J/solver_core.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ class solver_core {
2525
/// Solver solve parameters (from last call)
2626
std::optional<solve_params_t> last_solve_params;
2727

28-
/// The set of results
28+
/// The set of results
2929
// Will be passed to measures and initialized by them.
3030
results_t results;
3131

3232
/// Initialize the solver
3333
CPP2PY_ARG_AS_DICT solver_core(constr_params_t const &p);
3434

35-
/// Solve the impurity problem
35+
/// Solve the impurity problem
3636
CPP2PY_ARG_AS_DICT void solve(solve_params_t const &p);
3737

3838
// Green's function views for Python interface

c++/triqs_ctseg-J/util.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
inline long modulo(long i, long N) { return (i + N)%N;}
3+
inline long modulo(long i, long N) { return (i + N) % N; }
44

55
// Same as std::lower_bound, but i-th element of vector is returned by f[i]
66
// f is called on 0:N strictly
@@ -28,6 +28,4 @@ long det_lower_bound_y(auto const &d, auto const &y) {
2828
}
2929

3030
// Integer power
31-
constexpr unsigned int ipow(unsigned int n, unsigned int m) {
32-
return m == 0 ? 1 : m == 1 ? n : n * ipow(n, m - 1);
33-
}
31+
constexpr unsigned int ipow(unsigned int n, unsigned int m) { return m == 0 ? 1 : m == 1 ? n : n * ipow(n, m - 1); }

c++/triqs_ctseg-J/work_data.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ work_data_t::work_data_t(params_t const &p, inputs_t const &inputs, mpi::communi
131131
// Is there a non-zero Delta(tau)?
132132
for (auto const &bl : range(inputs.delta.size())) {
133133
if (max_element(abs(inputs.delta[bl].data())) > 1.e-13) has_delta = true;
134-
// Report if Delta(tau) has imaginary part.
134+
// Report if Delta(tau) has imaginary part.
135135
if (!is_gf_real(inputs.delta[bl], 1e-10)) {
136136
if (c.rank() == 0) {
137137
spdlog::info("WARNING: The Delta(tau) block number {} is not real in tau space", bl);
@@ -187,10 +187,10 @@ double trace_sign(work_data_t const &wdata) {
187187
// For every block, we compute the sign of the permutation that takes
188188
// [(c c_dag) (c c_dag) (c c_dag) ...] with the cdag and c in increasing time order
189189
// (the reference order of the det) to the decreasing-time-and-color-ordered list
190-
// of operators (the order that makes the trace positive).
191-
// This is equivalent to computing the sign of the permutation that takes
190+
// of operators (the order that makes the trace positive).
191+
// This is equivalent to computing the sign of the permutation that takes
192192
// [(c_dag c) (c_dag c) (c_dag c) ...] with the cdag and c in increasing time order
193-
// to the increasing time-and-color-ordered list of operators.
193+
// to the increasing time-and-color-ordered list of operators.
194194
for (auto bl : range(dets.size())) {
195195
auto s = long(dets[bl].size());
196196
auto n_colors_in_bl = wdata.gf_struct[bl].second;
@@ -250,9 +250,9 @@ double trace_sign(work_data_t const &wdata) {
250250
} // if color == k
251251
idx_c--;
252252
} // loop over c
253-
} // loop over colors
254-
} // if block not empty
255-
} // loop over blocks
253+
} // loop over colors
254+
} // if block not empty
255+
} // loop over blocks
256256
return sign;
257257
} // sign computation
258258

test/c++/dynamical_U.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ TEST(CTSEGJ, Dynamical_U) {
5757
auto D0w = gf<imfreq>({beta, Boson, n_iw}, {1, 1});
5858
auto D0t = gf<imtime>({beta, Boson, param_constructor.n_tau}, {1, 1});
5959
D0w(om_) << 2 * l * l * w0 / (om_ * om_ - w0 * w0);
60-
D0t() = fourier(D0w);
60+
D0t() = fourier(D0w);
6161
Solver.D0_tau().data()(range::all, 0, 0) = D0t.data()(range::all, 0, 0);
6262
Solver.D0_tau().data()(range::all, 0, 1) = D0t.data()(range::all, 0, 0);
6363
Solver.D0_tau().data()(range::all, 1, 0) = D0t.data()(range::all, 0, 0);

0 commit comments

Comments
 (0)