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,58 @@
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): Hannah Schreiber
4
+ *
5
+ * Copyright (C) 2022-24 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ /**
12
+ * @file index_mapper.h
13
+ * @author Hannah Schreiber
14
+ * @brief Contains the Gudhi::persistence_matrix::Index_mapper class and
15
+ * Gudhi::persistence_matrix::Dummy_index_mapper structure.
16
+ */
17
+
18
+ #ifndef PM_INDEX_MAPPER_H
19
+ #define PM_INDEX_MAPPER_H
20
+
21
+ namespace Gudhi {
22
+ namespace persistence_matrix {
23
+
24
+ // Note: this would be a good candidate for std::optional instead of a mixin as its only role for now
25
+ // is to store a map. If this does not change later.
26
+
27
+ /**
28
+ * @private
29
+ * @ingroup persistence_matrix
30
+ *
31
+ * @brief Empty structure.
32
+ * Inherited instead of @ref Index_mapper.
33
+ */
34
+ struct Dummy_index_mapper {
35
+ friend void swap([[maybe_unused]] Dummy_index_mapper& d1, [[maybe_unused]] Dummy_index_mapper& d2) noexcept {}
36
+ };
37
+
38
+ /**
39
+ * @private
40
+ * @ingroup persistence_matrix
41
+ *
42
+ * @brief Map container. Though for translation between different index types.
43
+ *
44
+ * @tparam Map Map type
45
+ */
46
+ template <class Map>
47
+ struct Index_mapper {
48
+ using Index_map = Map;
49
+
50
+ Index_map map_;
51
+
52
+ friend void swap(Index_mapper& mapper1, Index_mapper& mapper2) noexcept { mapper1.map_.swap(mapper2.map_); }
53
+ };
54
+
55
+ } // namespace persistence_matrix
56
+ } // namespace Gudhi
57
+
58
+ #endif // PM_INDEX_MAPPER_H
@@ -0,0 +1,227 @@
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): Hannah Schreiber
4
+ *
5
+ * Copyright (C) 2022-24 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ /**
12
+ * @file matrix_dimension_holders.h
13
+ * @author Hannah Schreiber
14
+ * @brief Contains the @ref Gudhi::persistence_matrix::Matrix_max_dimension_holder
15
+ * @ref Gudhi::persistence_matrix::Matrix_all_dimension_holder classes
16
+ * and the @ref Gudhi::persistence_matrix::Dummy_matrix_dimension_holder structure.
17
+ */
18
+
19
+ #ifndef PM_MATRIX_DIM_HOLDER_H
20
+ #define PM_MATRIX_DIM_HOLDER_H
21
+
22
+ #include <utility> //std::swap, std::move & std::exchange
23
+ #include <vector>
24
+
25
+ namespace Gudhi {
26
+ namespace persistence_matrix {
27
+
28
+ /**
29
+ * @ingroup persistence_matrix
30
+ *
31
+ * @brief Empty structure.
32
+ * Inherited instead of @ref Matrix_max_dimension_holder or @ref Matrix_all_dimension_holder, when the maximal
33
+ * dimension of a matrix is not stored.
34
+ */
35
+ struct Dummy_matrix_dimension_holder {
36
+ template <typename Dimension>
37
+ Dummy_matrix_dimension_holder([[maybe_unused]] Dimension maximalDimension)
38
+ {}
39
+
40
+ friend void swap([[maybe_unused]] Dummy_matrix_dimension_holder& d1,
41
+ [[maybe_unused]] Dummy_matrix_dimension_holder& d2) noexcept
42
+ {}
43
+ };
44
+
45
+ // TODO: find an easy way to give access to get_null_value<Dimension>() to replace the -1s
46
+
47
+ /**
48
+ * @ingroup persistence_matrix
49
+ *
50
+ * @brief Class managing the maximal dimension of a cell represented in the inheriting matrix, when the option of
51
+ * cell removal is not enabled.
52
+ *
53
+ * @tparam Dimension Dimension value type. Has to be an integer type.
54
+ * If unsigned, the maximal value of the type should not be attained during a run.
55
+ */
56
+ template <typename Dimension>
57
+ class Matrix_max_dimension_holder
58
+ {
59
+ public:
60
+ /**
61
+ * @brief Default constructor. If a dimension is specified, stores it as the maximal value.
62
+ *
63
+ * @param maximalDimension Value of the maximal dimension. Has to be either positive or -1. Default value: -1.
64
+ */
65
+ Matrix_max_dimension_holder(Dimension maximalDimension = -1) : maxDim_(maximalDimension) {};
66
+ /**
67
+ * @brief Copy constructor.
68
+ *
69
+ * @param toCopy Matrix to copy.
70
+ */
71
+ Matrix_max_dimension_holder(const Matrix_max_dimension_holder& toCopy) = default;
72
+ /**
73
+ * @brief Move constructor.
74
+ *
75
+ * @param other Matrix to move.
76
+ */
77
+ Matrix_max_dimension_holder(Matrix_max_dimension_holder&& other) noexcept
78
+ : maxDim_(std::exchange(other.maxDim_, -1)) {};
79
+
80
+ ~Matrix_max_dimension_holder() = default;
81
+
82
+ /**
83
+ * @brief Returns the maximal dimension of a cell represented in the matrix.
84
+ *
85
+ * @return The maximal dimension.
86
+ */
87
+ Dimension get_max_dimension() const { return maxDim_; };
88
+
89
+ /**
90
+ * @brief Assign operator.
91
+ */
92
+ Matrix_max_dimension_holder& operator=(const Matrix_max_dimension_holder& other) = default;
93
+
94
+ /**
95
+ * @brief Move assign operator.
96
+ */
97
+ Matrix_max_dimension_holder& operator=(Matrix_max_dimension_holder&& other) noexcept
98
+ {
99
+ if (this == &other) return *this;
100
+
101
+ maxDim_ = std::exchange(other.maxDim_, -1);
102
+ return *this;
103
+ };
104
+
105
+ /**
106
+ * @brief Swap operator.
107
+ */
108
+ friend void swap(Matrix_max_dimension_holder& matrix1, Matrix_max_dimension_holder& matrix2) noexcept
109
+ {
110
+ std::swap(matrix1.maxDim_, matrix2.maxDim_);
111
+ }
112
+
113
+ protected:
114
+ void _update_up(Dimension dimension)
115
+ {
116
+ if (maxDim_ == -1 || maxDim_ < dimension) maxDim_ = dimension;
117
+ };
118
+
119
+ void _reset() { maxDim_ = -1; }
120
+
121
+ private:
122
+ Dimension maxDim_; /**< Current maximal dimension. */
123
+ };
124
+
125
+ /**
126
+ * @ingroup persistence_matrix
127
+ *
128
+ * @brief Class managing the maximal dimension of a cell represented in the inheriting matrix, when the option of
129
+ * cell removal is enabled.
130
+ *
131
+ * @tparam Dimension Dimension value type. Has to be an integer type.
132
+ * If unsigned, the maximal value of the type should not be attained during a run.
133
+ */
134
+ template <typename Dimension>
135
+ class Matrix_all_dimension_holder
136
+ {
137
+ public:
138
+ /**
139
+ * @brief Default constructor. If a dimension is specified, stores it as the maximal value.
140
+ *
141
+ * @param maximalDimension Value of the maximal dimension. Has to be either positive or -1. Default value: -1.
142
+ */
143
+ Matrix_all_dimension_holder(Dimension maximalDimension = -1)
144
+ : dimensions_(maximalDimension < 0 ? 0 : maximalDimension + 1, 0), maxDim_(maximalDimension)
145
+ {
146
+ if (maxDim_ != -1) dimensions_[maxDim_] = 1;
147
+ };
148
+
149
+ /**
150
+ * @brief Copy constructor.
151
+ *
152
+ * @param toCopy Matrix to copy.
153
+ */
154
+ Matrix_all_dimension_holder(const Matrix_all_dimension_holder& toCopy) = default;
155
+ /**
156
+ * @brief Move constructor.
157
+ *
158
+ * @param other Matrix to move.
159
+ */
160
+ Matrix_all_dimension_holder(Matrix_all_dimension_holder&& other) noexcept
161
+ : dimensions_(std::move(other.dimensions_)), maxDim_(std::exchange(other.maxDim_, -1)) {};
162
+
163
+ ~Matrix_all_dimension_holder() = default;
164
+
165
+ /**
166
+ * @brief Returns the maximal dimension of a cell represented in the matrix.
167
+ *
168
+ * @return The maximal dimension.
169
+ */
170
+ Dimension get_max_dimension() const { return maxDim_; };
171
+
172
+ /**
173
+ * @brief Assign operator.
174
+ */
175
+ Matrix_all_dimension_holder& operator=(const Matrix_all_dimension_holder& other) = default;
176
+
177
+ /**
178
+ * @brief Move assign operator.
179
+ */
180
+ Matrix_all_dimension_holder& operator=(Matrix_all_dimension_holder&& other) noexcept
181
+ {
182
+ if (this == &other) return *this;
183
+
184
+ dimensions_ = std::move(other.dimensions_);
185
+ maxDim_ = std::exchange(other.maxDim_, -1);
186
+ return *this;
187
+ };
188
+
189
+ /**
190
+ * @brief Swap operator.
191
+ */
192
+ friend void swap(Matrix_all_dimension_holder& matrix1, Matrix_all_dimension_holder& matrix2) noexcept
193
+ {
194
+ std::swap(matrix1.maxDim_, matrix2.maxDim_);
195
+ matrix1.dimensions_.swap(matrix2.dimensions_);
196
+ }
197
+
198
+ protected:
199
+ void _update_up(unsigned int dimension)
200
+ {
201
+ if (dimensions_.size() <= dimension) dimensions_.resize(dimension + 1, 0);
202
+ ++(dimensions_[dimension]);
203
+ maxDim_ = dimensions_.size() - 1;
204
+ };
205
+
206
+ void _update_down(unsigned int dimension)
207
+ {
208
+ --(dimensions_[dimension]); // assumes dimension already exists and is not 0
209
+ while (!dimensions_.empty() && dimensions_.back() == 0) dimensions_.pop_back();
210
+ maxDim_ = dimensions_.size() - 1;
211
+ };
212
+
213
+ void _reset()
214
+ {
215
+ dimensions_.clear();
216
+ maxDim_ = -1;
217
+ }
218
+
219
+ private:
220
+ std::vector<unsigned int> dimensions_; /**< Number of cells by dimension. */
221
+ Dimension maxDim_; /**< Current maximal dimension. */
222
+ };
223
+
224
+ } // namespace persistence_matrix
225
+ } // namespace Gudhi
226
+
227
+ #endif // PM_MATRIX_DIM_HOLDER_H
@@ -0,0 +1,200 @@
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): Hannah Schreiber
4
+ *
5
+ * Copyright (C) 2022-24 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ /**
12
+ * @file matrix_row_access.h
13
+ * @author Hannah Schreiber
14
+ * @brief Contains the @ref Gudhi::persistence_matrix::Matrix_row_access class and
15
+ * @ref Gudhi::persistence_matrix::Dummy_matrix_row_access structure.
16
+ */
17
+
18
+ #ifndef PM_BASE_MATRIX_RA_H
19
+ #define PM_BASE_MATRIX_RA_H
20
+
21
+ #include <utility> //std::move
22
+
23
+ namespace Gudhi {
24
+ namespace persistence_matrix {
25
+
26
+ /**
27
+ * @ingroup persistence_matrix
28
+ *
29
+ * @brief Empty structure.
30
+ * Inherited instead of @ref Matrix_row_access, when the the row access is not enabled.
31
+ */
32
+ struct Dummy_matrix_row_access {
33
+ Dummy_matrix_row_access([[maybe_unused]] unsigned int numberOfRows = 0) {};
34
+
35
+ friend void swap([[maybe_unused]] Dummy_matrix_row_access& d1, [[maybe_unused]] Dummy_matrix_row_access& d2) noexcept
36
+ {}
37
+ };
38
+
39
+ /**
40
+ * @class Matrix_row_access matrix_row_access.h gudhi/Persistence_matrix/matrix_row_access.h
41
+ * @ingroup persistence_matrix
42
+ *
43
+ * @brief Class managing the row access for the inheriting matrix.
44
+ *
45
+ * @tparam Row Either boost::intrusive::list<Matrix_entry,...> if @ref PersistenceMatrixOptions::has_intrusive_rows
46
+ * is true, or std::set<Matrix_entry, RowEntryComp> otherwise.
47
+ * @tparam Row_container Either std::map<Index,Row> if @ref PersistenceMatrixOptions::has_removable_rows is
48
+ * true, or std::vector<Row> otherwise.
49
+ * @tparam has_removable_rows Value of @ref PersistenceMatrixOptions::has_removable_rows.
50
+ * @tparam ID_index @ref IDIdx index type.
51
+ */
52
+ template <typename Row, typename Row_container, bool has_removable_rows, typename ID_index>
53
+ class Matrix_row_access
54
+ {
55
+ public:
56
+ /**
57
+ * @brief Default constructor.
58
+ */
59
+ Matrix_row_access() : rows_(new Row_container()) {};
60
+
61
+ /**
62
+ * @brief Constructor reserving space for the given number of rows.
63
+ *
64
+ * Has only an effect if @ref PersistenceMatrixOptions::has_removable_rows is false.
65
+ *
66
+ * @param numberOfRows Number of rows to reserve space for.
67
+ */
68
+ Matrix_row_access(unsigned int numberOfRows) : rows_(new Row_container())
69
+ {
70
+ if constexpr (!has_removable_rows) {
71
+ rows_->resize(numberOfRows);
72
+ }
73
+ }
74
+
75
+ /**
76
+ * @brief Copy constructor.
77
+ *
78
+ * @param toCopy Matrix to copy.
79
+ */
80
+ Matrix_row_access(const Matrix_row_access& toCopy)
81
+ : rows_(new Row_container()) // as the matrix is rebuild, the rows should not be copied.
82
+ {
83
+ if constexpr (!has_removable_rows) {
84
+ rows_->resize(toCopy.rows_->size());
85
+ }
86
+ }
87
+
88
+ /**
89
+ * @brief Move constructor.
90
+ *
91
+ * @param other Matrix to move.
92
+ */
93
+ Matrix_row_access(Matrix_row_access&& other) noexcept : rows_(std::exchange(other.rows_, nullptr)) {}
94
+
95
+ /**
96
+ * @brief Destructor.
97
+ */
98
+ ~Matrix_row_access() { delete rows_; }
99
+
100
+ /**
101
+ * @brief Returns the row at the given @ref rowindex "row index".
102
+ * The type of the row depends on the chosen options, see @ref PersistenceMatrixOptions::has_intrusive_rows.
103
+ *
104
+ * @param rowIndex @ref rowindex "Row index" of the row to return: @ref IDIdx for @ref chainmatrix "chain matrices"
105
+ * or updated @ref IDIdx for @ref boundarymatrix "boundary matrices" if swaps occurred.
106
+ * @return Reference to the row.
107
+ */
108
+ Row& get_row(ID_index rowIndex)
109
+ {
110
+ if constexpr (has_removable_rows) {
111
+ return rows_->at(rowIndex);
112
+ } else {
113
+ return rows_->operator[](rowIndex);
114
+ }
115
+ }
116
+
117
+ /**
118
+ * @brief Returns the row at the given @ref rowindex "row index".
119
+ * The type of the row depends on the chosen options, see @ref PersistenceMatrixOptions::has_intrusive_rows.
120
+ *
121
+ * @param rowIndex @ref rowindex "Row index" of the row to return: @ref IDIdx for @ref chainmatrix "chain matrices"
122
+ * or updated @ref IDIdx for @ref boundarymatrix "boundary matrices" if swaps occurred.
123
+ * @return Const reference to the row.
124
+ */
125
+ const Row& get_row(ID_index rowIndex) const
126
+ {
127
+ if constexpr (has_removable_rows) {
128
+ return rows_->at(rowIndex);
129
+ } else {
130
+ return rows_->operator[](rowIndex);
131
+ }
132
+ }
133
+
134
+ /**
135
+ * @brief Only available if @ref PersistenceMatrixOptions::has_removable_rows is true. Removes the given row
136
+ * from the row container if the row exists and is empty.
137
+ *
138
+ * @param rowIndex @ref rowindex "Row index" of the row to remove.
139
+ */
140
+ void erase_empty_row(ID_index rowIndex)
141
+ {
142
+ static_assert(has_removable_rows, "'erase_empty_row' is not implemented for the chosen options.");
143
+
144
+ auto it = rows_->find(rowIndex);
145
+ if (it != rows_->end() && it->second.empty()) rows_->erase(it);
146
+ }
147
+
148
+ /**
149
+ * @brief Assign operator.
150
+ */
151
+ Matrix_row_access& operator=(const Matrix_row_access& other)
152
+ {
153
+ if constexpr (has_removable_rows)
154
+ rows_->reserve(other.rows_->size());
155
+ else
156
+ rows_->resize(other.rows_->size());
157
+ return *this;
158
+ }
159
+
160
+ /**
161
+ * @brief Move assign operator.
162
+ */
163
+ Matrix_row_access& operator=(Matrix_row_access&& other) noexcept
164
+ {
165
+ if (this == &other) return *this;
166
+
167
+ rows_ = std::exchange(other.rows_, nullptr);
168
+ return *this;
169
+ }
170
+
171
+ /**
172
+ * @brief Swap operator.
173
+ */
174
+ friend void swap(Matrix_row_access& matrix1, Matrix_row_access& matrix2) noexcept
175
+ {
176
+ std::swap(matrix1.rows_, matrix2.rows_);
177
+ }
178
+
179
+ protected:
180
+ Row_container* _get_rows_ptr() const { return rows_; }
181
+
182
+ void _resize(ID_index size)
183
+ {
184
+ static_assert(!has_removable_rows, "'_resize' is not implemented for the chosen options.");
185
+
186
+ if (rows_->size() <= size) rows_->resize(size + 1);
187
+ }
188
+
189
+ private:
190
+ /**
191
+ * @brief Row container. A pointer to facilitate column swaps when two matrices are swapped.
192
+ * Has to be destroyed after matrix_, therefore has to be inherited.
193
+ */
194
+ Row_container* rows_;
195
+ };
196
+
197
+ } // namespace persistence_matrix
198
+ } // namespace Gudhi
199
+
200
+ #endif // PM_BASE_MATRIX_RA_H
@@ -0,0 +1,166 @@
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): Hannah Schreiber
4
+ *
5
+ * Copyright (C) 2022-24 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ /**
12
+ * @file ru_pairing.h
13
+ * @author Hannah Schreiber
14
+ * @brief Contains the @ref Gudhi::persistence_matrix::RU_pairing class and
15
+ * @ref Gudhi::persistence_matrix::Dummy_ru_pairing structure.
16
+ */
17
+
18
+ #ifndef PM_RU_PAIRING_H
19
+ #define PM_RU_PAIRING_H
20
+
21
+ #include <unordered_map>
22
+
23
+ namespace Gudhi {
24
+ namespace persistence_matrix {
25
+
26
+ template <typename Master_matrix>
27
+ class RU_barcode_swap;
28
+
29
+ /**
30
+ * @ingroup persistence_matrix
31
+ *
32
+ * @brief Empty structure.
33
+ * Inherited instead of @ref RU_pairing, when the computation of the barcode was not enabled or if the pairing
34
+ * is already managed by the vine update classes.
35
+ */
36
+ struct Dummy_ru_pairing {
37
+ friend void swap([[maybe_unused]] Dummy_ru_pairing& d1, [[maybe_unused]] Dummy_ru_pairing& d2) noexcept {}
38
+ };
39
+
40
+ /**
41
+ * @class RU_pairing ru_pairing.h gudhi/Persistence_matrix/ru_pairing.h
42
+ * @ingroup persistence_matrix
43
+ *
44
+ * @brief Class managing the barcode for @ref RU_matrix if the option was enabled.
45
+ *
46
+ * @tparam Master_matrix An instantiation of @ref Matrix from which all types and options are deduced.
47
+ */
48
+ template <class Master_matrix>
49
+ class RU_pairing
50
+ {
51
+ public:
52
+ using Barcode = typename Master_matrix::Barcode; /**< Barcode type. */
53
+
54
+ /**
55
+ * @brief Default constructor.
56
+ */
57
+ RU_pairing() = default;
58
+
59
+ /**
60
+ * @brief Returns the current barcode which is maintained at any insertion, removal or vine swap.
61
+ *
62
+ * @return Const reference to the barcode.
63
+ */
64
+ const Barcode& get_current_barcode() const { return barcode_; }
65
+
66
+ /**
67
+ * @brief Swap operator.
68
+ */
69
+ friend void swap(RU_pairing& pairing1, RU_pairing& pairing2) noexcept
70
+ {
71
+ pairing1.barcode_.swap(pairing2.barcode_);
72
+ pairing1.indexToBar_.swap(pairing2.indexToBar_);
73
+ pairing1.idToPosition_.swap(pairing2.idToPosition_);
74
+ }
75
+
76
+ protected:
77
+ using Pos_index = typename Master_matrix::Pos_index;
78
+ using ID_index = typename Master_matrix::ID_index;
79
+ using Dimension = typename Master_matrix::Dimension;
80
+
81
+ void _reserve(unsigned int numberOfColumns) { indexToBar_.reserve(numberOfColumns); }
82
+
83
+ void _update_barcode(ID_index birthPivot, Pos_index death)
84
+ {
85
+ auto it = idToPosition_.find(birthPivot);
86
+ Pos_index pivotBirth = it == idToPosition_.end() ? birthPivot : it->second;
87
+ if constexpr (Master_matrix::hasFixedBarcode || !Master_matrix::Option_list::has_removable_columns) {
88
+ barcode_[indexToBar_[pivotBirth]].death = death;
89
+ indexToBar_.push_back(indexToBar_[pivotBirth]);
90
+ } else {
91
+ auto& barIt = indexToBar_.at(pivotBirth);
92
+ barIt->death = death;
93
+ indexToBar_.try_emplace(death, barIt); // list so iterators are stable
94
+ }
95
+ }
96
+
97
+ void _add_bar(Dimension dim, Pos_index birth)
98
+ {
99
+ barcode_.emplace_back(birth, Master_matrix::template get_null_value<Pos_index>(), dim);
100
+ if constexpr (Master_matrix::hasFixedBarcode || !Master_matrix::Option_list::has_removable_columns) {
101
+ indexToBar_.push_back(barcode_.size() - 1);
102
+ } else {
103
+ indexToBar_.try_emplace(birth, --barcode_.end());
104
+ }
105
+ }
106
+
107
+ void _remove_last(Pos_index eventIndex)
108
+ {
109
+ static_assert(Master_matrix::Option_list::has_removable_columns, "_remove_last not available.");
110
+ constexpr const Pos_index nullDeath = Master_matrix::template get_null_value<Pos_index>();
111
+
112
+ if constexpr (Master_matrix::hasFixedBarcode) {
113
+ auto& bar = barcode_[indexToBar_[eventIndex]];
114
+ if (bar.death == nullDeath) { // birth
115
+ barcode_.pop_back(); // sorted by birth and eventIndex has to be the highest one
116
+ } else { // death
117
+ bar.death = nullDeath;
118
+ };
119
+ indexToBar_.pop_back();
120
+ } else { // birth order eventually shuffled by vine updates. No sort possible to keep the matchings.
121
+ auto it = indexToBar_.find(eventIndex);
122
+ typename Barcode::iterator bar = it->second;
123
+
124
+ if (bar->death == nullDeath)
125
+ barcode_.erase(bar);
126
+ else
127
+ bar->death = nullDeath;
128
+
129
+ indexToBar_.erase(it);
130
+ }
131
+
132
+ auto& map = static_cast<typename Master_matrix::Master_RU_matrix*>(this)->positionToID_;
133
+ auto it = map.find(eventIndex);
134
+ if (it != map.end()) {
135
+ idToPosition_.erase(it->second);
136
+ map.erase(it);
137
+ }
138
+ }
139
+
140
+ void _insert_id_position(ID_index id, Pos_index pos) { idToPosition_.emplace(id, pos); }
141
+
142
+ void _reset()
143
+ {
144
+ barcode_.clear();
145
+ indexToBar_.clear();
146
+ }
147
+
148
+ private:
149
+ using Dictionary = typename Master_matrix::Bar_dictionary;
150
+
151
+ // could also just mark everything as protected as RU_barcode_swap inherits from RU_pairing
152
+ // but this way, it marks a better difference between "class using this mixin" with "class extending this mixin"
153
+ friend RU_barcode_swap<Master_matrix>;
154
+
155
+ Barcode barcode_; /**< Bar container. */
156
+ Dictionary indexToBar_; /**< Map from @ref MatIdx index to bar index. */
157
+ /**
158
+ * @brief Map from cell ID to cell position. Only stores a pair if ID != position.
159
+ */
160
+ std::unordered_map<ID_index, Pos_index> idToPosition_; // TODO: test other map types
161
+ };
162
+
163
+ } // namespace persistence_matrix
164
+ } // namespace Gudhi
165
+
166
+ #endif // PM_RU_PAIRING_H