multipers 2.3.3b6__cp313-cp313-macosx_10_13_x86_64.whl

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

Potentially problematic release.


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

Files changed (183) hide show
  1. multipers/.dylibs/libc++.1.0.dylib +0 -0
  2. multipers/.dylibs/libtbb.12.16.dylib +0 -0
  3. multipers/__init__.py +33 -0
  4. multipers/_signed_measure_meta.py +453 -0
  5. multipers/_slicer_meta.py +211 -0
  6. multipers/array_api/__init__.py +45 -0
  7. multipers/array_api/numpy.py +41 -0
  8. multipers/array_api/torch.py +58 -0
  9. multipers/data/MOL2.py +458 -0
  10. multipers/data/UCR.py +18 -0
  11. multipers/data/__init__.py +1 -0
  12. multipers/data/graphs.py +466 -0
  13. multipers/data/immuno_regions.py +27 -0
  14. multipers/data/minimal_presentation_to_st_bf.py +0 -0
  15. multipers/data/pytorch2simplextree.py +91 -0
  16. multipers/data/shape3d.py +101 -0
  17. multipers/data/synthetic.py +113 -0
  18. multipers/distances.py +202 -0
  19. multipers/filtration_conversions.pxd +229 -0
  20. multipers/filtration_conversions.pxd.tp +84 -0
  21. multipers/filtrations/__init__.py +18 -0
  22. multipers/filtrations/density.py +574 -0
  23. multipers/filtrations/filtrations.py +361 -0
  24. multipers/filtrations.pxd +224 -0
  25. multipers/function_rips.cpython-313-darwin.so +0 -0
  26. multipers/function_rips.pyx +105 -0
  27. multipers/grids.cpython-313-darwin.so +0 -0
  28. multipers/grids.pyx +433 -0
  29. multipers/gudhi/Persistence_slices_interface.h +132 -0
  30. multipers/gudhi/Simplex_tree_interface.h +239 -0
  31. multipers/gudhi/Simplex_tree_multi_interface.h +551 -0
  32. multipers/gudhi/cubical_to_boundary.h +59 -0
  33. multipers/gudhi/gudhi/Bitmap_cubical_complex.h +450 -0
  34. multipers/gudhi/gudhi/Bitmap_cubical_complex_base.h +1070 -0
  35. multipers/gudhi/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h +579 -0
  36. multipers/gudhi/gudhi/Debug_utils.h +45 -0
  37. multipers/gudhi/gudhi/Fields/Multi_field.h +484 -0
  38. multipers/gudhi/gudhi/Fields/Multi_field_operators.h +455 -0
  39. multipers/gudhi/gudhi/Fields/Multi_field_shared.h +450 -0
  40. multipers/gudhi/gudhi/Fields/Multi_field_small.h +531 -0
  41. multipers/gudhi/gudhi/Fields/Multi_field_small_operators.h +507 -0
  42. multipers/gudhi/gudhi/Fields/Multi_field_small_shared.h +531 -0
  43. multipers/gudhi/gudhi/Fields/Z2_field.h +355 -0
  44. multipers/gudhi/gudhi/Fields/Z2_field_operators.h +376 -0
  45. multipers/gudhi/gudhi/Fields/Zp_field.h +420 -0
  46. multipers/gudhi/gudhi/Fields/Zp_field_operators.h +400 -0
  47. multipers/gudhi/gudhi/Fields/Zp_field_shared.h +418 -0
  48. multipers/gudhi/gudhi/Flag_complex_edge_collapser.h +337 -0
  49. multipers/gudhi/gudhi/Matrix.h +2107 -0
  50. multipers/gudhi/gudhi/Multi_critical_filtration.h +1038 -0
  51. multipers/gudhi/gudhi/Multi_persistence/Box.h +174 -0
  52. multipers/gudhi/gudhi/Multi_persistence/Line.h +282 -0
  53. multipers/gudhi/gudhi/Off_reader.h +173 -0
  54. multipers/gudhi/gudhi/One_critical_filtration.h +1441 -0
  55. multipers/gudhi/gudhi/Persistence_matrix/Base_matrix.h +769 -0
  56. multipers/gudhi/gudhi/Persistence_matrix/Base_matrix_with_column_compression.h +686 -0
  57. multipers/gudhi/gudhi/Persistence_matrix/Boundary_matrix.h +842 -0
  58. multipers/gudhi/gudhi/Persistence_matrix/Chain_matrix.h +1350 -0
  59. multipers/gudhi/gudhi/Persistence_matrix/Id_to_index_overlay.h +1105 -0
  60. multipers/gudhi/gudhi/Persistence_matrix/Position_to_index_overlay.h +859 -0
  61. multipers/gudhi/gudhi/Persistence_matrix/RU_matrix.h +910 -0
  62. multipers/gudhi/gudhi/Persistence_matrix/allocators/entry_constructors.h +139 -0
  63. multipers/gudhi/gudhi/Persistence_matrix/base_pairing.h +230 -0
  64. multipers/gudhi/gudhi/Persistence_matrix/base_swap.h +211 -0
  65. multipers/gudhi/gudhi/Persistence_matrix/boundary_cell_position_to_id_mapper.h +60 -0
  66. multipers/gudhi/gudhi/Persistence_matrix/boundary_face_position_to_id_mapper.h +60 -0
  67. multipers/gudhi/gudhi/Persistence_matrix/chain_pairing.h +136 -0
  68. multipers/gudhi/gudhi/Persistence_matrix/chain_rep_cycles.h +190 -0
  69. multipers/gudhi/gudhi/Persistence_matrix/chain_vine_swap.h +616 -0
  70. multipers/gudhi/gudhi/Persistence_matrix/columns/chain_column_extra_properties.h +150 -0
  71. multipers/gudhi/gudhi/Persistence_matrix/columns/column_dimension_holder.h +106 -0
  72. multipers/gudhi/gudhi/Persistence_matrix/columns/column_utilities.h +219 -0
  73. multipers/gudhi/gudhi/Persistence_matrix/columns/entry_types.h +327 -0
  74. multipers/gudhi/gudhi/Persistence_matrix/columns/heap_column.h +1140 -0
  75. multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_list_column.h +934 -0
  76. multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_set_column.h +934 -0
  77. multipers/gudhi/gudhi/Persistence_matrix/columns/list_column.h +980 -0
  78. multipers/gudhi/gudhi/Persistence_matrix/columns/naive_vector_column.h +1092 -0
  79. multipers/gudhi/gudhi/Persistence_matrix/columns/row_access.h +192 -0
  80. multipers/gudhi/gudhi/Persistence_matrix/columns/set_column.h +921 -0
  81. multipers/gudhi/gudhi/Persistence_matrix/columns/small_vector_column.h +1093 -0
  82. multipers/gudhi/gudhi/Persistence_matrix/columns/unordered_set_column.h +1012 -0
  83. multipers/gudhi/gudhi/Persistence_matrix/columns/vector_column.h +1244 -0
  84. multipers/gudhi/gudhi/Persistence_matrix/matrix_dimension_holders.h +186 -0
  85. multipers/gudhi/gudhi/Persistence_matrix/matrix_row_access.h +164 -0
  86. multipers/gudhi/gudhi/Persistence_matrix/ru_pairing.h +156 -0
  87. multipers/gudhi/gudhi/Persistence_matrix/ru_rep_cycles.h +376 -0
  88. multipers/gudhi/gudhi/Persistence_matrix/ru_vine_swap.h +540 -0
  89. multipers/gudhi/gudhi/Persistent_cohomology/Field_Zp.h +118 -0
  90. multipers/gudhi/gudhi/Persistent_cohomology/Multi_field.h +173 -0
  91. multipers/gudhi/gudhi/Persistent_cohomology/Persistent_cohomology_column.h +128 -0
  92. multipers/gudhi/gudhi/Persistent_cohomology.h +745 -0
  93. multipers/gudhi/gudhi/Points_off_io.h +171 -0
  94. multipers/gudhi/gudhi/Simple_object_pool.h +69 -0
  95. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_iterators.h +463 -0
  96. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +83 -0
  97. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_siblings.h +106 -0
  98. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_star_simplex_iterators.h +277 -0
  99. multipers/gudhi/gudhi/Simplex_tree/hooks_simplex_base.h +62 -0
  100. multipers/gudhi/gudhi/Simplex_tree/indexing_tag.h +27 -0
  101. multipers/gudhi/gudhi/Simplex_tree/serialization_utils.h +62 -0
  102. multipers/gudhi/gudhi/Simplex_tree/simplex_tree_options.h +157 -0
  103. multipers/gudhi/gudhi/Simplex_tree.h +2794 -0
  104. multipers/gudhi/gudhi/Simplex_tree_multi.h +152 -0
  105. multipers/gudhi/gudhi/distance_functions.h +62 -0
  106. multipers/gudhi/gudhi/graph_simplicial_complex.h +104 -0
  107. multipers/gudhi/gudhi/persistence_interval.h +253 -0
  108. multipers/gudhi/gudhi/persistence_matrix_options.h +170 -0
  109. multipers/gudhi/gudhi/reader_utils.h +367 -0
  110. multipers/gudhi/mma_interface_coh.h +256 -0
  111. multipers/gudhi/mma_interface_h0.h +223 -0
  112. multipers/gudhi/mma_interface_matrix.h +293 -0
  113. multipers/gudhi/naive_merge_tree.h +536 -0
  114. multipers/gudhi/scc_io.h +310 -0
  115. multipers/gudhi/truc.h +1403 -0
  116. multipers/io.cpython-313-darwin.so +0 -0
  117. multipers/io.pyx +644 -0
  118. multipers/ml/__init__.py +0 -0
  119. multipers/ml/accuracies.py +90 -0
  120. multipers/ml/invariants_with_persistable.py +79 -0
  121. multipers/ml/kernels.py +176 -0
  122. multipers/ml/mma.py +713 -0
  123. multipers/ml/one.py +472 -0
  124. multipers/ml/point_clouds.py +352 -0
  125. multipers/ml/signed_measures.py +1589 -0
  126. multipers/ml/sliced_wasserstein.py +461 -0
  127. multipers/ml/tools.py +113 -0
  128. multipers/mma_structures.cpython-313-darwin.so +0 -0
  129. multipers/mma_structures.pxd +128 -0
  130. multipers/mma_structures.pyx +2786 -0
  131. multipers/mma_structures.pyx.tp +1094 -0
  132. multipers/multi_parameter_rank_invariant/diff_helpers.h +84 -0
  133. multipers/multi_parameter_rank_invariant/euler_characteristic.h +97 -0
  134. multipers/multi_parameter_rank_invariant/function_rips.h +322 -0
  135. multipers/multi_parameter_rank_invariant/hilbert_function.h +769 -0
  136. multipers/multi_parameter_rank_invariant/persistence_slices.h +148 -0
  137. multipers/multi_parameter_rank_invariant/rank_invariant.h +369 -0
  138. multipers/multiparameter_edge_collapse.py +41 -0
  139. multipers/multiparameter_module_approximation/approximation.h +2330 -0
  140. multipers/multiparameter_module_approximation/combinatory.h +129 -0
  141. multipers/multiparameter_module_approximation/debug.h +107 -0
  142. multipers/multiparameter_module_approximation/euler_curves.h +0 -0
  143. multipers/multiparameter_module_approximation/format_python-cpp.h +286 -0
  144. multipers/multiparameter_module_approximation/heap_column.h +238 -0
  145. multipers/multiparameter_module_approximation/images.h +79 -0
  146. multipers/multiparameter_module_approximation/list_column.h +174 -0
  147. multipers/multiparameter_module_approximation/list_column_2.h +232 -0
  148. multipers/multiparameter_module_approximation/ru_matrix.h +347 -0
  149. multipers/multiparameter_module_approximation/set_column.h +135 -0
  150. multipers/multiparameter_module_approximation/structure_higher_dim_barcode.h +36 -0
  151. multipers/multiparameter_module_approximation/unordered_set_column.h +166 -0
  152. multipers/multiparameter_module_approximation/utilities.h +403 -0
  153. multipers/multiparameter_module_approximation/vector_column.h +223 -0
  154. multipers/multiparameter_module_approximation/vector_matrix.h +331 -0
  155. multipers/multiparameter_module_approximation/vineyards.h +464 -0
  156. multipers/multiparameter_module_approximation/vineyards_trajectories.h +649 -0
  157. multipers/multiparameter_module_approximation.cpython-313-darwin.so +0 -0
  158. multipers/multiparameter_module_approximation.pyx +235 -0
  159. multipers/pickle.py +90 -0
  160. multipers/plots.py +456 -0
  161. multipers/point_measure.cpython-313-darwin.so +0 -0
  162. multipers/point_measure.pyx +395 -0
  163. multipers/simplex_tree_multi.cpython-313-darwin.so +0 -0
  164. multipers/simplex_tree_multi.pxd +134 -0
  165. multipers/simplex_tree_multi.pyx +10840 -0
  166. multipers/simplex_tree_multi.pyx.tp +2009 -0
  167. multipers/slicer.cpython-313-darwin.so +0 -0
  168. multipers/slicer.pxd +3034 -0
  169. multipers/slicer.pxd.tp +234 -0
  170. multipers/slicer.pyx +20481 -0
  171. multipers/slicer.pyx.tp +1088 -0
  172. multipers/tensor/tensor.h +672 -0
  173. multipers/tensor.pxd +13 -0
  174. multipers/test.pyx +44 -0
  175. multipers/tests/__init__.py +62 -0
  176. multipers/torch/__init__.py +1 -0
  177. multipers/torch/diff_grids.py +240 -0
  178. multipers/torch/rips_density.py +310 -0
  179. multipers-2.3.3b6.dist-info/METADATA +128 -0
  180. multipers-2.3.3b6.dist-info/RECORD +183 -0
  181. multipers-2.3.3b6.dist-info/WHEEL +6 -0
  182. multipers-2.3.3b6.dist-info/licenses/LICENSE +21 -0
  183. multipers-2.3.3b6.dist-info/top_level.txt +1 -0
