Skip to content

Commit

Permalink
Replace std::endl with \n
Browse files Browse the repository at this point in the history
  • Loading branch information
krivenko committed Aug 24, 2024
1 parent 9a3cee3 commit 47cd84e
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 158 deletions.
2 changes: 1 addition & 1 deletion c++/som/cache_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void cache_index::extend() {
std::size_t new_cap = cap + CACHE_SIZE;
#ifdef EXT_DEBUG
std::cerr << "Extending LHS cache from " << cap << " to " << new_cap
<< " entries." << std::endl;
<< " entries.\n";
#endif
entries.reserve(new_cap);
for(std::size_t id = cap; id < new_cap; ++id) {
Expand Down
15 changes: 7 additions & 8 deletions c++/som/elementary_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ template <typename KernelType> double elementary_update<KernelType>::accept() {
update[opt].reset();

#ifdef EXT_DEBUG
std::cerr << "* Elementary update accepted" << std::endl;
std::cerr << "* Elementary update accepted\n";
std::cerr << "Temporary configuration: size = " << data.temp_conf.size()
<< ", norm = " << data.temp_conf.norm()
<< ", χ = " << std::sqrt(data.temp_objf_value) << std::endl;
<< ", χ = " << std::sqrt(data.temp_objf_value) << '\n';
using triqs::utility::is_zero;
if(!is_zero(data.temp_conf.norm() - data.global_conf.norm(), 1e-10))
TRIQS_RUNTIME_ERROR
Expand All @@ -176,16 +176,15 @@ template <typename KernelType> double elementary_update<KernelType>::accept() {
#ifdef EXT_DEBUG
std::cerr << "Copying temporary configuration to global configuration "
<< "(χ(temp) = " << std::sqrt(data.temp_objf_value)
<< ", χ(global) = " << std::sqrt(data.global_objf_value) << ")"
<< std::endl;
<< ", χ(global) = " << std::sqrt(data.global_objf_value) << ")\n";
#endif
data.global_conf = data.temp_conf;
kern.cache_copy(data.temp_conf, data.global_conf);
data.global_objf_value = data.temp_objf_value;
}

#ifdef EXT_DEBUG
std::cerr << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
std::cerr << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n";
#endif

// Update internal state of the distribution function
Expand All @@ -198,11 +197,11 @@ template <typename KernelType> double elementary_update<KernelType>::accept() {
template <typename KernelType> void elementary_update<KernelType>::reject() {

#ifdef EXT_DEBUG
std::cerr << "* Elementary update rejected" << std::endl;
std::cerr << "* Elementary update rejected\n";
std::cerr << "Temporary configuration: size = " << data.temp_conf.size()
<< ", norm = " << data.temp_conf.norm()
<< ", χ = " << std::sqrt(data.temp_objf_value) << std::endl;
std::cerr << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
<< ", χ = " << std::sqrt(data.temp_objf_value) << '\n';
std::cerr << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n";
#endif

// Reset all considered updates
Expand Down
23 changes: 11 additions & 12 deletions c++/som/solution_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ solution_worker<KernelType>::operator()(configuration const& init_config) {

#ifdef EXT_DEBUG
std::cerr << "solution_worker: using initial configuration (size = "
<< conf.size() << ", norm = " << conf.norm() << "):" << std::endl;
std::cerr << conf << std::endl;
<< conf.size() << ", norm = " << conf.norm() << "):\n";
std::cerr << conf << '\n';
#endif

run(conf);
Expand All @@ -220,8 +220,7 @@ configuration solution_worker<KernelType>::operator()(int init_config_size) {
#ifdef EXT_DEBUG
std::cerr
<< "solution_worker: using a randomly generated initial configuration "
<< "(size = " << init_config_size << ", norm = " << norm << ")"
<< std::endl;
<< "(size = " << init_config_size << ", norm = " << norm << ")\n";
#endif

auto& rng = mc.get_rng(); // cppcheck-suppress constVariableReference
Expand All @@ -240,8 +239,8 @@ configuration solution_worker<KernelType>::operator()(int init_config_size) {

#ifdef EXT_DEBUG
std::cerr << "Generated configuration (size = " << conf.size()
<< ", norm = " << conf.norm() << "):" << std::endl;
std::cerr << conf << std::endl;
<< ", norm = " << conf.norm() << "):\n";
std::cerr << conf << '\n';

#ifndef NDEBUG
for(auto const& r : conf) assert(r.norm() >= weight_min);
Expand All @@ -256,7 +255,7 @@ template <typename KernelType>
void solution_worker<KernelType>::run(configuration& conf) {

#ifdef EXT_DEBUG
std::cerr << "solution_worker: starting simulation ..." << std::endl;
std::cerr << "solution_worker: starting simulation ...\n";
#endif

using std::swap;
Expand All @@ -280,17 +279,17 @@ void solution_worker<KernelType>::run(configuration& conf) {
mc.collect_results(MPI_COMM_SELF);
if(cc_update) {
std::cout << "Times update_consistent_constraints has been proposed: "
<< cc_update->get_n_proposed() << std::endl;
<< cc_update->get_n_proposed() << '\n';
std::cout << "Acceptance rate for update_consistent_constraints: "
<< cc_update->get_acceptance_rate() << std::endl;
<< cc_update->get_acceptance_rate() << '\n';
}
}

// Stopped prematurely
if(res_code) throw(stopped(res_code));

#ifdef EXT_DEBUG
std::cerr << "solution_worker: simulation ended." << std::endl;
std::cerr << "solution_worker: simulation ended.\n";
#endif
}

Expand All @@ -304,8 +303,8 @@ void solution_worker<KernelType>::reset_temp_conf() {

#ifdef EXT_DEBUG
std::cerr << "Temporary configuration reset to (χ = "
<< std::sqrt(data.temp_objf_value) << ")" << std::endl;
std::cerr << data.temp_conf << std::endl;
<< std::sqrt(data.temp_objf_value) << ")\n";
std::cerr << data.temp_conf << '\n';
#endif

data.Z.reset();
Expand Down
32 changes: 14 additions & 18 deletions c++/som/som_core/accumulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ template <typename KernelType> void som_core::accumulate_impl() {
auto const& m = std::get<typename KernelType::mesh_type>(mesh);

if(params.verbosity > 0) {
mpi_cout(comm) << "Constructing integral kernel... " << std::endl;
mpi_cout(comm) << "Constructing integral kernel... \n";
}
KernelType kernel(m);
if(params.verbosity > 0) {
mpi_cout(comm) << "Constructed kernel: " << kernel << std::endl;
mpi_cout(comm) << "Constructed kernel: " << kernel << '\n';
}

// Find solution for each component of GF
Expand All @@ -113,13 +113,13 @@ template <typename KernelType> void som_core::accumulate_impl() {
if(params.verbosity > 0)
mpi_cout(comm)
<< "Accumulating particular solutions for observable component [" << n
<< "," << n << "]" << std::endl;
<< "," << n << "]\n";

auto of = d.make_objf(kernel);
if(params.verbosity >= 2 && of.get_U_dagger()) {
mpi_cout(comm) << "Supplied covariance matrix has " +
std::to_string(of.get_sigma2().size())
<< " positive eigenvalues" << std::endl;
<< " positive eigenvalues\n";
}

solution_worker<KernelType> worker(
Expand All @@ -140,8 +140,7 @@ template <typename KernelType> void som_core::accumulate_impl() {
if(n_sol_max > params.adjust_l_range.second) {
if(params.verbosity >= 1)
mpi_cout(comm)
<< "WARNING: Upper bound of adjust_l_range has been reached"
<< std::endl;
<< "WARNING: Upper bound of adjust_l_range has been reached\n";
break;
}
} else
Expand All @@ -153,17 +152,17 @@ template <typename KernelType> void som_core::accumulate_impl() {
if(params.adjust_l) {
mpi_cout(comm) << "Increasing the total number of solutions to be "
"accumulated to "
<< n_sol_max << std::endl;
<< n_sol_max << '\n';
} else {
mpi_cout(comm) << "Accumulating a total of " << n_sol_max
<< " solutions" << std::endl;
<< " solutions\n";
}
}

for(; (n_sol = comm.rank() + i * comm.size()) < n_sol_max; ++i) {
if(params.verbosity >= 2) {
mpi_cout(comm) << "Accumulation of particular solution " << n_sol
<< std::endl;
<< '\n';
}

d.particular_solutions.emplace_back(worker(1 + rng(params.max_rects)),
Expand All @@ -175,7 +174,7 @@ template <typename KernelType> void som_core::accumulate_impl() {

if(params.verbosity >= 2) {
mpi_cout(comm) << "Solution " << n_sol << ": χ = " << std::sqrt(chi2)
<< std::endl;
<< '\n';
}
}
comm.barrier(0);
Expand All @@ -197,14 +196,14 @@ template <typename KernelType> void som_core::accumulate_impl() {
n_verygood_solutions = mpi::all_reduce(n_verygood_solutions, comm);

if(params.verbosity >= 1) {
mpi_cout(comm) << "χ_{min} = " << chi_min << std::endl;
mpi_cout(comm) << "χ_{min} = " << chi_min << '\n';
if(params.adjust_l) {
mpi_cout(comm) << "Number of good solutions (χ / χ_{min} ≤ "
<< params.adjust_l_good_chi
<< ") = " << n_good_solutions << std::endl;
<< ") = " << n_good_solutions << '\n';
mpi_cout(comm) << "Number of very good solutions (χ / χ_{min} ≤ "
<< params.adjust_l_verygood_chi
<< ") = " << n_verygood_solutions << std::endl;
<< ") = " << n_verygood_solutions << '\n';
}
}

Expand All @@ -224,17 +223,14 @@ template <typename KernelType> void som_core::accumulate_impl() {
h = mpi::all_reduce(h, comm);
}

if(params.verbosity >= 1) {
mpi_cout(comm) << "Accumulation completed" << std::endl;
}
if(params.verbosity >= 1) { mpi_cout(comm) << "Accumulation completed\n"; }
}

ci.invalidate_all();

if(params.verbosity >= 1)
mpi_cout(comm)
<< "Accumulation for all observable components has been completed"
<< std::endl;
<< "Accumulation for all observable components has been completed\n";
}

void som_core::accumulate(accumulate_parameters_t const& p) {
Expand Down
19 changes: 9 additions & 10 deletions c++/som/som_core/adjust_f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ int som_core::adjust_f_impl(adjust_f_parameters_t const& p) {
auto stop_callback = triqs::utility::clock_callback(p.max_time);

if(p.verbosity > 0) {
mpi_cout(comm) << "Constructing integral kernel... " << std::endl;
mpi_cout(comm) << "Constructing integral kernel... \n";
}
KernelType kernel(m);
if(p.verbosity > 0) {
mpi_cout(comm) << "Constructed kernel: " << kernel << std::endl;
mpi_cout(comm) << "Constructed kernel: " << kernel << '\n';
}

// Find solution for each component of GF
Expand All @@ -86,7 +86,7 @@ int som_core::adjust_f_impl(adjust_f_parameters_t const& p) {

if(p.verbosity > 0)
mpi_cout(comm) << "Running algorithm for observable component [" << n
<< "," << n << "]" << std::endl;
<< "," << n << "]\n";

auto of = d.make_objf<KernelType>(kernel);
if(of.get_U_dagger())
Expand All @@ -111,7 +111,7 @@ int som_core::adjust_f_impl(adjust_f_parameters_t const& p) {
<< "WARNING: Upper bound of f_range has been reached,"
" will use F = " +
std::to_string(F)
<< std::endl;
<< '\n';
break;
}

Expand All @@ -123,7 +123,7 @@ int som_core::adjust_f_impl(adjust_f_parameters_t const& p) {
for(int i = 0; (n_sol = comm.rank() + i * comm.size()) < p.l; ++i) {
if(p.verbosity >= 2) {
mpi_cout(comm) << "Accumulation of particular solution " << n_sol
<< std::endl;
<< '\n';
}

auto solution = worker(1 + rng(params.max_rects));
Expand All @@ -135,7 +135,7 @@ int som_core::adjust_f_impl(adjust_f_parameters_t const& p) {
<< (kappa > p.kappa ? "" : "not ") << R"(good (κ = )"
<< kappa
<< ", χ = " << std::sqrt(worker.get_objf_value())
<< ")." << std::endl;
<< ").\n";
}
}
comm.barrier(0);
Expand All @@ -144,12 +144,11 @@ int som_core::adjust_f_impl(adjust_f_parameters_t const& p) {
if(p.verbosity >= 1)
mpi_cout(comm) << "F = " << F << ", " << l_good
<< R"( solutions with κ > )" << p.kappa << " (out of "
<< p.l << ")" << std::endl;
<< p.l << ")\n";

// Converged
if(l_good > p.l / 2) {
if(p.verbosity >= 1)
mpi_cout(comm) << "F = " << F << " is enough." << std::endl;
if(p.verbosity >= 1) mpi_cout(comm) << "F = " << F << " is enough.\n";
break;
}
}
Expand All @@ -170,7 +169,7 @@ int som_core::adjust_f(adjust_f_parameters_t const& p) {

if(p.verbosity >= 1) {
mpi_cout(comm) << "Adjusting the number of global updates F using " << p.l
<< " particular solutions ..." << std::endl;
<< " particular solutions ...\n";
}

#define IMPL_CASE(r, okmk) \
Expand Down
Loading

0 comments on commit 47cd84e

Please sign in to comment.