diff options
Diffstat (limited to 'src/Bitmap_cubical_complex')
-rw-r--r-- | src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h | 55 | ||||
-rw-r--r-- | src/Bitmap_cubical_complex/example/CMakeLists.txt | 26 | ||||
-rw-r--r-- | src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h | 35 | ||||
-rw-r--r-- | src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex/counter.h | 13 | ||||
-rw-r--r-- | src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h | 177 | ||||
-rw-r--r-- | src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h | 39 | ||||
-rw-r--r-- | src/Bitmap_cubical_complex/utilities/CMakeLists.txt | 29 | ||||
-rw-r--r-- | src/Bitmap_cubical_complex/utilities/README | 18 | ||||
-rw-r--r-- | src/Bitmap_cubical_complex/utilities/cubical_complex_persistence.cpp (renamed from src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp) | 0 | ||||
-rw-r--r-- | src/Bitmap_cubical_complex/utilities/periodic_cubical_complex_persistence.cpp (renamed from src/Bitmap_cubical_complex/example/Bitmap_cubical_complex_periodic_boundary_conditions.cpp) | 0 |
10 files changed, 188 insertions, 204 deletions
diff --git a/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h b/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h index 5963caa3..ee84e201 100644 --- a/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h +++ b/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h @@ -63,7 +63,7 @@ namespace cubical_complex { * For further details and theory of cubical complexes, please consult \cite kaczynski2004computational as well as the * following paper \cite peikert2012topological . * - * \section cubicalcomplexdatastructure Data structure. + * \section cubicalcomplexdatastructure Data structure * * The implementation of Cubical complex provides a representation of complexes that occupy a rectangular region in * \f$\mathbb{R}^n\f$. This extra assumption allows for a memory efficient way of storing cubical complexes in a form @@ -85,37 +85,14 @@ namespace cubical_complex { * present in the product that gives the cube \f$C\f$. In a similar way, we can compute boundary and the coboundary of * each cube. Further details can be found in the literature. * - * \section inputformat Input Format. + * \section inputformat Input Format * * In the current implantation, filtration is given at the maximal cubes, and it is then extended by the lower star * filtration to all cubes. There are a number of constructors that can be used to construct cubical complex by users * who want to use the code directly. They can be found in the \a Bitmap_cubical_complex class. * Currently one input from a text file is used. It uses a format used already in Perseus software - * (http://www.sas.upenn.edu/~vnanda/perseus/) by Vidit Nanda. - * Below we are providing a description of the format. The first line contains a number d begin the dimension of the - * bitmap (2 in the example below). Next d lines are the numbers of top dimensional cubes in each dimensions (3 and 3 - * in the example below). Next, in lexicographical order, the filtration of top dimensional cubes is given (1 4 6 8 - * 20 4 7 6 5 in the example below). - * - * - * \image html "exampleBitmap.png" "Example of a input data." - * - * The input file for the following complex is: - * \verbatim -2 -3 -3 -1 -4 -6 -8 -20 -4 -7 -6 -5 -\endverbatim - + * (http://www.sas.upenn.edu/~vnanda/perseus/) by Vidit Nanda. The file format is described here: \ref FileFormatsPerseus. + * * \section PeriodicBoundaryConditions Periodic boundary conditions * Often one would like to impose periodic boundary conditions to the cubical complex. Let \f$ I_1\times ... \times * I_n \f$ be a box that is decomposed with a cubical complex \f$ \mathcal{K} \f$. Imposing periodic boundary @@ -123,28 +100,10 @@ namespace cubical_complex { * considered the same. In particular, if for a bitmap \f$ \mathcal{K} \f$ periodic boundary conditions are imposed * in all directions, then complex \f$ \mathcal{K} \f$ became n-dimensional torus. One can use various constructors * from the file Bitmap_cubical_complex_periodic_boundary_conditions_base.h to construct cubical complex with periodic - * boundary conditions. One can also use Perseus style input files. To indicate periodic boundary conditions in a - * given direction, then number of top dimensional cells in this direction have to be multiplied by -1. For instance: - - *\verbatim -2 --3 -3 -1 -4 -6 -8 -20 -4 -7 -6 -5 -\endverbatim - - * Indicate that we have imposed periodic boundary conditions in the direction x, but not in the direction y. - + * boundary conditions. One can also use Perseus style input files (see \ref FileFormatsPerseus). + * * \section BitmapExamples Examples - * End user programs are available in example/Bitmap_cubical_complex folder. + * End user programs are available in example/Bitmap_cubical_complex and utilities/Bitmap_cubical_complex folders. * * \copyright GNU General Public License v3. */ diff --git a/src/Bitmap_cubical_complex/example/CMakeLists.txt b/src/Bitmap_cubical_complex/example/CMakeLists.txt index a0401619..99304aa4 100644 --- a/src/Bitmap_cubical_complex/example/CMakeLists.txt +++ b/src/Bitmap_cubical_complex/example/CMakeLists.txt @@ -1,17 +1,6 @@ cmake_minimum_required(VERSION 2.6) project(Bitmap_cubical_complex_examples) -add_executable ( Bitmap_cubical_complex Bitmap_cubical_complex.cpp ) -if (TBB_FOUND) - target_link_libraries(Bitmap_cubical_complex ${TBB_LIBRARIES}) -endif() - -add_test(NAME Bitmap_cubical_complex_example_persistence_one_sphere COMMAND $<TARGET_FILE:Bitmap_cubical_complex> - "${CMAKE_SOURCE_DIR}/data/bitmap/CubicalOneSphere.txt") - -add_test(NAME Bitmap_cubical_complex_example_persistence_two_sphere COMMAND $<TARGET_FILE:Bitmap_cubical_complex> - "${CMAKE_SOURCE_DIR}/data/bitmap/CubicalTwoSphere.txt") - add_executable ( Random_bitmap_cubical_complex Random_bitmap_cubical_complex.cpp ) if (TBB_FOUND) target_link_libraries(Random_bitmap_cubical_complex ${TBB_LIBRARIES}) @@ -19,19 +8,4 @@ endif() add_test(NAME Bitmap_cubical_complex_example_random COMMAND $<TARGET_FILE:Random_bitmap_cubical_complex> "2" "100" "100") -add_executable ( Bitmap_cubical_complex_periodic_boundary_conditions Bitmap_cubical_complex_periodic_boundary_conditions.cpp ) -if (TBB_FOUND) - target_link_libraries(Bitmap_cubical_complex_periodic_boundary_conditions ${TBB_LIBRARIES}) -endif() - -add_test(NAME Bitmap_cubical_complex_example_periodic_boundary_conditions_2d_torus - COMMAND $<TARGET_FILE:Bitmap_cubical_complex_periodic_boundary_conditions> - "${CMAKE_SOURCE_DIR}/data/bitmap/2d_torus.txt") - -add_test(NAME Bitmap_cubical_complex_example_periodic_boundary_conditions_3d_torus - COMMAND $<TARGET_FILE:Bitmap_cubical_complex_periodic_boundary_conditions> - "${CMAKE_SOURCE_DIR}/data/bitmap/3d_torus.txt") - -install(TARGETS Bitmap_cubical_complex DESTINATION bin) install(TARGETS Random_bitmap_cubical_complex DESTINATION bin) -install(TARGETS Bitmap_cubical_complex_periodic_boundary_conditions DESTINATION bin) 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 <algorithm> // for sort #include <vector> #include <numeric> // for iota +#include <cstddef> 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<unsigned>& dimensions, const std::vector<Filtration_value>& 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<bool> 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<T>* 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<Simplex_handle, Simplex_handle> endpoints(Simplex_handle sh) { - std::vector<size_t> bdry = this->get_boundary_of_a_cell(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() << 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<T>* 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<T>; protected: - std::vector<size_t> key_associated_to_simplex; - std::vector<size_t> simplex_associated_to_key; + std::vector<std::size_t> key_associated_to_simplex; + std::vector<std::size_t> simplex_associated_to_key; }; // Bitmap_cubical_complex template <typename T> @@ -528,7 +529,7 @@ 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"; } - this->simplex_associated_to_key = std::vector<size_t>(this->data.size()); + 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); #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<T>::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 <iostream> #include <vector> +#include <cstddef> 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_base.h b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h index 4adadce6..bf257be1 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 @@ -34,6 +34,7 @@ #include <limits> #include <utility> #include <stdexcept> +#include <cstddef> namespace Gudhi { @@ -103,7 +104,7 @@ class Bitmap_cubical_complex_base { * The boundary elements are guaranteed to be returned so that the * incidence coefficients of boundary elements are alternating. */ - virtual inline std::vector<size_t> get_boundary_of_a_cell(size_t cell) const; + virtual inline std::vector<std::size_t> get_boundary_of_a_cell(std::size_t cell) const; /** * The functions get_coboundary_of_a_cell, get_coboundary_of_a_cell, * get_dimension_of_a_cell and get_cell_data are the basic @@ -118,7 +119,7 @@ class Bitmap_cubical_complex_base { * not guaranteed to be returned with alternating incidence numbers. * **/ - virtual inline std::vector<size_t> get_coboundary_of_a_cell(size_t cell) const; + virtual inline std::vector<std::size_t> get_coboundary_of_a_cell(std::size_t cell) const; /** * This procedure compute incidence numbers between cubes. For a cube \f$A\f$ of @@ -139,15 +140,15 @@ class Bitmap_cubical_complex_base { * @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) const { + virtual int compute_incidence_between_cells(std::size_t coface, std::size_t face) const { // 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); // 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; } @@ -180,7 +181,7 @@ class Bitmap_cubical_complex_base { * To compute incidence between cells use compute_incidence_between_cells * procedure **/ - inline unsigned get_dimension_of_a_cell(size_t cell) const; + inline unsigned get_dimension_of_a_cell(std::size_t cell) const; /** * In the case of get_cell_data, the output parameter is a reference to the value of a cube in a given position. @@ -188,7 +189,7 @@ class Bitmap_cubical_complex_base { * code do not check if we have a filtration or not. i.e. it do not check if the value of a filtration of a cell is * not smaller than the value of a filtration of its boundary and not greater than the value of its coboundary. **/ - inline T& get_cell_data(size_t cell); + inline T& get_cell_data(std::size_t cell); /** * Typical input used to construct a baseBitmap class is a filtration given at the top dimensional cells. @@ -222,10 +223,10 @@ class Bitmap_cubical_complex_base { * equally distributed in the range of data. * Sometimes if most of the cells have different birth-death times, the performance of the algorithms to compute * persistence gets worst. When dealing with this type of data, one may want to put different values on cells to - * some number of bins. The function put_data_to_bins( size_t number_of_bins ) is designed for that purpose. + * some number of bins. The function put_data_to_bins( std::size_t number_of_bins ) is designed for that purpose. * The parameter of the function is the number of bins (distinct values) we want to have in the cubical complex. **/ - void put_data_to_bins(size_t number_of_bins); + void put_data_to_bins(std::size_t number_of_bins); /** * Function that put the input data to bins. By putting data to bins we mean rounding them to a sequence of values @@ -285,11 +286,11 @@ class Bitmap_cubical_complex_base { * boundary and coboundary and dimension * and in function get_cell_data to get a filtration of a cell. */ - size_t operator*() { return this->counter; } + std::size_t operator*() { return this->counter; } friend class Bitmap_cubical_complex_base; protected: - size_t counter; + std::size_t counter; }; /** @@ -329,26 +330,26 @@ class Bitmap_cubical_complex_base { /** * Boundary_range class provides ranges for boundary iterators. **/ - typedef typename std::vector<size_t>::const_iterator Boundary_iterator; - typedef typename std::vector<size_t> Boundary_range; + typedef typename std::vector<std::size_t>::const_iterator Boundary_iterator; + typedef typename std::vector<std::size_t> Boundary_range; /** * boundary_simplex_range creates an object of a Boundary_simplex_range class * that provides ranges for the Boundary_simplex_iterator. **/ - Boundary_range boundary_range(size_t sh) { return this->get_boundary_of_a_cell(sh); } + Boundary_range boundary_range(std::size_t sh) { return this->get_boundary_of_a_cell(sh); } /** * Coboundary_range class provides ranges for boundary iterators. **/ - typedef typename std::vector<size_t>::const_iterator Coboundary_iterator; - typedef typename std::vector<size_t> Coboundary_range; + typedef typename std::vector<std::size_t>::const_iterator Coboundary_iterator; + typedef typename std::vector<std::size_t> Coboundary_range; /** * boundary_simplex_range creates an object of a Boundary_simplex_range class * that provides ranges for the Boundary_simplex_iterator. **/ - Coboundary_range coboundary_range(size_t sh) { return this->get_coboundary_of_a_cell(sh); } + Coboundary_range coboundary_range(std::size_t sh) { return this->get_coboundary_of_a_cell(sh); } /** * @brief Iterator through top dimensional cells of the complex. The cells appear in order they are stored @@ -357,18 +358,18 @@ class Bitmap_cubical_complex_base { class Top_dimensional_cells_iterator : std::iterator<std::input_iterator_tag, T> { public: Top_dimensional_cells_iterator(Bitmap_cubical_complex_base& b) : b(b) { - this->counter = std::vector<size_t>(b.dimension()); + this->counter = std::vector<std::size_t>(b.dimension()); // std::fill( this->counter.begin() , this->counter.end() , 0 ); } Top_dimensional_cells_iterator operator++() { // first find first element of the counter that can be increased: - size_t dim = 0; + std::size_t dim = 0; while ((dim != this->b.dimension()) && (this->counter[dim] == this->b.sizes[dim] - 1)) ++dim; if (dim != this->b.dimension()) { ++this->counter[dim]; - for (size_t i = 0; i != dim; ++i) { + for (std::size_t i = 0; i != dim; ++i) { this->counter[i] = 0; } } else { @@ -392,7 +393,7 @@ class Bitmap_cubical_complex_base { bool operator==(const Top_dimensional_cells_iterator& rhs) const { if (&this->b != &rhs.b) return false; if (this->counter.size() != rhs.counter.size()) return false; - for (size_t i = 0; i != this->counter.size(); ++i) { + for (std::size_t i = 0; i != this->counter.size(); ++i) { if (this->counter[i] != rhs.counter[i]) return false; } return true; @@ -407,25 +408,25 @@ class Bitmap_cubical_complex_base { * boundary and coboundary and dimension * and in function get_cell_data to get a filtration of a cell. */ - size_t operator*() { return this->compute_index_in_bitmap(); } + std::size_t operator*() { return this->compute_index_in_bitmap(); } - size_t compute_index_in_bitmap() const { - size_t index = 0; - for (size_t i = 0; i != this->counter.size(); ++i) { + std::size_t compute_index_in_bitmap() const { + std::size_t index = 0; + for (std::size_t i = 0; i != this->counter.size(); ++i) { index += (2 * this->counter[i] + 1) * this->b.multipliers[i]; } return index; } void print_counter() const { - for (size_t i = 0; i != this->counter.size(); ++i) { + for (std::size_t i = 0; i != this->counter.size(); ++i) { std::cout << this->counter[i] << " "; } } friend class Bitmap_cubical_complex_base; protected: - std::vector<size_t> counter; + std::vector<std::size_t> counter; Bitmap_cubical_complex_base& b; }; @@ -442,7 +443,7 @@ class Bitmap_cubical_complex_base { **/ Top_dimensional_cells_iterator top_dimensional_cells_iterator_end() { Top_dimensional_cells_iterator a(*this); - for (size_t i = 0; i != this->dimension(); ++i) { + for (std::size_t i = 0; i != this->dimension(); ++i) { a.counter[i] = this->sizes[i] - 1; } a.counter[0]++; @@ -471,7 +472,7 @@ class Bitmap_cubical_complex_base { //****************************************************************************************************************// //****************************************************************************************************************// - inline size_t number_cells() const { return this->total_number_of_cells; } + inline std::size_t number_cells() const { return this->total_number_of_cells; } //****************************************************************************************************************// //****************************************************************************************************************// @@ -482,11 +483,11 @@ class Bitmap_cubical_complex_base { std::vector<unsigned> sizes; std::vector<unsigned> multipliers; std::vector<T> data; - size_t total_number_of_cells; + std::size_t total_number_of_cells; void set_up_containers(const std::vector<unsigned>& 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); multiplier *= 2 * sizes[i] + 1; @@ -495,18 +496,18 @@ class Bitmap_cubical_complex_base { this->total_number_of_cells = multiplier; } - size_t compute_position_in_bitmap(const std::vector<unsigned>& counter) { - size_t position = 0; - for (size_t i = 0; i != this->multipliers.size(); ++i) { + std::size_t compute_position_in_bitmap(const std::vector<unsigned>& counter) { + std::size_t position = 0; + for (std::size_t i = 0; i != this->multipliers.size(); ++i) { position += this->multipliers[i] * counter[i]; } return position; } - std::vector<unsigned> compute_counter_for_given_cell(size_t cell) const { + std::vector<unsigned> compute_counter_for_given_cell(std::size_t cell) const { std::vector<unsigned> counter; counter.reserve(this->sizes.size()); - for (size_t dim = this->sizes.size(); dim != 0; --dim) { + for (std::size_t dim = this->sizes.size(); dim != 0; --dim) { counter.push_back(cell / this->multipliers[dim - 1]); cell = cell % this->multipliers[dim - 1]; } @@ -523,40 +524,38 @@ class Bitmap_cubical_complex_base { }; template <typename T> -void Bitmap_cubical_complex_base<T>::put_data_to_bins(size_t number_of_bins) { - bool bdg = false; +void Bitmap_cubical_complex_base<T>::put_data_to_bins(std::size_t number_of_bins) { + bool dbg = false; std::pair<T, T> min_max = this->min_max_filtration(); T dx = (min_max.second - min_max.first) / (T)number_of_bins; // now put the data into the appropriate bins: - for (size_t i = 0; i != this->data.size(); ++i) { - if (bdg) { + for (std::size_t i = 0; i != this->data.size(); ++i) { + if (dbg) { std::cerr << "Before binning : " << this->data[i] << std::endl; } this->data[i] = min_max.first + dx * (this->data[i] - min_max.first) / number_of_bins; - if (bdg) { + if (dbg) { std::cerr << "After binning : " << this->data[i] << std::endl; - getchar(); } } } template <typename T> void Bitmap_cubical_complex_base<T>::put_data_to_bins(T diameter_of_bin) { - bool bdg = false; + bool dbg = false; std::pair<T, T> min_max = this->min_max_filtration(); - size_t number_of_bins = (min_max.second - min_max.first) / diameter_of_bin; + std::size_t number_of_bins = (min_max.second - min_max.first) / diameter_of_bin; // now put the data into the appropriate bins: - for (size_t i = 0; i != this->data.size(); ++i) { - if (bdg) { + for (std::size_t i = 0; i != this->data.size(); ++i) { + if (dbg) { std::cerr << "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 (bdg) { + if (dbg) { std::cerr << "After binning : " << this->data[i] << std::endl; - getchar(); } } } @@ -564,7 +563,7 @@ void Bitmap_cubical_complex_base<T>::put_data_to_bins(T diameter_of_bin) { template <typename T> std::pair<T, T> Bitmap_cubical_complex_base<T>::min_max_filtration() { std::pair<T, T> min_max(std::numeric_limits<T>::max(), std::numeric_limits<T>::min()); - for (size_t i = 0; i != this->data.size(); ++i) { + for (std::size_t i = 0; i != this->data.size(); ++i) { if (this->data[i] < min_max.first) min_max.first = this->data[i]; if (this->data[i] > min_max.second) min_max.second = this->data[i]; } @@ -590,23 +589,24 @@ void Bitmap_cubical_complex_base<T>::setup_bitmap_based_on_top_dimensional_cells const std::vector<unsigned>& sizes_in_following_directions, const std::vector<T>& top_dimensional_cells) { this->set_up_containers(sizes_in_following_directions); - size_t number_of_top_dimensional_elements = 1; - for (size_t i = 0; i != sizes_in_following_directions.size(); ++i) { + std::size_t number_of_top_dimensional_elements = 1; + for (std::size_t i = 0; i != sizes_in_following_directions.size(); ++i) { number_of_top_dimensional_elements *= sizes_in_following_directions[i]; } if (number_of_top_dimensional_elements != top_dimensional_cells.size()) { - std::cerr << "Error in constructor Bitmap_cubical_complex_base ( std::vector<size_t> sizes_in_following_directions" - << ", std::vector<T> top_dimensional_cells ). Number of top dimensional elements that follow from " - << "sizes_in_following_directions vector is different than the size of top_dimensional_cells vector." + std::cerr << "Error in constructor Bitmap_cubical_complex_base ( std::vector<std::size_t> " + << "sizes_in_following_directions, std::vector<T> top_dimensional_cells ). Number of top dimensional " + << "elements that follow from sizes_in_following_directions vector is different than the size of " + << "top_dimensional_cells vector." << std::endl; throw( - "Error in constructor Bitmap_cubical_complex_base( std::vector<size_t> sizes_in_following_directions," + "Error in constructor Bitmap_cubical_complex_base( std::vector<std::size_t> sizes_in_following_directions," "std::vector<T> top_dimensional_cells ). Number of top dimensional elements that follow from " "sizes_in_following_directions vector is different than the size of top_dimensional_cells vector."); } Bitmap_cubical_complex_base<T>::Top_dimensional_cells_iterator it(*this); - size_t index = 0; + std::size_t index = 0; for (it = this->top_dimensional_cells_iterator_begin(); it != this->top_dimensional_cells_iterator_end(); ++it) { this->get_cell_data(*it) = top_dimensional_cells[index]; ++index; @@ -630,15 +630,17 @@ void Bitmap_cubical_complex_base<T>::read_perseus_style_file(const char* perseus if (dbg) { std::cerr << "dimensionOfData : " << dimensionOfData << std::endl; - getchar(); } std::vector<unsigned> sizes; sizes.reserve(dimensionOfData); - for (size_t i = 0; i != dimensionOfData; ++i) { + // all dimensions multiplied + std::size_t dimensions = 1; + for (std::size_t i = 0; i != dimensionOfData; ++i) { unsigned size_in_this_dimension; inFiltration >> size_in_this_dimension; 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; } @@ -648,9 +650,11 @@ void Bitmap_cubical_complex_base<T>::read_perseus_style_file(const char* perseus Bitmap_cubical_complex_base<T>::Top_dimensional_cells_iterator it(*this); it = this->top_dimensional_cells_iterator_begin(); - while (!inFiltration.eof()) { - T filtrationLevel; - inFiltration >> filtrationLevel; + T filtrationLevel; + for (std::size_t i = 0; i < dimensions; ++i) { + if (!(inFiltration >> filtrationLevel) || (inFiltration.eof())) { + throw std::ios_base::failure("Bad Perseus file format."); + } if (dbg) { std::cerr << "Cell of an index : " << it.compute_index_in_bitmap() << " and dimension: " << this->get_dimension_of_a_cell(it.compute_index_in_bitmap()) @@ -659,6 +663,7 @@ void Bitmap_cubical_complex_base<T>::read_perseus_style_file(const char* perseus this->get_cell_data(*it) = filtrationLevel; ++it; } + inFiltration.close(); this->impose_lower_star_filtration(); } @@ -697,15 +702,15 @@ Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base(const char* perseus_ } template <typename T> -std::vector<size_t> Bitmap_cubical_complex_base<T>::get_boundary_of_a_cell(size_t cell) const { - std::vector<size_t> boundary_elements; +std::vector<std::size_t> Bitmap_cubical_complex_base<T>::get_boundary_of_a_cell(std::size_t cell) const { + std::vector<std::size_t> boundary_elements; // Speed traded of for memory. Check if it is better in practice. boundary_elements.reserve(this->dimension() * 2); - size_t sum_of_dimensions = 0; - size_t cell1 = cell; - for (size_t i = this->multipliers.size(); i != 0; --i) { + std::size_t sum_of_dimensions = 0; + std::size_t cell1 = cell; + for (std::size_t i = this->multipliers.size(); i != 0; --i) { unsigned position = cell1 / this->multipliers[i - 1]; if (position % 2 == 1) { if (sum_of_dimensions % 2) { @@ -724,11 +729,11 @@ std::vector<size_t> Bitmap_cubical_complex_base<T>::get_boundary_of_a_cell(size_ } template <typename T> -std::vector<size_t> Bitmap_cubical_complex_base<T>::get_coboundary_of_a_cell(size_t cell) const { +std::vector<std::size_t> Bitmap_cubical_complex_base<T>::get_coboundary_of_a_cell(std::size_t cell) const { std::vector<unsigned> counter = this->compute_counter_for_given_cell(cell); - std::vector<size_t> coboundary_elements; - size_t cell1 = cell; - for (size_t i = this->multipliers.size(); i != 0; --i) { + std::vector<std::size_t> 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 (position % 2 == 0) { if ((cell > this->multipliers[i - 1]) && (counter[i - 1] != 0)) { @@ -744,11 +749,11 @@ std::vector<size_t> Bitmap_cubical_complex_base<T>::get_coboundary_of_a_cell(siz } template <typename T> -unsigned Bitmap_cubical_complex_base<T>::get_dimension_of_a_cell(size_t cell) const { +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; unsigned dimension = 0; - for (size_t i = this->multipliers.size(); i != 0; --i) { + for (std::size_t i = this->multipliers.size(); i != 0; --i) { unsigned position = cell / this->multipliers[i - 1]; if (dbg) { @@ -756,7 +761,6 @@ unsigned Bitmap_cubical_complex_base<T>::get_dimension_of_a_cell(size_t cell) co std::cerr << "cell : " << cell << std::endl; std::cerr << "position : " << position << std::endl; std::cerr << "multipliers[" << i - 1 << "] = " << this->multipliers[i - 1] << std::endl; - getchar(); } if (position % 2 == 1) { @@ -769,7 +773,7 @@ unsigned Bitmap_cubical_complex_base<T>::get_dimension_of_a_cell(size_t cell) co } template <typename T> -inline T& Bitmap_cubical_complex_base<T>::get_cell_data(size_t cell) { +inline T& Bitmap_cubical_complex_base<T>::get_cell_data(std::size_t cell) { return this->data[cell]; } @@ -780,12 +784,12 @@ void Bitmap_cubical_complex_base<T>::impose_lower_star_filtration() { // this vector will be used to check which elements have already been taken care of in imposing lower star filtration std::vector<bool> is_this_cell_considered(this->data.size(), false); - size_t size_to_reserve = 1; - for (size_t i = 0; i != this->multipliers.size(); ++i) { - size_to_reserve *= (size_t)((this->multipliers[i] - 1) / 2); + std::size_t size_to_reserve = 1; + for (std::size_t i = 0; i != this->multipliers.size(); ++i) { + size_to_reserve *= (std::size_t)((this->multipliers[i] - 1) / 2); } - std::vector<size_t> indices_to_consider; + std::vector<std::size_t> indices_to_consider; indices_to_consider.reserve(size_to_reserve); // we assume here that we already have a filtration on the top dimensional cells and // we have to extend it to lower ones. @@ -797,27 +801,24 @@ 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"; - for (size_t i = 0; i != indices_to_consider.size(); ++i) { + for (std::size_t i = 0; i != indices_to_consider.size(); ++i) { std::cout << indices_to_consider[i] << " "; } - getchar(); } - std::vector<size_t> new_indices_to_consider; - for (size_t i = 0; i != indices_to_consider.size(); ++i) { - std::vector<size_t> bd = this->get_boundary_of_a_cell(indices_to_consider[i]); - for (size_t boundaryIt = 0; boundaryIt != bd.size(); ++boundaryIt) { + std::vector<std::size_t> new_indices_to_consider; + for (std::size_t i = 0; i != indices_to_consider.size(); ++i) { + 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]] << " while of a cell: " << indices_to_consider[i] << " is: " << this->data[indices_to_consider[i]] << std::endl; - getchar(); } 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] << " to : " << this->data[indices_to_consider[i]] << std::endl; - getchar(); } } if (is_this_cell_considered[bd[boundaryIt]] == false) { @@ -831,8 +832,8 @@ void Bitmap_cubical_complex_base<T>::impose_lower_star_filtration() { } template <typename T> -bool compareFirstElementsOfTuples(const std::pair<std::pair<T, size_t>, char>& first, - const std::pair<std::pair<T, size_t>, char>& second) { +bool compareFirstElementsOfTuples(const std::pair<std::pair<T, std::size_t>, char>& first, + const std::pair<std::pair<T, std::size_t>, char>& second) { if (first.first.first < second.first.first) { return true; } else { 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 <limits> // for numeric_limits<> #include <vector> #include <stdexcept> +#include <cstddef> 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<size_t> get_boundary_of_a_cell(size_t cell) const; + virtual std::vector<std::size_t> 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<size_t> get_coboundary_of_a_cell(size_t cell) const; + virtual std::vector<std::size_t> 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<unsigned> coface_counter = this->compute_counter_for_given_cell(coface); std::vector<unsigned> 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<unsigned>& 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<T>::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<T>::Bitmap_cubical_comp std::vector<unsigned> 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<T>::Bitmap_cubical_comp // ***********************Methods************************ // template <typename T> -std::vector<size_t> Bitmap_cubical_complex_periodic_boundary_conditions_base<T>::get_boundary_of_a_cell( - size_t cell) const { +std::vector<std::size_t> Bitmap_cubical_complex_periodic_boundary_conditions_base<T>::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<size_t> boundary_elements; + std::vector<std::size_t> 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<size_t> Bitmap_cubical_complex_periodic_boundary_conditions_base<T>: } template <typename T> -std::vector<size_t> Bitmap_cubical_complex_periodic_boundary_conditions_base<T>::get_coboundary_of_a_cell( - size_t cell) const { +std::vector<std::size_t> Bitmap_cubical_complex_periodic_boundary_conditions_base<T>::get_coboundary_of_a_cell( + std::size_t cell) const { std::vector<unsigned> counter = this->compute_counter_for_given_cell(cell); - std::vector<size_t> coboundary_elements; - size_t cell1 = cell; - for (size_t i = this->multipliers.size(); i != 0; --i) { + std::vector<std::size_t> 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) { diff --git a/src/Bitmap_cubical_complex/utilities/CMakeLists.txt b/src/Bitmap_cubical_complex/utilities/CMakeLists.txt new file mode 100644 index 00000000..676a730a --- /dev/null +++ b/src/Bitmap_cubical_complex/utilities/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 2.6) +project(Bitmap_cubical_complex_utilities) + +add_executable ( cubical_complex_persistence cubical_complex_persistence.cpp ) +if (TBB_FOUND) + target_link_libraries(cubical_complex_persistence ${TBB_LIBRARIES}) +endif() + +add_test(NAME Bitmap_cubical_complex_utility_persistence_one_sphere COMMAND $<TARGET_FILE:cubical_complex_persistence> + "${CMAKE_SOURCE_DIR}/data/bitmap/CubicalOneSphere.txt") + +add_test(NAME Bitmap_cubical_complex_utility_persistence_two_sphere COMMAND $<TARGET_FILE:cubical_complex_persistence> + "${CMAKE_SOURCE_DIR}/data/bitmap/CubicalTwoSphere.txt") + +add_executable ( periodic_cubical_complex_persistence periodic_cubical_complex_persistence.cpp ) +if (TBB_FOUND) + target_link_libraries(periodic_cubical_complex_persistence ${TBB_LIBRARIES}) +endif() + +add_test(NAME Bitmap_cubical_complex_utility_periodic_boundary_conditions_2d_torus + COMMAND $<TARGET_FILE:periodic_cubical_complex_persistence> + "${CMAKE_SOURCE_DIR}/data/bitmap/2d_torus.txt") + +add_test(NAME Bitmap_cubical_complex_utility_periodic_boundary_conditions_3d_torus + COMMAND $<TARGET_FILE:periodic_cubical_complex_persistence> + "${CMAKE_SOURCE_DIR}/data/bitmap/3d_torus.txt") + +install(TARGETS cubical_complex_persistence DESTINATION bin) +install(TARGETS periodic_cubical_complex_persistence DESTINATION bin) diff --git a/src/Bitmap_cubical_complex/utilities/README b/src/Bitmap_cubical_complex/utilities/README new file mode 100644 index 00000000..ddff7034 --- /dev/null +++ b/src/Bitmap_cubical_complex/utilities/README @@ -0,0 +1,18 @@ +# Bitmap_cubical_complex #
+
+## `cubical_complex_persistence` ##
+This program computes persistent homology, by using the Bitmap_cubical_complex class, of cubical complexes provided in text files in Perseus style. See [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsPerseus) for a description of the file format.
+
+Example:
+
+* Create a Cubical Complex from the Perseus style file `CubicalTwoSphere.txt`, computes Persistence cohomology from it and writes the results in a persistence file `CubicalTwoSphere.txt_persistence`:
+`cubical_complex_persistence data/bitmap/CubicalTwoSphere.txt`
+
+## `periodic_cubical_complex_persistence` ##
+
+Same as above, but with periodic boundary conditions.
+
+Example:
+
+* Create a Periodical Cubical Complex from the Perseus style file `3d_torus.txt`, computes Persistence cohomology from it and writes the results in a persistence file `3d_torus.txt_persistence`:
+`periodic_cubical_complex_persistence data/bitmap/3d_torus.txt`
diff --git a/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp b/src/Bitmap_cubical_complex/utilities/cubical_complex_persistence.cpp index 9d1bc08c..9d1bc08c 100644 --- a/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp +++ b/src/Bitmap_cubical_complex/utilities/cubical_complex_persistence.cpp diff --git a/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex_periodic_boundary_conditions.cpp b/src/Bitmap_cubical_complex/utilities/periodic_cubical_complex_persistence.cpp index c812cb3a..c812cb3a 100644 --- a/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex_periodic_boundary_conditions.cpp +++ b/src/Bitmap_cubical_complex/utilities/periodic_cubical_complex_persistence.cpp |