@@ -0,0 +1,347 @@
1
+ /* This file is part of the MMA Library -
2
+ * https://gitlab.inria.fr/dloiseau/multipers - which is released under MIT. See
3
+ * file LICENSE for full license details. Author(s): Hannah Schreiber
4
+ *
5
+ * Copyright (C) 2022 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ #ifndef RU_MATRIX_H
12
+ #define RU_MATRIX_H
13
+
14
+ #include <vector>
15
+
16
+ #include "utilities.h" //type definitions
17
+ #include "vector_matrix.h"
18
+
19
+ namespace Gudhi::multiparameter::mma {
20
+
21
+ template <class Column_type> class RU_matrix {
22
+ public:
23
+ RU_matrix();
24
+ RU_matrix(boundary_matrix &orderedBoundaries);
25
+ RU_matrix(int numberOfColumns);
26
+ RU_matrix(RU_matrix &matrixToCopy);
27
+ RU_matrix(RU_matrix &&other) noexcept;
28
+
29
+ void insert_boundary(index columnIndex, boundary_type &boundary);
30
+ dimension_type get_dimension(index index);
31
+ unsigned int get_number_of_simplices();
32
+
33
+ void initialize();
34
+ void vine_swap(index index);
35
+ const barcode_type &get_current_barcode();
36
+
37
+ void print_matrices(); // for debug
38
+
39
+ RU_matrix<Column_type> &operator=(RU_matrix<Column_type> other);
40
+ template <class Friend_column_type>
41
+ friend void swap(RU_matrix<Column_type> &matrix1,
42
+ RU_matrix<Friend_column_type> &matrix2);
43
+
44
+ private:
45
+ Vector_matrix<Column_type> reducedMatrixR_;
46
+ Vector_matrix<Column_type> mirrorMatrixU_;
47
+ barcode_type barcode_;
48
+ std::vector<int> indexToBar_;
49
+
50
+ void _initialize_U();
51
+ void _swap_at_index(index index);
52
+ void _add_to(index sourceIndex, index targetIndex);
53
+ void _positive_vine_swap(index index);
54
+ void _negative_vine_swap(index index);
55
+ void _positive_negative_vine_swap(index index);
56
+ void _negative_positive_vine_swap(index index);
57
+ };
58
+
59
+ template <class Column_type> inline RU_matrix<Column_type>::RU_matrix() {}
60
+
61
+ template <class Column_type>
62
+ inline RU_matrix<Column_type>::RU_matrix(boundary_matrix &orderedBoundaries)
63
+ : reducedMatrixR_(orderedBoundaries),
64
+ mirrorMatrixU_(orderedBoundaries.size()) {
65
+ _initialize_U();
66
+ }
67
+
68
+ template <class Column_type>
69
+ inline RU_matrix<Column_type>::RU_matrix(int numberOfColumns)
70
+ : reducedMatrixR_(numberOfColumns), mirrorMatrixU_(numberOfColumns) {
71
+ _initialize_U();
72
+ }
73
+
74
+ template <class Column_type>
75
+ inline RU_matrix<Column_type>::RU_matrix(RU_matrix &matrixToCopy)
76
+ : reducedMatrixR_(matrixToCopy.reducedMatrixR_),
77
+ mirrorMatrixU_(matrixToCopy.mirrorMatrixU_),
78
+ barcode_(matrixToCopy.barcode_), indexToBar_(matrixToCopy.indexToBar_) {}
79
+
80
+ template <class Column_type>
81
+ inline RU_matrix<Column_type>::RU_matrix(
82
+ RU_matrix<Column_type> &&other) noexcept
83
+ : reducedMatrixR_(std::move(other.reducedMatrixR_)),
84
+ mirrorMatrixU_(std::move(other.mirrorMatrixU_)),
85
+ barcode_(std::move(other.barcode_)),
86
+ indexToBar_(std::move(other.indexToBar_)) {}
87
+
88
+ template <class Column_type>
89
+ inline void RU_matrix<Column_type>::insert_boundary(index columnIndex,
90
+ boundary_type &boundary) {
91
+ reducedMatrixR_.insert_boundary(columnIndex, boundary);
92
+ boundary_type id(1, columnIndex);
93
+ mirrorMatrixU_.insert_column(columnIndex, Column_type(id));
94
+ }
95
+
96
+ template <class Column_type>
97
+ inline dimension_type RU_matrix<Column_type>::get_dimension(index index) {
98
+ return reducedMatrixR_.get_column_dimension(index);
99
+ }
100
+
101
+ template <class Column_type>
102
+ inline unsigned int RU_matrix<Column_type>::get_number_of_simplices() {
103
+ return reducedMatrixR_.get_number_of_columns();
104
+ }
105
+
106
+ template <class Column_type> inline void RU_matrix<Column_type>::initialize() {
107
+ std::unordered_map<index, index> pivotsToColumn;
108
+ indexToBar_.resize(reducedMatrixR_.get_number_of_columns(), -1);
109
+
110
+ for (unsigned int i = 0; i < reducedMatrixR_.get_number_of_columns(); i++) {
111
+ if (!(reducedMatrixR_.is_zero_column(i))) {
112
+ Column_type &curr = reducedMatrixR_.get_column(i);
113
+ int pivot = curr.get_pivot();
114
+
115
+ while (pivot != -1 &&
116
+ pivotsToColumn.find(pivot) != pivotsToColumn.end()) {
117
+ curr.add(reducedMatrixR_.get_column(pivotsToColumn.at(pivot)));
118
+ mirrorMatrixU_.get_column(pivotsToColumn.at(pivot))
119
+ .add(mirrorMatrixU_.get_column(i));
120
+ pivot = curr.get_pivot();
121
+ }
122
+
123
+ if (pivot != -1) {
124
+ pivotsToColumn.emplace(pivot, i);
125
+ barcode_.at(indexToBar_.at(pivot)).death = i;
126
+ indexToBar_.at(i) = indexToBar_.at(pivot);
127
+ } else {
128
+ barcode_.push_back(Bar(get_dimension(i), i, -1));
129
+ indexToBar_.at(i) = barcode_.size() - 1;
130
+ }
131
+ } else {
132
+ barcode_.push_back(Bar(get_dimension(i), i, -1));
133
+ indexToBar_.at(i) = barcode_.size() - 1;
134
+ }
135
+ }
136
+ }
137
+
138
+ template <class Column_type>
139
+ inline void RU_matrix<Column_type>::vine_swap(index index) {
140
+ if (index >= reducedMatrixR_.get_number_of_columns() - 1)
141
+ return;
142
+
143
+ bool iIsPositive =
144
+ (barcode_.at(indexToBar_.at(index)).birth == static_cast<int>(index));
145
+ bool iiIsPositive = (barcode_.at(indexToBar_.at(index + 1)).birth ==
146
+ static_cast<int>(index) + 1);
147
+
148
+ if (iIsPositive && iiIsPositive)
149
+ _positive_vine_swap(index);
150
+ else if (!iIsPositive && !iiIsPositive)
151
+ _negative_vine_swap(index);
152
+ else if (iIsPositive && !iiIsPositive)
153
+ _positive_negative_vine_swap(index);
154
+ else
155
+ _negative_positive_vine_swap(index);
156
+ }
157
+
158
+ template <class Column_type>
159
+ inline const barcode_type &RU_matrix<Column_type>::get_current_barcode() {
160
+ return barcode_;
161
+ }
162
+
163
+ template <class Column_type>
164
+ inline void RU_matrix<Column_type>::print_matrices() {
165
+ boundary_type b;
166
+
167
+ std::cout << "R:\n";
168
+ for (unsigned int i = 0; i < reducedMatrixR_.get_number_of_columns(); i++) {
169
+ reducedMatrixR_.get_boundary(i, b);
170
+ if (b.empty()) {
171
+ std::cout << "-\n";
172
+ } else {
173
+ for (unsigned int i : b)
174
+ std::cout << i << " ";
175
+ std::cout << "\n";
176
+ b.clear();
177
+ }
178
+ }
179
+ std::cout << "\n";
180
+
181
+ std::cout << "U:\n";
182
+ for (unsigned int i = 0; i < mirrorMatrixU_.get_number_of_columns(); i++) {
183
+ mirrorMatrixU_.get_boundary(i, b);
184
+ if (b.empty()) {
185
+ std::cout << "-\n";
186
+ } else {
187
+ for (unsigned int i : b)
188
+ std::cout << i << " ";
189
+ std::cout << "\n";
190
+ b.clear();
191
+ }
192
+ }
193
+ std::cout << "\n";
194
+ }
195
+
196
+ template <class Column_type>
197
+ inline RU_matrix<Column_type> &
198
+ RU_matrix<Column_type>::operator=(RU_matrix<Column_type> other) {
199
+ std::swap(reducedMatrixR_, other.reducedMatrixR_);
200
+ std::swap(mirrorMatrixU_, other.mirrorMatrixU_);
201
+ std::swap(barcode_, other.barcode_);
202
+ std::swap(indexToBar_, other.indexToBar_);
203
+ return *this;
204
+ }
205
+
206
+ template <class Column_type>
207
+ inline void RU_matrix<Column_type>::_initialize_U() {
208
+ boundary_type id(1);
209
+ for (unsigned int i = 0; i < reducedMatrixR_.get_number_of_columns(); i++) {
210
+ id.at(0) = i;
211
+ mirrorMatrixU_.insert_column(i, Column_type(id));
212
+ }
213
+ }
214
+
215
+ template <class Column_type>
216
+ inline void RU_matrix<Column_type>::_swap_at_index(index index) {
217
+ reducedMatrixR_.swap_at_indices(index, index + 1);
218
+ mirrorMatrixU_.swap_at_indices(index, index + 1);
219
+ }
220
+
221
+ template <class Column_type>
222
+ inline void RU_matrix<Column_type>::_add_to(index sourceIndex,
223
+ index targetIndex) {
224
+ reducedMatrixR_.add_to(sourceIndex, targetIndex);
225
+ mirrorMatrixU_.add_to(targetIndex, sourceIndex);
226
+ }
227
+
228
+ template <class Column_type>
229
+ inline void RU_matrix<Column_type>::_positive_vine_swap(index index) {
230
+ int iDeath = barcode_.at(indexToBar_.at(index)).death;
231
+ int iiDeath = barcode_.at(indexToBar_.at(index + 1)).death;
232
+
233
+ if (get_dimension(index) == get_dimension(index + 1)) {
234
+ if (!mirrorMatrixU_.is_zero_cell(index, index + 1))
235
+ mirrorMatrixU_.zero_cell(index, index + 1);
236
+
237
+ if (iDeath != -1 && iiDeath != -1 &&
238
+ !(reducedMatrixR_.is_zero_cell(iiDeath, index))) {
239
+ if (iDeath < iiDeath) {
240
+ _swap_at_index(index);
241
+ _add_to(iDeath, iiDeath);
242
+
243
+ barcode_.at(indexToBar_.at(index)).birth = index + 1;
244
+ barcode_.at(indexToBar_.at(index + 1)).birth = index;
245
+ std::swap(indexToBar_.at(index), indexToBar_.at(index + 1));
246
+
247
+ return;
248
+ }
249
+
250
+ if (iiDeath < iDeath) {
251
+ _swap_at_index(index);
252
+ _add_to(iiDeath, iDeath);
253
+
254
+ return;
255
+ }
256
+ }
257
+
258
+ _swap_at_index(index);
259
+
260
+ if (iDeath != -1 || iiDeath == -1 ||
261
+ reducedMatrixR_.is_zero_cell(iiDeath, index + 1)) {
262
+ barcode_.at(indexToBar_.at(index)).birth = index + 1;
263
+ barcode_.at(indexToBar_.at(index + 1)).birth = index;
264
+ std::swap(indexToBar_.at(index), indexToBar_.at(index + 1));
265
+ }
266
+
267
+ return;
268
+ }
269
+
270
+ _swap_at_index(index);
271
+
272
+ barcode_.at(indexToBar_.at(index)).birth = index + 1;
273
+ barcode_.at(indexToBar_.at(index + 1)).birth = index;
274
+ std::swap(indexToBar_.at(index), indexToBar_.at(index + 1));
275
+ }
276
+
277
+ template <class Column_type>
278
+ inline void RU_matrix<Column_type>::_negative_vine_swap(index index) {
279
+ if (get_dimension(index) == get_dimension(index + 1) &&
280
+ !mirrorMatrixU_.is_zero_cell(index, index + 1)) {
281
+ _add_to(index, index + 1);
282
+ _swap_at_index(index);
283
+
284
+ if (barcode_.at(indexToBar_.at(index)).birth <
285
+ barcode_.at(indexToBar_.at(index + 1)).birth) {
286
+ barcode_.at(indexToBar_.at(index)).death = index + 1;
287
+ barcode_.at(indexToBar_.at(index + 1)).death = index;
288
+ std::swap(indexToBar_.at(index), indexToBar_.at(index + 1));
289
+
290
+ return;
291
+ }
292
+
293
+ _add_to(index, index + 1);
294
+
295
+ return;
296
+ }
297
+
298
+ _swap_at_index(index);
299
+
300
+ barcode_.at(indexToBar_.at(index)).death = index + 1;
301
+ barcode_.at(indexToBar_.at(index + 1)).death = index;
302
+ std::swap(indexToBar_.at(index), indexToBar_.at(index + 1));
303
+ }
304
+
305
+ template <class Column_type>
306
+ inline void RU_matrix<Column_type>::_positive_negative_vine_swap(index index) {
307
+ if (get_dimension(index) == get_dimension(index + 1) &&
308
+ !mirrorMatrixU_.is_zero_cell(index, index + 1))
309
+ mirrorMatrixU_.zero_cell(index, index + 1);
310
+
311
+ _swap_at_index(index);
312
+
313
+ barcode_.at(indexToBar_.at(index)).birth = index + 1;
314
+ barcode_.at(indexToBar_.at(index + 1)).death = index;
315
+ std::swap(indexToBar_.at(index), indexToBar_.at(index + 1));
316
+ }
317
+
318
+ template <class Column_type>
319
+ inline void RU_matrix<Column_type>::_negative_positive_vine_swap(index index) {
320
+ if (get_dimension(index) == get_dimension(index + 1) &&
321
+ !mirrorMatrixU_.is_zero_cell(index, index + 1)) {
322
+ _add_to(index, index + 1);
323
+ _swap_at_index(index);
324
+ _add_to(index, index + 1);
325
+
326
+ return;
327
+ }
328
+
329
+ _swap_at_index(index);
330
+
331
+ barcode_.at(indexToBar_.at(index)).death = index + 1;
332
+ barcode_.at(indexToBar_.at(index + 1)).birth = index;
333
+ std::swap(indexToBar_.at(index), indexToBar_.at(index + 1));
334
+ }
335
+
336
+ template <class Column_type>
337
+ inline void swap(RU_matrix<Column_type> &matrix1,
338
+ RU_matrix<Column_type> &matrix2) {
339
+ std::swap(matrix1.reducedMatrixR_, matrix2.reducedMatrixR_);
340
+ std::swap(matrix1.mirrorMatrixU_, matrix2.mirrorMatrixU_);
341
+ matrix1.barcode_.swap(matrix2.barcode_);
342
+ matrix1.indexToBar_.swap(matrix2.indexToBar_);
343
+ }
344
+
345
+ } // namespace Gudhi::multiparameter::mma
346
+
347
+ #endif // RU_MATRIX_H
@@ -0,0 +1,135 @@
1
+ /* This file is part of the MMA Library - https://gitlab.inria.fr/dloiseau/multipers - which is released under MIT.
2
+ * See file LICENSE for full license details.
3
+ * Author(s): Hannah Schreiber
4
+ *
5
+ * Copyright (C) 2022 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ #ifndef SETCOLUMN_H
12
+ #define SETCOLUMN_H
13
+
14
+ #include <iostream>
15
+ #include <list>
16
+ #include <set>
17
+
18
+ #include "utilities.h"
19
+
20
+ namespace Gudhi::multiparameter::mma {
21
+
22
+ class Set_column
23
+ {
24
+ public:
25
+ Set_column();
26
+ Set_column(boundary_type& boundary);
27
+ Set_column(Set_column& column);
28
+ Set_column(Set_column&& column) noexcept;
29
+
30
+ void get_content(boundary_type& container);
31
+ bool contains(unsigned int value) const;
32
+ bool is_empty();
33
+ dimension_type get_dimension() const;
34
+ int get_pivot();
35
+ void clear();
36
+ void clear(unsigned int value);
37
+ void reorder(std::vector<index>& valueMap);
38
+ void add(Set_column& column);
39
+
40
+ Set_column& operator=(Set_column other);
41
+
42
+ friend void swap(Set_column& col1, Set_column& col2);
43
+
44
+ private:
45
+ int dim_;
46
+ std::set<unsigned int> column_;
47
+ };
48
+
49
+ inline Set_column::Set_column() : dim_(0)
50
+ {}
51
+
52
+ inline Set_column::Set_column(boundary_type &boundary)
53
+ : dim_(boundary.size() == 0 ? 0 : boundary.size() - 1),
54
+ column_(boundary.begin(), boundary.end())
55
+ {}
56
+
57
+ inline Set_column::Set_column(Set_column &column)
58
+ : dim_(column.dim_),
59
+ column_(column.column_)
60
+ {}
61
+
62
+ inline Set_column::Set_column(Set_column &&column) noexcept
63
+ : dim_(std::exchange(column.dim_, 0)),
64
+ column_(std::move(column.column_))
65
+ {}
66
+
67
+ inline void Set_column::get_content(boundary_type &container)
68
+ {
69
+ std::copy(column_.begin(), column_.end(), std::back_inserter(container));
70
+ }
71
+
72
+ inline bool Set_column::contains(unsigned int value) const
73
+ {
74
+ return column_.find(value) != column_.end();
75
+ }
76
+
77
+ inline bool Set_column::is_empty()
78
+ {
79
+ return column_.empty();
80
+ }
81
+
82
+ inline dimension_type Set_column::get_dimension() const
83
+ {
84
+ return dim_;
85
+ }
86
+
87
+ inline int Set_column::get_pivot()
88
+ {
89
+ if (column_.empty()) return -1;
90
+ return *(column_.rbegin());
91
+ }
92
+
93
+ inline void Set_column::clear()
94
+ {
95
+ column_.clear();
96
+ }
97
+
98
+ inline void Set_column::clear(unsigned int value)
99
+ {
100
+ column_.erase(value);
101
+ }
102
+
103
+ inline void Set_column::reorder(std::vector<index> &valueMap)
104
+ {
105
+ std::set<unsigned int> newSet;
106
+ for (const unsigned int& v : column_) newSet.insert(valueMap.at(v));
107
+ column_.swap(newSet);
108
+ }
109
+
110
+ inline void Set_column::add(Set_column &column)
111
+ {
112
+ for (const unsigned int& v : column.column_){
113
+ if (column_.find(v) != column_.end())
114
+ column_.erase(v);
115
+ else
116
+ column_.insert(v);
117
+ }
118
+ }
119
+
120
+ inline Set_column &Set_column::operator=(Set_column other)
121
+ {
122
+ std::swap(dim_, other.dim_);
123
+ std::swap(column_, other.column_);
124
+ return *this;
125
+ }
126
+
127
+ inline void swap(Set_column& col1, Set_column& col2)
128
+ {
129
+ std::swap(col1.dim_, col2.dim_);
130
+ col1.column_.swap(col2.column_);
131
+ }
132
+
133
+ } //namespace Vineyard
134
+
135
+ #endif // SETCOLUMN_H
@@ -0,0 +1,36 @@
1
+ /* This file is part of the MMA Library - https://gitlab.inria.fr/dloiseau/multipers - which is released under MIT.
2
+ * See file LICENSE for full license details.
3
+ * Author(s): David Loiseaux
4
+ *
5
+ * Copyright (C) 2021 Inria
6
+ *
7
+ * Modification(s):
8
+ * - 2022/03 Hannah Schreiber: Integration of the new Vineyard_persistence class, renaming and cleanup.
9
+ */
10
+ /**
11
+ * @file structure_higher_dim_barcode.h
12
+ * @author David Loiseaux, Hannah Schreiber
13
+ * @brief Structures to handle higher dimensional persistence.
14
+ */
15
+
16
+ #ifndef STRUCTURE_HIGHER_DIM_BARCODE_H_INCLUDED
17
+ #define STRUCTURE_HIGHER_DIM_BARCODE_H_INCLUDED
18
+
19
+ #include <vector>
20
+
21
+ unsigned int get_index_from_position_and_size(
22
+ const std::vector<unsigned int> &position,
23
+ const std::vector<unsigned int> &size)
24
+ {
25
+ unsigned int indice = 0;
26
+ assert(position.size() == size.size() &&
27
+ "Position and Size vector must be of the same size !");
28
+ unsigned int last_product = 1;
29
+ for (unsigned int i = 0; i < position.size(); i++){
30
+ indice += last_product * position[i];
31
+ last_product *= size[i];
32
+ }
33
+ return indice;
34
+ }
35
+
36
+ #endif // STRUCTURE_HIGHER_DIM_BARCODE_H_INCLUDED
@@ -0,0 +1,166 @@
1
+ /* This file is part of the MMA Library - https://gitlab.inria.fr/dloiseau/multipers - which is released under MIT.
2
+ * See file LICENSE for full license details.
3
+ * Author(s): Hannah Schreiber
4
+ *
5
+ * Copyright (C) 2022 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ #ifndef UNORDEREDSETCOLUMN_H
12
+ #define UNORDEREDSETCOLUMN_H
13
+
14
+ #include <iostream>
15
+ #include <list>
16
+ #include <unordered_set>
17
+ #include <algorithm>
18
+
19
+ #include "utilities.h"
20
+
21
+ namespace Vineyard {
22
+
23
+ class Unordered_set_column
24
+ {
25
+ public:
26
+ Unordered_set_column();
27
+ Unordered_set_column(boundary_type& boundary);
28
+ Unordered_set_column(Unordered_set_column& column);
29
+ Unordered_set_column(Unordered_set_column&& column) noexcept;
30
+
31
+ void get_content(boundary_type& container);
32
+ bool contains(unsigned int value) const;
33
+ bool is_empty();
34
+ dimension_type get_dimension() const;
35
+ int get_pivot();
36
+ void clear();
37
+ void clear(unsigned int value);
38
+ void reorder(std::vector<index>& valueMap);
39
+ void add(Unordered_set_column& column);
40
+
41
+ Unordered_set_column& operator=(Unordered_set_column other);
42
+
43
+ friend void swap(Unordered_set_column& col1, Unordered_set_column& col2);
44
+
45
+ private:
46
+ int dim_;
47
+ std::unordered_set<unsigned int> column_;
48
+ bool pivotChanged_;
49
+ int pivot_;
50
+ };
51
+
52
+ inline Unordered_set_column::Unordered_set_column()
53
+ : dim_(0), pivotChanged_(false), pivot_(-1)
54
+ {}
55
+
56
+ inline Unordered_set_column::Unordered_set_column(boundary_type &boundary)
57
+ : dim_(boundary.size() == 0 ? 0 : boundary.size() - 1),
58
+ column_(boundary.begin(), boundary.end()),
59
+ pivotChanged_(false),
60
+ pivot_(boundary.size() == 0 ? -1 : *std::max_element(boundary.begin(), boundary.end()))
61
+ {}
62
+
63
+ inline Unordered_set_column::Unordered_set_column(Unordered_set_column &column)
64
+ : dim_(column.dim_),
65
+ column_(column.column_),
66
+ pivotChanged_(column.pivotChanged_),
67
+ pivot_(column.pivot_)
68
+ {}
69
+
70
+ inline Unordered_set_column::Unordered_set_column(Unordered_set_column &&column) noexcept
71
+ : dim_(std::exchange(column.dim_, 0)),
72
+ column_(std::move(column.column_)),
73
+ pivotChanged_(std::exchange(column.pivotChanged_, 0)),
74
+ pivot_(std::exchange(column.pivot_, 0))
75
+ {}
76
+
77
+ inline void Unordered_set_column::get_content(boundary_type &container)
78
+ {
79
+ std::copy(column_.begin(), column_.end(), std::back_inserter(container));
80
+ std::sort(container.begin(), container.end());
81
+ }
82
+
83
+ inline bool Unordered_set_column::contains(unsigned int value) const
84
+ {
85
+ return column_.find(value) != column_.end();
86
+ }
87
+
88
+ inline bool Unordered_set_column::is_empty()
89
+ {
90
+ return column_.empty();
91
+ }
92
+
93
+ inline dimension_type Unordered_set_column::get_dimension() const
94
+ {
95
+ return dim_;
96
+ }
97
+
98
+ inline int Unordered_set_column::get_pivot()
99
+ {
100
+ if (pivotChanged_){
101
+ pivot_ = column_.size() == 0 ?
102
+ -1
103
+ : *std::max_element(column_.begin(), column_.end());
104
+ pivotChanged_ = false;
105
+ }
106
+
107
+ return pivot_;
108
+ }
109
+
110
+ inline void Unordered_set_column::clear()
111
+ {
112
+ column_.clear();
113
+ pivot_ = -1;
114
+ pivotChanged_ = false;
115
+ }
116
+
117
+ inline void Unordered_set_column::clear(unsigned int value)
118
+ {
119
+ column_.erase(value);
120
+ if (static_cast<int>(value) == pivot_) pivotChanged_ = true;
121
+ }
122
+
123
+ inline void Unordered_set_column::reorder(std::vector<index> &valueMap)
124
+ {
125
+ std::unordered_set<unsigned int> newSet;
126
+ for (const unsigned int& v : column_) newSet.insert(valueMap.at(v));
127
+ column_.swap(newSet);
128
+ pivotChanged_ = true;
129
+ }
130
+
131
+ inline void Unordered_set_column::add(Unordered_set_column &column)
132
+ {
133
+ for (const unsigned int& v : column.column_){
134
+ if (column_.find(v) != column_.end()){
135
+ column_.erase(v);
136
+ if (static_cast<int>(v) == pivot_) pivotChanged_ = true;
137
+ } else {
138
+ column_.insert(v);
139
+ if (static_cast<int>(v) > pivot_){
140
+ pivot_ = v;
141
+ pivotChanged_ = false;
142
+ }
143
+ }
144
+ }
145
+ }
146
+
147
+ inline Unordered_set_column &Unordered_set_column::operator=(Unordered_set_column other)
148
+ {
149
+ std::swap(dim_, other.dim_);
150
+ std::swap(column_, other.column_);
151
+ std::swap(pivotChanged_, other.pivotChanged_);
152
+ std::swap(pivot_, other.pivot_);
153
+ return *this;
154
+ }
155
+
156
+ inline void swap(Unordered_set_column& col1, Unordered_set_column& col2)
157
+ {
158
+ std::swap(col1.dim_, col2.dim_);
159
+ col1.column_.swap(col2.column_);
160
+ std::swap(col1.pivotChanged_, col2.pivotChanged_);
161
+ std::swap(col1.pivot_, col2.pivot_);
162
+ }
163
+
164
+ } //namespace Vineyard
165
+
166
+ #endif // UNORDEREDSETCOLUMN_H