multipers 2.4.0b1__cp312-cp312-macosx_11_0_arm64.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.
Files changed (184) hide show
  1. multipers/.dylibs/libboost_timer.dylib +0 -0
  2. multipers/.dylibs/libc++.1.0.dylib +0 -0
  3. multipers/.dylibs/libtbb.12.17.dylib +0 -0
  4. multipers/__init__.py +33 -0
  5. multipers/_signed_measure_meta.py +426 -0
  6. multipers/_slicer_meta.py +231 -0
  7. multipers/array_api/__init__.py +62 -0
  8. multipers/array_api/numpy.py +124 -0
  9. multipers/array_api/torch.py +133 -0
  10. multipers/data/MOL2.py +458 -0
  11. multipers/data/UCR.py +18 -0
  12. multipers/data/__init__.py +1 -0
  13. multipers/data/graphs.py +466 -0
  14. multipers/data/immuno_regions.py +27 -0
  15. multipers/data/minimal_presentation_to_st_bf.py +0 -0
  16. multipers/data/pytorch2simplextree.py +91 -0
  17. multipers/data/shape3d.py +101 -0
  18. multipers/data/synthetic.py +113 -0
  19. multipers/distances.py +202 -0
  20. multipers/filtration_conversions.pxd +736 -0
  21. multipers/filtration_conversions.pxd.tp +226 -0
  22. multipers/filtrations/__init__.py +21 -0
  23. multipers/filtrations/density.py +529 -0
  24. multipers/filtrations/filtrations.py +480 -0
  25. multipers/filtrations.pxd +534 -0
  26. multipers/filtrations.pxd.tp +332 -0
  27. multipers/function_rips.cpython-312-darwin.so +0 -0
  28. multipers/function_rips.pyx +104 -0
  29. multipers/grids.cpython-312-darwin.so +0 -0
  30. multipers/grids.pyx +538 -0
  31. multipers/gudhi/Persistence_slices_interface.h +213 -0
  32. multipers/gudhi/Simplex_tree_interface.h +274 -0
  33. multipers/gudhi/Simplex_tree_multi_interface.h +648 -0
  34. multipers/gudhi/gudhi/Bitmap_cubical_complex.h +450 -0
  35. multipers/gudhi/gudhi/Bitmap_cubical_complex_base.h +1070 -0
  36. multipers/gudhi/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h +579 -0
  37. multipers/gudhi/gudhi/Debug_utils.h +52 -0
  38. multipers/gudhi/gudhi/Degree_rips_bifiltration.h +2307 -0
  39. multipers/gudhi/gudhi/Dynamic_multi_parameter_filtration.h +2524 -0
  40. multipers/gudhi/gudhi/Fields/Multi_field.h +453 -0
  41. multipers/gudhi/gudhi/Fields/Multi_field_operators.h +460 -0
  42. multipers/gudhi/gudhi/Fields/Multi_field_shared.h +444 -0
  43. multipers/gudhi/gudhi/Fields/Multi_field_small.h +584 -0
  44. multipers/gudhi/gudhi/Fields/Multi_field_small_operators.h +490 -0
  45. multipers/gudhi/gudhi/Fields/Multi_field_small_shared.h +580 -0
  46. multipers/gudhi/gudhi/Fields/Z2_field.h +391 -0
  47. multipers/gudhi/gudhi/Fields/Z2_field_operators.h +389 -0
  48. multipers/gudhi/gudhi/Fields/Zp_field.h +493 -0
  49. multipers/gudhi/gudhi/Fields/Zp_field_operators.h +384 -0
  50. multipers/gudhi/gudhi/Fields/Zp_field_shared.h +492 -0
  51. multipers/gudhi/gudhi/Flag_complex_edge_collapser.h +337 -0
  52. multipers/gudhi/gudhi/Matrix.h +2200 -0
  53. multipers/gudhi/gudhi/Multi_filtration/Multi_parameter_generator.h +1712 -0
  54. multipers/gudhi/gudhi/Multi_filtration/multi_filtration_conversions.h +237 -0
  55. multipers/gudhi/gudhi/Multi_filtration/multi_filtration_utils.h +225 -0
  56. multipers/gudhi/gudhi/Multi_parameter_filtered_complex.h +485 -0
  57. multipers/gudhi/gudhi/Multi_parameter_filtration.h +2643 -0
  58. multipers/gudhi/gudhi/Multi_persistence/Box.h +233 -0
  59. multipers/gudhi/gudhi/Multi_persistence/Line.h +309 -0
  60. multipers/gudhi/gudhi/Multi_persistence/Multi_parameter_filtered_complex_pcoh_interface.h +268 -0
  61. multipers/gudhi/gudhi/Multi_persistence/Persistence_interface_cohomology.h +159 -0
  62. multipers/gudhi/gudhi/Multi_persistence/Persistence_interface_matrix.h +463 -0
  63. multipers/gudhi/gudhi/Multi_persistence/Point.h +853 -0
  64. multipers/gudhi/gudhi/Off_reader.h +173 -0
  65. multipers/gudhi/gudhi/Persistence_matrix/Base_matrix.h +834 -0
  66. multipers/gudhi/gudhi/Persistence_matrix/Base_matrix_with_column_compression.h +838 -0
  67. multipers/gudhi/gudhi/Persistence_matrix/Boundary_matrix.h +833 -0
  68. multipers/gudhi/gudhi/Persistence_matrix/Chain_matrix.h +1367 -0
  69. multipers/gudhi/gudhi/Persistence_matrix/Id_to_index_overlay.h +1157 -0
  70. multipers/gudhi/gudhi/Persistence_matrix/Position_to_index_overlay.h +869 -0
  71. multipers/gudhi/gudhi/Persistence_matrix/RU_matrix.h +905 -0
  72. multipers/gudhi/gudhi/Persistence_matrix/allocators/entry_constructors.h +122 -0
  73. multipers/gudhi/gudhi/Persistence_matrix/base_pairing.h +260 -0
  74. multipers/gudhi/gudhi/Persistence_matrix/base_swap.h +288 -0
  75. multipers/gudhi/gudhi/Persistence_matrix/chain_pairing.h +170 -0
  76. multipers/gudhi/gudhi/Persistence_matrix/chain_rep_cycles.h +247 -0
  77. multipers/gudhi/gudhi/Persistence_matrix/chain_vine_swap.h +571 -0
  78. multipers/gudhi/gudhi/Persistence_matrix/columns/chain_column_extra_properties.h +182 -0
  79. multipers/gudhi/gudhi/Persistence_matrix/columns/column_dimension_holder.h +130 -0
  80. multipers/gudhi/gudhi/Persistence_matrix/columns/column_utilities.h +235 -0
  81. multipers/gudhi/gudhi/Persistence_matrix/columns/entry_types.h +312 -0
  82. multipers/gudhi/gudhi/Persistence_matrix/columns/heap_column.h +1092 -0
  83. multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_list_column.h +923 -0
  84. multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_set_column.h +914 -0
  85. multipers/gudhi/gudhi/Persistence_matrix/columns/list_column.h +930 -0
  86. multipers/gudhi/gudhi/Persistence_matrix/columns/naive_vector_column.h +1071 -0
  87. multipers/gudhi/gudhi/Persistence_matrix/columns/row_access.h +203 -0
  88. multipers/gudhi/gudhi/Persistence_matrix/columns/set_column.h +886 -0
  89. multipers/gudhi/gudhi/Persistence_matrix/columns/unordered_set_column.h +984 -0
  90. multipers/gudhi/gudhi/Persistence_matrix/columns/vector_column.h +1213 -0
  91. multipers/gudhi/gudhi/Persistence_matrix/index_mapper.h +58 -0
  92. multipers/gudhi/gudhi/Persistence_matrix/matrix_dimension_holders.h +227 -0
  93. multipers/gudhi/gudhi/Persistence_matrix/matrix_row_access.h +200 -0
  94. multipers/gudhi/gudhi/Persistence_matrix/ru_pairing.h +166 -0
  95. multipers/gudhi/gudhi/Persistence_matrix/ru_rep_cycles.h +319 -0
  96. multipers/gudhi/gudhi/Persistence_matrix/ru_vine_swap.h +562 -0
  97. multipers/gudhi/gudhi/Persistence_on_a_line.h +152 -0
  98. multipers/gudhi/gudhi/Persistence_on_rectangle.h +617 -0
  99. multipers/gudhi/gudhi/Persistent_cohomology/Field_Zp.h +118 -0
  100. multipers/gudhi/gudhi/Persistent_cohomology/Multi_field.h +173 -0
  101. multipers/gudhi/gudhi/Persistent_cohomology/Persistent_cohomology_column.h +128 -0
  102. multipers/gudhi/gudhi/Persistent_cohomology.h +769 -0
  103. multipers/gudhi/gudhi/Points_off_io.h +171 -0
  104. multipers/gudhi/gudhi/Projective_cover_kernel.h +379 -0
  105. multipers/gudhi/gudhi/Simple_object_pool.h +69 -0
  106. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_iterators.h +559 -0
  107. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +83 -0
  108. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_siblings.h +121 -0
  109. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_star_simplex_iterators.h +277 -0
  110. multipers/gudhi/gudhi/Simplex_tree/filtration_value_utils.h +155 -0
  111. multipers/gudhi/gudhi/Simplex_tree/hooks_simplex_base.h +62 -0
  112. multipers/gudhi/gudhi/Simplex_tree/indexing_tag.h +27 -0
  113. multipers/gudhi/gudhi/Simplex_tree/serialization_utils.h +60 -0
  114. multipers/gudhi/gudhi/Simplex_tree/simplex_tree_options.h +105 -0
  115. multipers/gudhi/gudhi/Simplex_tree.h +3170 -0
  116. multipers/gudhi/gudhi/Slicer.h +848 -0
  117. multipers/gudhi/gudhi/Thread_safe_slicer.h +393 -0
  118. multipers/gudhi/gudhi/distance_functions.h +62 -0
  119. multipers/gudhi/gudhi/graph_simplicial_complex.h +104 -0
  120. multipers/gudhi/gudhi/multi_simplex_tree_helpers.h +147 -0
  121. multipers/gudhi/gudhi/persistence_interval.h +263 -0
  122. multipers/gudhi/gudhi/persistence_matrix_options.h +188 -0
  123. multipers/gudhi/gudhi/reader_utils.h +367 -0
  124. multipers/gudhi/gudhi/simple_mdspan.h +484 -0
  125. multipers/gudhi/gudhi/slicer_helpers.h +779 -0
  126. multipers/gudhi/tmp_h0_pers/mma_interface_h0.h +223 -0
  127. multipers/gudhi/tmp_h0_pers/naive_merge_tree.h +536 -0
  128. multipers/io.cpython-312-darwin.so +0 -0
  129. multipers/io.pyx +472 -0
  130. multipers/ml/__init__.py +0 -0
  131. multipers/ml/accuracies.py +90 -0
  132. multipers/ml/invariants_with_persistable.py +79 -0
  133. multipers/ml/kernels.py +176 -0
  134. multipers/ml/mma.py +713 -0
  135. multipers/ml/one.py +472 -0
  136. multipers/ml/point_clouds.py +352 -0
  137. multipers/ml/signed_measures.py +1667 -0
  138. multipers/ml/sliced_wasserstein.py +461 -0
  139. multipers/ml/tools.py +113 -0
  140. multipers/mma_structures.cpython-312-darwin.so +0 -0
  141. multipers/mma_structures.pxd +134 -0
  142. multipers/mma_structures.pyx +1483 -0
  143. multipers/mma_structures.pyx.tp +1126 -0
  144. multipers/multi_parameter_rank_invariant/diff_helpers.h +85 -0
  145. multipers/multi_parameter_rank_invariant/euler_characteristic.h +95 -0
  146. multipers/multi_parameter_rank_invariant/function_rips.h +317 -0
  147. multipers/multi_parameter_rank_invariant/hilbert_function.h +761 -0
  148. multipers/multi_parameter_rank_invariant/persistence_slices.h +149 -0
  149. multipers/multi_parameter_rank_invariant/rank_invariant.h +350 -0
  150. multipers/multiparameter_edge_collapse.py +41 -0
  151. multipers/multiparameter_module_approximation/approximation.h +2541 -0
  152. multipers/multiparameter_module_approximation/debug.h +107 -0
  153. multipers/multiparameter_module_approximation/format_python-cpp.h +292 -0
  154. multipers/multiparameter_module_approximation/utilities.h +428 -0
  155. multipers/multiparameter_module_approximation.cpython-312-darwin.so +0 -0
  156. multipers/multiparameter_module_approximation.pyx +286 -0
  157. multipers/ops.cpython-312-darwin.so +0 -0
  158. multipers/ops.pyx +231 -0
  159. multipers/pickle.py +89 -0
  160. multipers/plots.py +550 -0
  161. multipers/point_measure.cpython-312-darwin.so +0 -0
  162. multipers/point_measure.pyx +409 -0
  163. multipers/simplex_tree_multi.cpython-312-darwin.so +0 -0
  164. multipers/simplex_tree_multi.pxd +136 -0
  165. multipers/simplex_tree_multi.pyx +11719 -0
  166. multipers/simplex_tree_multi.pyx.tp +2102 -0
  167. multipers/slicer.cpython-312-darwin.so +0 -0
  168. multipers/slicer.pxd +2097 -0
  169. multipers/slicer.pxd.tp +263 -0
  170. multipers/slicer.pyx +13042 -0
  171. multipers/slicer.pyx.tp +1259 -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 +70 -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/vector_interface.pxd +46 -0
  180. multipers-2.4.0b1.dist-info/METADATA +131 -0
  181. multipers-2.4.0b1.dist-info/RECORD +184 -0
  182. multipers-2.4.0b1.dist-info/WHEEL +6 -0
  183. multipers-2.4.0b1.dist-info/licenses/LICENSE +21 -0
  184. multipers-2.4.0b1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,559 @@
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): Clément Maria
4
+ *
5
+ * Copyright (C) 2014 Inria
6
+ *
7
+ * Modification(s):
8
+ * - 2022/04 Vincent Rouvreau: Add Simplex_tree_boundary_opposite_vertex_simplex_iterator for alpha and cech purpose
9
+ * - YYYY/MM Author: Description of the modification
10
+ */
11
+
12
+ #ifndef SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_
13
+ #define SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_
14
+
15
+ #include <gudhi/Debug_utils.h>
16
+
17
+ #include <boost/iterator/iterator_facade.hpp>
18
+
19
+ #include <utility> // for std::pair
20
+
21
+ namespace Gudhi {
22
+
23
+ /** \addtogroup simplex_tree
24
+ * Iterators and range types for the Simplex_tree.
25
+ * @{
26
+ */
27
+
28
+ /** \brief Iterator over the vertices of a simplex
29
+ * in a SimplexTree.
30
+ *
31
+ * Forward iterator, 'value_type' is SimplexTree::Vertex_handle.*/
32
+ template<class SimplexTree>
33
+ class Simplex_tree_simplex_vertex_iterator : public boost::iterator_facade<
34
+ Simplex_tree_simplex_vertex_iterator<SimplexTree>,
35
+ typename SimplexTree::Vertex_handle const, boost::forward_traversal_tag,
36
+ typename SimplexTree::Vertex_handle const> {
37
+ public:
38
+ typedef typename SimplexTree::Simplex_handle Simplex_handle;
39
+ typedef typename SimplexTree::Siblings Siblings;
40
+ typedef typename SimplexTree::Vertex_handle Vertex_handle;
41
+
42
+ explicit Simplex_tree_simplex_vertex_iterator(SimplexTree const* st)
43
+ : // any end() iterator
44
+ sib_(nullptr),
45
+ v_(st->null_vertex()) {
46
+ }
47
+
48
+ Simplex_tree_simplex_vertex_iterator(SimplexTree const* st, Simplex_handle sh)
49
+ : sib_(st->self_siblings(sh)),
50
+ v_(sh->first) {
51
+ }
52
+
53
+ private:
54
+ friend class boost::iterator_core_access;
55
+
56
+ bool equal(Simplex_tree_simplex_vertex_iterator const &other) const {
57
+ return sib_ == other.sib_ && v_ == other.v_;
58
+ }
59
+
60
+ Vertex_handle const& dereference() const {
61
+ return v_;
62
+ }
63
+
64
+ void increment() {
65
+ v_ = sib_->parent();
66
+ sib_ = sib_->oncles();
67
+ }
68
+
69
+ Siblings const* sib_;
70
+ Vertex_handle v_;
71
+ };
72
+
73
+ /*---------------------------------------------------------------------------*/
74
+ /** \brief Iterator over the simplices of the boundary of a
75
+ * simplex.
76
+ *
77
+ * Forward iterator, value_type is SimplexTree::Simplex_handle.*/
78
+ template<class SimplexTree>
79
+ class Simplex_tree_boundary_simplex_iterator : public boost::iterator_facade<
80
+ Simplex_tree_boundary_simplex_iterator<SimplexTree>,
81
+ typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
82
+ public:
83
+ using Simplex_handle = typename SimplexTree::Simplex_handle;
84
+ using Vertex_handle = typename SimplexTree::Vertex_handle;
85
+ using Siblings = typename SimplexTree::Siblings;
86
+ using Static_vertex_vector = typename SimplexTree::Static_vertex_vector;
87
+
88
+ // For cython purpose only. The object it initializes should be overwritten ASAP and never used before it is overwritten.
89
+ Simplex_tree_boundary_simplex_iterator()
90
+ : sib_(nullptr),
91
+ st_(nullptr) {
92
+ }
93
+
94
+ // any end() iterator
95
+ explicit Simplex_tree_boundary_simplex_iterator(SimplexTree const* st)
96
+ : last_(st->null_vertex()),
97
+ next_(st->null_vertex()),
98
+ sib_(nullptr),
99
+ sh_(st->null_simplex()),
100
+ st_(st) {
101
+ }
102
+
103
+ template<class SimplexHandle>
104
+ Simplex_tree_boundary_simplex_iterator(SimplexTree const* st, SimplexHandle sh)
105
+ : last_(sh->first),
106
+ next_(st->null_vertex()),
107
+ sib_(nullptr),
108
+ sh_(st->null_simplex()),
109
+ st_(st) {
110
+ // Only check once at the beginning instead of for every increment, as this is expensive.
111
+ if constexpr (SimplexTree::Options::contiguous_vertices)
112
+ GUDHI_CHECK(st_->contiguous_vertices(), "The set of vertices is not { 0, ..., n } without holes");
113
+ Siblings const* sib = st->self_siblings(sh);
114
+ next_ = sib->parent();
115
+ sib_ = sib->oncles();
116
+ if (sib_ != nullptr) {
117
+ if constexpr (SimplexTree::Options::contiguous_vertices &&
118
+ !SimplexTree::Options::stable_simplex_handles)
119
+ {
120
+ if (sib_->oncles() == nullptr) // Only relevant for edges
121
+ sh_ = sib_->members_.begin() + next_;
122
+ else
123
+ sh_ = sib_->find(next_);
124
+ } else {
125
+ sh_ = sib_->find(next_);
126
+ }
127
+ }
128
+ }
129
+
130
+ private:
131
+ friend class boost::iterator_core_access;
132
+ // valid when iterating along the SAME boundary.
133
+ bool equal(Simplex_tree_boundary_simplex_iterator const& other) const {
134
+ return sh_ == other.sh_;
135
+ }
136
+
137
+ Simplex_handle const& dereference() const {
138
+ assert(sh_ != st_->null_simplex());
139
+ return sh_;
140
+ }
141
+
142
+ void increment() {
143
+ if (sib_ == nullptr) {
144
+ sh_ = st_->null_simplex();
145
+ return;
146
+ }
147
+
148
+ Siblings const* for_sib = sib_;
149
+ Siblings const* new_sib = sib_->oncles();
150
+ auto rit = suffix_.rbegin();
151
+ if constexpr (SimplexTree::Options::contiguous_vertices && !SimplexTree::Options::stable_simplex_handles) {
152
+ if (new_sib == nullptr) {
153
+ // We reached the root, use a short-cut to find a vertex.
154
+ if (rit == suffix_.rend()) {
155
+ // Segment, this vertex is the last boundary simplex
156
+ sh_ = for_sib->members_.begin() + last_;
157
+ sib_ = nullptr;
158
+ return;
159
+ } else {
160
+ // Dim >= 2, initial step of the descent
161
+ sh_ = for_sib->members_.begin() + *rit;
162
+ for_sib = sh_->second.children();
163
+ ++rit;
164
+ }
165
+ }
166
+ }
167
+
168
+ for (; rit != suffix_.rend(); ++rit) {
169
+ sh_ = for_sib->find(*rit);
170
+ for_sib = sh_->second.children();
171
+ }
172
+ sh_ = for_sib->find(last_); // sh_ points to the right simplex now
173
+ suffix_.push_back(next_);
174
+ next_ = sib_->parent();
175
+ sib_ = new_sib;
176
+ }
177
+
178
+ // Most of the storage should be moved to the range, iterators should be light.
179
+ Vertex_handle last_; // last vertex of the simplex
180
+ Vertex_handle next_; // next vertex to push in suffix_
181
+ Static_vertex_vector suffix_;
182
+ Siblings const* sib_; // where the next search will start from
183
+ Simplex_handle sh_; // current Simplex_handle in the boundary
184
+ SimplexTree const* st_; // simplex containing the simplicial complex
185
+ };
186
+
187
+ /** \brief Iterator over the simplices of the boundary of a simplex and their opposite vertices.
188
+ *
189
+ * Forward iterator, value_type is std::pair<SimplexTree::Simplex_handle, SimplexTree::Vertex_handle>.*/
190
+ template<class SimplexTree>
191
+ class Simplex_tree_boundary_opposite_vertex_simplex_iterator : public boost::iterator_facade<
192
+ Simplex_tree_boundary_opposite_vertex_simplex_iterator<SimplexTree>,
193
+ std::pair<typename SimplexTree::Simplex_handle, typename SimplexTree::Vertex_handle> const, boost::forward_traversal_tag> {
194
+ public:
195
+ using Simplex_handle = typename SimplexTree::Simplex_handle;
196
+ using Vertex_handle = typename SimplexTree::Vertex_handle;
197
+ using Siblings = typename SimplexTree::Siblings;
198
+ using Static_vertex_vector = typename SimplexTree::Static_vertex_vector;
199
+
200
+ // For cython purpose only. The object it initializes should be overwritten ASAP and never used before it is
201
+ // overwritten.
202
+ Simplex_tree_boundary_opposite_vertex_simplex_iterator()
203
+ : sib_(nullptr),
204
+ st_(nullptr) {
205
+ }
206
+
207
+ // any end() iterator
208
+ explicit Simplex_tree_boundary_opposite_vertex_simplex_iterator(SimplexTree const* st)
209
+ : last_(st->null_vertex()),
210
+ next_(st->null_vertex()),
211
+ sib_(nullptr),
212
+ baov_(st->null_simplex(), st->null_vertex()),
213
+ st_(st) {
214
+ }
215
+
216
+ template<class SimplexHandle>
217
+ Simplex_tree_boundary_opposite_vertex_simplex_iterator(SimplexTree const* st, SimplexHandle sh)
218
+ : last_(sh->first),
219
+ next_(st->null_vertex()),
220
+ sib_(nullptr),
221
+ baov_(st->null_simplex(), sh->first),
222
+ st_(st) {
223
+ // Only check once at the beginning instead of for every increment, as this is expensive.
224
+ if constexpr (SimplexTree::Options::contiguous_vertices)
225
+ GUDHI_CHECK(st_->contiguous_vertices(), "The set of vertices is not { 0, ..., n } without holes");
226
+ Siblings const* sib = st->self_siblings(sh);
227
+ next_ = sib->parent();
228
+ sib_ = sib->oncles();
229
+ if (sib_ != nullptr) {
230
+ if constexpr (SimplexTree::Options::contiguous_vertices &&
231
+ !SimplexTree::Options::stable_simplex_handles) {
232
+ if (sib_->oncles() == nullptr)
233
+ // Only relevant for edges
234
+ baov_.first = sib_->members_.begin() + next_;
235
+ else
236
+ baov_.first = sib_->find(next_);
237
+ } else {
238
+ baov_.first = sib_->find(next_);
239
+ }
240
+ }
241
+ }
242
+
243
+ private:
244
+ friend class boost::iterator_core_access;
245
+
246
+ // valid when iterating along the SAME boundary.
247
+ bool equal(Simplex_tree_boundary_opposite_vertex_simplex_iterator const& other) const {
248
+ return (baov_.first == other.baov_.first);
249
+ }
250
+
251
+ std::pair<Simplex_handle, Vertex_handle> const& dereference() const {
252
+ return baov_;
253
+ }
254
+
255
+ void increment() {
256
+ if (sib_ == nullptr) {
257
+ baov_.first = st_->null_simplex();
258
+ return; // ------>>
259
+ }
260
+ Siblings const* for_sib = sib_;
261
+ Siblings const* new_sib = sib_->oncles();
262
+ auto rit = suffix_.rbegin();
263
+ if constexpr (SimplexTree::Options::contiguous_vertices && !SimplexTree::Options::stable_simplex_handles) {
264
+ if (new_sib == nullptr) {
265
+ // We reached the root, use a short-cut to find a vertex.
266
+ if (rit == suffix_.rend()) {
267
+ baov_.second = baov_.first->first;
268
+ // Segment, this vertex is the last boundary simplex
269
+ baov_.first = for_sib->members_.begin() + last_;
270
+ sib_ = nullptr;
271
+ return;
272
+ } else {
273
+ // Dim >= 2, initial step of the descent
274
+ baov_.first = for_sib->members_.begin() + *rit;
275
+ for_sib = baov_.first->second.children();
276
+ ++rit;
277
+ }
278
+ }
279
+ }
280
+
281
+ for (; rit != suffix_.rend(); ++rit) {
282
+ baov_.first = for_sib->find(*rit);
283
+ for_sib = baov_.first->second.children();
284
+ }
285
+ baov_.first = for_sib->find(last_); // baov_.first points to the right simplex now
286
+ suffix_.push_back(next_);
287
+ next_ = sib_->parent();
288
+ sib_ = new_sib;
289
+ baov_.second = suffix_.back();
290
+ }
291
+
292
+ // Most of the storage should be moved to the range, iterators should be light.
293
+ Vertex_handle last_; // last vertex of the simplex
294
+ Vertex_handle next_; // next vertex to push in suffix_
295
+ Static_vertex_vector suffix_;
296
+ Siblings const* sib_; // where the next search will start from
297
+ std::pair<Simplex_handle, Vertex_handle> baov_; // a pair containing the current Simplex_handle in the boundary and its opposite vertex
298
+ SimplexTree const* st_; // simplex containing the simplicial complex
299
+ };
300
+
301
+ /*---------------------------------------------------------------------------*/
302
+ /** \brief Iterator over the simplices of a simplicial complex.
303
+ *
304
+ * Forward iterator, value_type is SimplexTree::Simplex_handle.*/
305
+ template<class SimplexTree>
306
+ class Simplex_tree_complex_simplex_iterator : public boost::iterator_facade<
307
+ Simplex_tree_complex_simplex_iterator<SimplexTree>,
308
+ typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
309
+ public:
310
+ typedef typename SimplexTree::Simplex_handle Simplex_handle;
311
+ typedef typename SimplexTree::Siblings Siblings;
312
+ typedef typename SimplexTree::Vertex_handle Vertex_handle;
313
+
314
+ // any end() iterator
315
+ Simplex_tree_complex_simplex_iterator()
316
+ : sib_(nullptr),
317
+ st_(nullptr) {
318
+ }
319
+
320
+ explicit Simplex_tree_complex_simplex_iterator(SimplexTree const* st)
321
+ : sib_(nullptr),
322
+ st_(st) {
323
+ if (st == nullptr || st->root() == nullptr || st->root()->members().empty()) {
324
+ st_ = nullptr;
325
+ } else {
326
+ sh_ = st->root()->members().begin();
327
+ sib_ = st->root();
328
+ while (st->has_children(sh_)) {
329
+ sib_ = sh_->second.children();
330
+ sh_ = sib_->members().begin();
331
+ }
332
+ }
333
+ }
334
+ private:
335
+ friend class boost::iterator_core_access;
336
+
337
+ // valid when iterating along the SAME boundary.
338
+ bool equal(Simplex_tree_complex_simplex_iterator const& other) const {
339
+ if (other.st_ == nullptr) {
340
+ return (st_ == nullptr);
341
+ }
342
+ if (st_ == nullptr) {
343
+ return false;
344
+ }
345
+ return (&(sh_->second) == &(other.sh_->second));
346
+ }
347
+
348
+ Simplex_handle const& dereference() const {
349
+ return sh_;
350
+ }
351
+
352
+ // Depth first traversal.
353
+ void increment() {
354
+ ++sh_;
355
+ if (sh_ == sib_->members().end()) {
356
+ if (sib_->oncles() == nullptr) {
357
+ st_ = nullptr;
358
+ return;
359
+ } // reach the end
360
+ sh_ = sib_->oncles()->members().find(sib_->parent());
361
+ sib_ = sib_->oncles();
362
+ return;
363
+ }
364
+ while (st_->has_children(sh_)) {
365
+ sib_ = sh_->second.children();
366
+ sh_ = sib_->members().begin();
367
+ }
368
+ }
369
+
370
+ Simplex_handle sh_;
371
+ Siblings const* sib_;
372
+ SimplexTree const* st_;
373
+ };
374
+
375
+ /** \brief Iterator over the simplices of the skeleton of a given
376
+ * dimension of the simplicial complex.
377
+ *
378
+ * Forward iterator, value_type is SimplexTree::Simplex_handle.*/
379
+ template<class SimplexTree>
380
+ class Simplex_tree_skeleton_simplex_iterator : public boost::iterator_facade<
381
+ Simplex_tree_skeleton_simplex_iterator<SimplexTree>,
382
+ typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
383
+ public:
384
+ typedef typename SimplexTree::Simplex_handle Simplex_handle;
385
+ typedef typename SimplexTree::Siblings Siblings;
386
+ typedef typename SimplexTree::Vertex_handle Vertex_handle;
387
+
388
+ // any end() iterator
389
+ Simplex_tree_skeleton_simplex_iterator()
390
+ : sib_(nullptr),
391
+ st_(nullptr),
392
+ dim_skel_(0),
393
+ curr_dim_(0) {
394
+ }
395
+
396
+ Simplex_tree_skeleton_simplex_iterator(SimplexTree const* st, int dim_skel)
397
+ : sib_(nullptr),
398
+ st_(st),
399
+ dim_skel_(dim_skel),
400
+ curr_dim_(0) {
401
+ if (st == nullptr || st->root() == nullptr || st->root()->members().empty()) {
402
+ st_ = nullptr;
403
+ } else {
404
+ sh_ = st->root()->members().begin();
405
+ sib_ = st->root();
406
+ while (st->has_children(sh_) && curr_dim_ < dim_skel_) {
407
+ sib_ = sh_->second.children();
408
+ sh_ = sib_->members().begin();
409
+ ++curr_dim_;
410
+ }
411
+ }
412
+ }
413
+ private:
414
+ friend class boost::iterator_core_access;
415
+
416
+ // valid when iterating along the SAME boundary.
417
+ bool equal(Simplex_tree_skeleton_simplex_iterator const& other) const {
418
+ if (other.st_ == nullptr) {
419
+ return (st_ == nullptr);
420
+ }
421
+ if (st_ == nullptr) {
422
+ return false;
423
+ }
424
+ return (&(sh_->second) == &(other.sh_->second));
425
+ }
426
+
427
+ Simplex_handle const& dereference() const {
428
+ return sh_;
429
+ }
430
+
431
+ // Depth first traversal of the skeleton.
432
+ void increment() {
433
+ ++sh_;
434
+ if (sh_ == sib_->members().end()) {
435
+ if (sib_->oncles() == nullptr) {
436
+ st_ = nullptr;
437
+ return;
438
+ } // reach the end
439
+ sh_ = sib_->oncles()->members().find(sib_->parent());
440
+ sib_ = sib_->oncles();
441
+ --curr_dim_;
442
+ return;
443
+ }
444
+ while (st_->has_children(sh_) && curr_dim_ < dim_skel_) {
445
+ sib_ = sh_->second.children();
446
+ sh_ = sib_->members().begin();
447
+ ++curr_dim_;
448
+ }
449
+ }
450
+
451
+ Simplex_handle sh_;
452
+ Siblings const* sib_;
453
+ SimplexTree const* st_;
454
+ int dim_skel_;
455
+ int curr_dim_;
456
+ };
457
+
458
+ /** \brief Iterator over the simplices of the simplicial complex that match the dimension specified by the parameter.
459
+ *
460
+ * Forward iterator, value_type is SimplexTree::Simplex_handle.*/
461
+ template<class SimplexTree>
462
+ class Simplex_tree_dimension_simplex_iterator : public boost::iterator_facade<
463
+ Simplex_tree_dimension_simplex_iterator<SimplexTree>,
464
+ typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
465
+ public:
466
+ typedef typename SimplexTree::Simplex_handle Simplex_handle;
467
+ typedef typename SimplexTree::Siblings Siblings;
468
+ typedef typename SimplexTree::Vertex_handle Vertex_handle;
469
+
470
+ // any end() iterator
471
+ Simplex_tree_dimension_simplex_iterator()
472
+ : sib_(nullptr),
473
+ st_(nullptr),
474
+ dim_(0),
475
+ curr_dim_(0) {
476
+ }
477
+
478
+ Simplex_tree_dimension_simplex_iterator(SimplexTree const* st, int dim)
479
+ : sib_(nullptr),
480
+ st_(st),
481
+ dim_(dim),
482
+ curr_dim_(0) {
483
+ if (st == nullptr || st->root() == nullptr || st->root()->members().empty() ||
484
+ st->upper_bound_dimension() < dim || dim < 0) {
485
+ st_ = nullptr;
486
+ } else {
487
+ sh_ = st->root()->members().begin();
488
+ sib_ = st->root();
489
+ until_leaf_or_dim();
490
+ // if we reached a leaf that does not respect the required dimension - call increment
491
+ if (curr_dim_ != dim_)
492
+ increment();
493
+ }
494
+ }
495
+ private:
496
+ friend class boost::iterator_core_access;
497
+
498
+ // valid when iterating along the SAME boundary.
499
+ bool equal(Simplex_tree_dimension_simplex_iterator const& other) const {
500
+ if (other.st_ == nullptr) {
501
+ return (st_ == nullptr);
502
+ }
503
+ if (st_ == nullptr) {
504
+ return false;
505
+ }
506
+ return (&(sh_->second) == &(other.sh_->second));
507
+ }
508
+
509
+ Simplex_handle const& dereference() const {
510
+ return sh_;
511
+ }
512
+
513
+ void until_leaf_or_dim() {
514
+ while (st_->has_children(sh_) && curr_dim_ != dim_) {
515
+ sib_ = sh_->second.children();
516
+ sh_ = sib_->members().begin();
517
+ ++curr_dim_;
518
+ }
519
+ #ifdef DEBUG_TRACES
520
+ std::clog << "Simplex_tree::dimension_simplex_range until_leaf_or_dim reached (";
521
+ for (auto vertex : st_->simplex_vertex_range(sh_)) {
522
+ std::clog << vertex << ",";
523
+ }
524
+ std::clog << ")\n";
525
+ #endif // DEBUG_TRACES
526
+ }
527
+ // Depth first traversal of the tree structure. Returns when reaching a simplex with a given dimension
528
+ void increment() {
529
+ ++sh_;
530
+ while (sh_ == sib_->members().end()) {
531
+ if (sib_->oncles() == nullptr) {
532
+ st_ = nullptr;
533
+ return;
534
+ } // reach the end
535
+ sh_ = sib_->oncles()->members().find(sib_->parent());
536
+ sib_ = sib_->oncles();
537
+ --curr_dim_;
538
+ ++sh_;
539
+ until_leaf_or_dim();
540
+ }
541
+ // It seems we do it twice here, but necessary when coming from the constructor
542
+ until_leaf_or_dim();
543
+ // if we reached a leaf that does not respect the dimension - recall increment
544
+ if (curr_dim_ != dim_)
545
+ increment();
546
+ }
547
+
548
+ Simplex_handle sh_;
549
+ Siblings const* sib_;
550
+ SimplexTree const* st_;
551
+ int dim_;
552
+ int curr_dim_;
553
+ };
554
+
555
+ /** @}*/ // end addtogroup simplex_tree
556
+
557
+ } // namespace Gudhi
558
+
559
+ #endif // SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_
@@ -0,0 +1,83 @@
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): Clément Maria
4
+ *
5
+ * Copyright (C) 2014 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ #ifndef SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
12
+ #define SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
13
+
14
+ // Empty base optimization for MSVC - https://learn.microsoft.com/en-us/cpp/cpp/empty-bases
15
+ #if _MSC_VER
16
+ #define GUDHI_EMPTY_BASE_CLASS_OPTIMIZATION __declspec(empty_bases)
17
+ #else
18
+ #define GUDHI_EMPTY_BASE_CLASS_OPTIMIZATION
19
+ #endif
20
+
21
+ #include <boost/core/empty_value.hpp>
22
+
23
+ namespace Gudhi {
24
+
25
+ /** \addtogroup simplex_tree
26
+ * Represents a node of a Simplex_tree.
27
+ * @{
28
+ */
29
+
30
+ /** \brief Node of a simplex tree with filtration value
31
+ * and simplex key.
32
+ *
33
+ * It stores explicitly its own filtration value and its own Simplex_key.
34
+ */
35
+ template <class SimplexTree>
36
+ struct GUDHI_EMPTY_BASE_CLASS_OPTIMIZATION Simplex_tree_node_explicit_storage
37
+ : SimplexTree::Filtration_simplex_base,
38
+ SimplexTree::Key_simplex_base,
39
+ SimplexTree::Hooks_simplex_base,
40
+ boost::empty_value<typename SimplexTree::Simplex_data> {
41
+ typedef typename SimplexTree::Siblings Siblings;
42
+ typedef typename SimplexTree::Filtration_value Filtration_value;
43
+ typedef typename SimplexTree::Simplex_key Simplex_key;
44
+ typedef typename SimplexTree::Simplex_data Simplex_data;
45
+
46
+ Simplex_tree_node_explicit_storage() : children_(nullptr) {}
47
+
48
+ Simplex_tree_node_explicit_storage(Siblings* sib, const Filtration_value& filtration = Filtration_value())
49
+ : SimplexTree::Filtration_simplex_base(filtration), children_(sib)
50
+ {}
51
+
52
+ //will fail to compile when called with SimplexTree::Options::store_key is false.
53
+ Simplex_tree_node_explicit_storage(Siblings* sib, Filtration_value filtration, Simplex_key key)
54
+ : SimplexTree::Filtration_simplex_base(filtration), SimplexTree::Key_simplex_base(key), children_(sib)
55
+ {}
56
+
57
+ /*
58
+ * Assign children to the node
59
+ */
60
+ void assign_children(Siblings * children) {
61
+ children_ = children;
62
+ }
63
+
64
+ /* Careful -> children_ can be NULL*/
65
+ Siblings * children() {
66
+ return children_;
67
+ }
68
+ const Siblings * children() const {
69
+ return children_;
70
+ }
71
+
72
+ Simplex_data& data() { return boost::empty_value<Simplex_data>::get(); }
73
+ const Simplex_data& data() const { return boost::empty_value<Simplex_data>::get(); }
74
+
75
+ private:
76
+ Siblings * children_;
77
+ };
78
+
79
+ /** @}*/ // end addtogroup simplex_tree
80
+
81
+ } // namespace Gudhi
82
+
83
+ #endif // SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_