23 #ifndef BITMAP_CUBICAL_COMPLEX_PERIODIC_BOUNDARY_CONDITIONS_BASE_H_ 24 #define BITMAP_CUBICAL_COMPLEX_PERIODIC_BOUNDARY_CONDITIONS_BASE_H_ 26 #include <gudhi/Bitmap_cubical_complex_base.h> 36 namespace cubical_complex {
68 const std::vector<unsigned>& sizes,
69 const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed);
83 const std::vector<unsigned>& dimensions,
const std::vector<T>& topDimensionalCells,
84 const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed);
131 std::vector<unsigned> coface_counter = this->compute_counter_for_given_cell(coface);
132 std::vector<unsigned> face_counter = this->compute_counter_for_given_cell(face);
135 int number_of_position_in_which_counters_do_not_agree = -1;
136 std::size_t number_of_full_faces_that_comes_before = 0;
137 for (std::size_t i = 0; i != coface_counter.size(); ++i) {
138 if ((coface_counter[i] % 2 == 1) && (number_of_position_in_which_counters_do_not_agree == -1)) {
139 ++number_of_full_faces_that_comes_before;
141 if (coface_counter[i] != face_counter[i]) {
142 if (number_of_position_in_which_counters_do_not_agree != -1) {
143 std::cout <<
"Cells given to compute_incidence_between_cells procedure do not form a pair of coface-face.\n";
144 throw std::logic_error(
145 "Cells given to compute_incidence_between_cells procedure do not form a pair of coface-face.");
147 number_of_position_in_which_counters_do_not_agree = i;
152 if (number_of_full_faces_that_comes_before % 2) incidence = -1;
154 if ((coface_counter[number_of_position_in_which_counters_do_not_agree] + 1 ==
155 face_counter[number_of_position_in_which_counters_do_not_agree]) ||
156 ((coface_counter[number_of_position_in_which_counters_do_not_agree] != 1) &&
157 (face_counter[number_of_position_in_which_counters_do_not_agree] == 0))) {
165 std::vector<bool> directions_in_which_periodic_b_cond_are_to_be_imposed;
167 void set_up_containers(
const std::vector<unsigned>& sizes) {
168 unsigned multiplier = 1;
169 for (std::size_t i = 0; i != sizes.size(); ++i) {
170 this->sizes.push_back(sizes[i]);
171 this->multipliers.push_back(multiplier);
173 if (directions_in_which_periodic_b_cond_are_to_be_imposed[i]) {
174 multiplier *= 2 * sizes[i];
176 multiplier *= 2 * sizes[i] + 1;
180 this->data = std::vector<T>(multiplier, std::numeric_limits<T>::infinity());
181 this->total_number_of_cells = multiplier;
185 const std::vector<T>& topDimensionalCells);
190 void construct_complex_based_on_top_dimensional_cells(
191 const std::vector<unsigned>& dimensions,
const std::vector<T>& topDimensionalCells,
192 const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed);
195 template <
typename T>
197 const std::vector<unsigned>& dimensions,
const std::vector<T>& topDimensionalCells,
198 const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed) {
199 this->directions_in_which_periodic_b_cond_are_to_be_imposed = directions_in_which_periodic_b_cond_are_to_be_imposed;
200 this->set_up_containers(dimensions);
210 template <
typename T>
212 const std::vector<unsigned>& sizes,
213 const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed) {
214 this->directions_in_which_periodic_b_cond_are_to_be_imposed(directions_in_which_periodic_b_cond_are_to_be_imposed);
215 this->set_up_containers(sizes);
218 template <
typename T>
220 const char* perseus_style_file) {
224 std::ifstream inFiltration;
225 inFiltration.open(perseus_style_file);
226 unsigned dimensionOfData;
227 inFiltration >> dimensionOfData;
229 this->directions_in_which_periodic_b_cond_are_to_be_imposed = std::vector<bool>(dimensionOfData,
false);
231 std::vector<unsigned> sizes;
232 sizes.reserve(dimensionOfData);
233 for (std::size_t i = 0; i != dimensionOfData; ++i) {
234 int size_in_this_dimension;
235 inFiltration >> size_in_this_dimension;
236 if (size_in_this_dimension < 0) {
237 this->directions_in_which_periodic_b_cond_are_to_be_imposed[i] =
true;
239 sizes.push_back(abs(size_in_this_dimension));
241 this->set_up_containers(sizes);
246 while (!inFiltration.eof()) {
247 double filtrationLevel;
248 inFiltration >> filtrationLevel;
249 if (inFiltration.eof())
break;
252 std::cerr <<
"Cell of an index : " << it.compute_index_in_bitmap()
254 <<
" get the value : " << filtrationLevel << std::endl;
259 inFiltration.close();
263 template <
typename T>
265 const std::vector<unsigned>& sizes) {
266 this->directions_in_which_periodic_b_cond_are_to_be_imposed = std::vector<bool>(sizes.size(),
false);
267 this->set_up_containers(sizes);
270 template <
typename T>
272 const std::vector<unsigned>& dimensions,
const std::vector<T>& topDimensionalCells) {
273 std::vector<bool> directions_in_which_periodic_b_cond_are_to_be_imposed = std::vector<bool>(dimensions.size(),
false);
274 this->construct_complex_based_on_top_dimensional_cells(dimensions, topDimensionalCells,
275 directions_in_which_periodic_b_cond_are_to_be_imposed);
278 template <
typename T>
280 const std::vector<unsigned>& dimensions,
const std::vector<T>& topDimensionalCells,
281 const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed) {
282 this->construct_complex_based_on_top_dimensional_cells(dimensions, topDimensionalCells,
283 directions_in_which_periodic_b_cond_are_to_be_imposed);
288 template <
typename T>
290 std::size_t cell)
const {
293 std::cerr <<
"Computations of boundary of a cell : " << cell << std::endl;
296 std::vector<std::size_t> boundary_elements;
297 boundary_elements.reserve(this->
dimension() * 2);
298 std::size_t cell1 = cell;
299 std::size_t sum_of_dimensions = 0;
301 for (std::size_t i = this->multipliers.size(); i != 0; --i) {
302 unsigned position = cell1 / this->multipliers[i - 1];
304 if (position % 2 == 1) {
306 if (!directions_in_which_periodic_b_cond_are_to_be_imposed[i - 1]) {
308 if (sum_of_dimensions % 2) {
309 boundary_elements.push_back(cell - this->multipliers[i - 1]);
310 boundary_elements.push_back(cell + this->multipliers[i - 1]);
312 boundary_elements.push_back(cell + this->multipliers[i - 1]);
313 boundary_elements.push_back(cell - this->multipliers[i - 1]);
316 std::cerr << cell - this->multipliers[i - 1] <<
" " << cell + this->multipliers[i - 1] <<
" ";
320 if (position != 2 * this->sizes[i - 1] - 1) {
322 if (sum_of_dimensions % 2) {
323 boundary_elements.push_back(cell - this->multipliers[i - 1]);
324 boundary_elements.push_back(cell + this->multipliers[i - 1]);
326 boundary_elements.push_back(cell + this->multipliers[i - 1]);
327 boundary_elements.push_back(cell - this->multipliers[i - 1]);
330 std::cerr << cell - this->multipliers[i - 1] <<
" " << cell + this->multipliers[i - 1] <<
" ";
334 if (sum_of_dimensions % 2) {
335 boundary_elements.push_back(cell - this->multipliers[i - 1]);
336 boundary_elements.push_back(cell - (2 * this->sizes[i - 1] - 1) * this->multipliers[i - 1]);
338 boundary_elements.push_back(cell - (2 * this->sizes[i - 1] - 1) * this->multipliers[i - 1]);
339 boundary_elements.push_back(cell - this->multipliers[i - 1]);
342 std::cerr << cell - this->multipliers[i - 1] <<
" " 343 << cell - (2 * this->sizes[i - 1] - 1) * this->multipliers[i - 1] <<
" ";
349 cell1 = cell1 % this->multipliers[i - 1];
351 return boundary_elements;
354 template <
typename T>
356 std::size_t cell)
const {
357 std::vector<unsigned>
counter = this->compute_counter_for_given_cell(cell);
358 std::vector<std::size_t> coboundary_elements;
359 std::size_t cell1 = cell;
360 for (std::size_t i = this->multipliers.size(); i != 0; --i) {
361 unsigned position = cell1 / this->multipliers[i - 1];
363 if (position % 2 == 0) {
364 if (!this->directions_in_which_periodic_b_cond_are_to_be_imposed[i - 1]) {
366 if ((counter[i - 1] != 0) && (cell > this->multipliers[i - 1])) {
367 coboundary_elements.push_back(cell - this->multipliers[i - 1]);
369 if ((counter[i - 1] != 2 * this->sizes[i - 1]) && (cell + this->multipliers[i - 1] < this->data.size())) {
370 coboundary_elements.push_back(cell + this->multipliers[i - 1]);
374 if (counter[i - 1] != 0) {
375 coboundary_elements.push_back(cell - this->multipliers[i - 1]);
376 coboundary_elements.push_back(cell + this->multipliers[i - 1]);
379 coboundary_elements.push_back(cell + this->multipliers[i - 1]);
380 coboundary_elements.push_back(cell + (2 * this->sizes[i - 1] - 1) * this->multipliers[i - 1]);
385 cell1 = cell1 % this->multipliers[i - 1];
387 return coboundary_elements;
392 namespace Cubical_complex = cubical_complex;
396 #endif // BITMAP_CUBICAL_COMPLEX_PERIODIC_BOUNDARY_CONDITIONS_BASE_H_ void impose_lower_star_filtration()
Definition: Bitmap_cubical_complex_base.h:781
unsigned dimension() const
Definition: Bitmap_cubical_complex_base.h:207
T & get_cell_data(std::size_t cell)
Definition: Bitmap_cubical_complex_base.h:776
Cubical complex with periodic boundary conditions represented as a bitmap.
Definition: Bitmap_cubical_complex_periodic_boundary_conditions_base.h:52
Cubical complex represented as a bitmap, class with basic implementation.
Definition: Bitmap_cubical_complex_base.h:63
unsigned get_dimension_of_a_cell(std::size_t cell) const
Definition: Bitmap_cubical_complex_base.h:752
Definition: SimplicialComplexForAlpha.h:26
virtual int compute_incidence_between_cells(std::size_t coface, std::size_t face)
Definition: Bitmap_cubical_complex_periodic_boundary_conditions_base.h:129
This is an implementation of a counter being a vector of integers.
Definition: counter.h:44
Bitmap_cubical_complex_periodic_boundary_conditions_base()
Definition: Bitmap_cubical_complex_periodic_boundary_conditions_base.h:59
Top_dimensional_cells_iterator top_dimensional_cells_iterator_end()
Definition: Bitmap_cubical_complex_base.h:444
Top_dimensional_cells_iterator top_dimensional_cells_iterator_begin()
Definition: Bitmap_cubical_complex_base.h:436
virtual std::vector< std::size_t > get_boundary_of_a_cell(std::size_t cell) const
Definition: Bitmap_cubical_complex_periodic_boundary_conditions_base.h:289
virtual ~Bitmap_cubical_complex_periodic_boundary_conditions_base()
Definition: Bitmap_cubical_complex_periodic_boundary_conditions_base.h:89
virtual std::vector< std::size_t > get_coboundary_of_a_cell(std::size_t cell) const
Definition: Bitmap_cubical_complex_periodic_boundary_conditions_base.h:355
Iterator through top dimensional cells of the complex. The cells appear in order they are stored in t...
Definition: Bitmap_cubical_complex_base.h:358