From a4f21dd92265c825322885f8acac3b5303762c66 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 5 Dec 2017 21:58:15 +0000 Subject: After fix code review git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3038 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 07971bb9211bdfd340c0525c12610bbcf3897951 --- .../include/gudhi/Bitmap_cubical_complex.h | 35 +++++++++---------- .../include/gudhi/Bitmap_cubical_complex/counter.h | 13 ++++---- ...cal_complex_periodic_boundary_conditions_base.h | 39 +++++++++++----------- 3 files changed, 45 insertions(+), 42 deletions(-) (limited to 'src/Bitmap_cubical_complex') 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 f82e8ce9..969daba6 100644 --- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h +++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h @@ -35,6 +35,7 @@ #include // for sort #include #include // for iota +#include namespace Gudhi { @@ -61,7 +62,7 @@ class Bitmap_cubical_complex : public T { //*********************************************// // Typedefs and typenames //*********************************************// - typedef size_t Simplex_key; + typedef std::size_t Simplex_key; typedef typename T::filtration_type Filtration_value; typedef Simplex_key Simplex_handle; @@ -82,7 +83,7 @@ class Bitmap_cubical_complex : public T { if (globalDbg) { std::cerr << "Bitmap_cubical_complex( const char* perseus_style_file )\n"; } - for (size_t i = 0; i != this->total_number_of_cells; ++i) { + for (std::size_t i = 0; i != this->total_number_of_cells; ++i) { this->key_associated_to_simplex[i] = i; } // we initialize this only once, in each constructor, when the bitmap is constructed. @@ -99,7 +100,7 @@ class Bitmap_cubical_complex : public T { Bitmap_cubical_complex(const std::vector& dimensions, const std::vector& top_dimensional_cells) : T(dimensions, top_dimensional_cells), key_associated_to_simplex(this->total_number_of_cells + 1) { - for (size_t i = 0; i != this->total_number_of_cells; ++i) { + for (std::size_t i = 0; i != this->total_number_of_cells; ++i) { this->key_associated_to_simplex[i] = i; } // we initialize this only once, in each constructor, when the bitmap is constructed. @@ -120,7 +121,7 @@ class Bitmap_cubical_complex : public T { std::vector directions_in_which_periodic_b_cond_are_to_be_imposed) : T(dimensions, top_dimensional_cells, directions_in_which_periodic_b_cond_are_to_be_imposed), key_associated_to_simplex(this->total_number_of_cells + 1) { - for (size_t i = 0; i != this->total_number_of_cells; ++i) { + for (std::size_t i = 0; i != this->total_number_of_cells; ++i) { this->key_associated_to_simplex[i] = i; } // we initialize this only once, in each constructor, when the bitmap is constructed. @@ -141,7 +142,7 @@ class Bitmap_cubical_complex : public T { /** * Returns number of all cubes in the complex. **/ - size_t num_simplices() const { return this->total_number_of_cells; } + std::size_t num_simplices() const { return this->total_number_of_cells; } /** * Returns a Simplex_handle to a cube that do not exist in this complex. @@ -156,7 +157,7 @@ class Bitmap_cubical_complex : public T { /** * Returns dimension of the complex. **/ - inline size_t dimension() const { return this->sizes.size(); } + inline std::size_t dimension() const { return this->sizes.size(); } /** * Return dimension of a cell pointed by the Simplex_handle. @@ -308,7 +309,7 @@ class Bitmap_cubical_complex : public T { private: Bitmap_cubical_complex* b; - size_t position; + std::size_t position; }; /** @@ -379,7 +380,7 @@ class Bitmap_cubical_complex : public T { * Function needed for compatibility with Gudhi. Not useful for other purposes. **/ std::pair endpoints(Simplex_handle sh) { - std::vector bdry = this->get_boundary_of_a_cell(sh); + std::vector bdry = this->get_boundary_of_a_cell(sh); if (globalDbg) { std::cerr << "std::pair endpoints( Simplex_handle sh )\n"; std::cerr << "bdry.size() : " << bdry.size() << std::endl; @@ -401,9 +402,9 @@ class Bitmap_cubical_complex : public T { // Iterator over all simplices of the complex in the order of the indexing scheme. // 'value_type' must be 'Simplex_handle'. public: - Skeleton_simplex_iterator(Bitmap_cubical_complex* b, size_t d) : b(b), dimension(d) { + Skeleton_simplex_iterator(Bitmap_cubical_complex* b, std::size_t d) : b(b), dimension(d) { if (globalDbg) { - std::cerr << "Skeleton_simplex_iterator ( Bitmap_cubical_complex* b , size_t d )\n"; + std::cerr << "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; @@ -469,7 +470,7 @@ class Bitmap_cubical_complex : public T { private: Bitmap_cubical_complex* b; - size_t position; + std::size_t position; unsigned dimension; }; @@ -519,8 +520,8 @@ class Bitmap_cubical_complex : public T { friend class is_before_in_filtration; protected: - std::vector key_associated_to_simplex; - std::vector simplex_associated_to_key; + std::vector key_associated_to_simplex; + std::vector simplex_associated_to_key; }; // Bitmap_cubical_complex template @@ -528,7 +529,7 @@ void Bitmap_cubical_complex::initialize_simplex_associated_to_key() { if (globalDbg) { std::cerr << "void Bitmap_cubical_complex::initialize_elements_ordered_according_to_filtration() \n"; } - this->simplex_associated_to_key = std::vector(this->data.size()); + 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); #ifdef GUDHI_USE_TBB tbb::parallel_sort(simplex_associated_to_key.begin(), simplex_associated_to_key.end(), @@ -538,7 +539,7 @@ void Bitmap_cubical_complex::initialize_simplex_associated_to_key() { #endif // we still need to deal here with a key_associated_to_simplex: - for (size_t i = 0; i != simplex_associated_to_key.size(); ++i) { + for (std::size_t i = 0; i != simplex_associated_to_key.size(); ++i) { this->key_associated_to_simplex[simplex_associated_to_key[i]] = i; } } @@ -558,8 +559,8 @@ class is_before_in_filtration { return fil1 < fil2; } // in this case they are on the same filtration level, so the dimension decide. - size_t dim1 = CC_->get_dimension_of_a_cell(sh1); - size_t dim2 = CC_->get_dimension_of_a_cell(sh2); + std::size_t dim1 = CC_->get_dimension_of_a_cell(sh1); + std::size_t dim2 = CC_->get_dimension_of_a_cell(sh2); if (dim1 != dim2) { return dim1 < dim2; } diff --git a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex/counter.h b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex/counter.h index 4b072f10..705b68a0 100644 --- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex/counter.h +++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex/counter.h @@ -25,6 +25,7 @@ #include #include +#include namespace Gudhi { @@ -63,14 +64,14 @@ class counter { * If the value of the function is false, that means, that the counter have reached its end-value. **/ bool increment() { - size_t i = 0; + std::size_t i = 0; while ((i != this->end.size()) && (this->current[i] == this->end[i])) { ++i; } if (i == this->end.size())return false; ++this->current[i]; - for (size_t j = 0; j != i; ++j) { + for (std::size_t j = 0; j != i; ++j) { this->current[j] = this->begin[j]; } return true; @@ -80,7 +81,7 @@ class counter { * Function to check if we are at the end of counter. **/ bool isFinal() { - for (size_t i = 0; i != this->current.size(); ++i) { + for (std::size_t i = 0; i != this->current.size(); ++i) { if (this->current[i] == this->end[i])return true; } return false; @@ -93,7 +94,7 @@ class counter { **/ std::vector< unsigned > find_opposite(const std::vector< bool >& directionsForPeriodicBCond) { std::vector< unsigned > result; - for (size_t i = 0; i != this->current.size(); ++i) { + for (std::size_t i = 0; i != this->current.size(); ++i) { if ((this->current[i] == this->end[i]) && (directionsForPeriodicBCond[i] == true)) { result.push_back(this->begin[i]); } else { @@ -108,7 +109,7 @@ class counter { **/ std::vector< bool > directions_of_finals() { std::vector< bool > result; - for (size_t i = 0; i != this->current.size(); ++i) { + for (std::size_t i = 0; i != this->current.size(); ++i) { if (this->current[i] == this->end[i]) { result.push_back(true); } else { @@ -123,7 +124,7 @@ class counter { **/ friend std::ostream& operator<<(std::ostream& out, const counter& c) { // std::cerr << "c.current.size() : " << c.current.size() << endl; - for (size_t i = 0; i != c.current.size(); ++i) { + for (std::size_t i = 0; i != c.current.size(); ++i) { out << c.current[i] << " "; } return out; 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 e2f86f3b..4a0d1c74 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 @@ -29,6 +29,7 @@ #include // for numeric_limits<> #include #include +#include namespace Gudhi { @@ -94,7 +95,7 @@ class Bitmap_cubical_complex_periodic_boundary_conditions_base : public Bitmap_c * The boundary elements are guaranteed to be returned so that the * incidence coefficients are alternating. */ - virtual std::vector get_boundary_of_a_cell(size_t cell) const; + virtual std::vector get_boundary_of_a_cell(std::size_t cell) const; /** * A version of a function that return coboundary of a given cell for an object of @@ -104,7 +105,7 @@ class Bitmap_cubical_complex_periodic_boundary_conditions_base : public Bitmap_c * To compute incidence between cells use compute_incidence_between_cells * procedure */ - virtual std::vector get_coboundary_of_a_cell(size_t cell) const; + virtual std::vector get_coboundary_of_a_cell(std::size_t cell) const; /** * This procedure compute incidence numbers between cubes. For a cube \f$A\f$ of @@ -125,15 +126,15 @@ class Bitmap_cubical_complex_periodic_boundary_conditions_base : public Bitmap_c * @exception std::logic_error In case when the cube \f$B\f$ is not n-1 * dimensional face of a cube \f$A\f$. **/ - virtual int compute_incidence_between_cells(size_t coface, size_t face) { + virtual int compute_incidence_between_cells(std::size_t coface, std::size_t face) { // first get the counters for coface and face: std::vector coface_counter = this->compute_counter_for_given_cell(coface); std::vector face_counter = this->compute_counter_for_given_cell(face); // coface_counter and face_counter should agree at all positions except from one: int number_of_position_in_which_counters_do_not_agree = -1; - size_t number_of_full_faces_that_comes_before = 0; - for (size_t i = 0; i != coface_counter.size(); ++i) { + std::size_t number_of_full_faces_that_comes_before = 0; + for (std::size_t i = 0; i != coface_counter.size(); ++i) { if ((coface_counter[i] % 2 == 1) && (number_of_position_in_which_counters_do_not_agree == -1)) { ++number_of_full_faces_that_comes_before; } @@ -165,7 +166,7 @@ class Bitmap_cubical_complex_periodic_boundary_conditions_base : public Bitmap_c void set_up_containers(const std::vector& sizes) { unsigned multiplier = 1; - for (size_t i = 0; i != sizes.size(); ++i) { + for (std::size_t i = 0; i != sizes.size(); ++i) { this->sizes.push_back(sizes[i]); this->multipliers.push_back(multiplier); @@ -198,7 +199,7 @@ void Bitmap_cubical_complex_periodic_boundary_conditions_base::construct_comp this->directions_in_which_periodic_b_cond_are_to_be_imposed = directions_in_which_periodic_b_cond_are_to_be_imposed; this->set_up_containers(dimensions); - size_t i = 0; + std::size_t i = 0; for (auto it = this->top_dimensional_cells_iterator_begin(); it != this->top_dimensional_cells_iterator_end(); ++it) { this->get_cell_data(*it) = topDimensionalCells[i]; ++i; @@ -229,7 +230,7 @@ Bitmap_cubical_complex_periodic_boundary_conditions_base::Bitmap_cubical_comp std::vector sizes; sizes.reserve(dimensionOfData); - for (size_t i = 0; i != dimensionOfData; ++i) { + for (std::size_t i = 0; i != dimensionOfData; ++i) { int size_in_this_dimension; inFiltration >> size_in_this_dimension; if (size_in_this_dimension < 0) { @@ -285,19 +286,19 @@ Bitmap_cubical_complex_periodic_boundary_conditions_base::Bitmap_cubical_comp // ***********************Methods************************ // template -std::vector Bitmap_cubical_complex_periodic_boundary_conditions_base::get_boundary_of_a_cell( - size_t cell) const { +std::vector Bitmap_cubical_complex_periodic_boundary_conditions_base::get_boundary_of_a_cell( + std::size_t cell) const { bool dbg = false; if (dbg) { std::cerr << "Computations of boundary of a cell : " << cell << std::endl; } - std::vector boundary_elements; + std::vector boundary_elements; boundary_elements.reserve(this->dimension() * 2); - size_t cell1 = cell; - size_t sum_of_dimensions = 0; + std::size_t cell1 = cell; + std::size_t sum_of_dimensions = 0; - for (size_t i = this->multipliers.size(); i != 0; --i) { + for (std::size_t i = this->multipliers.size(); i != 0; --i) { unsigned position = cell1 / this->multipliers[i - 1]; // this cell have a nonzero length in this direction, therefore we can compute its boundary in this direction. if (position % 2 == 1) { @@ -351,12 +352,12 @@ std::vector Bitmap_cubical_complex_periodic_boundary_conditions_base: } template -std::vector Bitmap_cubical_complex_periodic_boundary_conditions_base::get_coboundary_of_a_cell( - size_t cell) const { +std::vector Bitmap_cubical_complex_periodic_boundary_conditions_base::get_coboundary_of_a_cell( + std::size_t cell) const { std::vector counter = this->compute_counter_for_given_cell(cell); - std::vector coboundary_elements; - size_t cell1 = cell; - for (size_t i = this->multipliers.size(); i != 0; --i) { + std::vector coboundary_elements; + std::size_t cell1 = cell; + for (std::size_t i = this->multipliers.size(); i != 0; --i) { unsigned position = cell1 / this->multipliers[i - 1]; // if the cell has zero length in this direction, then it will have cbd in this direction. if (position % 2 == 0) { -- cgit v1.2.3