diff options
Diffstat (limited to 'src/Bitmap_cubical_complex')
9 files changed, 126 insertions, 83 deletions
diff --git a/src/Bitmap_cubical_complex/example/CMakeLists.txt b/src/Bitmap_cubical_complex/example/CMakeLists.txt index dc659f2d..0ff290ef 100644 --- a/src/Bitmap_cubical_complex/example/CMakeLists.txt +++ b/src/Bitmap_cubical_complex/example/CMakeLists.txt @@ -6,5 +6,3 @@ if (TBB_FOUND) endif() add_test(NAME Bitmap_cubical_complex_example_random COMMAND $<TARGET_FILE:Random_bitmap_cubical_complex> "2" "100" "100") - -install(TARGETS Random_bitmap_cubical_complex DESTINATION bin) diff --git a/src/Bitmap_cubical_complex/example/Random_bitmap_cubical_complex.cpp b/src/Bitmap_cubical_complex/example/Random_bitmap_cubical_complex.cpp index 46ea8f2e..e5512418 100644 --- a/src/Bitmap_cubical_complex/example/Random_bitmap_cubical_complex.cpp +++ b/src/Bitmap_cubical_complex/example/Random_bitmap_cubical_complex.cpp @@ -21,7 +21,7 @@ int main(int argc, char** argv) { srand(time(0)); - std::cout + std::clog << "This program computes persistent homology, by using bitmap_cubical_complex class, of cubical " << "complexes. The first parameter of the program is the dimension D of the bitmap. The next D parameters are " << "number of top dimensional cubes in each dimension of the bitmap. The program will create random cubical " 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 37514dee..29fabc6c 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::cerr << "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::cerr << "Simplex_handle null_simplex()\n"; + std::clog << "Simplex_handle null_simplex()\n"; } return std::numeric_limits<Simplex_handle>::max(); } @@ -152,7 +152,7 @@ class Bitmap_cubical_complex : public T { **/ inline unsigned dimension(Simplex_handle sh) const { if (globalDbg) { - std::cerr << "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::cerr << "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::cerr << "Simplex_key null_key()\n"; + std::clog << "Simplex_key null_key()\n"; } return std::numeric_limits<Simplex_handle>::max(); } @@ -185,7 +185,7 @@ class Bitmap_cubical_complex : public T { **/ Simplex_key key(Simplex_handle sh) const { if (globalDbg) { - std::cerr << "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::cerr << "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::cerr << "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; @@ -237,21 +237,27 @@ class Bitmap_cubical_complex : public T { * Filtration_simplex_iterator class provides an iterator though the whole structure in the order of filtration. * Secondary criteria for filtration are: * (1) Dimension of a cube (lower dimensional comes first). - * (2) Position in the data structure (the ones that are earlies in the data structure comes first). + * (2) Position in the data structure (the ones that are earliest in the data structure come first). **/ class Filtration_simplex_range; - class Filtration_simplex_iterator : std::iterator<std::input_iterator_tag, Simplex_handle> { + class Filtration_simplex_iterator { // Iterator over all simplices of the complex in the order of the indexing scheme. // 'value_type' must be 'Simplex_handle'. public: + typedef std::input_iterator_tag iterator_category; + typedef Simplex_handle value_type; + typedef std::ptrdiff_t difference_type; + typedef value_type* pointer; + typedef value_type reference; + Filtration_simplex_iterator(Bitmap_cubical_complex* b) : b(b), position(0) {} Filtration_simplex_iterator() : b(NULL), position(0) {} Filtration_simplex_iterator operator++() { if (globalDbg) { - std::cerr << "Filtration_simplex_iterator operator++\n"; + std::clog << "Filtration_simplex_iterator operator++\n"; } ++this->position; return (*this); @@ -265,7 +271,7 @@ class Bitmap_cubical_complex : public T { Filtration_simplex_iterator& operator=(const Filtration_simplex_iterator& rhs) { if (globalDbg) { - std::cerr << "Filtration_simplex_iterator operator =\n"; + std::clog << "Filtration_simplex_iterator operator =\n"; } this->b = rhs.b; this->position = rhs.position; @@ -274,21 +280,21 @@ class Bitmap_cubical_complex : public T { bool operator==(const Filtration_simplex_iterator& rhs) const { if (globalDbg) { - std::cerr << "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::cerr << "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::cerr << "Simplex_handle operator*()\n"; + std::clog << "Simplex_handle operator*()\n"; } return this->b->simplex_associated_to_key[this->position]; } @@ -314,14 +320,14 @@ class Bitmap_cubical_complex : public T { Filtration_simplex_iterator begin() { if (globalDbg) { - std::cerr << "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::cerr << "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 +353,7 @@ class Bitmap_cubical_complex : public T { **/ Filtration_simplex_range filtration_simplex_range() { if (globalDbg) { - std::cerr << "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 +376,8 @@ class Bitmap_cubical_complex : public T { std::pair<Simplex_handle, Simplex_handle> endpoints(Simplex_handle sh) { std::vector<std::size_t> bdry = this->get_boundary_of_a_cell(sh); if (globalDbg) { - std::cerr << "std::pair<Simplex_handle, Simplex_handle> endpoints( Simplex_handle sh )\n"; - std::cerr << "bdry.size() : " << bdry.size() << "\n"; + std::clog << "std::pair<Simplex_handle, Simplex_handle> 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) @@ -386,13 +392,19 @@ class Bitmap_cubical_complex : public T { **/ class Skeleton_simplex_range; - class Skeleton_simplex_iterator : std::iterator<std::input_iterator_tag, Simplex_handle> { + class Skeleton_simplex_iterator { // Iterator over all simplices of the complex in the order of the indexing scheme. // 'value_type' must be 'Simplex_handle'. public: + typedef std::input_iterator_tag iterator_category; + typedef Simplex_handle value_type; + typedef std::ptrdiff_t difference_type; + typedef value_type* pointer; + typedef value_type reference; + 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 , 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 +418,7 @@ class Bitmap_cubical_complex : public T { Skeleton_simplex_iterator operator++() { if (globalDbg) { - std::cerr << "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 +437,7 @@ class Bitmap_cubical_complex : public T { Skeleton_simplex_iterator& operator=(const Skeleton_simplex_iterator& rhs) { if (globalDbg) { - std::cerr << "Skeleton_simplex_iterator operator =\n"; + std::clog << "Skeleton_simplex_iterator operator =\n"; } this->b = rhs.b; this->position = rhs.position; @@ -435,21 +447,21 @@ class Bitmap_cubical_complex : public T { bool operator==(const Skeleton_simplex_iterator& rhs) const { if (globalDbg) { - std::cerr << "bool operator ==\n"; + std::clog << "bool operator ==\n"; } return (this->position == rhs.position); } bool operator!=(const Skeleton_simplex_iterator& rhs) const { if (globalDbg) { - std::cerr << "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::cerr << "Simplex_handle operator*() \n"; + std::clog << "Simplex_handle operator*() \n"; } return this->position; } @@ -476,14 +488,14 @@ class Bitmap_cubical_complex : public T { Skeleton_simplex_iterator begin() { if (globalDbg) { - std::cerr << "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::cerr << "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 +512,7 @@ class Bitmap_cubical_complex : public T { **/ Skeleton_simplex_range skeleton_simplex_range(unsigned dimension) { if (globalDbg) { - std::cerr << "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 +527,7 @@ class Bitmap_cubical_complex : public T { template <typename T> void Bitmap_cubical_complex<T>::initialize_simplex_associated_to_key() { if (globalDbg) { - std::cerr << "void Bitmap_cubical_complex<T>::initialize_elements_ordered_according_to_filtration() \n"; + std::clog << "void Bitmap_cubical_complex<T>::initialize_elements_ordered_according_to_filtration() \n"; } this->simplex_associated_to_key = std::vector<std::size_t>(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 0d6299d2..2bf62f9b 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 @@ -13,6 +13,8 @@ #include <gudhi/Bitmap_cubical_complex/counter.h> +#include <boost/config.hpp> + #include <iostream> #include <vector> #include <string> @@ -41,7 +43,7 @@ namespace cubical_complex { * Each cell is represented by a single * bit (in case of black and white bitmaps, or by a single element of a type T * (here T is a filtration type of a bitmap, typically a double). - * All the informations needed for homology and + * All the information needed for homology and * persistent homology computations (like dimension of a cell, boundary and * coboundary elements of a cell, are then obtained from the * position of the element in C. @@ -110,6 +112,16 @@ class Bitmap_cubical_complex_base { virtual inline std::vector<std::size_t> get_coboundary_of_a_cell(std::size_t cell) const; /** + * This function finds a top-dimensional cell that is incident to the input cell and has + * the same filtration value. In case several cells are suitable, an arbitrary one is + * returned. Note that the input parameter can be a cell of any dimension (vertex, edge, etc). + * On the other hand, the output is always indicating the position of + * a top-dimensional cube in the data structure. + * \pre The filtration values are assigned as per `impose_lower_star_filtration()`. + **/ + inline size_t get_top_dimensional_coface_of_a_cell(size_t splx); + + /** * This procedure compute incidence numbers between cubes. For a cube \f$A\f$ of * dimension n and a cube \f$B \subset A\f$ of dimension n-1, an incidence * between \f$A\f$ and \f$B\f$ is the integer with which \f$B\f$ appears in the boundary of \f$A\f$. @@ -142,7 +154,7 @@ class Bitmap_cubical_complex_base { } if (coface_counter[i] != face_counter[i]) { if (number_of_position_in_which_counters_do_not_agree != -1) { - std::cout << "Cells given to compute_incidence_between_cells procedure do not form a pair of coface-face.\n"; + std::cerr << "Cells given to compute_incidence_between_cells procedure do not form a pair of coface-face.\n"; throw std::logic_error( "Cells given to compute_incidence_between_cells procedure do not form a pair of coface-face."); } @@ -197,7 +209,7 @@ class Bitmap_cubical_complex_base { /** * Returns number of all cubes in the data structure. **/ - inline unsigned size() const { return this->data.size(); } + inline std::size_t size() const { return this->data.size(); } /** * Writing to stream operator. By using it we get the values T of cells in order in which they are stored in the @@ -239,8 +251,14 @@ class Bitmap_cubical_complex_base { * @brief Iterator through all cells in the complex (in order they appear in the structure -- i.e. * in lexicographical order). **/ - class All_cells_iterator : std::iterator<std::input_iterator_tag, T> { + class All_cells_iterator { public: + typedef std::input_iterator_tag iterator_category; + typedef std::size_t value_type; + typedef std::ptrdiff_t difference_type; + typedef value_type* pointer; + typedef value_type reference; + All_cells_iterator() { this->counter = 0; } All_cells_iterator operator++() { @@ -343,8 +361,14 @@ class Bitmap_cubical_complex_base { * @brief Iterator through top dimensional cells of the complex. The cells appear in order they are stored * in the structure (i.e. in lexicographical order) **/ - class Top_dimensional_cells_iterator : std::iterator<std::input_iterator_tag, T> { + class Top_dimensional_cells_iterator { public: + typedef std::input_iterator_tag iterator_category; + typedef std::size_t value_type; + typedef std::ptrdiff_t difference_type; + typedef value_type* pointer; + typedef value_type reference; + Top_dimensional_cells_iterator(Bitmap_cubical_complex_base& b) : b(b) { this->counter = std::vector<std::size_t>(b.dimension()); // std::fill( this->counter.begin() , this->counter.end() , 0 ); @@ -408,7 +432,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 +545,11 @@ void Bitmap_cubical_complex_base<T>::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::cerr << "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::cerr << "After binning : " << this->data[i] << std::endl; + std::clog << "After binning : " << this->data[i] << std::endl; } } } @@ -539,11 +563,11 @@ void Bitmap_cubical_complex_base<T>::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::cerr << "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::cerr << "After binning : " << this->data[i] << std::endl; + std::clog << "After binning : " << this->data[i] << std::endl; } } } @@ -603,6 +627,19 @@ void Bitmap_cubical_complex_base<T>::setup_bitmap_based_on_top_dimensional_cells } template <typename T> +size_t Bitmap_cubical_complex_base<T>::get_top_dimensional_coface_of_a_cell(size_t splx) { + if (this->get_dimension_of_a_cell(splx) == this->dimension()){return splx;} + else{ + for (auto v : this->get_coboundary_of_a_cell(splx)){ + if(this->get_cell_data(v) == this->get_cell_data(splx)){ + return this->get_top_dimensional_coface_of_a_cell(v); + } + } + } + BOOST_UNREACHABLE_RETURN(-2); +} + +template <typename T> Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base(const std::vector<unsigned>& sizes_in_following_directions, const std::vector<T>& top_dimensional_cells) { this->setup_bitmap_based_on_top_dimensional_cells_list(sizes_in_following_directions, top_dimensional_cells); @@ -617,7 +654,7 @@ void Bitmap_cubical_complex_base<T>::read_perseus_style_file(const char* perseus inFiltration >> dimensionOfData; if (dbg) { - std::cerr << "dimensionOfData : " << dimensionOfData << std::endl; + std::clog << "dimensionOfData : " << dimensionOfData << std::endl; } std::vector<unsigned> sizes; @@ -630,7 +667,7 @@ void Bitmap_cubical_complex_base<T>::read_perseus_style_file(const char* perseus sizes.push_back(size_in_this_dimension); dimensions *= size_in_this_dimension; if (dbg) { - std::cerr << "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 +688,7 @@ void Bitmap_cubical_complex_base<T>::read_perseus_style_file(const char* perseus } if (dbg) { - std::cerr << "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 +791,20 @@ std::vector<std::size_t> Bitmap_cubical_complex_base<T>::get_coboundary_of_a_cel template <typename T> unsigned Bitmap_cubical_complex_base<T>::get_dimension_of_a_cell(std::size_t cell) const { bool dbg = false; - if (dbg) std::cerr << "\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::cerr << "i-1 :" << i - 1 << std::endl; - std::cerr << "cell : " << cell << std::endl; - std::cerr << "position : " << position << std::endl; - std::cerr << "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::cerr << "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 +840,9 @@ void Bitmap_cubical_complex_base<T>::impose_lower_star_filtration() { while (indices_to_consider.size()) { if (dbg) { - std::cerr << "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<std::size_t> new_indices_to_consider; @@ -813,14 +850,14 @@ void Bitmap_cubical_complex_base<T>::impose_lower_star_filtration() { std::vector<std::size_t> bd = this->get_boundary_of_a_cell(indices_to_consider[i]); for (std::size_t boundaryIt = 0; boundaryIt != bd.size(); ++boundaryIt) { if (dbg) { - std::cerr << "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::cerr << "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 edd794fe..8ac7ae23 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 @@ -83,7 +83,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<std::size_t> get_boundary_of_a_cell(std::size_t cell) const; + virtual std::vector<std::size_t> get_boundary_of_a_cell(std::size_t cell) const override; /** * A version of a function that return coboundary of a given cell for an object of @@ -93,7 +93,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<std::size_t> get_coboundary_of_a_cell(std::size_t cell) const; + virtual std::vector<std::size_t> get_coboundary_of_a_cell(std::size_t cell) const override; /** * This procedure compute incidence numbers between cubes. For a cube \f$A\f$ of @@ -114,7 +114,7 @@ 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(std::size_t coface, std::size_t face) { + virtual int compute_incidence_between_cells(std::size_t coface, std::size_t face) const override { // first get the counters for coface and face: std::vector<unsigned> coface_counter = this->compute_counter_for_given_cell(coface); std::vector<unsigned> face_counter = this->compute_counter_for_given_cell(face); @@ -128,7 +128,7 @@ class Bitmap_cubical_complex_periodic_boundary_conditions_base : public Bitmap_c } if (coface_counter[i] != face_counter[i]) { if (number_of_position_in_which_counters_do_not_agree != -1) { - std::cout << "Cells given to compute_incidence_between_cells procedure do not form a pair of coface-face.\n"; + std::cerr << "Cells given to compute_incidence_between_cells procedure do not form a pair of coface-face.\n"; throw std::logic_error( "Cells given to compute_incidence_between_cells procedure do not form a pair of coface-face."); } @@ -237,7 +237,7 @@ Bitmap_cubical_complex_periodic_boundary_conditions_base<T>::Bitmap_cubical_comp if (inFiltration.eof()) break; if (dbg) { - std::cerr << "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<std::size_t> Bitmap_cubical_complex_periodic_boundary_conditions_bas std::size_t cell) const { bool dbg = false; if (dbg) { - std::cerr << "Computations of boundary of a cell : " << cell << std::endl; + std::clog << "Computations of boundary of a cell : " << cell << std::endl; } std::vector<std::size_t> boundary_elements; @@ -292,7 +292,6 @@ std::vector<std::size_t> Bitmap_cubical_complex_periodic_boundary_conditions_bas if (position % 2 == 1) { // if there are no periodic boundary conditions in this direction, we do not have to do anything. if (!directions_in_which_periodic_b_cond_are_to_be_imposed[i - 1]) { - // std::cerr << "A\n"; if (sum_of_dimensions % 2) { boundary_elements.push_back(cell - this->multipliers[i - 1]); boundary_elements.push_back(cell + this->multipliers[i - 1]); @@ -301,12 +300,11 @@ std::vector<std::size_t> Bitmap_cubical_complex_periodic_boundary_conditions_bas boundary_elements.push_back(cell - this->multipliers[i - 1]); } if (dbg) { - std::cerr << 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. if (position != 2 * this->sizes[i - 1] - 1) { - // std::cerr << "B\n"; if (sum_of_dimensions % 2) { boundary_elements.push_back(cell - this->multipliers[i - 1]); boundary_elements.push_back(cell + this->multipliers[i - 1]); @@ -315,10 +313,9 @@ std::vector<std::size_t> Bitmap_cubical_complex_periodic_boundary_conditions_bas boundary_elements.push_back(cell - this->multipliers[i - 1]); } if (dbg) { - std::cerr << cell - this->multipliers[i - 1] << " " << cell + this->multipliers[i - 1] << " "; + std::clog << cell - this->multipliers[i - 1] << " " << cell + this->multipliers[i - 1] << " "; } } else { - // std::cerr << "C\n"; if (sum_of_dimensions % 2) { boundary_elements.push_back(cell - this->multipliers[i - 1]); boundary_elements.push_back(cell - (2 * this->sizes[i - 1] - 1) * this->multipliers[i - 1]); @@ -327,7 +324,7 @@ std::vector<std::size_t> Bitmap_cubical_complex_periodic_boundary_conditions_bas boundary_elements.push_back(cell - this->multipliers[i - 1]); } if (dbg) { - std::cerr << cell - this->multipliers[i - 1] << " " + std::clog << cell - this->multipliers[i - 1] << " " << cell - (2 * this->sizes[i - 1] - 1) * this->multipliers[i - 1] << " "; } } diff --git a/src/Bitmap_cubical_complex/test/Bitmap_test.cpp b/src/Bitmap_cubical_complex/test/Bitmap_test.cpp index f18adb36..6f35b6da 100644 --- a/src/Bitmap_cubical_complex/test/Bitmap_test.cpp +++ b/src/Bitmap_cubical_complex/test/Bitmap_test.cpp @@ -1402,12 +1402,12 @@ BOOST_AUTO_TEST_CASE(check_if_boundary_of_boundary_is_zero_periodic_case_2d) { it != ba.all_cells_iterator_end(); ++it) { int i = 1; - // std::cout << "Element : " << *it << std::endl; + // std::clog << "Element : " << *it << std::endl; Bitmap_cubical_complex_periodic_boundary_conditions_base::Boundary_range bdrange = ba.boundary_range(*it); for (Bitmap_cubical_complex_periodic_boundary_conditions::Boundary_iterator bd = bdrange.begin(); bd != bdrange.end(); ++bd) { - // std::cout << *bd << " "; + // std::clog << *bd << " "; Bitmap_cubical_complex_periodic_boundary_conditions::Boundary_range second_bdrange = ba.boundary_range(*bd); int j = 1; for (Bitmap_cubical_complex_periodic_boundary_conditions::Boundary_iterator bd2 = second_bdrange.begin(); @@ -1441,7 +1441,7 @@ BOOST_AUTO_TEST_CASE(check_if_boundary_of_boundary_is_zero_periodic_case_3d) { std::vector<int> elems_in_boundary(number_of_all_elements, 0); for (Bitmap_cubical_complex_periodic_boundary_conditions::All_cells_iterator it = ba.all_cells_iterator_begin(); it != ba.all_cells_iterator_end(); ++it) { - // std::cout << "Element : " << *it << std::endl; + // std::clog << "Element : " << *it << std::endl; int i = 1; @@ -1449,7 +1449,7 @@ BOOST_AUTO_TEST_CASE(check_if_boundary_of_boundary_is_zero_periodic_case_3d) { for (Bitmap_cubical_complex_periodic_boundary_conditions::Boundary_iterator bd = bdrange.begin(); bd != bdrange.end(); ++bd) { Bitmap_cubical_complex_periodic_boundary_conditions::Boundary_range second_bdrange = ba.boundary_range(*bd); - // std::cout << *bd << " "; + // std::clog << *bd << " "; int j = 1; for (Bitmap_cubical_complex_periodic_boundary_conditions::Boundary_iterator bd2 = second_bdrange.begin(); bd2 != second_bdrange.end(); ++bd2) { @@ -1551,7 +1551,7 @@ BOOST_AUTO_TEST_CASE(compute_incidence_between_cells_test_periodic_boundary_cond Bitmap_cubical_complex_periodic_boundary_conditions_base::Boundary_range bdrange = ba.boundary_range(*it); for (Bitmap_cubical_complex_periodic_boundary_conditions::Boundary_iterator bd = bdrange.begin(); bd != bdrange.end(); ++bd) { - // std::cout << *bd << " "; + // std::clog << *bd << " "; Bitmap_cubical_complex_periodic_boundary_conditions::Boundary_range second_bdrange = ba.boundary_range(*bd); for (Bitmap_cubical_complex_periodic_boundary_conditions::Boundary_iterator bd2 = second_bdrange.begin(); bd2 != second_bdrange.end(); ++bd2) { @@ -1571,11 +1571,11 @@ BOOST_AUTO_TEST_CASE(perseus_file_read) { auto it = increasing.top_dimensional_cells_iterator_begin(); double value = increasing.get_cell_data(*it); - std::cout << "First value of sinusoid.txt is " << value << std::endl; + std::clog << "First value of sinusoid.txt is " << value << std::endl; BOOST_CHECK(value == 10.); // Next value ++it; value = increasing.get_cell_data(*it); - std::cout << "Second value of sinusoid.txt is " << value << std::endl; + std::clog << "Second value of sinusoid.txt is " << value << std::endl; BOOST_CHECK(value == std::numeric_limits<double>::infinity()); } diff --git a/src/Bitmap_cubical_complex/test/CMakeLists.txt b/src/Bitmap_cubical_complex/test/CMakeLists.txt index d2f002a6..eb7eb6b5 100644 --- a/src/Bitmap_cubical_complex/test/CMakeLists.txt +++ b/src/Bitmap_cubical_complex/test/CMakeLists.txt @@ -1,14 +1,13 @@ project(Bitmap_cubical_complex_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) # Do not forget to copy test files in current binary dir file(COPY "${CMAKE_SOURCE_DIR}/data/bitmap/sinusoid.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) add_executable ( Bitmap_cubical_complex_test_unit Bitmap_test.cpp ) -target_link_libraries(Bitmap_cubical_complex_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Bitmap_cubical_complex_test_unit ${TBB_LIBRARIES}) endif() -gudhi_add_coverage_test(Bitmap_cubical_complex_test_unit) +gudhi_add_boost_test(Bitmap_cubical_complex_test_unit) diff --git a/src/Bitmap_cubical_complex/utilities/cubical_complex_persistence.cpp b/src/Bitmap_cubical_complex/utilities/cubical_complex_persistence.cpp index a9792c2d..510861cd 100644 --- a/src/Bitmap_cubical_complex/utilities/cubical_complex_persistence.cpp +++ b/src/Bitmap_cubical_complex/utilities/cubical_complex_persistence.cpp @@ -19,7 +19,7 @@ #include <cstddef> int main(int argc, char** argv) { - std::cout + std::clog << "This program computes persistent homology, by using bitmap_cubical_complex class, of cubical " << "complexes provided in text files in Perseus style (the only numbered in the first line is a dimension D of a" << "bitmap. In the lines I between 2 and D+1 there are numbers of top dimensional cells in the direction I. Let " @@ -62,7 +62,7 @@ int main(int argc, char** argv) { pcoh.output_diagram(out); out.close(); - std::cout << "Result in file: " << output_file_name << "\n"; + std::clog << "Result in file: " << output_file_name << "\n"; return 0; } diff --git a/src/Bitmap_cubical_complex/utilities/periodic_cubical_complex_persistence.cpp b/src/Bitmap_cubical_complex/utilities/periodic_cubical_complex_persistence.cpp index fa97bac0..86816417 100644 --- a/src/Bitmap_cubical_complex/utilities/periodic_cubical_complex_persistence.cpp +++ b/src/Bitmap_cubical_complex/utilities/periodic_cubical_complex_persistence.cpp @@ -20,7 +20,7 @@ #include <string> int main(int argc, char** argv) { - std::cout + std::clog << "This program computes persistent homology, by using " << "Bitmap_cubical_complex_periodic_boundary_conditions class, of cubical complexes provided in text files in " << "Perseus style (the only numbered in the first line is a dimension D of a bitmap. In the lines I between 2 " @@ -64,7 +64,7 @@ int main(int argc, char** argv) { pcoh.output_diagram(out); out.close(); - std::cout << "Result in file: " << output_file_name << "\n"; + std::clog << "Result in file: " << output_file_name << "\n"; return 0; } |