diff --git a/c++/som/cache_index.cpp b/c++/som/cache_index.cpp index e3b4ea8f8..bbd38d3cb 100644 --- a/c++/som/cache_index.cpp +++ b/c++/som/cache_index.cpp @@ -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) { diff --git a/c++/som/elementary_update.cpp b/c++/som/elementary_update.cpp index 993ec05e4..188cf28f5 100644 --- a/c++/som/elementary_update.cpp +++ b/c++/som/elementary_update.cpp @@ -149,10 +149,10 @@ template double elementary_update::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 @@ -176,8 +176,7 @@ template double elementary_update::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); @@ -185,7 +184,7 @@ template double elementary_update::accept() { } #ifdef EXT_DEBUG - std::cerr << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl; + std::cerr << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"; #endif // Update internal state of the distribution function @@ -198,11 +197,11 @@ template double elementary_update::accept() { template void elementary_update::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 diff --git a/c++/som/solution_worker.cpp b/c++/som/solution_worker.cpp index c36518a0b..e66399b3b 100644 --- a/c++/som/solution_worker.cpp +++ b/c++/som/solution_worker.cpp @@ -200,8 +200,8 @@ solution_worker::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); @@ -220,8 +220,7 @@ configuration solution_worker::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 @@ -240,8 +239,8 @@ configuration solution_worker::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); @@ -256,7 +255,7 @@ template void solution_worker::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; @@ -280,9 +279,9 @@ void solution_worker::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'; } } @@ -290,7 +289,7 @@ void solution_worker::run(configuration& conf) { 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 } @@ -304,8 +303,8 @@ void solution_worker::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(); diff --git a/c++/som/som_core/accumulate.cpp b/c++/som/som_core/accumulate.cpp index 59f292a57..8b5db7aac 100644 --- a/c++/som/som_core/accumulate.cpp +++ b/c++/som/som_core/accumulate.cpp @@ -99,11 +99,11 @@ template void som_core::accumulate_impl() { auto const& m = std::get(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 @@ -113,13 +113,13 @@ template 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 worker( @@ -140,8 +140,7 @@ template 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 @@ -153,17 +152,17 @@ template 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)), @@ -175,7 +174,7 @@ template void som_core::accumulate_impl() { if(params.verbosity >= 2) { mpi_cout(comm) << "Solution " << n_sol << ": χ = " << std::sqrt(chi2) - << std::endl; + << '\n'; } } comm.barrier(0); @@ -197,14 +196,14 @@ template 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'; } } @@ -224,17 +223,14 @@ template 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) { diff --git a/c++/som/som_core/adjust_f.cpp b/c++/som/som_core/adjust_f.cpp index e7c4ad65b..761bc3c65 100644 --- a/c++/som/som_core/adjust_f.cpp +++ b/c++/som/som_core/adjust_f.cpp @@ -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 @@ -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(kernel); if(of.get_U_dagger()) @@ -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; } @@ -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)); @@ -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); @@ -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; } } @@ -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) \ diff --git a/c++/som/som_core/final_solution.cpp b/c++/som/som_core/final_solution.cpp index 22693edd5..3917cebfd 100644 --- a/c++/som/som_core/final_solution.cpp +++ b/c++/som/som_core/final_solution.cpp @@ -97,7 +97,7 @@ std::vector som_core::compute_final_solution(double good_chi_rel, if(verbosity > 0) { mpi_cout(comm) << "Constructing the final solution " "for observable component [" - << n << "," << n << "]" << std::endl; + << n << "," << n << "]\n"; } auto& d = data[n]; @@ -109,7 +109,7 @@ std::vector som_core::compute_final_solution(double good_chi_rel, double const chi_min = std::sqrt(d.objf_min); double const chi_c = std::min(good_chi_abs, chi_min * good_chi_rel); if(verbosity > 0) { - mpi_cout(comm) << "Good solution threshold χ_c = " << chi_c << std::endl; + mpi_cout(comm) << "Good solution threshold χ_c = " << chi_c << '\n'; } for(auto const& s : d.particular_solutions) { @@ -131,8 +131,8 @@ std::vector som_core::compute_final_solution(double good_chi_rel, "values of good_chi_rel/good_chi_abs"; else { if(verbosity > 0) { - mpi_cout(comm) << "Selected " << n_good_solutions << " good solutions" - << std::endl; + mpi_cout(comm) << "Selected " << n_good_solutions + << " good solutions\n"; } } @@ -257,8 +257,7 @@ void update_O_mat(array& A_j_local_block, assert(first_dim(Ap_j_local_block) == J1); assert(first_dim(App_j_local_block) == J1); - if(verbose) - mpi_cout(comm) << " Updating matrix of quadratic form O" << std::endl; + if(verbose) mpi_cout(comm) << " Updating matrix of quadratic form O\n"; // A_j(e_k) block received from other ranks array A_j_remote_block; @@ -292,7 +291,7 @@ void update_O_mat(array& A_j_local_block, if(verbose) { mpi_cout(comm) << " Combining " << J1 << " solutions from rank " << j_block1 << " with " << J2 << " solutions from rank " - << j_block2 << std::endl; + << j_block2 << '\n'; } for(auto j1_local : range(J1)) { @@ -407,7 +406,7 @@ std::vector cc_protocol( for(; iter < p.max_iter; ++iter) { if(p.verbosity >= 1) mpi_cout(comm) << " Iteration " << (iter + 1) << " out of " << p.max_iter - << std::endl; + << '\n'; // Update matrix of the quadratic form update_O_mat(A_block, @@ -468,8 +467,7 @@ std::vector cc_protocol( mpi_cout(comm) << " Monitor function returned true, stopping iterations: " << sum_c_text << " = " << res.sum_abs << ", " << diff_c_text - << " / " << sum_c_text << " = " << res.diff_c_normalized - << std::endl; + << " / " << sum_c_text << " = " << res.diff_c_normalized << '\n'; } break; } @@ -479,21 +477,20 @@ std::vector cc_protocol( mpi_cout(comm) << " End of iteration " << (iter + 1) << ": " << sum_c_text << " = " << res.sum_abs << ", " << diff_c_text << " / " << sum_c_text << " = " - << res.diff_c_normalized << std::endl; + << res.diff_c_normalized << '\n'; } if(res.sum_abs > p.max_sum_abs_c) { if(p.verbosity >= 1) - mpi_cout(comm) - << "Failed to converge, " << sum_c_text << " = " << res.sum_abs - << " is too big. " - << "Consider decreasing der_penalty_coeff and/or der_penalty_init." - << std::endl; + mpi_cout(comm) << "Failed to converge, " << sum_c_text << " = " + << res.sum_abs << " is too big. " + << "Consider decreasing der_penalty_coeff and/or " + "der_penalty_init.\n"; break; } if(iter > 0 && (res.diff_c_normalized < convergence_tol)) { - if(p.verbosity >= 1) mpi_cout(comm) << "Convergence reached" << std::endl; + if(p.verbosity >= 1) mpi_cout(comm) << "Convergence reached\n"; break; } @@ -527,7 +524,7 @@ std::vector cc_protocol( } if(p.verbosity >= 1 && iter == p.max_iter) - mpi_cout(comm) << "Maximum number of iterations reached" << std::endl; + mpi_cout(comm) << "Maximum number of iterations reached\n"; return results; } @@ -551,7 +548,7 @@ std::vector som_core::compute_final_solution_cc_impl( if(p.verbosity > 0) mpi_cout(comm) << "Using CC protocol to construct the final solution " "for observable component [" - << n << "," << n << "]" << std::endl; + << n << "," << n << "]\n"; // Select good solutions std::vector good_solution_indices; @@ -560,7 +557,7 @@ std::vector som_core::compute_final_solution_cc_impl( double const chi_c = std::min(p.good_chi_abs, chi_min * p.good_chi_rel); if(p.verbosity > 0) { - mpi_cout(comm) << "Good solution threshold χ_c = " << chi_c << std::endl; + mpi_cout(comm) << "Good solution threshold χ_c = " << chi_c << '\n'; } auto is_good = [chi_c](double chi2) { return std::sqrt(chi2) <= chi_c; }; @@ -580,8 +577,7 @@ std::vector som_core::compute_final_solution_cc_impl( if(p.verbosity > 0) mpi_cout(comm) << "Selected " << good_solution_indices.size() << " good solutions on this rank and " - << index_map.size() << " good solutions in total" - << std::endl; + << index_map.size() << " good solutions in total\n"; } using mesh_t = typename KernelType::mesh_type; @@ -602,8 +598,7 @@ std::vector som_core::compute_final_solution_cc_impl( double convergence_tol = min_element(sqrt(of.get_sigma2()) / abs(rhs)); if(p.verbosity > 1) - mpi_cout(comm) << "Convergence tolerance is " << convergence_tol - << std::endl; + mpi_cout(comm) << "Convergence tolerance is " << convergence_tol << '\n'; // Compute coefficients c_j using CC optimization protocol auto results = cc_protocol(d.particular_solutions, @@ -637,7 +632,7 @@ std::vector som_core::compute_final_solution_cc_impl( if(p.verbosity >= 2) { mpi_cout(comm) << "Linear combination of particular solutions from iteration " - << res.iter << ": χ = " << std::sqrt(chi2) << std::endl; + << res.iter << ": χ = " << std::sqrt(chi2) << '\n'; } if(is_good(chi2)) { selected_iter = res.iter; @@ -658,11 +653,11 @@ std::vector som_core::compute_final_solution_cc_impl( mpi_cout(comm) << "Forming the resulting linear combination of particular solutions " "using coefficients from iteration " - << selected_iter << std::endl; + << selected_iter << '\n'; if(p.verbosity >= 2) mpi_cout(comm) << "Coefficients of the linear combination from iteration " - << selected_iter << ": " << *selected_c << std::endl; + << selected_iter << ": " << *selected_c << '\n'; } d.final_solution = sol; diff --git a/c++/som/update_cc.cpp b/c++/som/update_cc.cpp index 5cffe54eb..0c7655c20 100644 --- a/c++/som/update_cc.cpp +++ b/c++/som/update_cc.cpp @@ -133,8 +133,7 @@ void update_consistent_constraints::operator()() { std::cerr << "Maximum number of rectangles in non-overlapping configuration " << (2 * data.temp_conf.size() + 1) - << " would exceed max_rects = " << max_rects << ", rejecting" - << std::endl; + << " would exceed max_rects = " << max_rects << ", rejecting\n"; #endif return; } @@ -152,8 +151,8 @@ template double update_consistent_constraints::attempt() { #ifdef EXT_DEBUG - std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; - std::cerr << "* Proposing CC update" << std::endl; + std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; + std::cerr << "* Proposing CC update\n"; #endif proposed_conf = make_nonoverlapping(data.temp_conf, energy_window, width_min); @@ -162,17 +161,15 @@ double update_consistent_constraints::attempt() { #ifdef EXT_DEBUG std::cerr << proposed_conf.size() << " rectangles in the proposed configuration are too few " - "to apply the regularization functional, rejecting" - << std::endl; + "to apply the regularization functional, rejecting\n"; #endif return 0; } #ifdef EXT_DEBUG std::cerr << "Optimizing heights of rectangles in non-overlapping " - "configuration " - << std::endl - << proposed_conf << std::endl; + "configuration \n" + << proposed_conf << '\n'; #endif auto K = long(proposed_conf.size()); @@ -195,7 +192,7 @@ double update_consistent_constraints::attempt() { #ifdef EXT_DEBUG std::cerr << "CC optimization procedure produced a rectangle with a " "significantly negative weight, rejecting (rectangle norm = " - << rect_norm << ")" << std::endl; + << rect_norm << ")\n"; #endif return 0; } @@ -209,7 +206,7 @@ double update_consistent_constraints::attempt() { #ifdef EXT_DEBUG std::cerr << "Final non-overlapping configuration: size = " << proposed_conf.size() << ", norm = " << norm - << ", χ = " << std::sqrt(new_objf_value) << std::endl; + << ", χ = " << std::sqrt(new_objf_value) << '\n'; #endif return new_objf_value < data.temp_objf_value @@ -227,10 +224,10 @@ double update_consistent_constraints::accept() { data.temp_objf_value = new_objf_value; #ifdef EXT_DEBUG - std::cerr << "* CC update accepted" << std::endl; + std::cerr << "* CC 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'; for(auto& r : data.temp_conf) { if(r.norm() < weight_min) @@ -249,8 +246,7 @@ double update_consistent_constraints::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); @@ -258,7 +254,7 @@ double update_consistent_constraints::accept() { } #ifdef EXT_DEBUG - std::cerr << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl; + std::cerr << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"; #endif // Update internal state of the distribution function @@ -271,11 +267,11 @@ template void update_consistent_constraints::reject() { #ifdef EXT_DEBUG - std::cerr << "* CC update rejected" << std::endl; + std::cerr << "* CC 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 // Update internal state of the distribution function @@ -418,7 +414,7 @@ void update_consistent_constraints::optimize_heights() { heights(r_K)); } catch(triqs::runtime_error&) { #ifdef EXT_DEBUG - std::cerr << "Cholesky factorization has failed" << std::endl; + std::cerr << "Cholesky factorization has failed\n"; #endif break; } @@ -434,7 +430,7 @@ void update_consistent_constraints::optimize_heights() { std::cerr << " Iteration " << (iter + 1) << " out of " << max_iter << ": " << "sum(|Δnorm_k|) / norm = " << norm_diff_max - << ", χ^2 = " << chi2 << ", O/χ^2 = " << (O / chi2) << std::endl; + << ", χ^2 = " << chi2 << ", O/χ^2 = " << (O / chi2) << '\n'; #endif if(norm_diff_max < rect_norm_variation_tol) { @@ -442,7 +438,7 @@ void update_consistent_constraints::optimize_heights() { nda::array rectangle_norms = make_array_view(heights(r_K)) * widths(r_K); std::cerr << "Convergence reached, rectangle norms = " << rectangle_norms - << std::endl; + << '\n'; #endif break; } @@ -480,7 +476,7 @@ void update_consistent_constraints::optimize_heights() { #ifdef EXT_DEBUG if(iter == max_iter) { std::cerr << "Maximum number of iterations reached, heights = " - << heights(r_K) << std::endl; + << heights(r_K) << '\n'; } #endif } diff --git a/c++/som/updates_class1.cpp b/c++/som/updates_class1.cpp index 764a05ae9..5cbf8d18b 100644 --- a/c++/som/updates_class1.cpp +++ b/c++/som/updates_class1.cpp @@ -36,8 +36,8 @@ template double update_shift::attempt() { eu::attempt_cc_update(); #ifdef EXT_DEBUG - std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; - std::cerr << "* Proposing update_shift (A)" << std::endl; + std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; + std::cerr << "* Proposing update_shift (A)\n"; #endif auto& data = eu::get_data(); @@ -60,9 +60,9 @@ template double update_shift::attempt() { auto dc_opt = eu::optimize_parameter_change(dc, dc_min, dc_max); #ifdef EXT_DEBUG - std::cerr << "Selected rectangle: " << rect << " [" << t << "]" << std::endl; + std::cerr << "Selected rectangle: " << rect << " [" << t << "]\n"; std::cerr << "dc_min = " << dc_min << ", dc_max = " << dc_max - << ", dc = " << dc << ", dc_opt = " << dc_opt.second << std::endl; + << ", dc = " << dc << ", dc_opt = " << dc_opt.second << '\n'; #endif if(dc_opt.first) { @@ -75,7 +75,7 @@ template double update_shift::attempt() { #ifdef EXT_DEBUG std::cerr << "selected_parameter_change = " - << eu::get_selected_parameter_change() << std::endl; + << eu::get_selected_parameter_change() << '\n'; #endif return eu::transition_probability(); @@ -91,8 +91,8 @@ double update_change_width::attempt() { eu::attempt_cc_update(); #ifdef EXT_DEBUG - std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; - std::cerr << "* Proposing update_change_width (B)" << std::endl; + std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; + std::cerr << "* Proposing update_change_width (B)\n"; #endif auto& data = eu::get_data(); @@ -125,9 +125,9 @@ double update_change_width::attempt() { auto dw_opt = eu::optimize_parameter_change(dw, dw_min, dw_max); #ifdef EXT_DEBUG - std::cerr << "Selected rectangle: " << rect << " [" << t << "]" << std::endl; + std::cerr << "Selected rectangle: " << rect << " [" << t << "]\n"; std::cerr << "dw_min = " << dw_min << ", dw_max = " << dw_max - << ", dw = " << dw << ", dw_opt = " << dw_opt.second << std::endl; + << ", dw = " << dw << ", dw_opt = " << dw_opt.second << '\n'; #endif if(dw_opt.first) { @@ -144,7 +144,7 @@ double update_change_width::attempt() { #ifdef EXT_DEBUG std::cerr << "selected_parameter_change = " - << eu::get_selected_parameter_change() << std::endl; + << eu::get_selected_parameter_change() << '\n'; #endif return eu::transition_probability(); @@ -159,8 +159,8 @@ double update_change_weight2::attempt() { eu::attempt_cc_update(); #ifdef EXT_DEBUG - std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; - std::cerr << "* Proposing update_change_weight2 (C)" << std::endl; + std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; + std::cerr << "* Proposing update_change_weight2 (C)\n"; #endif auto& data = eu::get_data(); @@ -170,7 +170,7 @@ double update_change_weight2::attempt() { int size = data.temp_conf.size(); if(size < 2) { #ifdef EXT_DEBUG - std::cerr << "Not enough rectangles to change" << std::endl; + std::cerr << "Not enough rectangles to change\n"; #endif return 0; } @@ -209,10 +209,9 @@ double update_change_weight2::attempt() { #ifdef EXT_DEBUG std::cerr << "Selected rectangles: " << rect1 << " [" << t1 << "]" - << " and " << rect2 << " [" << t2 << "]" << std::endl; + << " and " << rect2 << " [" << t2 << "]\n"; std::cerr << "dh1_min = " << dh1_min << ", dh1_max = " << dh1_max - << ", dh1 = " << dh1 << ", dh1_opt = " << dh1_opt.second - << std::endl; + << ", dh1 = " << dh1 << ", dh1_opt = " << dh1_opt.second << '\n'; #endif if(dh1_opt.first) { @@ -231,7 +230,7 @@ double update_change_weight2::attempt() { #ifdef EXT_DEBUG std::cerr << "selected_parameter_change = " - << eu::get_selected_parameter_change() << std::endl; + << eu::get_selected_parameter_change() << '\n'; #endif return eu::transition_probability(); diff --git a/c++/som/updates_class2.cpp b/c++/som/updates_class2.cpp index c9c1d1094..879d2b5ca 100644 --- a/c++/som/updates_class2.cpp +++ b/c++/som/updates_class2.cpp @@ -37,8 +37,8 @@ template double update_insert::attempt() { eu::attempt_cc_update(); #ifdef EXT_DEBUG - std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; - std::cerr << "* Proposing update_insert (D)" << std::endl; + std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; + std::cerr << "* Proposing update_insert (D)\n"; #endif auto& data = eu::get_data(); @@ -48,8 +48,7 @@ template double update_insert::attempt() { int size = data.temp_conf.size(); if(size == max_rects) { #ifdef EXT_DEBUG - std::cerr << "Too many rectangles in the temporary configuration" - << std::endl; + std::cerr << "Too many rectangles in the temporary configuration\n"; #endif return 0; } @@ -57,12 +56,12 @@ template double update_insert::attempt() { int t = rng(size); auto const& rect = data.temp_conf[t]; #ifdef EXT_DEBUG - std::cerr << "Selected rectangle: " << rect << " [" << t << "]" << std::endl; + std::cerr << "Selected rectangle: " << rect << " [" << t << "]\n"; #endif if(rect.norm() <= 2 * weight_min) { #ifdef EXT_DEBUG - std::cerr << "Selected rectangle is too small" << std::endl; + std::cerr << "Selected rectangle is too small\n"; #endif return 0; } @@ -86,7 +85,7 @@ template double update_insert::attempt() { #ifdef EXT_DEBUG std::cerr << "snew_min = " << weight_min << ", snew_max = " << snew_max - << ", snew = " << snew << std::endl; + << ", snew = " << snew << '\n'; #endif } else { eu::get_update(eu::half).change_rectangle( @@ -99,7 +98,7 @@ template double update_insert::attempt() { #ifdef EXT_DEBUG std::cerr << "snew_min = " << weight_min << ", snew_max = " << snew_max << ", snew = " << snew << ", snew_opt = " << snew_opt.second - << std::endl; + << '\n'; #endif if(snew_opt.first) { @@ -115,7 +114,7 @@ template double update_insert::attempt() { #ifdef EXT_DEBUG std::cerr << "selected_parameter_change = " - << eu::get_selected_parameter_change() << std::endl; + << eu::get_selected_parameter_change() << '\n'; #endif return eu::transition_probability(); @@ -130,8 +129,8 @@ double update_remove_shift::attempt() { eu::attempt_cc_update(); #ifdef EXT_DEBUG - std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; - std::cerr << "* Proposing update_remove_shift (E)" << std::endl; + std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; + std::cerr << "* Proposing update_remove_shift (E)\n"; #endif auto& data = eu::get_data(); @@ -141,7 +140,7 @@ double update_remove_shift::attempt() { int size = data.temp_conf.size(); if(size < 2) { #ifdef EXT_DEBUG - std::cerr << "Not enough rectangles to change" << std::endl; + std::cerr << "Not enough rectangles to change\n"; #endif return 0; } @@ -176,13 +175,11 @@ double update_remove_shift::attempt() { auto dc2_opt = eu::optimize_parameter_change(dc2, dc2_min, dc2_max); #ifdef EXT_DEBUG - std::cerr << "Selected rectangle for removal: " << rect1 << " [" << t1 << "]" - << std::endl; - std::cerr << "Selected rectangle for shift: " << rect2 << " [" << t2 << "]" - << std::endl; + std::cerr << "Selected rectangle for removal: " << rect1 << " [" << t1 + << "]\n"; + std::cerr << "Selected rectangle for shift: " << rect2 << " [" << t2 << "]\n"; std::cerr << "dc2_min = " << dc2_min << ", dc2_max = " << dc2_max - << ", dc2 = " << dc2 << ", dc2_opt = " << dc2_opt.second - << std::endl; + << ", dc2 = " << dc2 << ", dc2_opt = " << dc2_opt.second << '\n'; #endif if(dc2_opt.first) { @@ -200,7 +197,7 @@ double update_remove_shift::attempt() { #ifdef EXT_DEBUG std::cerr << "selected_parameter_change = " - << eu::get_selected_parameter_change() << std::endl; + << eu::get_selected_parameter_change() << '\n'; #endif return eu::transition_probability(); @@ -215,8 +212,8 @@ double update_split_shift::attempt() { eu::attempt_cc_update(); #ifdef EXT_DEBUG - std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; - std::cerr << "* Proposing update_split_shift (F)" << std::endl; + std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; + std::cerr << "* Proposing update_split_shift (F)\n"; #endif auto& data = eu::get_data(); @@ -226,8 +223,7 @@ double update_split_shift::attempt() { int size = data.temp_conf.size(); if(size == max_rects) { #ifdef EXT_DEBUG - std::cerr << "Too many rectangles in the temporary configuration" - << std::endl; + std::cerr << "Too many rectangles in the temporary configuration\n"; #endif return 0; } @@ -236,17 +232,17 @@ double update_split_shift::attempt() { auto const& rect = data.temp_conf[t]; #ifdef EXT_DEBUG - std::cerr << "Selected rectangle: " << rect << " [" << t << "]" << std::endl; + std::cerr << "Selected rectangle: " << rect << " [" << t << "]\n"; #endif if(rect.width <= 2 * width_min) { #ifdef EXT_DEBUG - std::cerr << "Selected rectangle is too narrow" << std::endl; + std::cerr << "Selected rectangle is too narrow\n"; #endif return 0; } if(rect.norm() <= 2 * weight_min) { #ifdef EXT_DEBUG - std::cerr << "Selected rectangle is too small" << std::endl; + std::cerr << "Selected rectangle is too small\n"; #endif return 0; } @@ -279,8 +275,7 @@ double update_split_shift::attempt() { #ifdef EXT_DEBUG std::cerr << "dc1_min = " << dc1_min << ", dc1_max = " << dc1_max - << ", dc1 = " << dc1 << ", dc1_opt = " << dc1_opt.second - << std::endl; + << ", dc1 = " << dc1 << ", dc1_opt = " << dc1_opt.second << '\n'; #endif if(dc1_opt.first) { @@ -313,8 +308,7 @@ double update_split_shift::attempt() { #ifdef EXT_DEBUG std::cerr << "dc2_min = " << dc2_min << ", dc2_max = " << dc2_max - << ", dc2 = " << dc2 << ", dc2_opt = " << dc2_opt.second - << std::endl; + << ", dc2 = " << dc2 << ", dc2_opt = " << dc2_opt.second << '\n'; #endif if(dc2_opt.first) { @@ -330,7 +324,7 @@ double update_split_shift::attempt() { #ifdef EXT_DEBUG std::cerr << "selected_parameter_change = " - << eu::get_selected_parameter_change() << std::endl; + << eu::get_selected_parameter_change() << '\n'; #endif return eu::transition_probability(); @@ -344,8 +338,8 @@ template double update_glue_shift::attempt() { eu::attempt_cc_update(); #ifdef EXT_DEBUG - std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; - std::cerr << "* Proposing move_glue_shift (G)" << std::endl; + std::cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; + std::cerr << "* Proposing move_glue_shift (G)\n"; #endif auto& data = eu::get_data(); @@ -355,7 +349,7 @@ template double update_glue_shift::attempt() { int size = data.temp_conf.size(); if(size < 2) { #ifdef EXT_DEBUG - std::cerr << "Not enough rectangles to glue" << std::endl; + std::cerr << "Not enough rectangles to glue\n"; #endif return 0; } @@ -383,7 +377,7 @@ template double update_glue_shift::attempt() { #ifdef EXT_DEBUG std::cerr << "Selected rectangles: " << rect1 << " [" << t1 << "]" - << " and " << rect2 << " [" << t2 << "]" << std::endl; + << " and " << rect2 << " [" << t2 << "]\n"; #endif if(dc_min * dc_max > 0) { // In this case dc/2 can be outside [dc_min; dc_max] @@ -391,7 +385,7 @@ template double update_glue_shift::attempt() { #ifdef EXT_DEBUG std::cerr << "dc_min = " << dc_min << ", dc_max = " << dc_max - << ", dc = " << dc << std::endl; + << ", dc = " << dc << '\n'; #endif @@ -403,7 +397,7 @@ template double update_glue_shift::attempt() { #ifdef EXT_DEBUG std::cerr << "dc_min = " << dc_min << ", dc_max = " << dc_max - << ", dc = " << dc << ", dc_opt = " << dc_opt.second << std::endl; + << ", dc = " << dc << ", dc_opt = " << dc_opt.second << '\n'; #endif if(dc_opt.first) { @@ -417,7 +411,7 @@ template double update_glue_shift::attempt() { #ifdef EXT_DEBUG std::cerr << "selected_parameter_change = " - << eu::get_selected_parameter_change() << std::endl; + << eu::get_selected_parameter_change() << '\n'; #endif return eu::transition_probability(); diff --git a/c++/som/worker_parameters.cpp b/c++/som/worker_parameters.cpp index c7d58094b..ea47fffd4 100644 --- a/c++/som/worker_parameters.cpp +++ b/c++/som/worker_parameters.cpp @@ -140,8 +140,7 @@ void worker_parameters_t::validate(observable_kind kind) const { if(cc_update_rect_norm_variation_tol > min_rect_weight) std::cout << "WARNING: cc_update_rect_norm_variation_tol should normally " - "be set below min_rect_weight" - << std::endl; + "be set below min_rect_weight\n"; } } diff --git a/test/c++/global_index_map.cpp b/test/c++/global_index_map.cpp index 361575095..0aeba08b8 100644 --- a/test/c++/global_index_map.cpp +++ b/test/c++/global_index_map.cpp @@ -31,7 +31,7 @@ int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); if(mpi::has_env) { mpi::environment env(argc, argv); - std::cout << "MPI environment detected" << std::endl; + std::cout << "MPI environment detected\n"; return RUN_ALL_TESTS(); } else return RUN_ALL_TESTS(); diff --git a/test/c++/spectral_stats.cpp b/test/c++/spectral_stats.cpp index 8bbe01074..6c0331928 100644 --- a/test/c++/spectral_stats.cpp +++ b/test/c++/spectral_stats.cpp @@ -38,7 +38,7 @@ int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); if(mpi::has_env) { mpi::environment env(argc, argv); - std::cout << "MPI environment detected" << std::endl; + std::cout << "MPI environment detected\n"; return RUN_ALL_TESTS(); } else return RUN_ALL_TESTS();