multipers 2.3.3b6__cp313-cp313-macosx_10_13_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of multipers might be problematic. Click here for more details.

Files changed (183) hide show
  1. multipers/.dylibs/libc++.1.0.dylib +0 -0
  2. multipers/.dylibs/libtbb.12.16.dylib +0 -0
  3. multipers/__init__.py +33 -0
  4. multipers/_signed_measure_meta.py +453 -0
  5. multipers/_slicer_meta.py +211 -0
  6. multipers/array_api/__init__.py +45 -0
  7. multipers/array_api/numpy.py +41 -0
  8. multipers/array_api/torch.py +58 -0
  9. multipers/data/MOL2.py +458 -0
  10. multipers/data/UCR.py +18 -0
  11. multipers/data/__init__.py +1 -0
  12. multipers/data/graphs.py +466 -0
  13. multipers/data/immuno_regions.py +27 -0
  14. multipers/data/minimal_presentation_to_st_bf.py +0 -0
  15. multipers/data/pytorch2simplextree.py +91 -0
  16. multipers/data/shape3d.py +101 -0
  17. multipers/data/synthetic.py +113 -0
  18. multipers/distances.py +202 -0
  19. multipers/filtration_conversions.pxd +229 -0
  20. multipers/filtration_conversions.pxd.tp +84 -0
  21. multipers/filtrations/__init__.py +18 -0
  22. multipers/filtrations/density.py +574 -0
  23. multipers/filtrations/filtrations.py +361 -0
  24. multipers/filtrations.pxd +224 -0
  25. multipers/function_rips.cpython-313-darwin.so +0 -0
  26. multipers/function_rips.pyx +105 -0
  27. multipers/grids.cpython-313-darwin.so +0 -0
  28. multipers/grids.pyx +433 -0
  29. multipers/gudhi/Persistence_slices_interface.h +132 -0
  30. multipers/gudhi/Simplex_tree_interface.h +239 -0
  31. multipers/gudhi/Simplex_tree_multi_interface.h +551 -0
  32. multipers/gudhi/cubical_to_boundary.h +59 -0
  33. multipers/gudhi/gudhi/Bitmap_cubical_complex.h +450 -0
  34. multipers/gudhi/gudhi/Bitmap_cubical_complex_base.h +1070 -0
  35. multipers/gudhi/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h +579 -0
  36. multipers/gudhi/gudhi/Debug_utils.h +45 -0
  37. multipers/gudhi/gudhi/Fields/Multi_field.h +484 -0
  38. multipers/gudhi/gudhi/Fields/Multi_field_operators.h +455 -0
  39. multipers/gudhi/gudhi/Fields/Multi_field_shared.h +450 -0
  40. multipers/gudhi/gudhi/Fields/Multi_field_small.h +531 -0
  41. multipers/gudhi/gudhi/Fields/Multi_field_small_operators.h +507 -0
  42. multipers/gudhi/gudhi/Fields/Multi_field_small_shared.h +531 -0
  43. multipers/gudhi/gudhi/Fields/Z2_field.h +355 -0
  44. multipers/gudhi/gudhi/Fields/Z2_field_operators.h +376 -0
  45. multipers/gudhi/gudhi/Fields/Zp_field.h +420 -0
  46. multipers/gudhi/gudhi/Fields/Zp_field_operators.h +400 -0
  47. multipers/gudhi/gudhi/Fields/Zp_field_shared.h +418 -0
  48. multipers/gudhi/gudhi/Flag_complex_edge_collapser.h +337 -0
  49. multipers/gudhi/gudhi/Matrix.h +2107 -0
  50. multipers/gudhi/gudhi/Multi_critical_filtration.h +1038 -0
  51. multipers/gudhi/gudhi/Multi_persistence/Box.h +174 -0
  52. multipers/gudhi/gudhi/Multi_persistence/Line.h +282 -0
  53. multipers/gudhi/gudhi/Off_reader.h +173 -0
  54. multipers/gudhi/gudhi/One_critical_filtration.h +1441 -0
  55. multipers/gudhi/gudhi/Persistence_matrix/Base_matrix.h +769 -0
  56. multipers/gudhi/gudhi/Persistence_matrix/Base_matrix_with_column_compression.h +686 -0
  57. multipers/gudhi/gudhi/Persistence_matrix/Boundary_matrix.h +842 -0
  58. multipers/gudhi/gudhi/Persistence_matrix/Chain_matrix.h +1350 -0
  59. multipers/gudhi/gudhi/Persistence_matrix/Id_to_index_overlay.h +1105 -0
  60. multipers/gudhi/gudhi/Persistence_matrix/Position_to_index_overlay.h +859 -0
  61. multipers/gudhi/gudhi/Persistence_matrix/RU_matrix.h +910 -0
  62. multipers/gudhi/gudhi/Persistence_matrix/allocators/entry_constructors.h +139 -0
  63. multipers/gudhi/gudhi/Persistence_matrix/base_pairing.h +230 -0
  64. multipers/gudhi/gudhi/Persistence_matrix/base_swap.h +211 -0
  65. multipers/gudhi/gudhi/Persistence_matrix/boundary_cell_position_to_id_mapper.h +60 -0
  66. multipers/gudhi/gudhi/Persistence_matrix/boundary_face_position_to_id_mapper.h +60 -0
  67. multipers/gudhi/gudhi/Persistence_matrix/chain_pairing.h +136 -0
  68. multipers/gudhi/gudhi/Persistence_matrix/chain_rep_cycles.h +190 -0
  69. multipers/gudhi/gudhi/Persistence_matrix/chain_vine_swap.h +616 -0
  70. multipers/gudhi/gudhi/Persistence_matrix/columns/chain_column_extra_properties.h +150 -0
  71. multipers/gudhi/gudhi/Persistence_matrix/columns/column_dimension_holder.h +106 -0
  72. multipers/gudhi/gudhi/Persistence_matrix/columns/column_utilities.h +219 -0
  73. multipers/gudhi/gudhi/Persistence_matrix/columns/entry_types.h +327 -0
  74. multipers/gudhi/gudhi/Persistence_matrix/columns/heap_column.h +1140 -0
  75. multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_list_column.h +934 -0
  76. multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_set_column.h +934 -0
  77. multipers/gudhi/gudhi/Persistence_matrix/columns/list_column.h +980 -0
  78. multipers/gudhi/gudhi/Persistence_matrix/columns/naive_vector_column.h +1092 -0
  79. multipers/gudhi/gudhi/Persistence_matrix/columns/row_access.h +192 -0
  80. multipers/gudhi/gudhi/Persistence_matrix/columns/set_column.h +921 -0
  81. multipers/gudhi/gudhi/Persistence_matrix/columns/small_vector_column.h +1093 -0
  82. multipers/gudhi/gudhi/Persistence_matrix/columns/unordered_set_column.h +1012 -0
  83. multipers/gudhi/gudhi/Persistence_matrix/columns/vector_column.h +1244 -0
  84. multipers/gudhi/gudhi/Persistence_matrix/matrix_dimension_holders.h +186 -0
  85. multipers/gudhi/gudhi/Persistence_matrix/matrix_row_access.h +164 -0
  86. multipers/gudhi/gudhi/Persistence_matrix/ru_pairing.h +156 -0
  87. multipers/gudhi/gudhi/Persistence_matrix/ru_rep_cycles.h +376 -0
  88. multipers/gudhi/gudhi/Persistence_matrix/ru_vine_swap.h +540 -0
  89. multipers/gudhi/gudhi/Persistent_cohomology/Field_Zp.h +118 -0
  90. multipers/gudhi/gudhi/Persistent_cohomology/Multi_field.h +173 -0
  91. multipers/gudhi/gudhi/Persistent_cohomology/Persistent_cohomology_column.h +128 -0
  92. multipers/gudhi/gudhi/Persistent_cohomology.h +745 -0
  93. multipers/gudhi/gudhi/Points_off_io.h +171 -0
  94. multipers/gudhi/gudhi/Simple_object_pool.h +69 -0
  95. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_iterators.h +463 -0
  96. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +83 -0
  97. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_siblings.h +106 -0
  98. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_star_simplex_iterators.h +277 -0
  99. multipers/gudhi/gudhi/Simplex_tree/hooks_simplex_base.h +62 -0
  100. multipers/gudhi/gudhi/Simplex_tree/indexing_tag.h +27 -0
  101. multipers/gudhi/gudhi/Simplex_tree/serialization_utils.h +62 -0
  102. multipers/gudhi/gudhi/Simplex_tree/simplex_tree_options.h +157 -0
  103. multipers/gudhi/gudhi/Simplex_tree.h +2794 -0
  104. multipers/gudhi/gudhi/Simplex_tree_multi.h +152 -0
  105. multipers/gudhi/gudhi/distance_functions.h +62 -0
  106. multipers/gudhi/gudhi/graph_simplicial_complex.h +104 -0
  107. multipers/gudhi/gudhi/persistence_interval.h +253 -0
  108. multipers/gudhi/gudhi/persistence_matrix_options.h +170 -0
  109. multipers/gudhi/gudhi/reader_utils.h +367 -0
  110. multipers/gudhi/mma_interface_coh.h +256 -0
  111. multipers/gudhi/mma_interface_h0.h +223 -0
  112. multipers/gudhi/mma_interface_matrix.h +293 -0
  113. multipers/gudhi/naive_merge_tree.h +536 -0
  114. multipers/gudhi/scc_io.h +310 -0
  115. multipers/gudhi/truc.h +1403 -0
  116. multipers/io.cpython-313-darwin.so +0 -0
  117. multipers/io.pyx +644 -0
  118. multipers/ml/__init__.py +0 -0
  119. multipers/ml/accuracies.py +90 -0
  120. multipers/ml/invariants_with_persistable.py +79 -0
  121. multipers/ml/kernels.py +176 -0
  122. multipers/ml/mma.py +713 -0
  123. multipers/ml/one.py +472 -0
  124. multipers/ml/point_clouds.py +352 -0
  125. multipers/ml/signed_measures.py +1589 -0
  126. multipers/ml/sliced_wasserstein.py +461 -0
  127. multipers/ml/tools.py +113 -0
  128. multipers/mma_structures.cpython-313-darwin.so +0 -0
  129. multipers/mma_structures.pxd +128 -0
  130. multipers/mma_structures.pyx +2786 -0
  131. multipers/mma_structures.pyx.tp +1094 -0
  132. multipers/multi_parameter_rank_invariant/diff_helpers.h +84 -0
  133. multipers/multi_parameter_rank_invariant/euler_characteristic.h +97 -0
  134. multipers/multi_parameter_rank_invariant/function_rips.h +322 -0
  135. multipers/multi_parameter_rank_invariant/hilbert_function.h +769 -0
  136. multipers/multi_parameter_rank_invariant/persistence_slices.h +148 -0
  137. multipers/multi_parameter_rank_invariant/rank_invariant.h +369 -0
  138. multipers/multiparameter_edge_collapse.py +41 -0
  139. multipers/multiparameter_module_approximation/approximation.h +2330 -0
  140. multipers/multiparameter_module_approximation/combinatory.h +129 -0
  141. multipers/multiparameter_module_approximation/debug.h +107 -0
  142. multipers/multiparameter_module_approximation/euler_curves.h +0 -0
  143. multipers/multiparameter_module_approximation/format_python-cpp.h +286 -0
  144. multipers/multiparameter_module_approximation/heap_column.h +238 -0
  145. multipers/multiparameter_module_approximation/images.h +79 -0
  146. multipers/multiparameter_module_approximation/list_column.h +174 -0
  147. multipers/multiparameter_module_approximation/list_column_2.h +232 -0
  148. multipers/multiparameter_module_approximation/ru_matrix.h +347 -0
  149. multipers/multiparameter_module_approximation/set_column.h +135 -0
  150. multipers/multiparameter_module_approximation/structure_higher_dim_barcode.h +36 -0
  151. multipers/multiparameter_module_approximation/unordered_set_column.h +166 -0
  152. multipers/multiparameter_module_approximation/utilities.h +403 -0
  153. multipers/multiparameter_module_approximation/vector_column.h +223 -0
  154. multipers/multiparameter_module_approximation/vector_matrix.h +331 -0
  155. multipers/multiparameter_module_approximation/vineyards.h +464 -0
  156. multipers/multiparameter_module_approximation/vineyards_trajectories.h +649 -0
  157. multipers/multiparameter_module_approximation.cpython-313-darwin.so +0 -0
  158. multipers/multiparameter_module_approximation.pyx +235 -0
  159. multipers/pickle.py +90 -0
  160. multipers/plots.py +456 -0
  161. multipers/point_measure.cpython-313-darwin.so +0 -0
  162. multipers/point_measure.pyx +395 -0
  163. multipers/simplex_tree_multi.cpython-313-darwin.so +0 -0
  164. multipers/simplex_tree_multi.pxd +134 -0
  165. multipers/simplex_tree_multi.pyx +10840 -0
  166. multipers/simplex_tree_multi.pyx.tp +2009 -0
  167. multipers/slicer.cpython-313-darwin.so +0 -0
  168. multipers/slicer.pxd +3034 -0
  169. multipers/slicer.pxd.tp +234 -0
  170. multipers/slicer.pyx +20481 -0
  171. multipers/slicer.pyx.tp +1088 -0
  172. multipers/tensor/tensor.h +672 -0
  173. multipers/tensor.pxd +13 -0
  174. multipers/test.pyx +44 -0
  175. multipers/tests/__init__.py +62 -0
  176. multipers/torch/__init__.py +1 -0
  177. multipers/torch/diff_grids.py +240 -0
  178. multipers/torch/rips_density.py +310 -0
  179. multipers-2.3.3b6.dist-info/METADATA +128 -0
  180. multipers-2.3.3b6.dist-info/RECORD +183 -0
  181. multipers-2.3.3b6.dist-info/WHEEL +6 -0
  182. multipers-2.3.3b6.dist-info/licenses/LICENSE +21 -0
  183. multipers-2.3.3b6.dist-info/top_level.txt +1 -0
