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.
- multipers/.dylibs/libboost_timer.dylib +0 -0
- multipers/.dylibs/libc++.1.0.dylib +0 -0
- multipers/.dylibs/libtbb.12.17.dylib +0 -0
- multipers/__init__.py +33 -0
- multipers/_signed_measure_meta.py +426 -0
- multipers/_slicer_meta.py +231 -0
- multipers/array_api/__init__.py +62 -0
- multipers/array_api/numpy.py +124 -0
- multipers/array_api/torch.py +133 -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 +736 -0
- multipers/filtration_conversions.pxd.tp +226 -0
- multipers/filtrations/__init__.py +21 -0
- multipers/filtrations/density.py +529 -0
- multipers/filtrations/filtrations.py +480 -0
- multipers/filtrations.pxd +534 -0
- multipers/filtrations.pxd.tp +332 -0
- multipers/function_rips.cpython-312-darwin.so +0 -0
- multipers/function_rips.pyx +104 -0
- multipers/grids.cpython-312-darwin.so +0 -0
- multipers/grids.pyx +538 -0
- multipers/gudhi/Persistence_slices_interface.h +213 -0
- multipers/gudhi/Simplex_tree_interface.h +274 -0
- multipers/gudhi/Simplex_tree_multi_interface.h +648 -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 +52 -0
- multipers/gudhi/gudhi/Degree_rips_bifiltration.h +2307 -0
- multipers/gudhi/gudhi/Dynamic_multi_parameter_filtration.h +2524 -0
- multipers/gudhi/gudhi/Fields/Multi_field.h +453 -0
- multipers/gudhi/gudhi/Fields/Multi_field_operators.h +460 -0
- multipers/gudhi/gudhi/Fields/Multi_field_shared.h +444 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small.h +584 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small_operators.h +490 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small_shared.h +580 -0
- multipers/gudhi/gudhi/Fields/Z2_field.h +391 -0
- multipers/gudhi/gudhi/Fields/Z2_field_operators.h +389 -0
- multipers/gudhi/gudhi/Fields/Zp_field.h +493 -0
- multipers/gudhi/gudhi/Fields/Zp_field_operators.h +384 -0
- multipers/gudhi/gudhi/Fields/Zp_field_shared.h +492 -0
- multipers/gudhi/gudhi/Flag_complex_edge_collapser.h +337 -0
- multipers/gudhi/gudhi/Matrix.h +2200 -0
- multipers/gudhi/gudhi/Multi_filtration/Multi_parameter_generator.h +1712 -0
- multipers/gudhi/gudhi/Multi_filtration/multi_filtration_conversions.h +237 -0
- multipers/gudhi/gudhi/Multi_filtration/multi_filtration_utils.h +225 -0
- multipers/gudhi/gudhi/Multi_parameter_filtered_complex.h +485 -0
- multipers/gudhi/gudhi/Multi_parameter_filtration.h +2643 -0
- multipers/gudhi/gudhi/Multi_persistence/Box.h +233 -0
- multipers/gudhi/gudhi/Multi_persistence/Line.h +309 -0
- multipers/gudhi/gudhi/Multi_persistence/Multi_parameter_filtered_complex_pcoh_interface.h +268 -0
- multipers/gudhi/gudhi/Multi_persistence/Persistence_interface_cohomology.h +159 -0
- multipers/gudhi/gudhi/Multi_persistence/Persistence_interface_matrix.h +463 -0
- multipers/gudhi/gudhi/Multi_persistence/Point.h +853 -0
- multipers/gudhi/gudhi/Off_reader.h +173 -0
- multipers/gudhi/gudhi/Persistence_matrix/Base_matrix.h +834 -0
- multipers/gudhi/gudhi/Persistence_matrix/Base_matrix_with_column_compression.h +838 -0
- multipers/gudhi/gudhi/Persistence_matrix/Boundary_matrix.h +833 -0
- multipers/gudhi/gudhi/Persistence_matrix/Chain_matrix.h +1367 -0
- multipers/gudhi/gudhi/Persistence_matrix/Id_to_index_overlay.h +1157 -0
- multipers/gudhi/gudhi/Persistence_matrix/Position_to_index_overlay.h +869 -0
- multipers/gudhi/gudhi/Persistence_matrix/RU_matrix.h +905 -0
- multipers/gudhi/gudhi/Persistence_matrix/allocators/entry_constructors.h +122 -0
- multipers/gudhi/gudhi/Persistence_matrix/base_pairing.h +260 -0
- multipers/gudhi/gudhi/Persistence_matrix/base_swap.h +288 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_pairing.h +170 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_rep_cycles.h +247 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_vine_swap.h +571 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/chain_column_extra_properties.h +182 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/column_dimension_holder.h +130 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/column_utilities.h +235 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/entry_types.h +312 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/heap_column.h +1092 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_list_column.h +923 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_set_column.h +914 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/list_column.h +930 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/naive_vector_column.h +1071 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/row_access.h +203 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/set_column.h +886 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/unordered_set_column.h +984 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/vector_column.h +1213 -0
- multipers/gudhi/gudhi/Persistence_matrix/index_mapper.h +58 -0
- multipers/gudhi/gudhi/Persistence_matrix/matrix_dimension_holders.h +227 -0
- multipers/gudhi/gudhi/Persistence_matrix/matrix_row_access.h +200 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_pairing.h +166 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_rep_cycles.h +319 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_vine_swap.h +562 -0
- multipers/gudhi/gudhi/Persistence_on_a_line.h +152 -0
- multipers/gudhi/gudhi/Persistence_on_rectangle.h +617 -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 +769 -0
- multipers/gudhi/gudhi/Points_off_io.h +171 -0
- multipers/gudhi/gudhi/Projective_cover_kernel.h +379 -0
- multipers/gudhi/gudhi/Simple_object_pool.h +69 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_iterators.h +559 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +83 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_siblings.h +121 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_star_simplex_iterators.h +277 -0
- multipers/gudhi/gudhi/Simplex_tree/filtration_value_utils.h +155 -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 +60 -0
- multipers/gudhi/gudhi/Simplex_tree/simplex_tree_options.h +105 -0
- multipers/gudhi/gudhi/Simplex_tree.h +3170 -0
- multipers/gudhi/gudhi/Slicer.h +848 -0
- multipers/gudhi/gudhi/Thread_safe_slicer.h +393 -0
- multipers/gudhi/gudhi/distance_functions.h +62 -0
- multipers/gudhi/gudhi/graph_simplicial_complex.h +104 -0
- multipers/gudhi/gudhi/multi_simplex_tree_helpers.h +147 -0
- multipers/gudhi/gudhi/persistence_interval.h +263 -0
- multipers/gudhi/gudhi/persistence_matrix_options.h +188 -0
- multipers/gudhi/gudhi/reader_utils.h +367 -0
- multipers/gudhi/gudhi/simple_mdspan.h +484 -0
- multipers/gudhi/gudhi/slicer_helpers.h +779 -0
- multipers/gudhi/tmp_h0_pers/mma_interface_h0.h +223 -0
- multipers/gudhi/tmp_h0_pers/naive_merge_tree.h +536 -0
- multipers/io.cpython-312-darwin.so +0 -0
- multipers/io.pyx +472 -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 +1667 -0
- multipers/ml/sliced_wasserstein.py +461 -0
- multipers/ml/tools.py +113 -0
- multipers/mma_structures.cpython-312-darwin.so +0 -0
- multipers/mma_structures.pxd +134 -0
- multipers/mma_structures.pyx +1483 -0
- multipers/mma_structures.pyx.tp +1126 -0
- multipers/multi_parameter_rank_invariant/diff_helpers.h +85 -0
- multipers/multi_parameter_rank_invariant/euler_characteristic.h +95 -0
- multipers/multi_parameter_rank_invariant/function_rips.h +317 -0
- multipers/multi_parameter_rank_invariant/hilbert_function.h +761 -0
- multipers/multi_parameter_rank_invariant/persistence_slices.h +149 -0
- multipers/multi_parameter_rank_invariant/rank_invariant.h +350 -0
- multipers/multiparameter_edge_collapse.py +41 -0
- multipers/multiparameter_module_approximation/approximation.h +2541 -0
- multipers/multiparameter_module_approximation/debug.h +107 -0
- multipers/multiparameter_module_approximation/format_python-cpp.h +292 -0
- multipers/multiparameter_module_approximation/utilities.h +428 -0
- multipers/multiparameter_module_approximation.cpython-312-darwin.so +0 -0
- multipers/multiparameter_module_approximation.pyx +286 -0
- multipers/ops.cpython-312-darwin.so +0 -0
- multipers/ops.pyx +231 -0
- multipers/pickle.py +89 -0
- multipers/plots.py +550 -0
- multipers/point_measure.cpython-312-darwin.so +0 -0
- multipers/point_measure.pyx +409 -0
- multipers/simplex_tree_multi.cpython-312-darwin.so +0 -0
- multipers/simplex_tree_multi.pxd +136 -0
- multipers/simplex_tree_multi.pyx +11719 -0
- multipers/simplex_tree_multi.pyx.tp +2102 -0
- multipers/slicer.cpython-312-darwin.so +0 -0
- multipers/slicer.pxd +2097 -0
- multipers/slicer.pxd.tp +263 -0
- multipers/slicer.pyx +13042 -0
- multipers/slicer.pyx.tp +1259 -0
- multipers/tensor/tensor.h +672 -0
- multipers/tensor.pxd +13 -0
- multipers/test.pyx +44 -0
- multipers/tests/__init__.py +70 -0
- multipers/torch/__init__.py +1 -0
- multipers/torch/diff_grids.py +240 -0
- multipers/torch/rips_density.py +310 -0
- multipers/vector_interface.pxd +46 -0
- multipers-2.4.0b1.dist-info/METADATA +131 -0
- multipers-2.4.0b1.dist-info/RECORD +184 -0
- multipers-2.4.0b1.dist-info/WHEEL +6 -0
- multipers-2.4.0b1.dist-info/licenses/LICENSE +21 -0
- multipers-2.4.0b1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <array>
|
|
4
|
+
#include <cstdint>
|
|
5
|
+
|
|
6
|
+
#include "gudhi/Multi_parameter_filtration.h"
|
|
7
|
+
#include "gudhi/multi_simplex_tree_helpers.h"
|
|
8
|
+
#include "gudhi/persistence_matrix_options.h"
|
|
9
|
+
#include "gudhi/Multi_parameter_filtered_complex.h"
|
|
10
|
+
#include "gudhi/Multi_persistence/Persistence_interface_matrix.h"
|
|
11
|
+
#include "gudhi/Multi_persistence/Persistence_interface_cohomology.h"
|
|
12
|
+
#include "gudhi/Dynamic_multi_parameter_filtration.h"
|
|
13
|
+
#include "gudhi/Degree_rips_bifiltration.h"
|
|
14
|
+
#include "gudhi/Slicer.h"
|
|
15
|
+
|
|
16
|
+
#include "tmp_h0_pers/mma_interface_h0.h"
|
|
17
|
+
|
|
18
|
+
namespace multipers::tmp_interface {
|
|
19
|
+
|
|
20
|
+
template <typename Filtration>
|
|
21
|
+
using SimplexTreeMultiOptions = Gudhi::multi_persistence::Simplex_tree_options_multidimensional_filtration<Filtration>;
|
|
22
|
+
|
|
23
|
+
enum Column_types_strs : std::uint8_t {
|
|
24
|
+
LIST,
|
|
25
|
+
SET,
|
|
26
|
+
HEAP,
|
|
27
|
+
VECTOR,
|
|
28
|
+
NAIVE_VECTOR,
|
|
29
|
+
UNORDERED_SET,
|
|
30
|
+
INTRUSIVE_LIST,
|
|
31
|
+
INTRUSIVE_SET
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
enum Filtration_containers_strs : std::uint8_t {
|
|
35
|
+
Dynamic_multi_parameter_filtration,
|
|
36
|
+
Multi_parameter_filtration,
|
|
37
|
+
Degree_rips_bifiltration
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
using Available_columns = Gudhi::persistence_matrix::Column_types;
|
|
41
|
+
|
|
42
|
+
template <Gudhi::persistence_matrix::Column_types column_type = Gudhi::persistence_matrix::Column_types::INTRUSIVE_SET>
|
|
43
|
+
struct Multi_persistence_options : Gudhi::persistence_matrix::Default_options<column_type, true> {
|
|
44
|
+
using Index = std::uint32_t;
|
|
45
|
+
static const bool has_matrix_maximal_dimension_access = false;
|
|
46
|
+
static const bool has_column_pairings = true;
|
|
47
|
+
static const bool has_vine_update = true;
|
|
48
|
+
static const bool can_retrieve_representative_cycles = true;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
template <Gudhi::persistence_matrix::Column_types column_type = Gudhi::persistence_matrix::Column_types::INTRUSIVE_SET>
|
|
52
|
+
struct Multi_persistence_Clement_options : Gudhi::persistence_matrix::Default_options<column_type, true> {
|
|
53
|
+
using Index = std::uint32_t;
|
|
54
|
+
static const bool has_matrix_maximal_dimension_access = false;
|
|
55
|
+
static const bool has_column_pairings = true;
|
|
56
|
+
static const bool has_vine_update = true;
|
|
57
|
+
static const bool is_of_boundary_type = false;
|
|
58
|
+
static const Gudhi::persistence_matrix::Column_indexation_types column_indexation_type =
|
|
59
|
+
Gudhi::persistence_matrix::Column_indexation_types::POSITION;
|
|
60
|
+
static const bool can_retrieve_representative_cycles = true;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
template <Gudhi::persistence_matrix::Column_types column_type = Gudhi::persistence_matrix::Column_types::INTRUSIVE_SET>
|
|
64
|
+
struct No_vine_multi_persistence_options : Gudhi::persistence_matrix::Default_options<column_type, true> {
|
|
65
|
+
using Index = std::uint32_t;
|
|
66
|
+
static const bool has_matrix_maximal_dimension_access = false;
|
|
67
|
+
static const bool has_column_pairings = true;
|
|
68
|
+
static const bool has_vine_update = false;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
template <Gudhi::persistence_matrix::Column_types column_type = Gudhi::persistence_matrix::Column_types::INTRUSIVE_SET,
|
|
72
|
+
bool row_access = true>
|
|
73
|
+
struct fix_presentation_options : Gudhi::persistence_matrix::Default_options<column_type, true> {
|
|
74
|
+
using Index = std::uint32_t;
|
|
75
|
+
static const bool has_row_access = row_access;
|
|
76
|
+
static const bool has_map_column_container = false;
|
|
77
|
+
static const bool has_removable_columns = false; // WARN : idx will change if map is not true
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
template <Available_columns col>
|
|
81
|
+
using BackendOptionsWithVine = Multi_persistence_options<col>;
|
|
82
|
+
template <Available_columns col>
|
|
83
|
+
using BackendOptionsWithoutVine = No_vine_multi_persistence_options<col>;
|
|
84
|
+
|
|
85
|
+
template <Available_columns col>
|
|
86
|
+
using ClementBackendOptionsWithVine = Multi_persistence_Clement_options<col>;
|
|
87
|
+
|
|
88
|
+
// using SimplicialStructure = Gudhi::multiparameter::truc_interface::SimplicialStructure;
|
|
89
|
+
template <typename Filtration>
|
|
90
|
+
using StructureStuff = Gudhi::multi_persistence::Multi_parameter_filtered_complex<Filtration>;
|
|
91
|
+
|
|
92
|
+
template <Available_columns col>
|
|
93
|
+
using MatrixBackendNoVine = Gudhi::multi_persistence::Persistence_interface_matrix<BackendOptionsWithoutVine<col>>;
|
|
94
|
+
|
|
95
|
+
template <Available_columns col>
|
|
96
|
+
using MatrixBackendVine = Gudhi::multi_persistence::Persistence_interface_matrix<BackendOptionsWithVine<col>>;
|
|
97
|
+
|
|
98
|
+
template <Available_columns col>
|
|
99
|
+
using ClementMatrixBackendVine =
|
|
100
|
+
Gudhi::multi_persistence::Persistence_interface_matrix<ClementBackendOptionsWithVine<col>>;
|
|
101
|
+
template <typename Filtration>
|
|
102
|
+
using GraphBackendVine = Gudhi::multiparameter::truc_interface::Persistence_backend_h0<StructureStuff<Filtration>>;
|
|
103
|
+
|
|
104
|
+
template <typename value_type = float>
|
|
105
|
+
using Filtration_value = Gudhi::multi_filtration::Multi_parameter_filtration<value_type, false, true>;
|
|
106
|
+
|
|
107
|
+
template <Available_columns col = Available_columns::INTRUSIVE_SET>
|
|
108
|
+
using SimplicialNoVineMatrixTruc = Gudhi::multi_persistence::Slicer<Filtration_value<>, MatrixBackendNoVine<col>>;
|
|
109
|
+
|
|
110
|
+
template <Available_columns col = Available_columns::INTRUSIVE_SET>
|
|
111
|
+
using GeneralVineTruc = Gudhi::multi_persistence::Slicer<Filtration_value<>, MatrixBackendVine<col>>;
|
|
112
|
+
|
|
113
|
+
template <Available_columns col = Available_columns::INTRUSIVE_SET>
|
|
114
|
+
using GeneralNoVineTruc = Gudhi::multi_persistence::Slicer<Filtration_value<>, MatrixBackendNoVine<col>>;
|
|
115
|
+
|
|
116
|
+
template <Available_columns col = Available_columns::INTRUSIVE_SET>
|
|
117
|
+
using GeneralVineClementTruc = Gudhi::multi_persistence::Slicer<Filtration_value<>, ClementMatrixBackendVine<col>>;
|
|
118
|
+
|
|
119
|
+
template <Available_columns col = Available_columns::INTRUSIVE_SET>
|
|
120
|
+
using SimplicialVineMatrixTruc = Gudhi::multi_persistence::Slicer<Filtration_value<>, MatrixBackendVine<col>>;
|
|
121
|
+
using SimplicialVineGraphTruc =
|
|
122
|
+
Gudhi::multi_persistence::Slicer<Filtration_value<>, GraphBackendVine<Filtration_value<>>>;
|
|
123
|
+
|
|
124
|
+
// multi-critical
|
|
125
|
+
template <typename value_type = float>
|
|
126
|
+
using Multi_critical_filtration_value = Gudhi::multi_filtration::Multi_parameter_filtration<value_type>;
|
|
127
|
+
|
|
128
|
+
template <Available_columns col = Available_columns::INTRUSIVE_SET>
|
|
129
|
+
using KCriticalVineTruc = Gudhi::multi_persistence::Slicer<Multi_critical_filtration_value<>, MatrixBackendVine<col>>;
|
|
130
|
+
|
|
131
|
+
template <bool is_vine, Available_columns col = Available_columns::INTRUSIVE_SET>
|
|
132
|
+
using Matrix_interface = std::conditional_t<is_vine, MatrixBackendVine<col>, MatrixBackendNoVine<col>>;
|
|
133
|
+
|
|
134
|
+
template <Filtration_containers_strs fil_container, bool is_k_critical, typename value_type>
|
|
135
|
+
using filtration_options = std::conditional_t<fil_container == Filtration_containers_strs::Dynamic_multi_parameter_filtration,
|
|
136
|
+
Gudhi::multi_filtration::Dynamic_multi_parameter_filtration<value_type, false, !is_k_critical>,
|
|
137
|
+
std::conditional_t<fil_container == Filtration_containers_strs::Multi_parameter_filtration,
|
|
138
|
+
Gudhi::multi_filtration::Multi_parameter_filtration<value_type, false, !is_k_critical>,
|
|
139
|
+
Gudhi::multi_filtration::Degree_rips_bifiltration<value_type, false, !is_k_critical>>>;
|
|
140
|
+
|
|
141
|
+
template <bool is_vine,
|
|
142
|
+
bool is_k_critical,
|
|
143
|
+
typename value_type,
|
|
144
|
+
Available_columns col = Available_columns::INTRUSIVE_SET,
|
|
145
|
+
Filtration_containers_strs filt_cont = Filtration_containers_strs::Multi_parameter_filtration>
|
|
146
|
+
using MatrixTrucPythonInterface =
|
|
147
|
+
Gudhi::multi_persistence::Slicer<filtration_options<filt_cont,is_k_critical, value_type>, Matrix_interface<is_vine, col>>;
|
|
148
|
+
|
|
149
|
+
enum class BackendsEnum : std::uint8_t { Matrix, Graph, Clement, GudhiCohomology };
|
|
150
|
+
|
|
151
|
+
// Create a template metafunction to simplify the type selection
|
|
152
|
+
template <BackendsEnum backend, bool is_vine, Available_columns col, typename Filtration>
|
|
153
|
+
struct PersBackendOptsImpl;
|
|
154
|
+
|
|
155
|
+
template <bool is_vine, Available_columns col, typename Filtration>
|
|
156
|
+
struct PersBackendOptsImpl<BackendsEnum::Matrix, is_vine, col, Filtration> {
|
|
157
|
+
using type = Matrix_interface<is_vine, col>;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
template <bool is_vine, Available_columns col, typename Filtration>
|
|
161
|
+
struct PersBackendOptsImpl<BackendsEnum::Clement, is_vine, col, Filtration> {
|
|
162
|
+
static_assert(is_vine, "Clement is vine");
|
|
163
|
+
using type = ClementMatrixBackendVine<col>;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
template <bool is_vine, Available_columns col, typename Filtration>
|
|
167
|
+
struct PersBackendOptsImpl<BackendsEnum::GudhiCohomology, is_vine, col, Filtration> {
|
|
168
|
+
static_assert(!is_vine, "Gudhi is not vine");
|
|
169
|
+
using type = Gudhi::multi_persistence::Persistence_interface_cohomology<Filtration>;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
template <bool is_vine, Available_columns col, typename Filtration>
|
|
173
|
+
struct PersBackendOptsImpl<BackendsEnum::Graph, is_vine, col, Filtration> {
|
|
174
|
+
static_assert(is_vine, "Graph backend requires is_vine to be true");
|
|
175
|
+
using type = GraphBackendVine<Filtration>;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// Helper alias to extract the type
|
|
179
|
+
template <BackendsEnum backend, bool is_vine, Available_columns col, typename Filtration>
|
|
180
|
+
using PersBackendOpts = typename PersBackendOptsImpl<backend, is_vine, col, Filtration>::type;
|
|
181
|
+
|
|
182
|
+
template <BackendsEnum backend,
|
|
183
|
+
bool is_vine,
|
|
184
|
+
bool is_k_critical,
|
|
185
|
+
typename value_type,
|
|
186
|
+
Available_columns col = Available_columns::INTRUSIVE_SET,
|
|
187
|
+
Filtration_containers_strs filt_cont = Filtration_containers_strs::Multi_parameter_filtration>
|
|
188
|
+
using TrucPythonInterface = Gudhi::multi_persistence::Slicer<
|
|
189
|
+
filtration_options<filt_cont,is_k_critical, value_type>,
|
|
190
|
+
PersBackendOpts<backend, is_vine, col, filtration_options<filt_cont,is_k_critical, value_type>>>;
|
|
191
|
+
|
|
192
|
+
//for python
|
|
193
|
+
template<typename T>
|
|
194
|
+
using One_critical_filtration = Gudhi::multi_filtration::Multi_parameter_filtration<T, false, true>;
|
|
195
|
+
template<typename T>
|
|
196
|
+
using Multi_critical_filtration = Gudhi::multi_filtration::Multi_parameter_filtration<T, false, false>;
|
|
197
|
+
|
|
198
|
+
template <typename T>
|
|
199
|
+
using Bar = std::array<T, 2>;
|
|
200
|
+
template <class Slicer, typename T = typename Slicer::T>
|
|
201
|
+
using Barcode = typename Slicer::template Flat_barcode<T>;
|
|
202
|
+
template <class Slicer, typename T = typename Slicer::T>
|
|
203
|
+
using Dim_barcode = typename Slicer::template Multi_dimensional_flat_barcode<T>;
|
|
204
|
+
|
|
205
|
+
template<class Slicer>
|
|
206
|
+
std::string slicer_to_str(Slicer& s)
|
|
207
|
+
{
|
|
208
|
+
std::stringstream stream;
|
|
209
|
+
stream << s;
|
|
210
|
+
return stream.str();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
} // namespace multipers::tmp_interface
|
|
@@ -0,0 +1,274 @@
|
|
|
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): Vincent Rouvreau
|
|
4
|
+
*
|
|
5
|
+
* Copyright (C) 2016 Inria
|
|
6
|
+
*
|
|
7
|
+
* Modification(s):
|
|
8
|
+
* - YYYY/MM Author: Description of the modification
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#ifndef INCLUDE_SIMPLEX_TREE_INTERFACE_H_
|
|
12
|
+
#define INCLUDE_SIMPLEX_TREE_INTERFACE_H_
|
|
13
|
+
|
|
14
|
+
#include <cstddef>
|
|
15
|
+
#include <string>
|
|
16
|
+
#include <vector>
|
|
17
|
+
#include <utility> // std::pair
|
|
18
|
+
#include <tuple>
|
|
19
|
+
|
|
20
|
+
#include <gudhi/graph_simplicial_complex.h>
|
|
21
|
+
#include <gudhi/distance_functions.h>
|
|
22
|
+
#include <gudhi/Simplex_tree.h>
|
|
23
|
+
#include <gudhi/Points_off_io.h>
|
|
24
|
+
#include <gudhi/Flag_complex_edge_collapser.h>
|
|
25
|
+
|
|
26
|
+
namespace Gudhi {
|
|
27
|
+
|
|
28
|
+
/** Model of SimplexTreeOptions.
|
|
29
|
+
*
|
|
30
|
+
* Specific to python interfaces of the Simplex_tree */
|
|
31
|
+
struct Simplex_tree_options_for_python {
|
|
32
|
+
typedef linear_indexing_tag Indexing_tag;
|
|
33
|
+
typedef int Vertex_handle;
|
|
34
|
+
typedef double Filtration_value;
|
|
35
|
+
typedef std::uint32_t Simplex_key;
|
|
36
|
+
static const bool store_key = true;
|
|
37
|
+
static const bool store_filtration = true;
|
|
38
|
+
static const bool contiguous_vertices = false;
|
|
39
|
+
static const bool link_nodes_by_label = false;
|
|
40
|
+
static const bool stable_simplex_handles = false;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// CHANGED FROM THE ORIGINAL: added template parameter
|
|
44
|
+
template <class Simplex_tree_options = Simplex_tree_options_for_python>
|
|
45
|
+
class Simplex_tree_interface : public Simplex_tree<Simplex_tree_options>
|
|
46
|
+
{
|
|
47
|
+
public:
|
|
48
|
+
using Base = Simplex_tree<Simplex_tree_options>;
|
|
49
|
+
using Filtration_value = typename Base::Filtration_value;
|
|
50
|
+
using Vertex_handle = typename Base::Vertex_handle;
|
|
51
|
+
using Simplex_handle = typename Base::Simplex_handle;
|
|
52
|
+
using Insertion_result = typename std::pair<Simplex_handle, bool>;
|
|
53
|
+
using Simplex = std::vector<Vertex_handle>;
|
|
54
|
+
using Simplex_and_filtration = std::pair<Simplex, Filtration_value>;
|
|
55
|
+
using Filtered_simplices = std::vector<Simplex_and_filtration>;
|
|
56
|
+
using Skeleton_simplex_iterator = typename Base::Skeleton_simplex_iterator;
|
|
57
|
+
using Complex_simplex_iterator = typename Base::Complex_simplex_iterator;
|
|
58
|
+
using Extended_filtration_data = typename Base::Extended_filtration_data;
|
|
59
|
+
using Boundary_simplex_iterator = typename Base::Boundary_simplex_iterator;
|
|
60
|
+
using Siblings = typename Base::Siblings;
|
|
61
|
+
using Node = typename Base::Node;
|
|
62
|
+
typedef bool (*blocker_func_t)(Simplex simplex, void* user_data);
|
|
63
|
+
|
|
64
|
+
// CHANGED FROM THE ORIGINAL: constructors from simplex tree
|
|
65
|
+
Simplex_tree_interface() = default;
|
|
66
|
+
Simplex_tree_interface(const Base& st) : Base(st) {};
|
|
67
|
+
Simplex_tree_interface(Base&& st) : Base(std::move(st)) {};
|
|
68
|
+
Simplex_tree_interface& operator=(const Base& st){
|
|
69
|
+
Base::operator=(st);
|
|
70
|
+
return *this;
|
|
71
|
+
}
|
|
72
|
+
Simplex_tree_interface& operator=(Base&& st){
|
|
73
|
+
Base::operator=(std::move(st));
|
|
74
|
+
return *this;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public:
|
|
78
|
+
Extended_filtration_data efd;
|
|
79
|
+
|
|
80
|
+
bool find_simplex(const Simplex& simplex) { return (Base::find(simplex) != Base::null_simplex()); }
|
|
81
|
+
|
|
82
|
+
void assign_simplex_filtration(const Simplex& simplex, Filtration_value filtration)
|
|
83
|
+
{
|
|
84
|
+
Simplex_handle sh = Base::find(simplex);
|
|
85
|
+
if (sh == Base::null_simplex())
|
|
86
|
+
throw std::invalid_argument("Cannot assign a filtration to a simplex that is not in the complex");
|
|
87
|
+
Base::assign_filtration(sh, filtration);
|
|
88
|
+
Base::clear_filtration();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
bool insert(const Simplex& simplex, Filtration_value filtration = 0)
|
|
92
|
+
{
|
|
93
|
+
Insertion_result result = Base::insert_simplex_and_subfaces(simplex, filtration);
|
|
94
|
+
if (result.first != Base::null_simplex()) Base::clear_filtration();
|
|
95
|
+
return (result.second);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
void insert_matrix(double* filtrations, int n, int stride0, int stride1, double max_filtration)
|
|
99
|
+
{
|
|
100
|
+
// We could delegate to insert_graph, but wrapping the matrix in a graph interface is too much work,
|
|
101
|
+
// and this is a bit more efficient.
|
|
102
|
+
auto& rm = this->root()->members_;
|
|
103
|
+
for (int i = 0; i < n; ++i) {
|
|
104
|
+
char* p = reinterpret_cast<char*>(filtrations) + i * stride0;
|
|
105
|
+
double fv = *reinterpret_cast<double*>(p + i * stride1);
|
|
106
|
+
if (fv > max_filtration) continue;
|
|
107
|
+
auto sh = rm.emplace_hint(rm.end(), i, Node(this->root(), fv));
|
|
108
|
+
Siblings* children = nullptr;
|
|
109
|
+
// Should we make a first pass to count the number of edges so we can reserve the right space?
|
|
110
|
+
for (int j = i + 1; j < n; ++j) {
|
|
111
|
+
double fe = *reinterpret_cast<double*>(p + j * stride1);
|
|
112
|
+
if (fe > max_filtration) continue;
|
|
113
|
+
if (!children) {
|
|
114
|
+
children = new Siblings(this->root(), i);
|
|
115
|
+
sh->second.assign_children(children);
|
|
116
|
+
}
|
|
117
|
+
children->members().emplace_hint(children->members().end(), j, Node(children, fe));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
this->set_dimension(1, false);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Do not interface this function, only used in alpha complex interface for complex creation
|
|
124
|
+
bool insert_simplex(const Simplex& simplex, Filtration_value filtration = 0)
|
|
125
|
+
{
|
|
126
|
+
Insertion_result result = Base::insert_simplex(simplex, filtration);
|
|
127
|
+
return (result.second);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Do not interface this function, only used in strong witness interface for complex creation
|
|
131
|
+
bool insert_simplex(const std::vector<std::size_t>& simplex, Filtration_value filtration = 0)
|
|
132
|
+
{
|
|
133
|
+
Insertion_result result = Base::insert_simplex(simplex, filtration);
|
|
134
|
+
return (result.second);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
Filtration_value simplex_filtration(const Simplex& simplex) { return Base::filtration(Base::find(simplex)); }
|
|
138
|
+
|
|
139
|
+
void remove_maximal_simplex(const Simplex& simplex)
|
|
140
|
+
{
|
|
141
|
+
Base::remove_maximal_simplex(Base::find(simplex));
|
|
142
|
+
Base::clear_filtration();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
Simplex_and_filtration get_simplex_and_filtration(Simplex_handle f_simplex)
|
|
146
|
+
{
|
|
147
|
+
Simplex simplex;
|
|
148
|
+
for (auto vertex : Base::simplex_vertex_range(f_simplex)) {
|
|
149
|
+
simplex.insert(simplex.begin(), vertex);
|
|
150
|
+
}
|
|
151
|
+
return std::make_pair(std::move(simplex), Base::filtration(f_simplex));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
Filtered_simplices get_star(const Simplex& simplex)
|
|
155
|
+
{
|
|
156
|
+
Filtered_simplices star;
|
|
157
|
+
for (auto f_simplex : Base::star_simplex_range(Base::find(simplex))) {
|
|
158
|
+
Simplex simplex_star;
|
|
159
|
+
for (auto vertex : Base::simplex_vertex_range(f_simplex)) {
|
|
160
|
+
simplex_star.insert(simplex_star.begin(), vertex);
|
|
161
|
+
}
|
|
162
|
+
star.push_back(std::make_pair(simplex_star, Base::filtration(f_simplex)));
|
|
163
|
+
}
|
|
164
|
+
return star;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
Filtered_simplices get_cofaces(const Simplex& simplex, int dimension)
|
|
168
|
+
{
|
|
169
|
+
Filtered_simplices cofaces;
|
|
170
|
+
for (auto f_simplex : Base::cofaces_simplex_range(Base::find(simplex), dimension)) {
|
|
171
|
+
Simplex simplex_coface;
|
|
172
|
+
for (auto vertex : Base::simplex_vertex_range(f_simplex)) {
|
|
173
|
+
simplex_coface.insert(simplex_coface.begin(), vertex);
|
|
174
|
+
}
|
|
175
|
+
cofaces.push_back(std::make_pair(simplex_coface, Base::filtration(f_simplex)));
|
|
176
|
+
}
|
|
177
|
+
return cofaces;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
void compute_extended_filtration()
|
|
181
|
+
{
|
|
182
|
+
this->efd = this->extend_filtration();
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// CHANGED FROM THE ORIGINAL: Does collapses in a new simplex tree instead of inplace.
|
|
187
|
+
Simplex_tree_interface* collapse_edges(int nb_collapse_iteration) {
|
|
188
|
+
using Filtered_edge = std::tuple<Vertex_handle, Vertex_handle, Filtration_value>;
|
|
189
|
+
std::vector<Filtered_edge> edges;
|
|
190
|
+
for (Simplex_handle sh : Base::skeleton_simplex_range(1)) {
|
|
191
|
+
if (Base::dimension(sh) == 1) {
|
|
192
|
+
typename Base::Simplex_vertex_range rg = Base::simplex_vertex_range(sh);
|
|
193
|
+
auto vit = rg.begin();
|
|
194
|
+
Vertex_handle v = *vit;
|
|
195
|
+
Vertex_handle w = *++vit;
|
|
196
|
+
edges.emplace_back(v, w, Base::filtration(sh));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
for (int iteration = 0; iteration < nb_collapse_iteration; iteration++) {
|
|
201
|
+
edges = Gudhi::collapse::flag_complex_collapse_edges(std::move(edges));
|
|
202
|
+
}
|
|
203
|
+
Simplex_tree_interface* collapsed_stree_ptr = new Simplex_tree_interface();
|
|
204
|
+
// Copy the original 0-skeleton
|
|
205
|
+
for (Simplex_handle sh : Base::skeleton_simplex_range(0)) {
|
|
206
|
+
collapsed_stree_ptr->insert({*(Base::simplex_vertex_range(sh).begin())}, Base::filtration(sh));
|
|
207
|
+
}
|
|
208
|
+
// Insert remaining edges
|
|
209
|
+
for (auto remaining_edge : edges) {
|
|
210
|
+
collapsed_stree_ptr->insert({std::get<0>(remaining_edge), std::get<1>(remaining_edge)},
|
|
211
|
+
std::get<2>(remaining_edge));
|
|
212
|
+
}
|
|
213
|
+
return collapsed_stree_ptr;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
void expansion_with_blockers_callback(int dimension, blocker_func_t user_func, void* user_data)
|
|
217
|
+
{
|
|
218
|
+
Base::expansion_with_blockers(dimension, [&](Simplex_handle sh) {
|
|
219
|
+
Simplex simplex(Base::simplex_vertex_range(sh).begin(), Base::simplex_vertex_range(sh).end());
|
|
220
|
+
return user_func(simplex, user_data);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Iterator over the simplex tree
|
|
225
|
+
Complex_simplex_iterator get_simplices_iterator_begin()
|
|
226
|
+
{
|
|
227
|
+
// this specific case works because the range is just a pair of iterators - won't work if range was a vector
|
|
228
|
+
return Base::complex_simplex_range().begin();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
Complex_simplex_iterator get_simplices_iterator_end()
|
|
232
|
+
{
|
|
233
|
+
// this specific case works because the range is just a pair of iterators - won't work if range was a vector
|
|
234
|
+
return Base::complex_simplex_range().end();
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
typename std::vector<Simplex_handle>::const_iterator get_filtration_iterator_begin()
|
|
238
|
+
{
|
|
239
|
+
// Base::initialize_filtration(); already performed in filtration_simplex_range
|
|
240
|
+
// this specific case works because the range is just a pair of iterators - won't work if range was a vector
|
|
241
|
+
return Base::filtration_simplex_range().begin();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
typename std::vector<Simplex_handle>::const_iterator get_filtration_iterator_end()
|
|
245
|
+
{
|
|
246
|
+
// this specific case works because the range is just a pair of iterators - won't work if range was a vector
|
|
247
|
+
return Base::filtration_simplex_range().end();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
Skeleton_simplex_iterator get_skeleton_iterator_begin(int dimension)
|
|
251
|
+
{
|
|
252
|
+
// this specific case works because the range is just a pair of iterators - won't work if range was a vector
|
|
253
|
+
return Base::skeleton_simplex_range(dimension).begin();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
Skeleton_simplex_iterator get_skeleton_iterator_end(int dimension)
|
|
257
|
+
{
|
|
258
|
+
// this specific case works because the range is just a pair of iterators - won't work if range was a vector
|
|
259
|
+
return Base::skeleton_simplex_range(dimension).end();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
std::pair<Boundary_simplex_iterator, Boundary_simplex_iterator> get_boundary_iterators(const Simplex& simplex)
|
|
263
|
+
{
|
|
264
|
+
auto bd_sh = Base::find(simplex);
|
|
265
|
+
if (bd_sh == Base::null_simplex()) throw std::runtime_error("simplex not found - cannot find boundaries");
|
|
266
|
+
// this specific case works because the range is just a pair of iterators - won't work if range was a vector
|
|
267
|
+
auto boundary_srange = Base::boundary_simplex_range(bd_sh);
|
|
268
|
+
return std::make_pair(boundary_srange.begin(), boundary_srange.end());
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
} // namespace Gudhi
|
|
273
|
+
|
|
274
|
+
#endif // INCLUDE_SIMPLEX_TREE_INTERFACE_H_
|