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 --- .../include/gudhi/Bitmap_cubical_complex.h | 56 +++++++++++----------- .../include/gudhi/Bitmap_cubical_complex_base.h | 36 +++++++------- ...cal_complex_periodic_boundary_conditions_base.h | 10 ++-- 3 files changed, 51 insertions(+), 51 deletions(-) (limited to 'src/Bitmap_cubical_complex/include') diff --git a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h index 2f95dff3..aa255ec2 100644 --- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h +++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h @@ -69,7 +69,7 @@ class Bitmap_cubical_complex : public T { Bitmap_cubical_complex(const char* perseus_style_file) : T(perseus_style_file), key_associated_to_simplex(this->total_number_of_cells + 1) { if (globalDbg) { - std::cout << "Bitmap_cubical_complex( const char* perseus_style_file )\n"; + std::clog << "Bitmap_cubical_complex( const char* perseus_style_file )\n"; } for (std::size_t i = 0; i != this->total_number_of_cells; ++i) { this->key_associated_to_simplex[i] = i; @@ -137,7 +137,7 @@ class Bitmap_cubical_complex : public T { **/ static Simplex_handle null_simplex() { if (globalDbg) { - std::cout << "Simplex_handle null_simplex()\n"; + std::clog << "Simplex_handle null_simplex()\n"; } return std::numeric_limits::max(); } @@ -152,7 +152,7 @@ class Bitmap_cubical_complex : public T { **/ inline unsigned dimension(Simplex_handle sh) const { if (globalDbg) { - std::cout << "unsigned dimension(const Simplex_handle& sh)\n"; + std::clog << "unsigned dimension(const Simplex_handle& sh)\n"; } if (sh != null_simplex()) return this->get_dimension_of_a_cell(sh); return -1; @@ -163,7 +163,7 @@ class Bitmap_cubical_complex : public T { **/ Filtration_value filtration(Simplex_handle sh) { if (globalDbg) { - std::cout << "Filtration_value filtration(const Simplex_handle& sh)\n"; + std::clog << "Filtration_value filtration(const Simplex_handle& sh)\n"; } // Returns the filtration value of a simplex. if (sh != null_simplex()) return this->data[sh]; @@ -175,7 +175,7 @@ class Bitmap_cubical_complex : public T { **/ static Simplex_key null_key() { if (globalDbg) { - std::cout << "Simplex_key null_key()\n"; + std::clog << "Simplex_key null_key()\n"; } return std::numeric_limits::max(); } @@ -185,7 +185,7 @@ class Bitmap_cubical_complex : public T { **/ Simplex_key key(Simplex_handle sh) const { if (globalDbg) { - std::cout << "Simplex_key key(const Simplex_handle& sh)\n"; + std::clog << "Simplex_key key(const Simplex_handle& sh)\n"; } if (sh != null_simplex()) { return this->key_associated_to_simplex[sh]; @@ -198,7 +198,7 @@ class Bitmap_cubical_complex : public T { **/ Simplex_handle simplex(Simplex_key key) { if (globalDbg) { - std::cout << "Simplex_handle simplex(Simplex_key key)\n"; + std::clog << "Simplex_handle simplex(Simplex_key key)\n"; } if (key != null_key()) { return this->simplex_associated_to_key[key]; @@ -211,7 +211,7 @@ class Bitmap_cubical_complex : public T { **/ void assign_key(Simplex_handle sh, Simplex_key key) { if (globalDbg) { - std::cout << "void assign_key(Simplex_handle& sh, Simplex_key key)\n"; + std::clog << "void assign_key(Simplex_handle& sh, Simplex_key key)\n"; } if (key == null_key()) return; this->key_associated_to_simplex[sh] = key; @@ -251,7 +251,7 @@ class Bitmap_cubical_complex : public T { Filtration_simplex_iterator operator++() { if (globalDbg) { - std::cout << "Filtration_simplex_iterator operator++\n"; + std::clog << "Filtration_simplex_iterator operator++\n"; } ++this->position; return (*this); @@ -265,7 +265,7 @@ class Bitmap_cubical_complex : public T { Filtration_simplex_iterator& operator=(const Filtration_simplex_iterator& rhs) { if (globalDbg) { - std::cout << "Filtration_simplex_iterator operator =\n"; + std::clog << "Filtration_simplex_iterator operator =\n"; } this->b = rhs.b; this->position = rhs.position; @@ -274,21 +274,21 @@ class Bitmap_cubical_complex : public T { bool operator==(const Filtration_simplex_iterator& rhs) const { if (globalDbg) { - std::cout << "bool operator == ( const Filtration_simplex_iterator& rhs )\n"; + std::clog << "bool operator == ( const Filtration_simplex_iterator& rhs )\n"; } return (this->position == rhs.position); } bool operator!=(const Filtration_simplex_iterator& rhs) const { if (globalDbg) { - std::cout << "bool operator != ( const Filtration_simplex_iterator& rhs )\n"; + std::clog << "bool operator != ( const Filtration_simplex_iterator& rhs )\n"; } return !(*this == rhs); } Simplex_handle operator*() { if (globalDbg) { - std::cout << "Simplex_handle operator*()\n"; + std::clog << "Simplex_handle operator*()\n"; } return this->b->simplex_associated_to_key[this->position]; } @@ -314,14 +314,14 @@ class Bitmap_cubical_complex : public T { Filtration_simplex_iterator begin() { if (globalDbg) { - std::cout << "Filtration_simplex_iterator begin() \n"; + std::clog << "Filtration_simplex_iterator begin() \n"; } return Filtration_simplex_iterator(this->b); } Filtration_simplex_iterator end() { if (globalDbg) { - std::cout << "Filtration_simplex_iterator end()\n"; + std::clog << "Filtration_simplex_iterator end()\n"; } Filtration_simplex_iterator it(this->b); it.position = this->b->simplex_associated_to_key.size(); @@ -347,7 +347,7 @@ class Bitmap_cubical_complex : public T { **/ Filtration_simplex_range filtration_simplex_range() { if (globalDbg) { - std::cout << "Filtration_simplex_range filtration_simplex_range()\n"; + std::clog << "Filtration_simplex_range filtration_simplex_range()\n"; } // Returns a range over the simplices of the complex in the order of the filtration return Filtration_simplex_range(this); @@ -370,8 +370,8 @@ class Bitmap_cubical_complex : public T { std::pair endpoints(Simplex_handle sh) { std::vector bdry = this->get_boundary_of_a_cell(sh); if (globalDbg) { - std::cout << "std::pair endpoints( Simplex_handle sh )\n"; - std::cout << "bdry.size() : " << bdry.size() << "\n"; + std::clog << "std::pair endpoints( Simplex_handle sh )\n"; + std::clog << "bdry.size() : " << bdry.size() << "\n"; } // this method returns two first elements from the boundary of sh. if (bdry.size() < 2) @@ -392,7 +392,7 @@ class Bitmap_cubical_complex : public T { public: Skeleton_simplex_iterator(Bitmap_cubical_complex* b, std::size_t d) : b(b), dimension(d) { if (globalDbg) { - std::cout << "Skeleton_simplex_iterator ( Bitmap_cubical_complex* b , std::size_t d )\n"; + std::clog << "Skeleton_simplex_iterator ( Bitmap_cubical_complex* b , std::size_t d )\n"; } // find the position of the first simplex of a dimension d this->position = 0; @@ -406,7 +406,7 @@ class Bitmap_cubical_complex : public T { Skeleton_simplex_iterator operator++() { if (globalDbg) { - std::cout << "Skeleton_simplex_iterator operator++()\n"; + std::clog << "Skeleton_simplex_iterator operator++()\n"; } // increment the position as long as you did not get to the next element of the dimension dimension. ++this->position; @@ -425,7 +425,7 @@ class Bitmap_cubical_complex : public T { Skeleton_simplex_iterator& operator=(const Skeleton_simplex_iterator& rhs) { if (globalDbg) { - std::cout << "Skeleton_simplex_iterator operator =\n"; + std::clog << "Skeleton_simplex_iterator operator =\n"; } this->b = rhs.b; this->position = rhs.position; @@ -435,21 +435,21 @@ class Bitmap_cubical_complex : public T { bool operator==(const Skeleton_simplex_iterator& rhs) const { if (globalDbg) { - std::cout << "bool operator ==\n"; + std::clog << "bool operator ==\n"; } return (this->position == rhs.position); } bool operator!=(const Skeleton_simplex_iterator& rhs) const { if (globalDbg) { - std::cout << "bool operator != ( const Skeleton_simplex_iterator& rhs )\n"; + std::clog << "bool operator != ( const Skeleton_simplex_iterator& rhs )\n"; } return !(*this == rhs); } Simplex_handle operator*() { if (globalDbg) { - std::cout << "Simplex_handle operator*() \n"; + std::clog << "Simplex_handle operator*() \n"; } return this->position; } @@ -476,14 +476,14 @@ class Bitmap_cubical_complex : public T { Skeleton_simplex_iterator begin() { if (globalDbg) { - std::cout << "Skeleton_simplex_iterator begin()\n"; + std::clog << "Skeleton_simplex_iterator begin()\n"; } return Skeleton_simplex_iterator(this->b, this->dimension); } Skeleton_simplex_iterator end() { if (globalDbg) { - std::cout << "Skeleton_simplex_iterator end()\n"; + std::clog << "Skeleton_simplex_iterator end()\n"; } Skeleton_simplex_iterator it(this->b, this->dimension); it.position = this->b->data.size(); @@ -500,7 +500,7 @@ class Bitmap_cubical_complex : public T { **/ Skeleton_simplex_range skeleton_simplex_range(unsigned dimension) { if (globalDbg) { - std::cout << "Skeleton_simplex_range skeleton_simplex_range( unsigned dimension )\n"; + std::clog << "Skeleton_simplex_range skeleton_simplex_range( unsigned dimension )\n"; } return Skeleton_simplex_range(this, dimension); } @@ -515,7 +515,7 @@ class Bitmap_cubical_complex : public T { template void Bitmap_cubical_complex::initialize_simplex_associated_to_key() { if (globalDbg) { - std::cout << "void Bitmap_cubical_complex::initialize_elements_ordered_according_to_filtration() \n"; + std::clog << "void Bitmap_cubical_complex::initialize_elements_ordered_according_to_filtration() \n"; } this->simplex_associated_to_key = std::vector(this->data.size()); std::iota(std::begin(simplex_associated_to_key), std::end(simplex_associated_to_key), 0); diff --git a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h index 96036fd4..1eb77c9c 100644 --- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h +++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h @@ -408,7 +408,7 @@ class Bitmap_cubical_complex_base { void print_counter() const { for (std::size_t i = 0; i != this->counter.size(); ++i) { - std::cout << this->counter[i] << " "; + std::clog << this->counter[i] << " "; } } friend class Bitmap_cubical_complex_base; @@ -521,11 +521,11 @@ void Bitmap_cubical_complex_base::put_data_to_bins(std::size_t number_of_bins // now put the data into the appropriate bins: for (std::size_t i = 0; i != this->data.size(); ++i) { if (dbg) { - std::cout << "Before binning : " << this->data[i] << std::endl; + std::clog << "Before binning : " << this->data[i] << std::endl; } this->data[i] = min_max.first + dx * (this->data[i] - min_max.first) / number_of_bins; if (dbg) { - std::cout << "After binning : " << this->data[i] << std::endl; + std::clog << "After binning : " << this->data[i] << std::endl; } } } @@ -539,11 +539,11 @@ void Bitmap_cubical_complex_base::put_data_to_bins(T diameter_of_bin) { // now put the data into the appropriate bins: for (std::size_t i = 0; i != this->data.size(); ++i) { if (dbg) { - std::cout << "Before binning : " << this->data[i] << std::endl; + std::clog << "Before binning : " << this->data[i] << std::endl; } this->data[i] = min_max.first + diameter_of_bin * (this->data[i] - min_max.first) / number_of_bins; if (dbg) { - std::cout << "After binning : " << this->data[i] << std::endl; + std::clog << "After binning : " << this->data[i] << std::endl; } } } @@ -617,7 +617,7 @@ void Bitmap_cubical_complex_base::read_perseus_style_file(const char* perseus inFiltration >> dimensionOfData; if (dbg) { - std::cout << "dimensionOfData : " << dimensionOfData << std::endl; + std::clog << "dimensionOfData : " << dimensionOfData << std::endl; } std::vector sizes; @@ -630,7 +630,7 @@ void Bitmap_cubical_complex_base::read_perseus_style_file(const char* perseus sizes.push_back(size_in_this_dimension); dimensions *= size_in_this_dimension; if (dbg) { - std::cout << "size_in_this_dimension : " << size_in_this_dimension << std::endl; + std::clog << "size_in_this_dimension : " << size_in_this_dimension << std::endl; } } this->set_up_containers(sizes); @@ -651,7 +651,7 @@ void Bitmap_cubical_complex_base::read_perseus_style_file(const char* perseus } if (dbg) { - std::cout << "Cell of an index : " << it.compute_index_in_bitmap() + std::clog << "Cell of an index : " << it.compute_index_in_bitmap() << " and dimension: " << this->get_dimension_of_a_cell(it.compute_index_in_bitmap()) << " get the value : " << filtrationLevel << std::endl; } @@ -754,20 +754,20 @@ std::vector Bitmap_cubical_complex_base::get_coboundary_of_a_cel template unsigned Bitmap_cubical_complex_base::get_dimension_of_a_cell(std::size_t cell) const { bool dbg = false; - if (dbg) std::cout << "\n\n\n Computing position o a cell of an index : " << cell << std::endl; + if (dbg) std::clog << "\n\n\n Computing position o a cell of an index : " << cell << std::endl; unsigned dimension = 0; for (std::size_t i = this->multipliers.size(); i != 0; --i) { unsigned position = cell / this->multipliers[i - 1]; if (dbg) { - std::cout << "i-1 :" << i - 1 << std::endl; - std::cout << "cell : " << cell << std::endl; - std::cout << "position : " << position << std::endl; - std::cout << "multipliers[" << i - 1 << "] = " << this->multipliers[i - 1] << std::endl; + std::clog << "i-1 :" << i - 1 << std::endl; + std::clog << "cell : " << cell << std::endl; + std::clog << "position : " << position << std::endl; + std::clog << "multipliers[" << i - 1 << "] = " << this->multipliers[i - 1] << std::endl; } if (position % 2 == 1) { - if (dbg) std::cout << "Nonzero length in this direction \n"; + if (dbg) std::clog << "Nonzero length in this direction \n"; dimension++; } cell = cell % this->multipliers[i - 1]; @@ -803,9 +803,9 @@ void Bitmap_cubical_complex_base::impose_lower_star_filtration() { while (indices_to_consider.size()) { if (dbg) { - std::cout << "indices_to_consider in this iteration \n"; + std::clog << "indices_to_consider in this iteration \n"; for (std::size_t i = 0; i != indices_to_consider.size(); ++i) { - std::cout << indices_to_consider[i] << " "; + std::clog << indices_to_consider[i] << " "; } } std::vector new_indices_to_consider; @@ -813,14 +813,14 @@ void Bitmap_cubical_complex_base::impose_lower_star_filtration() { std::vector bd = this->get_boundary_of_a_cell(indices_to_consider[i]); for (std::size_t boundaryIt = 0; boundaryIt != bd.size(); ++boundaryIt) { if (dbg) { - std::cout << "filtration of a cell : " << bd[boundaryIt] << " is : " << this->data[bd[boundaryIt]] + std::clog << "filtration of a cell : " << bd[boundaryIt] << " is : " << this->data[bd[boundaryIt]] << " while of a cell: " << indices_to_consider[i] << " is: " << this->data[indices_to_consider[i]] << std::endl; } if (this->data[bd[boundaryIt]] > this->data[indices_to_consider[i]]) { this->data[bd[boundaryIt]] = this->data[indices_to_consider[i]]; if (dbg) { - std::cout << "Setting the value of a cell : " << bd[boundaryIt] + std::clog << "Setting the value of a cell : " << bd[boundaryIt] << " to : " << this->data[indices_to_consider[i]] << std::endl; } } diff --git a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h index 3942dc34..18901469 100644 --- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h +++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h @@ -237,7 +237,7 @@ Bitmap_cubical_complex_periodic_boundary_conditions_base::Bitmap_cubical_comp if (inFiltration.eof()) break; if (dbg) { - std::cout << "Cell of an index : " << it.compute_index_in_bitmap() + std::clog << "Cell of an index : " << it.compute_index_in_bitmap() << " and dimension: " << this->get_dimension_of_a_cell(it.compute_index_in_bitmap()) << " get the value : " << filtrationLevel << std::endl; } @@ -278,7 +278,7 @@ std::vector Bitmap_cubical_complex_periodic_boundary_conditions_bas std::size_t cell) const { bool dbg = false; if (dbg) { - std::cout << "Computations of boundary of a cell : " << cell << std::endl; + std::clog << "Computations of boundary of a cell : " << cell << std::endl; } std::vector boundary_elements; @@ -300,7 +300,7 @@ std::vector Bitmap_cubical_complex_periodic_boundary_conditions_bas boundary_elements.push_back(cell - this->multipliers[i - 1]); } if (dbg) { - std::cout << cell - this->multipliers[i - 1] << " " << cell + this->multipliers[i - 1] << " "; + std::clog << cell - this->multipliers[i - 1] << " " << cell + this->multipliers[i - 1] << " "; } } else { // in this direction we have to do boundary conditions. Therefore, we need to check if we are not at the end. @@ -313,7 +313,7 @@ std::vector Bitmap_cubical_complex_periodic_boundary_conditions_bas boundary_elements.push_back(cell - this->multipliers[i - 1]); } if (dbg) { - std::cout << cell - this->multipliers[i - 1] << " " << cell + this->multipliers[i - 1] << " "; + std::clog << cell - this->multipliers[i - 1] << " " << cell + this->multipliers[i - 1] << " "; } } else { if (sum_of_dimensions % 2) { @@ -324,7 +324,7 @@ std::vector Bitmap_cubical_complex_periodic_boundary_conditions_bas boundary_elements.push_back(cell - this->multipliers[i - 1]); } if (dbg) { - std::cout << cell - this->multipliers[i - 1] << " " + std::clog << cell - this->multipliers[i - 1] << " " << cell - (2 * this->sizes[i - 1] - 1) * this->multipliers[i - 1] << " "; } } -- cgit v1.2.3