@@ -0,0 +1,579 @@
1
+ /* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
2
+ * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
3
+ * Author(s): Pawel Dlotko
4
+ *
5
+ * Copyright (C) 2015 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ #ifndef BITMAP_CUBICAL_COMPLEX_PERIODIC_BOUNDARY_CONDITIONS_BASE_H_
12
+ #define BITMAP_CUBICAL_COMPLEX_PERIODIC_BOUNDARY_CONDITIONS_BASE_H_
13
+
14
+ #include <gudhi/Bitmap_cubical_complex_base.h>
15
+ #include <gudhi/Debug_utils.h>
16
+
17
+ #include <cmath>
18
+ #include <limits> // for numeric_limits<>
19
+ #include <vector>
20
+ #include <stdexcept>
21
+ #include <cstddef>
22
+
23
+ namespace Gudhi {
24
+
25
+ namespace cubical_complex {
26
+
27
+ // in this class, we are storing all the elements which are in normal bitmap (i.e. the bitmap without the periodic
28
+ // boundary conditions). But, we set up the iterators and the procedures to compute boundary and coboundary in the way
29
+ // that it is all right. We assume here that all the cells that are on the left / bottom and so on remains, while all
30
+ // the cells on the right / top are not in the Bitmap_cubical_complex_periodic_boundary_conditions_base
31
+
32
+ /**
33
+ * @brief Cubical complex with periodic boundary conditions represented as a bitmap.
34
+ * @ingroup cubical_complex
35
+ * @details This is a class implementing a bitmap data structure with periodic boundary conditions. Most of the
36
+ * functions are
37
+ * identical to the functions from Bitmap_cubical_complex_base.
38
+ * The ones that needed to be updated are the constructors and get_boundary_of_a_cell and get_coboundary_of_a_cell.
39
+ */
40
+ template <typename T>
41
+ class Bitmap_cubical_complex_periodic_boundary_conditions_base : public Bitmap_cubical_complex_base<T> {
42
+ public:
43
+ // constructors that take an extra parameter:
44
+
45
+ /**
46
+ * Default constructor of Bitmap_cubical_complex_periodic_boundary_conditions_base class.
47
+ */
48
+ Bitmap_cubical_complex_periodic_boundary_conditions_base() {}
49
+ /**
50
+ * A constructor of Bitmap_cubical_complex_periodic_boundary_conditions_base class that takes the following
51
+ * parameters: (1) vector with numbers of top dimensional cells in all dimensions and (2) vector of booleans. If
52
+ * at i-th position of this vector there is true value, that means that periodic boundary conditions are to be
53
+ * imposed in this direction. In case of false, the periodic boundary conditions will not be imposed in the direction
54
+ * i.
55
+ */
56
+ Bitmap_cubical_complex_periodic_boundary_conditions_base(
57
+ const std::vector<unsigned>& sizes,
58
+ const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed);
59
+ /**
60
+ * A constructor of Bitmap_cubical_complex_periodic_boundary_conditions_base class that takes the name of Perseus
61
+ * style file as an input. Please consult the documentation about the specification of the file.
62
+ */
63
+ explicit Bitmap_cubical_complex_periodic_boundary_conditions_base(const char* perseusStyleFile);
64
+ /**
65
+ * A constructor of Bitmap_cubical_complex_periodic_boundary_conditions_base class that takes the following
66
+ * parameters: (1) vector with numbers of top dimensional cells in all dimensions and (2) vector of top dimensional
67
+ * cells (ordered lexicographically) and (3) vector of booleans. If at i-th position of this vector there is true
68
+ * value, that means that periodic boundary conditions are to be imposed in this direction. In case of false, the
69
+ * periodic boundary conditions will not be imposed in the direction i.
70
+ */
71
+ Bitmap_cubical_complex_periodic_boundary_conditions_base(
72
+ const std::vector<unsigned>& dimensions, const std::vector<T>& cells,
73
+ const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed,
74
+ bool input_top_cells);
75
+
76
+ /**
77
+ * Destructor of the Bitmap_cubical_complex_periodic_boundary_conditions_base class.
78
+ **/
79
+ virtual ~Bitmap_cubical_complex_periodic_boundary_conditions_base() {}
80
+
81
+ // overwritten methods co compute boundary and coboundary
82
+ /**
83
+ * A version of a function that return boundary of a given cell for an object of
84
+ * Bitmap_cubical_complex_periodic_boundary_conditions_base class.
85
+ * The boundary elements are guaranteed to be returned so that the
86
+ * incidence coefficients are alternating.
87
+ */
88
+ virtual std::vector<std::size_t> get_boundary_of_a_cell(std::size_t cell) const override;
89
+
90
+ /**
91
+ * A version of a function that return coboundary of a given cell for an object of
92
+ * Bitmap_cubical_complex_periodic_boundary_conditions_base class.
93
+ * Note that unlike in the case of boundary, over here the elements are
94
+ * not guaranteed to be returned with alternating incidence numbers.
95
+ * To compute incidence between cells use compute_incidence_between_cells
96
+ * procedure
97
+ */
98
+ virtual std::vector<std::size_t> get_coboundary_of_a_cell(std::size_t cell) const override;
99
+
100
+ /**
101
+ * This procedure compute incidence numbers between cubes. For a cube \f$A\f$ of
102
+ * dimension n and a cube \f$B \subset A\f$ of dimension n-1, an incidence
103
+ * between \f$A\f$ and \f$B\f$ is the integer with which \f$B\f$ appears in the boundary of \f$A\f$.
104
+ * Note that first parameter is a cube of dimension n,
105
+ * and the second parameter is an adjusted cube in dimension n-1.
106
+ * Given \f$A = [b_1,e_1] \times \ldots \ [b_{j-1},e_{j-1}] \times [b_{j},e_{j}] \times [b_{j+1},e_{j+1}] \times \ldots
107
+ *\times [b_{n},e_{n}] \f$
108
+ * such that \f$ b_{j} \neq e_{j} \f$
109
+ * and \f$B = [b_1,e_1] \times \ldots \ [b_{j-1},e_{j-1}] \times [a,a] \times [b_{j+1},e_{j+1}] \times \ldots \times
110
+ *[b_{n},e_{n}]s \f$
111
+ * where \f$ a = b_{j}\f$ or \f$ a = e_{j}\f$, the incidence between \f$A\f$ and \f$B\f$
112
+ * computed by this procedure is given by formula:
113
+ * \f$ c\ (-1)^{\sum_{i=1}^{j-1} dim [b_{i},e_{i}]} \f$
114
+ * Where \f$ dim [b_{i},e_{i}] = 0 \f$ if \f$ b_{i}=e_{i} \f$ and 1 in other case.
115
+ * c is -1 if \f$ a = b_{j}\f$ and 1 if \f$ a = e_{j}\f$.
116
+ * @exception std::logic_error In case when the cube \f$B\f$ is not n-1
117
+ * dimensional face of a cube \f$A\f$.
118
+ **/
119
+ virtual int compute_incidence_between_cells(std::size_t coface, std::size_t face) const override {
120
+ // first get the counters for coface and face:
121
+ std::vector<unsigned> coface_counter = this->compute_counter_for_given_cell(coface);
122
+ std::vector<unsigned> face_counter = this->compute_counter_for_given_cell(face);
123
+
124
+ // coface_counter and face_counter should agree at all positions except from one:
125
+ int number_of_position_in_which_counters_do_not_agree = -1;
126
+ std::size_t number_of_full_faces_that_comes_before = 0;
127
+ for (std::size_t i = 0; i != coface_counter.size(); ++i) {
128
+ if ((coface_counter[i] % 2 == 1) && (number_of_position_in_which_counters_do_not_agree == -1)) {
129
+ ++number_of_full_faces_that_comes_before;
130
+ }
131
+ if (coface_counter[i] != face_counter[i]) {
132
+ if (number_of_position_in_which_counters_do_not_agree != -1) {
133
+ std::cerr << "Cells given to compute_incidence_between_cells procedure do not form a pair of coface-face.\n";
134
+ throw std::logic_error(
135
+ "Cells given to compute_incidence_between_cells procedure do not form a pair of coface-face.");
136
+ }
137
+ number_of_position_in_which_counters_do_not_agree = i;
138
+ }
139
+ }
140
+
141
+ int incidence = 1;
142
+ if (number_of_full_faces_that_comes_before % 2) incidence = -1;
143
+ // if the face cell is on the right from coface cell:
144
+ if ((coface_counter[number_of_position_in_which_counters_do_not_agree] + 1 ==
145
+ face_counter[number_of_position_in_which_counters_do_not_agree]) ||
146
+ ((coface_counter[number_of_position_in_which_counters_do_not_agree] != 1) &&
147
+ (face_counter[number_of_position_in_which_counters_do_not_agree] == 0))) {
148
+ incidence *= -1;
149
+ }
150
+
151
+ return incidence;
152
+ }
153
+
154
+ // The non-periodic code works for top dimensional cells, but not vertices.
155
+ class Vertices_iterator {
156
+ public:
157
+ typedef std::input_iterator_tag iterator_category;
158
+ typedef std::size_t value_type;
159
+ typedef std::ptrdiff_t difference_type;
160
+ typedef value_type* pointer;
161
+ typedef value_type reference;
162
+
163
+ Vertices_iterator(Bitmap_cubical_complex_periodic_boundary_conditions_base* b) : counter(b->dimension()), b(b) {}
164
+
165
+ Vertices_iterator operator++() {
166
+ // first find first element of the counter that can be increased:
167
+ std::size_t dim = 0;
168
+ while ((dim != this->b->dimension()) && (this->counter[dim] == this->b->sizes[dim] - this->b->directions_in_which_periodic_b_cond_are_to_be_imposed[dim])) ++dim;
169
+
170
+ if (dim != this->b->dimension()) {
171
+ ++this->counter[dim];
172
+ for (std::size_t i = 0; i != dim; ++i) {
173
+ this->counter[i] = 0;
174
+ }
175
+ } else {
176
+ ++this->counter[0];
177
+ }
178
+ return *this;
179
+ }
180
+
181
+ Vertices_iterator operator++(int) {
182
+ Vertices_iterator result = *this;
183
+ ++(*this);
184
+ return result;
185
+ }
186
+
187
+ bool operator==(const Vertices_iterator& rhs) const {
188
+ if (this->b != rhs.b) return false;
189
+ GUDHI_CHECK(this->counter.size() == rhs.counter.size(), "impossible");
190
+ for (std::size_t i = 0; i != this->counter.size(); ++i) {
191
+ if (this->counter[i] != rhs.counter[i]) return false;
192
+ }
193
+ return true;
194
+ }
195
+
196
+ bool operator!=(const Vertices_iterator& rhs) const { return !(*this == rhs); }
197
+
198
+ /*
199
+ * The operator * returns position of a cube in the structure of cubical complex. This position can be then used as
200
+ * an argument of the following functions:
201
+ * get_boundary_of_a_cell, get_coboundary_of_a_cell, get_dimension_of_a_cell to get information about the cell
202
+ * boundary and coboundary and dimension
203
+ * and in function get_cell_data to get a filtration of a cell.
204
+ */
205
+ std::size_t operator*() const { return this->compute_index_in_bitmap(); }
206
+
207
+ std::size_t compute_index_in_bitmap() const {
208
+ std::size_t index = 0;
209
+ for (std::size_t i = 0; i != this->counter.size(); ++i) {
210
+ index += 2 * this->counter[i] * this->b->multipliers[i];
211
+ }
212
+ return index;
213
+ }
214
+
215
+ void print_counter() const {
216
+ for (std::size_t i = 0; i != this->counter.size(); ++i) {
217
+ std::clog << this->counter[i] << " ";
218
+ }
219
+ }
220
+ friend class Bitmap_cubical_complex_periodic_boundary_conditions_base;
221
+
222
+ protected:
223
+ std::vector<std::size_t> counter;
224
+ Bitmap_cubical_complex_periodic_boundary_conditions_base* b;
225
+ };
226
+
227
+ /*
228
+ * Function returning a Vertices_iterator to the first vertex of the bitmap.
229
+ */
230
+ Vertices_iterator vertices_iterator_begin() {
231
+ Vertices_iterator a(this);
232
+ return a;
233
+ }
234
+
235
+ /*
236
+ * Function returning a Vertices_iterator to the last vertex of the bitmap.
237
+ */
238
+ Vertices_iterator vertices_iterator_end() {
239
+ Vertices_iterator a(this);
240
+ for (std::size_t i = 0; i != this->dimension(); ++i) {
241
+ a.counter[i] = this->sizes[i] - this->directions_in_which_periodic_b_cond_are_to_be_imposed[i];
242
+ }
243
+ a.counter[0]++;
244
+ return a;
245
+ }
246
+
247
+ /*
248
+ * @brief Vertices_iterator_range class provides ranges for Vertices_iterator_range
249
+ */
250
+ class Vertices_range {
251
+ public:
252
+ Vertices_range(Bitmap_cubical_complex_periodic_boundary_conditions_base* b) : b(b) {}
253
+
254
+ Vertices_iterator begin() { return b->vertices_iterator_begin(); }
255
+
256
+ Vertices_iterator end() { return b->vertices_iterator_end(); }
257
+
258
+ private:
259
+ Bitmap_cubical_complex_periodic_boundary_conditions_base* b;
260
+ };
261
+
262
+ /* Returns a range over all vertices. */
263
+ Vertices_range vertices_range() { return Vertices_range(this); }
264
+
265
+ /**
266
+ * Set cells filtrations given those of the vertices, and based on lower star filtration.
267
+ * This is already called by the relevant constructors.
268
+ **/
269
+ void impose_lower_star_filtration_from_vertices();
270
+
271
+ protected:
272
+ std::vector<bool> directions_in_which_periodic_b_cond_are_to_be_imposed;
273
+
274
+ void set_up_containers(const std::vector<unsigned>& sizes, bool is_pos_inf) {
275
+ // The fact that multipliers[0]=1 is relied on by optimizations in other functions
276
+ unsigned multiplier = 1;
277
+ for (std::size_t i = 0; i != sizes.size(); ++i) {
278
+ this->sizes.push_back(sizes[i]);
279
+ this->multipliers.push_back(multiplier);
280
+
281
+ if (directions_in_which_periodic_b_cond_are_to_be_imposed[i]) {
282
+ multiplier *= 2 * sizes[i];
283
+ } else {
284
+ multiplier *= 2 * sizes[i] + 1;
285
+ }
286
+ }
287
+ // std::reverse( this->sizes.begin() , this->sizes.end() );
288
+ if (is_pos_inf)
289
+ this->data = std::vector<T>(multiplier, std::numeric_limits<T>::infinity());
290
+ else
291
+ this->data = std::vector<T>(multiplier, -std::numeric_limits<T>::infinity());
292
+ }
293
+ Bitmap_cubical_complex_periodic_boundary_conditions_base(const std::vector<unsigned>& sizes);
294
+ Bitmap_cubical_complex_periodic_boundary_conditions_base(const std::vector<unsigned>& dimensions,
295
+ const std::vector<T>& cells,
296
+ bool input_top_cells);
297
+
298
+ /**
299
+ * Procedures used to construct the data structures in the class.
300
+ **/
301
+ void construct_complex_based_on_top_dimensional_cells(
302
+ const std::vector<unsigned>& dimensions, const std::vector<T>& topDimensionalCells,
303
+ const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed);
304
+ void construct_complex_based_on_vertices(const std::vector<unsigned>& dimensions, const std::vector<T>& vertices,
305
+ const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed);
306
+ };
307
+
308
+ template <typename T>
309
+ void Bitmap_cubical_complex_periodic_boundary_conditions_base<T>::construct_complex_based_on_top_dimensional_cells(
310
+ const std::vector<unsigned>& dimensions, const std::vector<T>& topDimensionalCells,
311
+ const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed) {
312
+ this->directions_in_which_periodic_b_cond_are_to_be_imposed = directions_in_which_periodic_b_cond_are_to_be_imposed;
313
+ this->set_up_containers(dimensions, true);
314
+
315
+ std::size_t i = 0;
316
+ for (auto it = this->top_dimensional_cells_iterator_begin(); it != this->top_dimensional_cells_iterator_end(); ++it) {
317
+ this->get_cell_data(*it) = topDimensionalCells[i];
318
+ ++i;
319
+ }
320
+ this->impose_lower_star_filtration();
321
+ }
322
+
323
+ template <typename T>
324
+ void Bitmap_cubical_complex_periodic_boundary_conditions_base<T>::construct_complex_based_on_vertices(
325
+ const std::vector<unsigned>& dimensions, const std::vector<T>& vertices,
326
+ const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed) {
327
+ this->directions_in_which_periodic_b_cond_are_to_be_imposed = directions_in_which_periodic_b_cond_are_to_be_imposed;
328
+
329
+ std::vector<unsigned> top_cells_sizes;
330
+ std::transform (dimensions.begin(), dimensions.end(), directions_in_which_periodic_b_cond_are_to_be_imposed.begin(),
331
+ std::back_inserter(top_cells_sizes), [](unsigned i, bool b){ return i - !b;});
332
+ this->set_up_containers(top_cells_sizes, false);
333
+
334
+ std::size_t i = 0;
335
+ for (auto it = this->vertices_iterator_begin(); it != this->vertices_iterator_end(); ++it) {
336
+ this->get_cell_data(*it) = vertices[i];
337
+ ++i;
338
+ }
339
+ this->impose_lower_star_filtration_from_vertices();
340
+ }
341
+
342
+ template <typename T>
343
+ Bitmap_cubical_complex_periodic_boundary_conditions_base<T>::Bitmap_cubical_complex_periodic_boundary_conditions_base(
344
+ const std::vector<unsigned>& sizes,
345
+ const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed)
346
+ : directions_in_which_periodic_b_cond_are_to_be_imposed(directions_in_which_periodic_b_cond_are_to_be_imposed) {
347
+ this->set_up_containers(sizes, true);
348
+ }
349
+
350
+ template <typename T>
351
+ Bitmap_cubical_complex_periodic_boundary_conditions_base<T>::Bitmap_cubical_complex_periodic_boundary_conditions_base(
352
+ const char* perseus_style_file) {
353
+ // for Perseus style files:
354
+
355
+ std::ifstream inFiltration(perseus_style_file);
356
+ if(!inFiltration) throw std::ios_base::failure(std::string("Could not open the file ") + perseus_style_file);
357
+ unsigned dimensionOfData;
358
+ inFiltration >> dimensionOfData;
359
+
360
+ this->directions_in_which_periodic_b_cond_are_to_be_imposed = std::vector<bool>(dimensionOfData, false);
361
+
362
+ std::vector<unsigned> sizes;
363
+ sizes.reserve(dimensionOfData);
364
+ for (std::size_t i = 0; i != dimensionOfData; ++i) {
365
+ int size_in_this_dimension;
366
+ inFiltration >> size_in_this_dimension;
367
+ if (size_in_this_dimension < 0) {
368
+ this->directions_in_which_periodic_b_cond_are_to_be_imposed[i] = true;
369
+ }
370
+ sizes.push_back(abs(size_in_this_dimension));
371
+ }
372
+ this->set_up_containers(sizes, true);
373
+
374
+ typename Bitmap_cubical_complex_periodic_boundary_conditions_base<T>::Top_dimensional_cells_iterator
375
+ it = this->top_dimensional_cells_iterator_begin();
376
+
377
+ while (!inFiltration.eof()) {
378
+ double filtrationLevel;
379
+ inFiltration >> filtrationLevel;
380
+ if (inFiltration.eof()) break;
381
+
382
+ #ifdef DEBUG_TRACES
383
+ std::clog << "Cell of an index : " << it.compute_index_in_bitmap()
384
+ << " and dimension: " << this->get_dimension_of_a_cell(it.compute_index_in_bitmap())
385
+ << " get the value : " << filtrationLevel << std::endl;
386
+ #endif
387
+ this->get_cell_data(*it) = filtrationLevel;
388
+ ++it;
389
+ }
390
+ inFiltration.close();
391
+ this->impose_lower_star_filtration();
392
+ }
393
+
394
+ template <typename T>
395
+ Bitmap_cubical_complex_periodic_boundary_conditions_base<T>::Bitmap_cubical_complex_periodic_boundary_conditions_base(
396
+ const std::vector<unsigned>& sizes) {
397
+ this->directions_in_which_periodic_b_cond_are_to_be_imposed = std::vector<bool>(sizes.size(), false);
398
+ this->set_up_containers(sizes, true);
399
+ }
400
+
401
+ template <typename T>
402
+ Bitmap_cubical_complex_periodic_boundary_conditions_base<T>::Bitmap_cubical_complex_periodic_boundary_conditions_base(
403
+ const std::vector<unsigned>& dimensions, const std::vector<T>& cells, bool input_top_cells) {
404
+ std::vector<bool> directions_in_which_periodic_b_cond_are_to_be_imposed = std::vector<bool>(dimensions.size(), false);
405
+ if (input_top_cells) {
406
+ this->construct_complex_based_on_top_dimensional_cells(dimensions, cells,
407
+ directions_in_which_periodic_b_cond_are_to_be_imposed);
408
+ } else {
409
+ this->construct_complex_based_on_vertices(dimensions, cells,
410
+ directions_in_which_periodic_b_cond_are_to_be_imposed);
411
+ }
412
+ }
413
+
414
+ template <typename T>
415
+ Bitmap_cubical_complex_periodic_boundary_conditions_base<T>::Bitmap_cubical_complex_periodic_boundary_conditions_base(
416
+ const std::vector<unsigned>& dimensions, const std::vector<T>& cells,
417
+ const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed,
418
+ bool input_top_cells) {
419
+ if(input_top_cells) {
420
+ this->construct_complex_based_on_top_dimensional_cells(dimensions, cells,
421
+ directions_in_which_periodic_b_cond_are_to_be_imposed);
422
+ } else {
423
+ this->construct_complex_based_on_vertices(dimensions, cells,
424
+ directions_in_which_periodic_b_cond_are_to_be_imposed);
425
+ }
426
+ }
427
+
428
+ // ***********************Methods************************ //
429
+
430
+ template <typename T>
431
+ std::vector<std::size_t> Bitmap_cubical_complex_periodic_boundary_conditions_base<T>::get_boundary_of_a_cell(
432
+ std::size_t cell) const {
433
+ #ifdef DEBUG_TRACES
434
+ std::clog << "Computations of boundary of a cell : " << cell << std::endl;
435
+ #endif
436
+
437
+ std::vector<std::size_t> boundary_elements;
438
+ boundary_elements.reserve(this->dimension() * 2);
439
+ std::size_t cell1 = cell;
440
+ std::size_t sum_of_dimensions = 0;
441
+
442
+ for (std::size_t i = this->multipliers.size(); i != 0; --i) {
443
+ unsigned position = cell1 / this->multipliers[i - 1];
444
+ cell1 = cell1 % this->multipliers[i - 1];
445
+ // this cell have a nonzero length in this direction, therefore we can compute its boundary in this direction.
446
+ if (position % 2 == 1) {
447
+ // if there are no periodic boundary conditions in this direction, we do not have to do anything.
448
+ if (!directions_in_which_periodic_b_cond_are_to_be_imposed[i - 1]) {
449
+ if (sum_of_dimensions % 2) {
450
+ boundary_elements.push_back(cell - this->multipliers[i - 1]);
451
+ boundary_elements.push_back(cell + this->multipliers[i - 1]);
452
+ } else {
453
+ boundary_elements.push_back(cell + this->multipliers[i - 1]);
454
+ boundary_elements.push_back(cell - this->multipliers[i - 1]);
455
+ }
456
+ #ifdef DEBUG_TRACES
457
+ std::clog << cell - this->multipliers[i - 1] << " " << cell + this->multipliers[i - 1] << " ";
458
+ #endif
459
+ } else {
460
+ // in this direction we have to do boundary conditions. Therefore, we need to check if we are not at the end.
461
+ if (position != 2 * this->sizes[i - 1] - 1) {
462
+ if (sum_of_dimensions % 2) {
463
+ boundary_elements.push_back(cell - this->multipliers[i - 1]);
464
+ boundary_elements.push_back(cell + this->multipliers[i - 1]);
465
+ } else {
466
+ boundary_elements.push_back(cell + this->multipliers[i - 1]);
467
+ boundary_elements.push_back(cell - this->multipliers[i - 1]);
468
+ }
469
+ #ifdef DEBUG_TRACES
470
+ std::clog << cell - this->multipliers[i - 1] << " " << cell + this->multipliers[i - 1] << " ";
471
+ #endif
472
+ } else {
473
+ if (sum_of_dimensions % 2) {
474
+ boundary_elements.push_back(cell - this->multipliers[i - 1]);
475
+ boundary_elements.push_back(cell - (2 * this->sizes[i - 1] - 1) * this->multipliers[i - 1]);
476
+ } else {
477
+ boundary_elements.push_back(cell - (2 * this->sizes[i - 1] - 1) * this->multipliers[i - 1]);
478
+ boundary_elements.push_back(cell - this->multipliers[i - 1]);
479
+ }
480
+ #ifdef DEBUG_TRACES
481
+ std::clog << cell - this->multipliers[i - 1] << " "
482
+ << cell - (2 * this->sizes[i - 1] - 1) * this->multipliers[i - 1] << " ";
483
+ #endif
484
+ }
485
+ }
486
+ ++sum_of_dimensions;
487
+ }
488
+ }
489
+ return boundary_elements;
490
+ }
491
+
492
+ template <typename T>
493
+ std::vector<std::size_t> Bitmap_cubical_complex_periodic_boundary_conditions_base<T>::get_coboundary_of_a_cell(
494
+ std::size_t cell) const {
495
+ std::vector<unsigned> counter = this->compute_counter_for_given_cell(cell);
496
+ std::vector<std::size_t> coboundary_elements;
497
+ std::size_t cell1 = cell;
498
+ for (std::size_t i = this->multipliers.size(); i != 0; --i) {
499
+ unsigned position = cell1 / this->multipliers[i - 1];
500
+ cell1 = cell1 % this->multipliers[i - 1];
501
+ // if the cell has zero length in this direction, then it will have cbd in this direction.
502
+ if (position % 2 == 0) {
503
+ if (!this->directions_in_which_periodic_b_cond_are_to_be_imposed[i - 1]) {
504
+ // no periodic boundary conditions in this direction
505
+ if ((counter[i - 1] != 0) && (cell > this->multipliers[i - 1])) {
506
+ coboundary_elements.push_back(cell - this->multipliers[i - 1]);
507
+ }
508
+ if ((counter[i - 1] != 2 * this->sizes[i - 1]) && (cell + this->multipliers[i - 1] < this->data.size())) {
509
+ coboundary_elements.push_back(cell + this->multipliers[i - 1]);
510
+ }
511
+ } else {
512
+ // we want to have periodic boundary conditions in this direction
513
+ if (counter[i - 1] != 0) {
514
+ coboundary_elements.push_back(cell - this->multipliers[i - 1]);
515
+ coboundary_elements.push_back(cell + this->multipliers[i - 1]);
516
+ } else {
517
+ // in this case counter[i-1] == 0.
518
+ coboundary_elements.push_back(cell + this->multipliers[i - 1]);
519
+ coboundary_elements.push_back(cell + (2 * this->sizes[i - 1] - 1) * this->multipliers[i - 1]);
520
+ }
521
+ }
522
+ }
523
+ }
524
+ return coboundary_elements;
525
+ }
526
+
527
+ // Exact same code as the non-periodic version, duplicated for now to ensure it calls the right version of vertices_iterator_begin.
528
+ template <typename T>
529
+ void Bitmap_cubical_complex_periodic_boundary_conditions_base<T>::impose_lower_star_filtration_from_vertices() {
530
+ // this vector will be used to check which elements have already been taken care of in imposing lower star filtration
531
+ std::vector<bool> is_this_cell_considered(this->data.size(), false);
532
+
533
+ std::vector<std::size_t> indices_to_consider;
534
+ // we assume here that we already have a filtration on the vertices and
535
+ // we have to extend it to higher ones.
536
+ for (auto it = this->vertices_iterator_begin();
537
+ it != this->vertices_iterator_end(); ++it) {
538
+ indices_to_consider.push_back(it.compute_index_in_bitmap());
539
+ }
540
+
541
+ while (indices_to_consider.size()) { // Iteration on the dimension
542
+ #ifdef DEBUG_TRACES
543
+ std::clog << "indices_to_consider in this iteration \n";
544
+ for (auto index : indices_to_consider) {
545
+ std::clog << index << " ";
546
+ }
547
+ #endif
548
+ std::vector<std::size_t> new_indices_to_consider;
549
+ for (auto index : indices_to_consider) {
550
+ std::vector<std::size_t> cbd = this->get_coboundary_of_a_cell(index);
551
+ for (auto coboundary : cbd) {
552
+ #ifdef DEBUG_TRACES
553
+ std::clog << "filtration of a cell : " << coboundary << " is : " << this->data[coboundary]
554
+ << " while of a cell: " << index << " is: " << this->data[index]
555
+ << std::endl;
556
+ #endif
557
+ if (this->data[coboundary] < this->data[index]) {
558
+ this->data[coboundary] = this->data[index];
559
+ #ifdef DEBUG_TRACES
560
+ std::clog << "Setting the value of a cell : " << coboundary
561
+ << " to : " << this->data[index] << std::endl;
562
+ #endif
563
+ }
564
+ if (is_this_cell_considered[coboundary] == false) {
565
+ new_indices_to_consider.push_back(coboundary);
566
+ is_this_cell_considered[coboundary] = true;
567
+ }
568
+ }
569
+ }
570
+ indices_to_consider.swap(new_indices_to_consider);
571
+ }
572
+ }
573
+ } // namespace cubical_complex
574
+
575
+ namespace Cubical_complex = cubical_complex;
576
+
577
+ } // namespace Gudhi
578
+
579
+ #endif // BITMAP_CUBICAL_COMPLEX_PERIODIC_BOUNDARY_CONDITIONS_BASE_H_
@@ -0,0 +1,45 @@
1
+ /* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
2
+ * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
3
+ * Author(s): David Salinas
4
+ *
5
+ * Copyright (C) 2014 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+ #ifndef DEBUG_UTILS_H_
11
+ #define DEBUG_UTILS_H_
12
+
13
+ #include <iostream>
14
+
15
+ #ifndef NDEBUG
16
+ // GUDHI_DEBUG is the Gudhi official flag for debug mode.
17
+ #define GUDHI_DEBUG
18
+ #endif
19
+
20
+ // GUDHI_CHECK throw an exception if expression is false in debug mode, but does nothing in release mode
21
+ // Could assert in release mode, but cmake sets NDEBUG (for "NO DEBUG") in this mode, means assert does nothing.
22
+ #ifdef GUDHI_DEBUG
23
+ #define GUDHI_CHECK(expression, excpt) ((expression) ? (void) 0 : (throw excpt))
24
+ #define GUDHI_CHECK_code(CODE) CODE
25
+ #else
26
+ #define GUDHI_CHECK(expression, excpt) (void) 0
27
+ #define GUDHI_CHECK_code(CODE)
28
+ #endif
29
+
30
+ #define PRINT(a) std::clog << #a << ": " << (a) << " (DISP)" << std::endl
31
+
32
+ // #define DBG_VERBOSE
33
+ #ifdef DBG_VERBOSE
34
+ #define DBG(a) std::clog << "DBG: " << (a) << std::endl
35
+ #define DBGMSG(a, b) std::clog << "DBG: " << a << b << std::endl
36
+ #define DBGVALUE(a) std::clog << "DBG: " << #a << ": " << a << std::endl
37
+ #define DBGCONT(a) std::clog << "DBG: container " << #a << " -> "; for (auto x : a) std::clog << x << ","; std::clog << std::endl
38
+ #else
39
+ #define DBG(a) (void) 0
40
+ #define DBGMSG(a, b) (void) 0
41
+ #define DBGVALUE(a) (void) 0
42
+ #define DBGCONT(a) (void) 0
43
+ #endif
44
+
45
+ #endif // DEBUG_UTILS_H_