multipers 2.3.3b6__cp313-cp313-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.
Potentially problematic release.
This version of multipers might be problematic. Click here for more details.
- multipers/.dylibs/libc++.1.0.dylib +0 -0
- multipers/.dylibs/libtbb.12.16.dylib +0 -0
- multipers/__init__.py +33 -0
- multipers/_signed_measure_meta.py +453 -0
- multipers/_slicer_meta.py +211 -0
- multipers/array_api/__init__.py +45 -0
- multipers/array_api/numpy.py +41 -0
- multipers/array_api/torch.py +58 -0
- multipers/data/MOL2.py +458 -0
- multipers/data/UCR.py +18 -0
- multipers/data/__init__.py +1 -0
- multipers/data/graphs.py +466 -0
- multipers/data/immuno_regions.py +27 -0
- multipers/data/minimal_presentation_to_st_bf.py +0 -0
- multipers/data/pytorch2simplextree.py +91 -0
- multipers/data/shape3d.py +101 -0
- multipers/data/synthetic.py +113 -0
- multipers/distances.py +202 -0
- multipers/filtration_conversions.pxd +229 -0
- multipers/filtration_conversions.pxd.tp +84 -0
- multipers/filtrations/__init__.py +18 -0
- multipers/filtrations/density.py +574 -0
- multipers/filtrations/filtrations.py +361 -0
- multipers/filtrations.pxd +224 -0
- multipers/function_rips.cpython-313-darwin.so +0 -0
- multipers/function_rips.pyx +105 -0
- multipers/grids.cpython-313-darwin.so +0 -0
- multipers/grids.pyx +433 -0
- multipers/gudhi/Persistence_slices_interface.h +132 -0
- multipers/gudhi/Simplex_tree_interface.h +239 -0
- multipers/gudhi/Simplex_tree_multi_interface.h +551 -0
- multipers/gudhi/cubical_to_boundary.h +59 -0
- multipers/gudhi/gudhi/Bitmap_cubical_complex.h +450 -0
- multipers/gudhi/gudhi/Bitmap_cubical_complex_base.h +1070 -0
- multipers/gudhi/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h +579 -0
- multipers/gudhi/gudhi/Debug_utils.h +45 -0
- multipers/gudhi/gudhi/Fields/Multi_field.h +484 -0
- multipers/gudhi/gudhi/Fields/Multi_field_operators.h +455 -0
- multipers/gudhi/gudhi/Fields/Multi_field_shared.h +450 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small.h +531 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small_operators.h +507 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small_shared.h +531 -0
- multipers/gudhi/gudhi/Fields/Z2_field.h +355 -0
- multipers/gudhi/gudhi/Fields/Z2_field_operators.h +376 -0
- multipers/gudhi/gudhi/Fields/Zp_field.h +420 -0
- multipers/gudhi/gudhi/Fields/Zp_field_operators.h +400 -0
- multipers/gudhi/gudhi/Fields/Zp_field_shared.h +418 -0
- multipers/gudhi/gudhi/Flag_complex_edge_collapser.h +337 -0
- multipers/gudhi/gudhi/Matrix.h +2107 -0
- multipers/gudhi/gudhi/Multi_critical_filtration.h +1038 -0
- multipers/gudhi/gudhi/Multi_persistence/Box.h +174 -0
- multipers/gudhi/gudhi/Multi_persistence/Line.h +282 -0
- multipers/gudhi/gudhi/Off_reader.h +173 -0
- multipers/gudhi/gudhi/One_critical_filtration.h +1441 -0
- multipers/gudhi/gudhi/Persistence_matrix/Base_matrix.h +769 -0
- multipers/gudhi/gudhi/Persistence_matrix/Base_matrix_with_column_compression.h +686 -0
- multipers/gudhi/gudhi/Persistence_matrix/Boundary_matrix.h +842 -0
- multipers/gudhi/gudhi/Persistence_matrix/Chain_matrix.h +1350 -0
- multipers/gudhi/gudhi/Persistence_matrix/Id_to_index_overlay.h +1105 -0
- multipers/gudhi/gudhi/Persistence_matrix/Position_to_index_overlay.h +859 -0
- multipers/gudhi/gudhi/Persistence_matrix/RU_matrix.h +910 -0
- multipers/gudhi/gudhi/Persistence_matrix/allocators/entry_constructors.h +139 -0
- multipers/gudhi/gudhi/Persistence_matrix/base_pairing.h +230 -0
- multipers/gudhi/gudhi/Persistence_matrix/base_swap.h +211 -0
- multipers/gudhi/gudhi/Persistence_matrix/boundary_cell_position_to_id_mapper.h +60 -0
- multipers/gudhi/gudhi/Persistence_matrix/boundary_face_position_to_id_mapper.h +60 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_pairing.h +136 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_rep_cycles.h +190 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_vine_swap.h +616 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/chain_column_extra_properties.h +150 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/column_dimension_holder.h +106 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/column_utilities.h +219 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/entry_types.h +327 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/heap_column.h +1140 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_list_column.h +934 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_set_column.h +934 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/list_column.h +980 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/naive_vector_column.h +1092 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/row_access.h +192 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/set_column.h +921 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/small_vector_column.h +1093 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/unordered_set_column.h +1012 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/vector_column.h +1244 -0
- multipers/gudhi/gudhi/Persistence_matrix/matrix_dimension_holders.h +186 -0
- multipers/gudhi/gudhi/Persistence_matrix/matrix_row_access.h +164 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_pairing.h +156 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_rep_cycles.h +376 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_vine_swap.h +540 -0
- multipers/gudhi/gudhi/Persistent_cohomology/Field_Zp.h +118 -0
- multipers/gudhi/gudhi/Persistent_cohomology/Multi_field.h +173 -0
- multipers/gudhi/gudhi/Persistent_cohomology/Persistent_cohomology_column.h +128 -0
- multipers/gudhi/gudhi/Persistent_cohomology.h +745 -0
- multipers/gudhi/gudhi/Points_off_io.h +171 -0
- multipers/gudhi/gudhi/Simple_object_pool.h +69 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_iterators.h +463 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +83 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_siblings.h +106 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_star_simplex_iterators.h +277 -0
- multipers/gudhi/gudhi/Simplex_tree/hooks_simplex_base.h +62 -0
- multipers/gudhi/gudhi/Simplex_tree/indexing_tag.h +27 -0
- multipers/gudhi/gudhi/Simplex_tree/serialization_utils.h +62 -0
- multipers/gudhi/gudhi/Simplex_tree/simplex_tree_options.h +157 -0
- multipers/gudhi/gudhi/Simplex_tree.h +2794 -0
- multipers/gudhi/gudhi/Simplex_tree_multi.h +152 -0
- multipers/gudhi/gudhi/distance_functions.h +62 -0
- multipers/gudhi/gudhi/graph_simplicial_complex.h +104 -0
- multipers/gudhi/gudhi/persistence_interval.h +253 -0
- multipers/gudhi/gudhi/persistence_matrix_options.h +170 -0
- multipers/gudhi/gudhi/reader_utils.h +367 -0
- multipers/gudhi/mma_interface_coh.h +256 -0
- multipers/gudhi/mma_interface_h0.h +223 -0
- multipers/gudhi/mma_interface_matrix.h +293 -0
- multipers/gudhi/naive_merge_tree.h +536 -0
- multipers/gudhi/scc_io.h +310 -0
- multipers/gudhi/truc.h +1403 -0
- multipers/io.cpython-313-darwin.so +0 -0
- multipers/io.pyx +644 -0
- multipers/ml/__init__.py +0 -0
- multipers/ml/accuracies.py +90 -0
- multipers/ml/invariants_with_persistable.py +79 -0
- multipers/ml/kernels.py +176 -0
- multipers/ml/mma.py +713 -0
- multipers/ml/one.py +472 -0
- multipers/ml/point_clouds.py +352 -0
- multipers/ml/signed_measures.py +1589 -0
- multipers/ml/sliced_wasserstein.py +461 -0
- multipers/ml/tools.py +113 -0
- multipers/mma_structures.cpython-313-darwin.so +0 -0
- multipers/mma_structures.pxd +128 -0
- multipers/mma_structures.pyx +2786 -0
- multipers/mma_structures.pyx.tp +1094 -0
- multipers/multi_parameter_rank_invariant/diff_helpers.h +84 -0
- multipers/multi_parameter_rank_invariant/euler_characteristic.h +97 -0
- multipers/multi_parameter_rank_invariant/function_rips.h +322 -0
- multipers/multi_parameter_rank_invariant/hilbert_function.h +769 -0
- multipers/multi_parameter_rank_invariant/persistence_slices.h +148 -0
- multipers/multi_parameter_rank_invariant/rank_invariant.h +369 -0
- multipers/multiparameter_edge_collapse.py +41 -0
- multipers/multiparameter_module_approximation/approximation.h +2330 -0
- multipers/multiparameter_module_approximation/combinatory.h +129 -0
- multipers/multiparameter_module_approximation/debug.h +107 -0
- multipers/multiparameter_module_approximation/euler_curves.h +0 -0
- multipers/multiparameter_module_approximation/format_python-cpp.h +286 -0
- multipers/multiparameter_module_approximation/heap_column.h +238 -0
- multipers/multiparameter_module_approximation/images.h +79 -0
- multipers/multiparameter_module_approximation/list_column.h +174 -0
- multipers/multiparameter_module_approximation/list_column_2.h +232 -0
- multipers/multiparameter_module_approximation/ru_matrix.h +347 -0
- multipers/multiparameter_module_approximation/set_column.h +135 -0
- multipers/multiparameter_module_approximation/structure_higher_dim_barcode.h +36 -0
- multipers/multiparameter_module_approximation/unordered_set_column.h +166 -0
- multipers/multiparameter_module_approximation/utilities.h +403 -0
- multipers/multiparameter_module_approximation/vector_column.h +223 -0
- multipers/multiparameter_module_approximation/vector_matrix.h +331 -0
- multipers/multiparameter_module_approximation/vineyards.h +464 -0
- multipers/multiparameter_module_approximation/vineyards_trajectories.h +649 -0
- multipers/multiparameter_module_approximation.cpython-313-darwin.so +0 -0
- multipers/multiparameter_module_approximation.pyx +235 -0
- multipers/pickle.py +90 -0
- multipers/plots.py +456 -0
- multipers/point_measure.cpython-313-darwin.so +0 -0
- multipers/point_measure.pyx +395 -0
- multipers/simplex_tree_multi.cpython-313-darwin.so +0 -0
- multipers/simplex_tree_multi.pxd +134 -0
- multipers/simplex_tree_multi.pyx +10840 -0
- multipers/simplex_tree_multi.pyx.tp +2009 -0
- multipers/slicer.cpython-313-darwin.so +0 -0
- multipers/slicer.pxd +3034 -0
- multipers/slicer.pxd.tp +234 -0
- multipers/slicer.pyx +20481 -0
- multipers/slicer.pyx.tp +1088 -0
- multipers/tensor/tensor.h +672 -0
- multipers/tensor.pxd +13 -0
- multipers/test.pyx +44 -0
- multipers/tests/__init__.py +62 -0
- multipers/torch/__init__.py +1 -0
- multipers/torch/diff_grids.py +240 -0
- multipers/torch/rips_density.py +310 -0
- multipers-2.3.3b6.dist-info/METADATA +128 -0
- multipers-2.3.3b6.dist-info/RECORD +183 -0
- multipers-2.3.3b6.dist-info/WHEEL +6 -0
- multipers-2.3.3b6.dist-info/licenses/LICENSE +21 -0
- multipers-2.3.3b6.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,238 @@
|
|
|
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 HEAPCOLUMN_H
|
|
12
|
+
#define HEAPCOLUMN_H
|
|
13
|
+
|
|
14
|
+
#include <iostream>
|
|
15
|
+
#include <algorithm>
|
|
16
|
+
#include <cmath>
|
|
17
|
+
#include <vector>
|
|
18
|
+
#include <unordered_map>
|
|
19
|
+
#include <unordered_set>
|
|
20
|
+
|
|
21
|
+
#include "utilities.h"
|
|
22
|
+
|
|
23
|
+
namespace Vineyard {
|
|
24
|
+
|
|
25
|
+
class Heap_column
|
|
26
|
+
{
|
|
27
|
+
public:
|
|
28
|
+
Heap_column();
|
|
29
|
+
Heap_column(boundary_type& boundary);
|
|
30
|
+
Heap_column(Heap_column& column);
|
|
31
|
+
Heap_column(Heap_column&& column) noexcept;
|
|
32
|
+
|
|
33
|
+
void get_content(boundary_type& container);
|
|
34
|
+
bool contains(unsigned int value) const;
|
|
35
|
+
bool is_empty();
|
|
36
|
+
dimension_type get_dimension() const;
|
|
37
|
+
int get_pivot();
|
|
38
|
+
void clear();
|
|
39
|
+
void clear(unsigned int value);
|
|
40
|
+
void reorder(std::vector<index>& valueMap);
|
|
41
|
+
void add(Heap_column& column);
|
|
42
|
+
|
|
43
|
+
Heap_column& operator=(Heap_column other);
|
|
44
|
+
|
|
45
|
+
friend void swap(Heap_column& col1, Heap_column& col2);
|
|
46
|
+
|
|
47
|
+
private:
|
|
48
|
+
int dim_;
|
|
49
|
+
std::vector<unsigned int> column_;
|
|
50
|
+
unsigned int insertsSinceLastPrune_;
|
|
51
|
+
std::unordered_set<unsigned int> erasedValues_;
|
|
52
|
+
|
|
53
|
+
void _prune();
|
|
54
|
+
int _pop_pivot();
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
inline Heap_column::Heap_column() : dim_(0), insertsSinceLastPrune_(0)
|
|
58
|
+
{}
|
|
59
|
+
|
|
60
|
+
inline Heap_column::Heap_column(boundary_type& boundary)
|
|
61
|
+
: dim_(boundary.size() == 0 ? 0 : boundary.size() - 1),
|
|
62
|
+
column_(boundary),
|
|
63
|
+
insertsSinceLastPrune_(0)
|
|
64
|
+
{
|
|
65
|
+
std::make_heap(column_.begin(), column_.end());
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
inline Heap_column::Heap_column(Heap_column& column)
|
|
69
|
+
: dim_(column.dim_),
|
|
70
|
+
column_(column.column_),
|
|
71
|
+
insertsSinceLastPrune_(column.insertsSinceLastPrune_),
|
|
72
|
+
erasedValues_(column.erasedValues_)
|
|
73
|
+
{}
|
|
74
|
+
|
|
75
|
+
inline Heap_column::Heap_column(Heap_column&& column) noexcept
|
|
76
|
+
: dim_(std::exchange(column.dim_, 0)),
|
|
77
|
+
column_(std::move(column.column_)),
|
|
78
|
+
insertsSinceLastPrune_(std::exchange(column.insertsSinceLastPrune_, 0)),
|
|
79
|
+
erasedValues_(std::move(column.erasedValues_))
|
|
80
|
+
{}
|
|
81
|
+
|
|
82
|
+
inline void Heap_column::get_content(boundary_type &container)
|
|
83
|
+
{
|
|
84
|
+
_prune();
|
|
85
|
+
container = column_;
|
|
86
|
+
std::sort_heap(container.begin(), container.end());
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
inline bool Heap_column::contains(unsigned int value) const
|
|
90
|
+
{
|
|
91
|
+
if (erasedValues_.find(value) != erasedValues_.end()) return false;
|
|
92
|
+
|
|
93
|
+
unsigned int c = 0;
|
|
94
|
+
|
|
95
|
+
for (unsigned int v : column_){
|
|
96
|
+
if (v == value) c++;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return c % 2 != 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
inline bool Heap_column::is_empty()
|
|
103
|
+
{
|
|
104
|
+
int pivot = _pop_pivot();
|
|
105
|
+
if (pivot != -1){
|
|
106
|
+
column_.push_back(pivot);
|
|
107
|
+
std::push_heap(column_.begin(), column_.end());
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
inline dimension_type Heap_column::get_dimension() const
|
|
114
|
+
{
|
|
115
|
+
return dim_;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
inline int Heap_column::get_pivot()
|
|
119
|
+
{
|
|
120
|
+
int pivot = _pop_pivot();
|
|
121
|
+
if (pivot != -1){
|
|
122
|
+
column_.push_back(pivot);
|
|
123
|
+
std::push_heap(column_.begin(), column_.end());
|
|
124
|
+
}
|
|
125
|
+
return pivot;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
inline void Heap_column::clear()
|
|
129
|
+
{
|
|
130
|
+
column_.clear();
|
|
131
|
+
insertsSinceLastPrune_ = 0;
|
|
132
|
+
erasedValues_.clear();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
inline void Heap_column::clear(unsigned int value)
|
|
136
|
+
{
|
|
137
|
+
erasedValues_.insert(value);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
inline void Heap_column::reorder(std::vector<index> &valueMap)
|
|
141
|
+
{
|
|
142
|
+
std::vector<unsigned int> tempCol;
|
|
143
|
+
int pivot = _pop_pivot();
|
|
144
|
+
while (pivot != -1) {
|
|
145
|
+
tempCol.push_back(valueMap.at(pivot));
|
|
146
|
+
pivot = _pop_pivot();
|
|
147
|
+
}
|
|
148
|
+
column_.swap(tempCol);
|
|
149
|
+
std::make_heap(column_.begin(), column_.end());
|
|
150
|
+
|
|
151
|
+
insertsSinceLastPrune_ = 0;
|
|
152
|
+
erasedValues_.clear();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
inline void Heap_column::add(Heap_column &column)
|
|
156
|
+
{
|
|
157
|
+
std::vector<unsigned int>& colToAdd = column.column_;
|
|
158
|
+
const unsigned int size = colToAdd.size();
|
|
159
|
+
|
|
160
|
+
if (size == 0) return;
|
|
161
|
+
|
|
162
|
+
for (unsigned int v : colToAdd) {
|
|
163
|
+
if (column.erasedValues_.find(v) == column.erasedValues_.end()){
|
|
164
|
+
column_.push_back(v);
|
|
165
|
+
std::push_heap(column_.begin(), column_.end());
|
|
166
|
+
erasedValues_.erase(v);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
insertsSinceLastPrune_ += size;
|
|
170
|
+
|
|
171
|
+
if (2 * insertsSinceLastPrune_ > column_.size()) _prune();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
inline Heap_column& Heap_column::operator=(Heap_column other)
|
|
175
|
+
{
|
|
176
|
+
std::swap(dim_, other.dim_);
|
|
177
|
+
std::swap(column_, other.column_);
|
|
178
|
+
std::swap(insertsSinceLastPrune_, other.insertsSinceLastPrune_);
|
|
179
|
+
std::swap(erasedValues_, other.erasedValues_);
|
|
180
|
+
return *this;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
inline void Heap_column::_prune()
|
|
184
|
+
{
|
|
185
|
+
if (insertsSinceLastPrune_ == 0 && erasedValues_.empty()) return;
|
|
186
|
+
|
|
187
|
+
std::vector<unsigned int> tempCol;
|
|
188
|
+
int pivot = _pop_pivot();
|
|
189
|
+
while (pivot != -1) {
|
|
190
|
+
tempCol.push_back(pivot);
|
|
191
|
+
pivot = _pop_pivot();
|
|
192
|
+
}
|
|
193
|
+
column_.swap(tempCol);
|
|
194
|
+
std::make_heap(column_.begin(), column_.end());
|
|
195
|
+
|
|
196
|
+
insertsSinceLastPrune_ = 0;
|
|
197
|
+
erasedValues_.clear();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
inline int Heap_column::_pop_pivot()
|
|
201
|
+
{
|
|
202
|
+
if (column_.empty()) {
|
|
203
|
+
return -1;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
unsigned int pivot = column_.front();
|
|
207
|
+
std::pop_heap(column_.begin(), column_.end());
|
|
208
|
+
column_.pop_back();
|
|
209
|
+
while (!column_.empty() && column_.front() == pivot)
|
|
210
|
+
{
|
|
211
|
+
std::pop_heap(column_.begin(), column_.end());
|
|
212
|
+
column_.pop_back();
|
|
213
|
+
|
|
214
|
+
if (column_.empty()) {
|
|
215
|
+
return -1;
|
|
216
|
+
}
|
|
217
|
+
pivot = column_.front();
|
|
218
|
+
std::pop_heap(column_.begin(), column_.end());
|
|
219
|
+
column_.pop_back();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (erasedValues_.find(pivot) != erasedValues_.end())
|
|
223
|
+
pivot = _pop_pivot();
|
|
224
|
+
|
|
225
|
+
return pivot;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
inline void swap(Heap_column& col1, Heap_column& col2)
|
|
229
|
+
{
|
|
230
|
+
std::swap(col1.dim_, col2.dim_);
|
|
231
|
+
col1.column_.swap(col2.column_);
|
|
232
|
+
std::swap(col1.insertsSinceLastPrune_, col2.insertsSinceLastPrune_);
|
|
233
|
+
std::swap(col1.erasedValues_, col2.erasedValues_);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
} //namespace Vineyard
|
|
237
|
+
|
|
238
|
+
#endif // HEAPCOLUMN_H
|
|
@@ -0,0 +1,79 @@
|
|
|
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 images.h
|
|
12
|
+
* @author David Loiseaux, Hannah Schreiber
|
|
13
|
+
* @brief Functions to generate multipersistence images
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
#ifndef IMAGES_H_INCLUDED
|
|
17
|
+
#define IMAGES_H_INCLUDED
|
|
18
|
+
|
|
19
|
+
#include <vector>
|
|
20
|
+
|
|
21
|
+
#include "approximation.h"
|
|
22
|
+
#include "utilities.h"
|
|
23
|
+
namespace Gudhi::multiparameter::mma::representation{
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
using Gudhi::multiparameter::mma::boundary_matrix;
|
|
27
|
+
using Gudhi::multiparameter::mma::filtration_type;
|
|
28
|
+
using Gudhi::multiparameter::mma::dimension_type;
|
|
29
|
+
using Gudhi::multiparameter::mma::Module;
|
|
30
|
+
using Gudhi::multiparameter::mma::Box;
|
|
31
|
+
|
|
32
|
+
struct ImageArgs{
|
|
33
|
+
private:
|
|
34
|
+
unsigned int module_dim; // number of persistent parameters.
|
|
35
|
+
public:
|
|
36
|
+
std::vector<unsigned int> resolution; // resolution of the image
|
|
37
|
+
double p; // sum smoothing
|
|
38
|
+
bool normalize; // Enforce image to take values in [0,1]
|
|
39
|
+
int dimension; // if negative -> all dim
|
|
40
|
+
Box box; // Possible sub-box.
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
std::vector<std::vector<std::vector<double> > > get_2D_image_from_boundary_matrix(
|
|
46
|
+
boundary_matrix &boundaryMatrix,
|
|
47
|
+
std::vector<filtration_type> &filtersList,
|
|
48
|
+
const double precision,
|
|
49
|
+
const Box &box,
|
|
50
|
+
const double delta,
|
|
51
|
+
const double p,
|
|
52
|
+
const bool normalize,
|
|
53
|
+
const std::vector<unsigned int> &resolution,
|
|
54
|
+
const dimension_type dimension,
|
|
55
|
+
const bool complete = true,
|
|
56
|
+
const bool verbose = false)
|
|
57
|
+
{
|
|
58
|
+
Box bbox(box);
|
|
59
|
+
bbox.inflate(delta);
|
|
60
|
+
Module approximation =
|
|
61
|
+
Gudhi::multiparameter::mma::compute_vineyard_barcode_approximation(
|
|
62
|
+
boundaryMatrix,
|
|
63
|
+
filtersList,
|
|
64
|
+
precision,
|
|
65
|
+
bbox,
|
|
66
|
+
true,
|
|
67
|
+
complete,
|
|
68
|
+
false,
|
|
69
|
+
verbose);
|
|
70
|
+
|
|
71
|
+
if (dimension < 0)
|
|
72
|
+
return approximation.get_vectorization(delta, p, normalize, resolution[0], resolution[1]);
|
|
73
|
+
|
|
74
|
+
return {approximation.get_vectorization_in_dimension(dimension, delta, p, normalize, resolution[0], resolution[1])};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
} //namespace
|
|
78
|
+
|
|
79
|
+
#endif // IMAGES_H_INCLUDED
|
|
@@ -0,0 +1,174 @@
|
|
|
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 LISTCOLUMN_H
|
|
12
|
+
#define LISTCOLUMN_H
|
|
13
|
+
|
|
14
|
+
#include <iostream>
|
|
15
|
+
#include <list>
|
|
16
|
+
#include <unordered_set>
|
|
17
|
+
|
|
18
|
+
#include "utilities.h"
|
|
19
|
+
|
|
20
|
+
namespace Vineyard {
|
|
21
|
+
|
|
22
|
+
class List_column
|
|
23
|
+
{
|
|
24
|
+
public:
|
|
25
|
+
List_column();
|
|
26
|
+
List_column(boundary_type& boundary);
|
|
27
|
+
List_column(List_column& column);
|
|
28
|
+
List_column(List_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(List_column& column);
|
|
39
|
+
|
|
40
|
+
List_column& operator=(List_column other);
|
|
41
|
+
|
|
42
|
+
friend void swap(List_column& col1, List_column& col2);
|
|
43
|
+
|
|
44
|
+
private:
|
|
45
|
+
int dim_;
|
|
46
|
+
std::list<unsigned int> column_;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
inline List_column::List_column() : dim_(0)
|
|
50
|
+
{}
|
|
51
|
+
|
|
52
|
+
inline List_column::List_column(boundary_type &boundary)
|
|
53
|
+
: dim_(boundary.size() == 0 ? 0 : boundary.size() - 1),
|
|
54
|
+
column_(boundary.begin(), boundary.end())
|
|
55
|
+
{}
|
|
56
|
+
|
|
57
|
+
inline List_column::List_column(List_column &column)
|
|
58
|
+
: dim_(column.dim_),
|
|
59
|
+
column_(column.column_)
|
|
60
|
+
{}
|
|
61
|
+
|
|
62
|
+
inline List_column::List_column(List_column &&column) noexcept
|
|
63
|
+
: dim_(std::exchange(column.dim_, 0)),
|
|
64
|
+
column_(std::move(column.column_))
|
|
65
|
+
{}
|
|
66
|
+
|
|
67
|
+
inline void List_column::get_content(boundary_type &container)
|
|
68
|
+
{
|
|
69
|
+
std::copy(column_.begin(), column_.end(), std::back_inserter(container));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
inline bool List_column::contains(unsigned int value) const
|
|
73
|
+
{
|
|
74
|
+
for (unsigned int v : column_){
|
|
75
|
+
if (v == value) return true;
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
inline bool List_column::is_empty()
|
|
81
|
+
{
|
|
82
|
+
return column_.empty();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
inline dimension_type List_column::get_dimension() const
|
|
86
|
+
{
|
|
87
|
+
return dim_;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
inline int List_column::get_pivot()
|
|
91
|
+
{
|
|
92
|
+
if (column_.empty()) return -1;
|
|
93
|
+
|
|
94
|
+
return column_.back();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
inline void List_column::clear()
|
|
98
|
+
{
|
|
99
|
+
column_.clear();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
inline void List_column::clear(unsigned int value)
|
|
103
|
+
{
|
|
104
|
+
auto it = column_.begin();
|
|
105
|
+
while (it != column_.end() && *it != value) it++;
|
|
106
|
+
if (it != column_.end()) column_.erase(it);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
inline void List_column::reorder(std::vector<index> &valueMap)
|
|
110
|
+
{
|
|
111
|
+
std::list<unsigned int>::iterator it = column_.begin();
|
|
112
|
+
while (it != column_.end()) {
|
|
113
|
+
*it = valueMap.at(*it);
|
|
114
|
+
it++;
|
|
115
|
+
}
|
|
116
|
+
column_.sort();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
inline void List_column::add(List_column &column)
|
|
120
|
+
{
|
|
121
|
+
if (column.is_empty()) return;
|
|
122
|
+
if (column_.empty()){
|
|
123
|
+
std::copy(column.column_.begin(), column.column_.end(), std::back_inserter(column_));
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
std::list<unsigned int>::iterator itToAdd = column.column_.begin();
|
|
128
|
+
std::list<unsigned int>::iterator itTarget = column_.begin();
|
|
129
|
+
unsigned int valToAdd = *itToAdd;
|
|
130
|
+
unsigned int valTarget = *itTarget;
|
|
131
|
+
|
|
132
|
+
while (itToAdd != column.column_.end() && itTarget != column_.end())
|
|
133
|
+
{
|
|
134
|
+
if (itToAdd != column.column_.end() && itTarget != column_.end()){
|
|
135
|
+
if (valToAdd == valTarget){
|
|
136
|
+
column_.erase(itTarget++);
|
|
137
|
+
itToAdd++;
|
|
138
|
+
} else if (valToAdd < valTarget){
|
|
139
|
+
column_.insert(itTarget, valToAdd);
|
|
140
|
+
itToAdd++;
|
|
141
|
+
} else {
|
|
142
|
+
itTarget++;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
valToAdd = *itToAdd;
|
|
147
|
+
valTarget = *itTarget;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
while (itToAdd != column.column_.end()){
|
|
151
|
+
valToAdd = *itToAdd;
|
|
152
|
+
if (itToAdd != column.column_.end()){
|
|
153
|
+
column_.push_back(valToAdd);
|
|
154
|
+
itToAdd++;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
inline List_column &List_column::operator=(List_column other)
|
|
160
|
+
{
|
|
161
|
+
std::swap(dim_, other.dim_);
|
|
162
|
+
std::swap(column_, other.column_);
|
|
163
|
+
return *this;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
inline void swap(List_column& col1, List_column& col2)
|
|
167
|
+
{
|
|
168
|
+
std::swap(col1.dim_, col2.dim_);
|
|
169
|
+
col1.column_.swap(col2.column_);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
} //namespace Vineyard
|
|
173
|
+
|
|
174
|
+
#endif // LISTCOLUMN_H
|
|
@@ -0,0 +1,232 @@
|
|
|
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 LISTCOLUMN_H
|
|
12
|
+
#define LISTCOLUMN_H
|
|
13
|
+
|
|
14
|
+
#include <iostream>
|
|
15
|
+
#include <list>
|
|
16
|
+
#include <unordered_set>
|
|
17
|
+
|
|
18
|
+
#include "utilities.h"
|
|
19
|
+
|
|
20
|
+
namespace Vineyard {
|
|
21
|
+
|
|
22
|
+
class List_column
|
|
23
|
+
{
|
|
24
|
+
public:
|
|
25
|
+
List_column();
|
|
26
|
+
List_column(boundary_type& boundary);
|
|
27
|
+
List_column(List_column& column);
|
|
28
|
+
List_column(List_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(List_column& column);
|
|
39
|
+
|
|
40
|
+
List_column& operator=(List_column other);
|
|
41
|
+
|
|
42
|
+
friend void swap(List_column& col1, List_column& col2);
|
|
43
|
+
|
|
44
|
+
private:
|
|
45
|
+
int dim_;
|
|
46
|
+
std::list<unsigned int> column_;
|
|
47
|
+
std::unordered_set<unsigned int> erasedValues_;
|
|
48
|
+
|
|
49
|
+
void _cleanValues();
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
inline List_column::List_column() : dim_(0)
|
|
53
|
+
{}
|
|
54
|
+
|
|
55
|
+
inline List_column::List_column(boundary_type &boundary)
|
|
56
|
+
: dim_(boundary.size() == 0 ? 0 : boundary.size() - 1),
|
|
57
|
+
column_(boundary.begin(), boundary.end())
|
|
58
|
+
{}
|
|
59
|
+
|
|
60
|
+
inline List_column::List_column(List_column &column)
|
|
61
|
+
: dim_(column.dim_),
|
|
62
|
+
column_(column.column_),
|
|
63
|
+
erasedValues_(column.erasedValues_)
|
|
64
|
+
{}
|
|
65
|
+
|
|
66
|
+
inline List_column::List_column(List_column &&column) noexcept
|
|
67
|
+
: dim_(std::exchange(column.dim_, 0)),
|
|
68
|
+
column_(std::move(column.column_)),
|
|
69
|
+
erasedValues_(std::move(column.erasedValues_))
|
|
70
|
+
{}
|
|
71
|
+
|
|
72
|
+
inline void List_column::get_content(boundary_type &container)
|
|
73
|
+
{
|
|
74
|
+
_cleanValues();
|
|
75
|
+
std::copy(column_.begin(), column_.end(), std::back_inserter(container));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
inline bool List_column::contains(unsigned int value) const
|
|
79
|
+
{
|
|
80
|
+
if (erasedValues_.find(value) != erasedValues_.end()) return false;
|
|
81
|
+
|
|
82
|
+
for (unsigned int v : column_){
|
|
83
|
+
if (v == value) return true;
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
inline bool List_column::is_empty()
|
|
89
|
+
{
|
|
90
|
+
_cleanValues();
|
|
91
|
+
return column_.empty();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
inline dimension_type List_column::get_dimension() const
|
|
95
|
+
{
|
|
96
|
+
return dim_;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
inline int List_column::get_pivot()
|
|
100
|
+
{
|
|
101
|
+
while (!column_.empty() &&
|
|
102
|
+
erasedValues_.find(column_.back()) != erasedValues_.end()) {
|
|
103
|
+
erasedValues_.erase(column_.back());
|
|
104
|
+
column_.pop_back();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (column_.empty()) return -1;
|
|
108
|
+
|
|
109
|
+
return column_.back();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
inline void List_column::clear()
|
|
113
|
+
{
|
|
114
|
+
column_.clear();
|
|
115
|
+
erasedValues_.clear();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
inline void List_column::clear(unsigned int value)
|
|
119
|
+
{
|
|
120
|
+
erasedValues_.insert(value);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
inline void List_column::reorder(std::vector<index> &valueMap)
|
|
124
|
+
{
|
|
125
|
+
std::list<unsigned int>::iterator it = column_.begin();
|
|
126
|
+
while (it != column_.end()) {
|
|
127
|
+
unsigned int erased = erasedValues_.erase(*it);
|
|
128
|
+
if (erased > 0)
|
|
129
|
+
it = column_.erase(it);
|
|
130
|
+
else {
|
|
131
|
+
*it = valueMap.at(*it);
|
|
132
|
+
it++;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
column_.sort();
|
|
136
|
+
erasedValues_.clear();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
inline void List_column::add(List_column &column)
|
|
140
|
+
{
|
|
141
|
+
if (column.is_empty()) return;
|
|
142
|
+
if (column_.empty()){
|
|
143
|
+
std::copy(column.column_.begin(), column.column_.end(), std::back_inserter(column_));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
std::list<unsigned int>::iterator itToAdd = column.column_.begin();
|
|
148
|
+
std::list<unsigned int>::iterator itTarget = column_.begin();
|
|
149
|
+
unsigned int valToAdd = *itToAdd;
|
|
150
|
+
unsigned int valTarget = *itTarget;
|
|
151
|
+
|
|
152
|
+
while (itToAdd != column.column_.end() && itTarget != column_.end())
|
|
153
|
+
{
|
|
154
|
+
while (itToAdd != column.column_.end() &&
|
|
155
|
+
column.erasedValues_.find(valToAdd) != column.erasedValues_.end()) {
|
|
156
|
+
column.column_.erase(itToAdd++);
|
|
157
|
+
column.erasedValues_.erase(valToAdd);
|
|
158
|
+
valToAdd = *itToAdd;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
while (itTarget != column_.end() &&
|
|
162
|
+
erasedValues_.find(valTarget) != erasedValues_.end()) {
|
|
163
|
+
column_.erase(itTarget++);
|
|
164
|
+
valTarget = *itTarget;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (itToAdd != column.column_.end() && itTarget != column_.end()){
|
|
168
|
+
if (valToAdd == valTarget){
|
|
169
|
+
column_.erase(itTarget++);
|
|
170
|
+
itToAdd++;
|
|
171
|
+
} else if (valToAdd < valTarget){
|
|
172
|
+
column_.insert(itTarget, valToAdd);
|
|
173
|
+
itToAdd++;
|
|
174
|
+
} else {
|
|
175
|
+
itTarget++;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
valToAdd = *itToAdd;
|
|
180
|
+
valTarget = *itTarget;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
while (itToAdd != column.column_.end()){
|
|
184
|
+
valToAdd = *itToAdd;
|
|
185
|
+
|
|
186
|
+
while (itToAdd != column.column_.end() &&
|
|
187
|
+
column.erasedValues_.find(valToAdd) != column.erasedValues_.end()) {
|
|
188
|
+
column.column_.erase(itToAdd++);
|
|
189
|
+
column.erasedValues_.erase(valToAdd);
|
|
190
|
+
valToAdd = *itToAdd;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (itToAdd != column.column_.end()){
|
|
194
|
+
column_.push_back(valToAdd);
|
|
195
|
+
itToAdd++;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
erasedValues_.clear();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
inline List_column &List_column::operator=(List_column other)
|
|
203
|
+
{
|
|
204
|
+
std::swap(dim_, other.dim_);
|
|
205
|
+
std::swap(column_, other.column_);
|
|
206
|
+
std::swap(erasedValues_, other.erasedValues_);
|
|
207
|
+
return *this;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
inline void List_column::_cleanValues()
|
|
211
|
+
{
|
|
212
|
+
std::list<unsigned int>::iterator it = column_.begin();
|
|
213
|
+
while (it != column_.end() && !erasedValues_.empty()) {
|
|
214
|
+
unsigned int erased = erasedValues_.erase(*it);
|
|
215
|
+
if (erased > 0)
|
|
216
|
+
it = column_.erase(it);
|
|
217
|
+
else
|
|
218
|
+
it++;
|
|
219
|
+
}
|
|
220
|
+
erasedValues_.clear();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
inline void swap(List_column& col1, List_column& col2)
|
|
224
|
+
{
|
|
225
|
+
std::swap(col1.dim_, col2.dim_);
|
|
226
|
+
col1.column_.swap(col2.column_);
|
|
227
|
+
std::swap(col1.erasedValues_, col2.erasedValues_);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
} //namespace Vineyard
|
|
231
|
+
|
|
232
|
+
#endif // LISTCOLUMN_H
|