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,393 @@
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 Loiseaux
4
+ *
5
+ * Copyright (C) 2023 Inria
6
+ *
7
+ * Modification(s):
8
+ * - 2025/04 Hannah Schreiber: Reorganization + documentation.
9
+ * - YYYY/MM Author: Description of the modification
10
+ */
11
+
12
+ /**
13
+ * @file Thread_safe_slicer.h
14
+ * @author David Loiseaux
15
+ * @brief Contains the @ref Gudhi::multi_persistence::Thread_safe_slicer class.
16
+ */
17
+
18
+ #ifndef MP_THREAD_SAFE_SLICER_H_INCLUDED
19
+ #define MP_THREAD_SAFE_SLICER_H_INCLUDED
20
+
21
+ #include <ostream>
22
+ #include <utility>
23
+ #include <vector>
24
+
25
+ #include <gudhi/Multi_persistence/Line.h>
26
+
27
+ namespace Gudhi {
28
+ namespace multi_persistence {
29
+
30
+ /**
31
+ * @class Thread_safe_slicer Thread_safe_slicer.h gudhi/Thread_safe_slicer.h
32
+ * @ingroup multi_persistence
33
+ *
34
+ * @brief A more or less "thread safe version" of @ref Slicer. Gives access to all its const methods and persistence
35
+ * related methods. Each instance will store a pointer to the original slicer, but will have its own copies of all
36
+ * persistence related containers. It corresponds therefore more to a "light/week copy" of a slicer.
37
+ *
38
+ * @tparam Slicer Underlying @ref Slicer type.
39
+ */
40
+ template <class Slicer>
41
+ class Thread_safe_slicer : private Slicer
42
+ {
43
+ public:
44
+ using Persistence = typename Slicer::Persistence; /**< Persistence algorithm type. */
45
+ using Filtration_value = typename Slicer::Filtration_value; /**< Filtration value type. */
46
+ using T = typename Slicer::T; /**< Numerical filtration value element type. */
47
+ using Complex = typename Slicer::Complex; /**< Complex type. */
48
+ using Index = typename Slicer::Index; /**< Complex index type. */
49
+ using Dimension = typename Slicer::Dimension; /**< Dimension type. */
50
+ template <typename Value = T>
51
+ using Bar = typename Slicer::template Bar<Value>; /**< Bar type. */
52
+ /**
53
+ * @brief Barcode type. A vector of @ref Bar, a tuple like structure containing birth, death and dimension of a bar.
54
+ */
55
+ template <typename Value = T>
56
+ using Barcode = typename Slicer::template Barcode<Value>;
57
+ /**
58
+ * @brief Flat barcode type. All bars are represented by a birth and a death value stored respectively at even and
59
+ * odd indices of the vector.
60
+ */
61
+ template <typename Value = T>
62
+ using Flat_barcode = typename Slicer::template Flat_barcode<Value>;
63
+ /**
64
+ * @brief Barcode ordered by dimension type. A vector which has at index \f$ d \f$ the @ref Barcode of dimension
65
+ * \f$ d \f$.
66
+ */
67
+ template <typename Value = T>
68
+ using Multi_dimensional_barcode = typename Slicer::template Multi_dimensional_barcode<Value>;
69
+ /**
70
+ * @brief Flat barcode ordered by dimension type. A vector which has at index \f$ d \f$ the @ref Flat_barcode of
71
+ * dimension \f$ d \f$.
72
+ */
73
+ template <typename Value = T>
74
+ using Multi_dimensional_flat_barcode = typename Slicer::template Multi_dimensional_flat_barcode<Value>;
75
+ using Cycle = typename Slicer::Cycle; /**< Cycle type. */
76
+ using Thread_safe = Thread_safe_slicer; /**< Thread safe slicer type. */
77
+
78
+ // CONSTRUCTORS
79
+
80
+ /**
81
+ * @brief Constructor. Will store a pointer to the given slicer and copy all persistence related container.
82
+ *
83
+ * @param slicer Original slicer.
84
+ */
85
+ Thread_safe_slicer(const Slicer& slicer)
86
+ : Slicer(slicer.get_slice(), slicer.get_current_order(), slicer.get_persistence_algorithm()), slicer_(&slicer)
87
+ {}
88
+
89
+ /**
90
+ * @brief Copy constructor.
91
+ */
92
+ Thread_safe_slicer(const Thread_safe_slicer& slicer)
93
+ : Slicer(slicer.get_slice(), slicer.get_current_order(), slicer.get_persistence_algorithm()),
94
+ slicer_(slicer.slicer_)
95
+ {}
96
+
97
+ /**
98
+ * @brief Move constructor.
99
+ */
100
+ Thread_safe_slicer(Thread_safe_slicer&& slicer) noexcept
101
+ : Slicer(std::move(slicer.slice_), std::move(slicer.generatorOrder_), std::move(slicer.persistence_)),
102
+ slicer_(slicer.slicer_)
103
+ {}
104
+
105
+ ~Thread_safe_slicer() = default;
106
+
107
+ /**
108
+ * @brief Assign operator.
109
+ */
110
+ Thread_safe_slicer& operator=(const Thread_safe_slicer& other)
111
+ {
112
+ if (this == &other) return *this;
113
+
114
+ Slicer::slice_ = other.slice_;
115
+ Slicer::generatorOrder_ = other.generatorOrder_;
116
+ Slicer::persistence_.reinitialize(slicer_->complex_, Slicer::generatorOrder_);
117
+ slicer_ = other.slicer_;
118
+
119
+ return *this;
120
+ }
121
+
122
+ /**
123
+ * @brief Move assign operator.
124
+ */
125
+ Thread_safe_slicer& operator=(Thread_safe_slicer&& other) noexcept = delete;
126
+
127
+ // ACCESS
128
+
129
+ /**
130
+ * @brief Returns a copy of this object.
131
+ */
132
+ Thread_safe weak_copy() const { return Thread_safe_slicer(*this); }
133
+
134
+ /**
135
+ * @brief Returns the number of generators in the stored module.
136
+ */
137
+ Index get_number_of_cycle_generators() const { return slicer_->get_number_of_cycle_generators(); }
138
+
139
+ /**
140
+ * @brief Returns the number of parameters of the stored filtration. If the module is empty, the number returned is 0.
141
+ */
142
+ Index get_number_of_parameters() const { return slicer_->get_number_of_parameters(); }
143
+
144
+ /**
145
+ * @brief Returns a const reference to the current permutation map, indicating in which order are the generators
146
+ * with respect to the current slice (i.e., \$f order[i] \$f corresponds to the index in the complex of the
147
+ * \$f i^{th} \$f generator in the filtration represented by the slice). It will be initialized with
148
+ * @ref initialize_persistence_computation.
149
+ *
150
+ * If `ignoreInf` was true when calling @ref initialize_persistence_computation, indices of generators at infinity
151
+ * are not stored in the container. That means that the size can be smaller than what
152
+ * @ref get_number_of_cycle_generators returns.
153
+ */
154
+ const std::vector<Index>& get_current_order() const { return Slicer::get_current_order(); }
155
+
156
+ /**
157
+ * @brief Returns a const reference to the current slice. It can be initialized or updated with @ref set_slice
158
+ * and @ref push_to.
159
+ */
160
+ const std::vector<T>& get_slice() const { return Slicer::get_slice(); }
161
+
162
+ /**
163
+ * @brief Returns a reference to the current slice. It can also be initialized or updated with @ref set_slice
164
+ * and @ref push_to.
165
+ */
166
+ std::vector<T>& get_slice() { return Slicer::get_slice(); }
167
+
168
+ /**
169
+ * @brief Returns a const reference to the class computing the persistence of the current slice. It will be
170
+ * initialized with @ref initialize_persistence_computation.
171
+ */
172
+ const Persistence& get_persistence_algorithm() const { return Slicer::get_persistence_algorithm(); }
173
+
174
+ /**
175
+ * @brief Returns two filtration values representing respectively the greatest common lower bound of all filtration
176
+ * values in the filtration and the lowest common upper bound of them.
177
+ */
178
+ std::pair<Filtration_value, Filtration_value> get_bounding_box() const { return slicer_->get_bounding_box(); }
179
+
180
+ /**
181
+ * @brief Returns a const reference to the filtration value container. A filtration value at index \$f i \$f
182
+ * correspond to the filtration value associated to the generators at index \$f i \$f.
183
+ */
184
+ const typename Complex::Filtration_value_container& get_filtration_values() const
185
+ {
186
+ return slicer_->get_filtration_values();
187
+ }
188
+
189
+ /**
190
+ * @brief Returns a const reference to the filtration value associated to the generator at index \$f i \$f.
191
+ */
192
+ const Filtration_value& get_filtration_value(Index i) const { return slicer_->get_filtration_value(i); }
193
+
194
+ /**
195
+ * @brief Returns a const reference to the dimension container. A value at index \$f i \$f corresponds to the
196
+ * dimension of the generator at index \$f i \$f.
197
+ */
198
+ const std::vector<Dimension>& get_dimensions() const { return slicer_->get_dimensions(); }
199
+
200
+ /**
201
+ * @brief Returns the dimension of the generator at index \$f i \$f.
202
+ */
203
+ Dimension get_dimension(Index i) const { return slicer_->get_dimension(i); }
204
+
205
+ /**
206
+ * @brief Returns the maximal dimension of a generator in the module.
207
+ */
208
+ Dimension get_max_dimension() const { return slicer_->get_max_dimension(); }
209
+
210
+ /**
211
+ * @brief Returns a const reference to the boundary container. The element at index \$f i \$f corresponds to the
212
+ * boundary of the generator at index \$f i \$f.
213
+ */
214
+ const typename Complex::Boundary_container& get_boundaries() const { return slicer_->get_boundaries(); }
215
+
216
+ /**
217
+ * @brief Returns the boundary of the generator at index \$f i \$f.
218
+ */
219
+ const typename Complex::Boundary& get_boundary(Index i) const { return slicer_->get_boundary(i); }
220
+
221
+ // MODIFIERS
222
+
223
+ /**
224
+ * @brief Sets the current slice, that is the 1-parameter filtration values associated to each generator on that line.
225
+ * The value at \$f slice[i] \$f has to corresponds to the value for the generator at index \$f i \$f.
226
+ * One can also sets the slice directly from the line with @ref push_to.
227
+ *
228
+ * @tparam Array Container which can be converted into a vector of `T`.
229
+ */
230
+ template <class Array = std::initializer_list<T>>
231
+ void set_slice(const Array& slice)
232
+ {
233
+ Slicer::set_slice(slice);
234
+ }
235
+
236
+ /**
237
+ * @brief Sets the current slice by computing the 1-parameter filtration values fo each generator on the given line.
238
+ *
239
+ * @tparam Line_like Any type convertible to a @ref Line class. Default value: `std::initializer_list<T>`.
240
+ */
241
+ template <class Line_like = std::initializer_list<T>>
242
+ void push_to(const Line_like& line)
243
+ {
244
+ Slicer::_push_to(slicer_->complex_, Line<typename Line_like::value_type>(line));
245
+ }
246
+
247
+ /**
248
+ * @brief Sets the current slice by computing the 1-parameter filtration values fo each generator on the given line.
249
+ *
250
+ * @tparam U Template parameter of the given line.
251
+ */
252
+ template <class U>
253
+ void push_to(const Line<U>& line)
254
+ {
255
+ Slicer::_push_to(slicer_->complex_, line);
256
+ }
257
+
258
+ // PERSISTENCE
259
+
260
+ /**
261
+ * @brief Returns true if and only if @ref initialize_persistence_computation was properly called.
262
+ */
263
+ [[nodiscard]] bool persistence_computation_is_initialized() const
264
+ {
265
+ return Slicer::persistence_computation_is_initialized();
266
+ }
267
+
268
+ /**
269
+ * @brief Initializes the persistence computation of the current slice. If the slice was not set properly as
270
+ * a valid 1-dimensional filtration, the behaviour is undefined.
271
+ *
272
+ * @param ignoreInf If true, all cells at infinity filtration values are ignored for the initialization, resulting
273
+ * potentially in less storage use and better performance. But note that this can be problematic with the use of
274
+ * @ref vineyard_update. Default value: true.
275
+ */
276
+ void initialize_persistence_computation(const bool ignoreInf = true)
277
+ {
278
+ Slicer::_initialize_persistence_computation(slicer_->complex_, ignoreInf);
279
+ }
280
+
281
+ /**
282
+ * @brief After the persistence computation was initialized for a slice and the slice changes, this method can
283
+ * update everything necessary for the barcode without re-computing everything from scratch (contrary to
284
+ * @ref initialize_persistence_computation). Furthermore, it guarantees that the new barcode will "match" the
285
+ * precedent one. TODO: explain exactly what it means and how to do the matching.
286
+ * The method will have better performance if the complex is ordered by dimension.
287
+ *
288
+ * Only available if PersistenceAlgorithm::is_vine is true.
289
+ *
290
+ * @pre @ref initialize_persistence_computation has to be called at least once before.
291
+ *
292
+ * @warning If `ignoreInf` was set to true when initializing the persistence computation, any update of the slice has
293
+ * to keep at infinity the boundaries which were before, otherwise the behaviour is undefined (it will throw with
294
+ * high probability).
295
+ */
296
+ void vineyard_update() { Slicer::vineyard_update(); }
297
+
298
+ /**
299
+ * @brief Returns the barcode of the current slice. The barcode format will change depending on the template values.
300
+ *
301
+ * @pre @ref initialize_persistence_computation has to be called at some point before.
302
+ *
303
+ * @tparam byDim If true, the barcode is returned as @ref Multi_dimensional_barcode, otherwise as @ref Barcode.
304
+ * @tparam Value Type of the birth and death values.
305
+ * @param maxDim Maximal dimension to be included in the barcode. If negative, all dimensions are included.
306
+ * Default value: -1.
307
+ */
308
+ template <bool byDim = true, typename Value = T, bool idx = false>
309
+ auto get_barcode(int maxDim = -1)
310
+ {
311
+ // complex in parent is empty, so maxDim needs to be initialized from the outside.
312
+ if (maxDim < 0) maxDim = slicer_->get_max_dimension();
313
+ return Slicer::template get_barcode<byDim, Value, idx>(maxDim);
314
+ }
315
+
316
+ /**
317
+ * @brief Returns the barcode of the current slice. The barcode format will change depending on the template values.
318
+ *
319
+ * @pre @ref initialize_persistence_computation has to be called at some point before.
320
+ *
321
+ * @tparam byDim If true, the barcode is returned as @ref Multi_dimensional_flat_barcode, otherwise as
322
+ * @ref Flat_barcode.
323
+ * @tparam Value Type of the birth and death values.
324
+ * @param maxDim Maximal dimension to be included in the barcode. If negative, all dimensions are included.
325
+ * Default value: -1.
326
+ */
327
+ template <bool byDim = false, typename Value = T, bool idx = false>
328
+ auto get_flat_barcode(int maxDim = -1)
329
+ {
330
+ // complex in parent is empty, so maxDim needs to be initialized from the outside.
331
+ if (maxDim < 0) maxDim = slicer_->get_max_dimension();
332
+ return Slicer::template get_flat_barcode<byDim, Value, idx>(maxDim);
333
+ }
334
+
335
+ /**
336
+ * @brief Returns the representative cycles of the current slice. All cycles of dimension \f$ d \f$ are stored at
337
+ * index \f$ d \f$ of the returned vector. A cycle is represented by a vector of boundary indices. That is, the index
338
+ * \f$ i \f$ in a cycle represents the cell which boundary can be retrieved by @ref get_boundary "get_boundary(i)".
339
+ *
340
+ * Only available if PersistenceAlgorithm::has_rep_cycles is true.
341
+ *
342
+ * @pre @ref initialize_persistence_computation has to be called at least once before.
343
+ *
344
+ * @param update If true, updates the stored representative cycles, otherwise just returns the container in its
345
+ * current state. So should be true at least the first time the method is used.
346
+ */
347
+ std::vector<std::vector<Cycle>> get_representative_cycles(bool update = true)
348
+ {
349
+ return Slicer::_get_representative_cycles(slicer_->complex_, update);
350
+ }
351
+
352
+ Cycle get_most_persistent_cycle(Dimension dim = 1, bool update = true)
353
+ {
354
+ return Slicer::get_most_persistent_cycle(dim, update);
355
+ }
356
+
357
+ // FRIENDS
358
+
359
+ /**
360
+ * @brief Outstream operator.
361
+ */
362
+ friend std::ostream& operator<<(std::ostream& stream, Thread_safe_slicer& slicer)
363
+ {
364
+ stream << "-------------------- Thread_safe_slicer \n";
365
+
366
+ stream << "--- Filtered complex \n";
367
+ stream << slicer.slicer_->complex_;
368
+
369
+ stream << "--- Order \n";
370
+ stream << "{";
371
+ for (const auto& idx : slicer.get_current_order()) stream << idx << ", ";
372
+ stream << "}" << '\n';
373
+
374
+ stream << "--- Current slice filtration\n";
375
+ stream << "{";
376
+ for (const auto& val : slicer.get_slice()) stream << val << ", ";
377
+ stream << "\b" << "\b";
378
+ stream << "}" << '\n';
379
+
380
+ stream << "--- PersBackend \n";
381
+ stream << slicer.persistence_;
382
+
383
+ return stream;
384
+ }
385
+
386
+ private:
387
+ Slicer const* slicer_; /**< Original slicer. */
388
+ };
389
+
390
+ } // namespace multi_persistence
391
+ } // namespace Gudhi
392
+
393
+ #endif // MP_THREAD_SAFE_SLICER_H_INCLUDED
@@ -0,0 +1,62 @@
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 DISTANCE_FUNCTIONS_H_
12
+ #define DISTANCE_FUNCTIONS_H_
13
+
14
+ #include <gudhi/Debug_utils.h>
15
+
16
+ #include <boost/range/metafunctions.hpp>
17
+ #include <boost/range/size.hpp>
18
+
19
+ #include <cmath> // for std::sqrt
20
+ #include <type_traits> // for std::decay
21
+ #include <iterator> // for std::begin, std::end
22
+ #include <utility>
23
+
24
+ namespace Gudhi {
25
+
26
+ /** @file
27
+ * @brief Global distance functions
28
+ */
29
+
30
+ /** @brief Compute the Euclidean distance between two Points given by a range of coordinates. The points are assumed to
31
+ * have the same dimension. */
32
+ class Euclidean_distance {
33
+ public:
34
+ // boost::range_value is not SFINAE-friendly so we cannot use it in the return type
35
+ template< typename Point >
36
+ typename std::iterator_traits<typename boost::range_iterator<Point>::type>::value_type
37
+ operator()(const Point& p1, const Point& p2) const {
38
+ auto it1 = std::begin(p1);
39
+ auto it2 = std::begin(p2);
40
+ typedef typename boost::range_value<Point>::type NT;
41
+ NT dist = 0;
42
+ for (; it1 != std::end(p1); ++it1, ++it2) {
43
+ GUDHI_CHECK(it2 != std::end(p2), "inconsistent point dimensions");
44
+ NT tmp = *it1 - *it2;
45
+ dist += tmp*tmp;
46
+ }
47
+ GUDHI_CHECK(it2 == std::end(p2), "inconsistent point dimensions");
48
+ using std::sqrt;
49
+ return sqrt(dist);
50
+ }
51
+ template< typename T >
52
+ T operator() (const std::pair< T, T >& f, const std::pair< T, T >& s) const {
53
+ T dx = f.first - s.first;
54
+ T dy = f.second - s.second;
55
+ using std::sqrt;
56
+ return sqrt(dx*dx + dy*dy);
57
+ }
58
+ };
59
+
60
+ } // namespace Gudhi
61
+
62
+ #endif // DISTANCE_FUNCTIONS_H_
@@ -0,0 +1,104 @@
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 GRAPH_SIMPLICIAL_COMPLEX_H_
12
+ #define GRAPH_SIMPLICIAL_COMPLEX_H_
13
+
14
+ #include <boost/graph/adjacency_list.hpp>
15
+
16
+ #include <utility> // for pair<>
17
+ #include <vector>
18
+ #include <map>
19
+ #include <tuple> // for std::tie
20
+
21
+ namespace Gudhi {
22
+ /** @file
23
+ * @brief Graph simplicial complex methods
24
+ */
25
+
26
+ /* Edge tag for Boost PropertyGraph. */
27
+ struct edge_filtration_t {
28
+ typedef boost::edge_property_tag kind;
29
+ };
30
+
31
+ /* Vertex tag for Boost PropertyGraph. */
32
+ struct vertex_filtration_t {
33
+ typedef boost::vertex_property_tag kind;
34
+ };
35
+
36
+ /** \brief Proximity_graph contains the vertices and edges with their filtration values in order to store the result
37
+ * of `Gudhi::compute_proximity_graph` function.
38
+ *
39
+ * \tparam SimplicialComplexForProximityGraph furnishes `Filtration_value` type definition.
40
+ *
41
+ */
42
+ template <typename SimplicialComplexForProximityGraph>
43
+ using Proximity_graph = typename boost::adjacency_list < boost::vecS, boost::vecS, boost::directedS
44
+ , boost::property < vertex_filtration_t, typename SimplicialComplexForProximityGraph::Filtration_value >
45
+ , boost::property < edge_filtration_t, typename SimplicialComplexForProximityGraph::Filtration_value >>;
46
+
47
+ /** \brief Computes the proximity graph of the points.
48
+ *
49
+ * If points contains n elements, the proximity graph is the graph with n vertices, and an edge [u,v] iff the
50
+ * distance function between points u and v is smaller than threshold.
51
+ *
52
+ * \tparam SimplicialComplexForProximityGraph furnishes `Filtration_value` and `Vertex_handle` type definitions.
53
+ *
54
+ * \tparam ForwardPointRange furnishes `.begin()` and `.end()` methods.
55
+ *
56
+ * \tparam Distance furnishes `operator()(const Point& p1, const Point& p2)`, where
57
+ * `Point` is a point from the `ForwardPointRange`, and that returns a `Filtration_value`.
58
+ */
59
+ template< typename SimplicialComplexForProximityGraph
60
+ , typename ForwardPointRange
61
+ , typename Distance >
62
+ Proximity_graph<SimplicialComplexForProximityGraph> compute_proximity_graph(
63
+ const ForwardPointRange& points,
64
+ typename SimplicialComplexForProximityGraph::Filtration_value threshold,
65
+ Distance distance) {
66
+ using Vertex_handle = typename SimplicialComplexForProximityGraph::Vertex_handle;
67
+ using Filtration_value = typename SimplicialComplexForProximityGraph::Filtration_value;
68
+
69
+ std::vector<std::pair< Vertex_handle, Vertex_handle >> edges;
70
+ std::vector< Filtration_value > edges_fil;
71
+ std::map< Vertex_handle, Filtration_value > vertices;
72
+
73
+ Vertex_handle idx_u, idx_v;
74
+ Filtration_value fil;
75
+ idx_u = 0;
76
+ for (auto it_u = points.begin(); it_u != points.end(); ++it_u) {
77
+ idx_v = idx_u + 1;
78
+ for (auto it_v = it_u + 1; it_v != points.end(); ++it_v, ++idx_v) {
79
+ fil = distance(*it_u, *it_v);
80
+ if (fil <= threshold) {
81
+ edges.emplace_back(idx_u, idx_v);
82
+ edges_fil.push_back(fil);
83
+ }
84
+ }
85
+ ++idx_u;
86
+ }
87
+
88
+ // Points are labeled from 0 to idx_u-1
89
+ Proximity_graph<SimplicialComplexForProximityGraph> skel_graph(edges.begin(), edges.end(), edges_fil.begin(), idx_u);
90
+
91
+ auto vertex_prop = boost::get(vertex_filtration_t(), skel_graph);
92
+
93
+ typename boost::graph_traits<Proximity_graph<SimplicialComplexForProximityGraph>>::vertex_iterator vi, vi_end;
94
+ for (std::tie(vi, vi_end) = boost::vertices(skel_graph);
95
+ vi != vi_end; ++vi) {
96
+ boost::put(vertex_prop, *vi, 0.);
97
+ }
98
+
99
+ return skel_graph;
100
+ }
101
+
102
+ } // namespace Gudhi
103
+
104
+ #endif // GRAPH_SIMPLICIAL_COMPLEX_H_