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 25, 2024
1 parent ff1247c commit cf7e3b7
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 36 deletions.
6 changes: 3 additions & 3 deletions include/mpi_dispatcher/mpi_skel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ std::map<pMPI::JobId, pMPI::WorkerId> mpi_skel<WrapType>::run(MPI_Comm const& Co
MPI_Barrier(Comm);

if(comm_rank == root) {
std::cout << "Calculating " << parts.size() << " jobs using " << comm_size << " procs." << std::endl;
std::cout << "Calculating " << parts.size() << " jobs using " << comm_size << " procs.\n";
}

std::unique_ptr<pMPI::MPIMaster> disp;
Expand Down Expand Up @@ -117,7 +117,7 @@ std::map<pMPI::JobId, pMPI::WorkerId> mpi_skel<WrapType>::run(MPI_Comm const& Co
JobId p = worker.current_job();
if(VerboseOutput)
std::cout << "[" << p + 1 << "/" << parts.size() << "] P" << comm_rank << " : part " << p << " ["
<< parts[p].complexity << "] run;" << std::endl;
<< parts[p].complexity << "] run;\n";
parts[p].run();
worker.report_job_done();
}
Expand All @@ -129,7 +129,7 @@ std::map<pMPI::JobId, pMPI::WorkerId> mpi_skel<WrapType>::run(MPI_Comm const& Co
MPI_Barrier(Comm);
// Now spread the information, who did what.
if(VerboseOutput && comm_rank == root)
std::cout << "done." << std::endl;
std::cout << "done.\n";

MPI_Barrier(Comm);
std::map<pMPI::JobId, pMPI::WorkerId> job_map;
Expand Down
4 changes: 2 additions & 2 deletions include/pomerol/HamiltonianPart.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ class HamiltonianPart : public ComputableObject {
/// \return Reference to the output stream.
friend std::ostream& operator<<(std::ostream& os, HamiltonianPart const& part) {
if(part.isComplex())
os << part.getMatrix<true>() << std::endl;
os << part.getMatrix<true>() << '\n';
else
os << part.getMatrix<false>() << std::endl;
os << part.getMatrix<false>() << '\n';

return os;
}
Expand Down
2 changes: 1 addition & 1 deletion include/pomerol/IndexClassification.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ template <typename... IndexTypes> class IndexClassification {
for(ParticleIndex i = 0; i < ic.InfoToIndices.size(); ++i) {
os << "Index " << i << " = (";
libcommute::print_tuple(os, ic.IndicesToInfo[i]);
os << ")" << std::endl;
os << ")\n";
}
return os;
}
Expand Down
8 changes: 4 additions & 4 deletions include/pomerol/Misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ namespace Pomerol {
#endif
#ifndef NDEBUG
/// Print a debugging message to the standard output with a source file name and line number annotation.
#define DEBUG(MSG) std::cout << MSG_PREFIX << MSG << std::endl
#define DEBUG(MSG) std::cout << MSG_PREFIX << MSG << '\n'
#else
#define DEBUG(MSG)
#endif
/// Print a message to the standard output.
#define INFO(MSG) std::cout << MSG << std::endl
#define INFO(MSG) std::cout << MSG << '\n'
/// Print a message without a trailing new line character to the standard output.
#define INFO_NONEWLINE(MSG) std::cout << MSG << std::flush
#define INFO_NONEWLINE(MSG) std::cout << MSG
/// Print a message to the standard error stream.
#define ERROR(MSG) std::cerr << MSG_PREFIX << MSG << std::endl
#define ERROR(MSG) std::cerr << MSG_PREFIX << MSG << '\n'

/// Real floating point type.
using RealType = double;
Expand Down
6 changes: 3 additions & 3 deletions prog/anderson_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ class anderson_model : public quantum_model {

if(levels.size() != hoppings.size()) {
MPI_Finalize();
std::cerr << "Number of levels != number of hoppings" << std::endl;
std::cerr << "Number of levels != number of hoppings\n";
exit(2);
}

L = levels.size();
mpi_cout << "Diagonalization of 1+" << L << " sites" << std::endl;
mpi_cout << "Diagonalization of 1+" << L << " sites\n";

init_hamiltonian();
}
Expand Down Expand Up @@ -95,7 +95,7 @@ class anderson_model : public quantum_model {
}

if(!rank)
mpi_cout << "Hamiltonian:\n" << HExpr << std::endl;
mpi_cout << "Hamiltonian:\n" << HExpr << '\n';
}

private:
Expand Down
4 changes: 2 additions & 2 deletions prog/hubbard2d_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class hubbard2d_model : public quantum_model {
auto pos_up = SiteIndexF(x, (y + 1) % size_y);
auto pos_dia_right = SiteIndexF((x + 1) % size_x, (y + 1) % size_y);
auto pos_dia_left = SiteIndexF((x + 1) % size_x, (y - 1) % size_y);
std::cout << pos_dia_right << " " << pos_dia_left << std::endl;
std::cout << pos_dia_right << " " << pos_dia_left << '\n';
if(size_x > 1)
HExpr += LatticePresets::Hopping(std::min(names[pos], names[pos_right]),
std::max(names[pos], names[pos_right]),
Expand All @@ -119,7 +119,7 @@ class hubbard2d_model : public quantum_model {

auto rank = pMPI::rank(comm);
if(!rank)
mpi_cout << "Hamiltonian:\n" << HExpr << std::endl;
mpi_cout << "Hamiltonian:\n" << HExpr << '\n';
}

/// Prepare a set of indices to evaluate annihilation/creation operators and
Expand Down
12 changes: 6 additions & 6 deletions prog/quantum_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ void quantum_model::parse_args(int argc, char const* const argv[]) {
std::cout << args_parser;
exit(0);
} catch(args::ParseError& e) {
std::cerr << e.what() << std::endl;
std::cerr << e.what() << '\n';
std::cerr << args_parser;
exit(1);
} catch(args::ValidationError& e) {
std::cerr << e.what() << std::endl;
std::cerr << e.what() << '\n';
std::cerr << args_parser;
exit(1);
}
Expand All @@ -92,7 +92,7 @@ void quantum_model::compute() {
IndexInfoType IndexInfo = MakeIndexClassification(HExpr);
if(!rank) {
print_section("Indices");
std::cout << IndexInfo << std::endl;
std::cout << IndexInfo << '\n';
};

auto HS = MakeHilbertSpace(IndexInfo, HExpr);
Expand Down Expand Up @@ -162,7 +162,7 @@ void quantum_model::compute() {
for(auto const& ind2 : indices2) {
GreensFunction const& GF = G(ind2);
// Save Matsubara GF from pi/beta to pi/beta*(4*wf_max + 1)
std::cout << "Saving imfreq G" << ind2 << " on " << 4 * wf_max << " Matsubara freqs. " << std::endl;
std::cout << "Saving imfreq G" << ind2 << " on " << 4 * wf_max << " Matsubara freqs.\n";
grid_object<std::complex<double>, fmatsubara_grid> gf_imfreq(
fmatsubara_grid(wf_min, wf_max * 4, beta, true));
std::string ind_str = std::to_string(ind2.Index1) + std::to_string(ind2.Index2);
Expand Down Expand Up @@ -230,13 +230,13 @@ void quantum_model::compute() {
}
}
}
mpi_cout << "2PGF : " << freqs_2pgf.size() << " freqs to evaluate" << std::endl;
mpi_cout << "2PGF : " << freqs_2pgf.size() << " freqs to evaluate\n";

std::vector<ComplexType> chi_freq_data = G4.compute(true, freqs_2pgf, comm);

// dump 2PGF into files - loop through 2pgf components
if(!rank) {
mpi_cout << "Saving 2PGF " << index_comb << std::endl;
mpi_cout << "Saving 2PGF " << index_comb << '\n';
grid_object<std::complex<double>, bmatsubara_grid, fmatsubara_grid, fmatsubara_grid> full_vertex(
std::forward_as_tuple(bgrid, fgrid, fgrid));
grid_object<std::complex<double>, fmatsubara_grid, fmatsubara_grid> full_vertex_1freq(
Expand Down
6 changes: 3 additions & 3 deletions prog/quantum_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ class quantum_model {
/// Print a line preceded and forwarded by two horizontal rules.
void print_section(std::string const& str) {
if(!rank) {
std::cout << std::string(str.size(), '=') << std::endl;
std::cout << str << std::endl;
std::cout << std::string(str.size(), '=') << std::endl;
std::cout << std::string(str.size(), '=') << '\n';
std::cout << str << '\n';
std::cout << std::string(str.size(), '=') << '\n';
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/pomerol/HamiltonianPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ bool HamiltonianPart::reduce(RealType Cutoff) {
INFO("Left " << counter << " eigenvalues : ");

if(counter) {
INFO(Eigenvalues.head(counter) << std::endl << "_________");
INFO(Eigenvalues.head(counter) << "\n_________");
Eigenvalues = Eigenvalues.head(counter);
if(isComplex()) {
auto& HMatrix_ = getMatrix<true>();
Expand Down
2 changes: 1 addition & 1 deletion src/pomerol/MonomialOperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void MonomialOperator::compute(MPI_Comm const& comm) {
INFO_NONEWLINE((int)((1.0 * BlockIn / Size) * 100) << " " << std::flush);
parts[BlockIn].compute();
};
std::cout << std::endl;
std::cout << '\n';

setStatus(Computed);
}
Expand Down
2 changes: 1 addition & 1 deletion src/pomerol/MonomialOperatorPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ template <bool C> void MonomialOperatorPart::streamOutputImpl(std::ostream& os)
for(typename ColMajorMatrixType<C>::InnerIterator it(mat, P); it; ++it) {
QuantumState N = S.getFockState(to, it.row());
QuantumState M = S.getFockState(from, it.col());
os << N << " " << M << " : " << it.value() << std::endl;
os << N << " " << M << " : " << it.value() << '\n';
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions tutorial/example2site.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int main(int argc, char* argv[]) {

// Let us now print 'HExpr'.
if(pMPI::rank(MPI_COMM_WORLD) == 0)
std::cout << "HExpr = " << HExpr << std::endl;
std::cout << "HExpr = " << HExpr << '\n';

// In order to go further, we need to introduce the single-particle index space.
// A single-particle index is an integer that uniquely identifies a combination of
Expand All @@ -92,7 +92,7 @@ int main(int argc, char* argv[]) {
auto IndexInfo = MakeIndexClassification(HExpr);
// Print which indices we have.
if(pMPI::rank(MPI_COMM_WORLD) == 0)
std::cout << "Indices:\n" << IndexInfo << std::endl;
std::cout << "Indices:\n" << IndexInfo << '\n';

// Let us make a test that our Hamiltonian expression commutes with an operator
// that represents the total number of particles in the system.
Expand All @@ -101,8 +101,8 @@ int main(int argc, char* argv[]) {
Operators::n("B", (unsigned short)0, LatticePresets::up) +
Operators::n("B", (unsigned short)0, LatticePresets::down);
if(pMPI::rank(MPI_COMM_WORLD) == 0) {
std::cout << "NExpr = " << NExpr << std::endl;
std::cout << "[HExpr, NExpr] = " << (HExpr * NExpr - NExpr * HExpr) << std::endl;
std::cout << "NExpr = " << NExpr << '\n';
std::cout << "[HExpr, NExpr] = " << (HExpr * NExpr - NExpr * HExpr) << '\n';
}

// Having created the Hamiltonian expression and the IndexClassification object
Expand Down Expand Up @@ -139,7 +139,7 @@ int main(int argc, char* argv[]) {
H.compute(MPI_COMM_WORLD);

// Get ground energy energy.
std::cout << "The value of ground energy is " << H.getGroundEnergy() << std::endl;
std::cout << "The value of ground energy is " << H.getGroundEnergy() << '\n';

// Important remark 2!
//
Expand Down Expand Up @@ -263,7 +263,7 @@ int main(int argc, char* argv[]) {
EA.compute();
RealType occup_up = real(EA());
if(pMPI::rank(MPI_COMM_WORLD) == 0)
std::cout << "Occupation number of up spin is " << occup_up << std::endl;
std::cout << "Occupation number of up spin is " << occup_up << '\n';

print_section("Dynamical susceptibility");

Expand Down Expand Up @@ -354,8 +354,8 @@ int main(int argc, char* argv[]) {

void print_section(std::string const& str) {
if(!pMPI::rank(MPI_COMM_WORLD)) {
std::cout << std::string(str.size(), '=') << std::endl;
std::cout << str << std::endl;
std::cout << std::string(str.size(), '=') << std::endl;
std::cout << std::string(str.size(), '=') << '\n';
std::cout << str << '\n';
std::cout << std::string(str.size(), '=') << '\n';
}
}

0 comments on commit cf7e3b7

Please sign in to comment.