From bf4b4eeda9762ed9e99c2b24f19331fa0111fcfe Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 27 Jan 2020 10:43:16 +0100 Subject: Code review: Use std::clog instead of std::cout --- src/common/include/gudhi/Clock.h | 4 ++-- src/common/include/gudhi/Debug_utils.h | 10 +++++----- src/common/include/gudhi/Points_3D_off_io.h | 8 ++++---- src/common/include/gudhi/Points_off_io.h | 8 ++++---- src/common/include/gudhi/Unitary_tests_utils.h | 4 ++-- src/common/include/gudhi/distance_functions.h | 2 +- src/common/include/gudhi/reader_utils.h | 16 ++++++++-------- src/common/include/gudhi/writing_persistence_to_file.h | 2 +- 8 files changed, 27 insertions(+), 27 deletions(-) (limited to 'src/common/include/gudhi') diff --git a/src/common/include/gudhi/Clock.h b/src/common/include/gudhi/Clock.h index 00ab2f27..6966aaaa 100644 --- a/src/common/include/gudhi/Clock.h +++ b/src/common/include/gudhi/Clock.h @@ -41,9 +41,9 @@ class Clock { return msg; } - // Print current value to std::cout + // Print current value to std::clog void print() const { - std::cout << *this << std::endl; + std::clog << *this << std::endl; } friend std::ostream& operator<<(std::ostream& stream, const Clock& clock) { diff --git a/src/common/include/gudhi/Debug_utils.h b/src/common/include/gudhi/Debug_utils.h index d4e66d8d..f8375b00 100644 --- a/src/common/include/gudhi/Debug_utils.h +++ b/src/common/include/gudhi/Debug_utils.h @@ -27,14 +27,14 @@ #define GUDHI_CHECK_code(CODE) #endif -#define PRINT(a) std::cout << #a << ": " << (a) << " (DISP)" << std::endl +#define PRINT(a) std::clog << #a << ": " << (a) << " (DISP)" << std::endl // #define DBG_VERBOSE #ifdef DBG_VERBOSE - #define DBG(a) std::cout << "DBG: " << (a) << std::endl - #define DBGMSG(a, b) std::cout << "DBG: " << a << b << std::endl - #define DBGVALUE(a) std::cout << "DBG: " << #a << ": " << a << std::endl - #define DBGCONT(a) std::cout << "DBG: container " << #a << " -> "; for (auto x : a) std::cout << x << ","; std::cout << std::endl + #define DBG(a) std::clog << "DBG: " << (a) << std::endl + #define DBGMSG(a, b) std::clog << "DBG: " << a << b << std::endl + #define DBGVALUE(a) std::clog << "DBG: " << #a << ": " << a << std::endl + #define DBGCONT(a) std::clog << "DBG: container " << #a << " -> "; for (auto x : a) std::clog << x << ","; std::clog << std::endl #else #define DBG(a) (void) 0 #define DBGMSG(a, b) (void) 0 diff --git a/src/common/include/gudhi/Points_3D_off_io.h b/src/common/include/gudhi/Points_3D_off_io.h index 2d110af3..39b79c96 100644 --- a/src/common/include/gudhi/Points_3D_off_io.h +++ b/src/common/include/gudhi/Points_3D_off_io.h @@ -41,7 +41,7 @@ class Points_3D_off_visitor_reader { */ void init(int dim, int num_vertices, int num_faces, int num_edges) { #ifdef DEBUG_TRACES - std::cout << "Points_3D_off_visitor_reader::init - dim=" << dim << " - num_vertices=" << + std::clog << "Points_3D_off_visitor_reader::init - dim=" << dim << " - num_vertices=" << num_vertices << " - num_faces=" << num_faces << " - num_edges=" << num_edges << std::endl; #endif // DEBUG_TRACES if (dim == 3) { @@ -74,11 +74,11 @@ class Points_3D_off_visitor_reader { void point(const std::vector& point) { if (valid_) { #ifdef DEBUG_TRACES - std::cout << "Points_3D_off_visitor_reader::point "; + std::clog << "Points_3D_off_visitor_reader::point "; for (auto coordinate : point) { - std::cout << coordinate << " | "; + std::clog << coordinate << " | "; } - std::cout << std::endl; + std::clog << std::endl; #endif // DEBUG_TRACES // Fill the point cloud point_cloud_.push_back(Point_3(point[0], point[1], point[2])); diff --git a/src/common/include/gudhi/Points_off_io.h b/src/common/include/gudhi/Points_off_io.h index 99371d56..9dc40568 100644 --- a/src/common/include/gudhi/Points_off_io.h +++ b/src/common/include/gudhi/Points_off_io.h @@ -40,7 +40,7 @@ class Points_off_visitor_reader { */ void init(int dim, int num_vertices, int num_faces, int num_edges) { #ifdef DEBUG_TRACES - std::cout << "Points_off_visitor_reader::init - dim=" << dim << " - num_vertices=" << + std::clog << "Points_off_visitor_reader::init - dim=" << dim << " - num_vertices=" << num_vertices << " - num_faces=" << num_faces << " - num_edges=" << num_edges << std::endl; #endif // DEBUG_TRACES if (num_faces > 0) { @@ -66,11 +66,11 @@ class Points_off_visitor_reader { */ void point(const std::vector& point) { #ifdef DEBUG_TRACES - std::cout << "Points_off_visitor_reader::point "; + std::clog << "Points_off_visitor_reader::point "; for (auto coordinate : point) { - std::cout << coordinate << " | "; + std::clog << coordinate << " | "; } - std::cout << std::endl; + std::clog << std::endl; #endif // DEBUG_TRACES // Fill the point cloud point_cloud.push_back(Point_d(point.begin(), point.end())); diff --git a/src/common/include/gudhi/Unitary_tests_utils.h b/src/common/include/gudhi/Unitary_tests_utils.h index 9b86460a..9f995d01 100644 --- a/src/common/include/gudhi/Unitary_tests_utils.h +++ b/src/common/include/gudhi/Unitary_tests_utils.h @@ -20,7 +20,7 @@ template void GUDHI_TEST_FLOAT_EQUALITY_CHECK(FloatingType a, FloatingType b, FloatingType epsilon = std::numeric_limits::epsilon()) { #ifdef DEBUG_TRACES - std::cout << "GUDHI_TEST_FLOAT_EQUALITY_CHECK - " << a << " versus " << b + std::clog << "GUDHI_TEST_FLOAT_EQUALITY_CHECK - " << a << " versus " << b << " | diff = " << std::fabs(a - b) << " - epsilon = " << epsilon << std::endl; #endif BOOST_CHECK(std::fabs(a - b) <= epsilon); @@ -32,7 +32,7 @@ template FloatingType GUDHI_PROTECT_FLOAT(FloatingType value) { volatile FloatingType protected_value = value; #ifdef DEBUG_TRACES - std::cout << "GUDHI_PROTECT_FLOAT - " << protected_value << std::endl; + std::clog << "GUDHI_PROTECT_FLOAT - " << protected_value << std::endl; #endif return protected_value; } diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index 94cf9ccc..9bbc62b7 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -97,7 +97,7 @@ class Minimal_enclosing_ball_radius { Min_sphere ms(boost::size(*point_cloud.begin()), point_cloud.begin(), point_cloud.end()); #ifdef DEBUG_TRACES - std::cout << "Minimal_enclosing_ball_radius = " << std::sqrt(ms.squared_radius()) << " | nb points = " + std::clog << "Minimal_enclosing_ball_radius = " << std::sqrt(ms.squared_radius()) << " | nb points = " << boost::size(point_cloud) << " | dimension = " << boost::size(*point_cloud.begin()) << std::endl; #endif // DEBUG_TRACES diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index ac9e987b..0938f5c1 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -220,7 +220,7 @@ template std::vector> read_lower_triangular_matrix_from_csv_file(const std::string& filename, const char separator = ';') { #ifdef DEBUG_TRACES - std::cout << "Using procedure read_lower_triangular_matrix_from_csv_file \n"; + std::clog << "Using procedure read_lower_triangular_matrix_from_csv_file \n"; #endif // DEBUG_TRACES std::vector> result; std::ifstream in; @@ -272,12 +272,12 @@ std::vector> read_lower_triangular_matrix_from_csv in.close(); #ifdef DEBUG_TRACES - std::cout << "Here is the matrix we read : \n"; + std::clog << "Here is the matrix we read : \n"; for (size_t i = 0; i != result.size(); ++i) { for (size_t j = 0; j != result[i].size(); ++j) { - std::cout << result[i][j] << " "; + std::clog << result[i][j] << " "; } - std::cout << std::endl; + std::clog << std::endl; } #endif // DEBUG_TRACES @@ -294,7 +294,7 @@ Note: the function does not check that birth <= death. template void read_persistence_intervals_and_dimension(std::string const& filename, OutputIterator out) { #ifdef DEBUG_TRACES - std::cout << "read_persistence_intervals_and_dimension - " << filename << std::endl; + std::clog << "read_persistence_intervals_and_dimension - " << filename << std::endl; #endif // DEBUG_TRACES std::ifstream in(filename); if (!in.is_open()) { @@ -311,11 +311,11 @@ void read_persistence_intervals_and_dimension(std::string const& filename, Outpu double numbers[4]; int n = sscanf(line.c_str(), "%lf %lf %lf %lf", &numbers[0], &numbers[1], &numbers[2], &numbers[3]); #ifdef DEBUG_TRACES - std::cout << "[" << n << "] = "; + std::clog << "[" << n << "] = "; for (int i = 0; i < n; i++) { - std::cout << numbers[i] << ","; + std::clog << numbers[i] << ","; } - std::cout << std::endl; + std::clog << std::endl; #endif // DEBUG_TRACES if (n >= 2) { int dim = (n >= 3 ? static_cast(numbers[n - 3]) : -1); diff --git a/src/common/include/gudhi/writing_persistence_to_file.h b/src/common/include/gudhi/writing_persistence_to_file.h index 2e36b831..cdd8be0a 100644 --- a/src/common/include/gudhi/writing_persistence_to_file.h +++ b/src/common/include/gudhi/writing_persistence_to_file.h @@ -94,7 +94,7 @@ class Persistence_interval_common { **/ template void write_persistence_intervals_to_stream(const Persistence_interval_range& intervals, - std::ostream& out = std::cout) { + std::ostream& out = std::clog) { for (auto interval : intervals) { out << interval << "\n"; } -- cgit v1.2.3