multipers 2.3.3b6__cp311-cp311-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-311-darwin.so +0 -0
- multipers/function_rips.pyx +105 -0
- multipers/grids.cpython-311-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-311-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-311-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-311-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-311-darwin.so +0 -0
- multipers/point_measure.pyx +395 -0
- multipers/simplex_tree_multi.cpython-311-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-311-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,551 @@
|
|
|
1
|
+
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which
|
|
2
|
+
*is released under MIT. See file LICENSE or go to
|
|
3
|
+
*https://gudhi.inria.fr/licensing/ for full license details. Author(s): Vincent
|
|
4
|
+
*Rouvreau
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2016 Inria
|
|
7
|
+
*
|
|
8
|
+
* Modification(s):
|
|
9
|
+
* - 2022/11 David Loiseaux, Hannah Schreiber : adapt for
|
|
10
|
+
*multipersistence.
|
|
11
|
+
* - YYYY/MM Author: Description of the modification
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
#pragma once
|
|
15
|
+
|
|
16
|
+
#include "Simplex_tree_interface.h"
|
|
17
|
+
#include <cstddef>
|
|
18
|
+
#include <cstdint>
|
|
19
|
+
#include <gudhi/Simplex_tree_multi.h>
|
|
20
|
+
// #include <gudhi/Simplex_tree/multi_filtrations/Finitely_critical_filtrations.h>
|
|
21
|
+
#include "multiparameter_module_approximation/format_python-cpp.h"
|
|
22
|
+
|
|
23
|
+
#include <iostream>
|
|
24
|
+
#include <ranges>
|
|
25
|
+
#include <stdexcept>
|
|
26
|
+
#include <utility> // std::pair
|
|
27
|
+
#include <vector>
|
|
28
|
+
#include <limits> // has_quiet_NaN
|
|
29
|
+
|
|
30
|
+
namespace Gudhi {
|
|
31
|
+
namespace multiparameter {
|
|
32
|
+
namespace python_interface {
|
|
33
|
+
|
|
34
|
+
using interface_std = Simplex_tree<Simplex_tree_options_for_python>; // Interface not necessary
|
|
35
|
+
// (smaller so should do less
|
|
36
|
+
// segfaults)
|
|
37
|
+
|
|
38
|
+
template <class simplextreeinterface>
|
|
39
|
+
simplextreeinterface &get_simplextree_from_pointer(const uintptr_t splxptr) { // DANGER
|
|
40
|
+
simplextreeinterface &st = *(simplextreeinterface *)(splxptr);
|
|
41
|
+
return st;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
template <typename Filtration, typename value_type = typename Filtration::value_type>
|
|
45
|
+
class Simplex_tree_multi_interface
|
|
46
|
+
: public Simplex_tree_interface<
|
|
47
|
+
Gudhi::multi_persistence::Simplex_tree_options_multidimensional_filtration<Filtration>> {
|
|
48
|
+
public:
|
|
49
|
+
using SimplexTreeOptions = Gudhi::multi_persistence::Simplex_tree_options_multidimensional_filtration<Filtration>;
|
|
50
|
+
using Python_filtration_type = std::vector<typename SimplexTreeOptions::value_type>; // TODO :
|
|
51
|
+
// std::conditional
|
|
52
|
+
using Base = Simplex_tree<SimplexTreeOptions>;
|
|
53
|
+
using Filtration_value = typename Base::Filtration_value;
|
|
54
|
+
using Vertex_handle = typename Base::Vertex_handle;
|
|
55
|
+
using Simplex_handle = typename Base::Simplex_handle;
|
|
56
|
+
using Insertion_result = typename std::pair<Simplex_handle, bool>;
|
|
57
|
+
using Simplex = std::vector<Vertex_handle>;
|
|
58
|
+
using Simplex_and_filtration = std::pair<Simplex, Filtration_value *>;
|
|
59
|
+
using Filtered_simplices = std::vector<Simplex_and_filtration>;
|
|
60
|
+
using Skeleton_simplex_iterator = typename Base::Skeleton_simplex_iterator;
|
|
61
|
+
using Complex_simplex_iterator = typename Base::Complex_simplex_iterator;
|
|
62
|
+
using Extended_filtration_data = typename Base::Extended_filtration_data;
|
|
63
|
+
using Boundary_simplex_iterator = typename Base::Boundary_simplex_iterator;
|
|
64
|
+
typedef bool (*blocker_func_t)(Simplex simplex, void *user_data);
|
|
65
|
+
using euler_chars_type = std::vector<int>;
|
|
66
|
+
|
|
67
|
+
public:
|
|
68
|
+
static_assert(std::is_same_v<typename Base::Filtration_value, Filtration_value>,
|
|
69
|
+
"value_type has to be the same as Filtration::value_type. This is only a hack for python");
|
|
70
|
+
Extended_filtration_data efd;
|
|
71
|
+
|
|
72
|
+
bool find_simplex(const Simplex &simplex) { return (Base::find(simplex) != Base::null_simplex()); }
|
|
73
|
+
|
|
74
|
+
void assign_simplex_filtration(const Simplex &simplex, const Filtration_value &filtration) {
|
|
75
|
+
Base::assign_filtration(Base::find(simplex), filtration);
|
|
76
|
+
Base::clear_filtration();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
bool insert(const Simplex &simplex, const Filtration_value &filtration) {
|
|
80
|
+
Insertion_result result = Base::insert_simplex_and_subfaces(simplex, filtration);
|
|
81
|
+
if (result.first != Base::null_simplex()) Base::clear_filtration();
|
|
82
|
+
return (result.second);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Do not interface this function, only used in alpha complex interface for
|
|
86
|
+
// complex creation
|
|
87
|
+
bool insert_simplex(const Simplex &simplex, const Filtration_value &filtration) {
|
|
88
|
+
Insertion_result result = Base::insert_simplex(simplex, filtration);
|
|
89
|
+
return (result.second);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// bool insert_simplex(const Simplex& simplex, const Python_filtration_type&
|
|
93
|
+
// filtration ) {
|
|
94
|
+
// Filtration_value& filtration_ = *(Filtration_value*)(&filtration); //
|
|
95
|
+
// Jardinage for no copy. Insertion_result result =
|
|
96
|
+
// Base::insert_simplex(simplex, filtration); return (result.second);
|
|
97
|
+
// }
|
|
98
|
+
|
|
99
|
+
// Do not interface this function, only used in interface for complex creation
|
|
100
|
+
bool insert_simplex_and_subfaces(const Simplex &simplex, const Filtration_value &filtration) {
|
|
101
|
+
Insertion_result result = Base::insert_simplex_and_subfaces(simplex, filtration);
|
|
102
|
+
return (result.second);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// bool insert_simplex_and_subfaces(const Simplex& simplex, const
|
|
106
|
+
// Python_filtration_type& filtration ) {
|
|
107
|
+
// Filtration_value& filtration_ = *(Filtration_value*)(&filtration); //
|
|
108
|
+
// Jardinage for no copy. Insertion_result result =
|
|
109
|
+
// Base::insert_simplex_and_subfaces(simplex, filtration); return
|
|
110
|
+
// (result.second);
|
|
111
|
+
// }
|
|
112
|
+
|
|
113
|
+
// Do not interface this function, only used in strong witness interface for
|
|
114
|
+
// complex creation
|
|
115
|
+
bool insert_simplex(const std::vector<std::size_t> &simplex, const typename Filtration_value::Generator &filtration) {
|
|
116
|
+
Insertion_result result = Base::insert_simplex(simplex, filtration);
|
|
117
|
+
return (result.second);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Do not interface this function, only used in strong witness interface for
|
|
121
|
+
// complex creation
|
|
122
|
+
bool insert_simplex_and_subfaces(const std::vector<std::size_t> &simplex, const Filtration_value &filtration) {
|
|
123
|
+
Insertion_result result = Base::insert_simplex_and_subfaces(simplex, filtration);
|
|
124
|
+
return (result.second);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
typename SimplexTreeOptions::Filtration_value *simplex_filtration(const Simplex &simplex) {
|
|
128
|
+
auto &filtration = Base::filtration_mutable(Base::find(simplex));
|
|
129
|
+
return &filtration; // We return the pointer to get a numpy view
|
|
130
|
+
// afterward
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
Simplex_and_filtration get_simplex_and_filtration(Simplex_handle f_simplex) {
|
|
134
|
+
// Simplex simplex;
|
|
135
|
+
// for (auto vertex : Base::simplex_vertex_range(f_simplex)) {
|
|
136
|
+
// // simplex.insert(simplex.begin(), vertex); // why not push back ?
|
|
137
|
+
// }
|
|
138
|
+
auto it = Base::simplex_vertex_range(f_simplex);
|
|
139
|
+
Simplex simplex(it.begin(), it.end());
|
|
140
|
+
std::reverse(simplex.begin(), simplex.end());
|
|
141
|
+
return std::make_pair(std::move(simplex), &Base::filtration_mutable(f_simplex));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
Filtered_simplices get_star(const Simplex &simplex) {
|
|
145
|
+
Filtered_simplices star;
|
|
146
|
+
for (auto f_simplex : Base::star_simplex_range(Base::find(simplex))) {
|
|
147
|
+
Simplex simplex_star;
|
|
148
|
+
for (auto vertex : Base::simplex_vertex_range(f_simplex)) {
|
|
149
|
+
simplex_star.insert(simplex_star.begin(), vertex);
|
|
150
|
+
}
|
|
151
|
+
star.push_back(std::make_pair(simplex_star, &Base::filtration_mutable(f_simplex)));
|
|
152
|
+
}
|
|
153
|
+
return star;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
Filtered_simplices get_cofaces(const Simplex &simplex, int dimension) {
|
|
157
|
+
Filtered_simplices cofaces;
|
|
158
|
+
for (auto f_simplex : Base::cofaces_simplex_range(Base::find(simplex), dimension)) {
|
|
159
|
+
Simplex simplex_coface;
|
|
160
|
+
for (auto vertex : Base::simplex_vertex_range(f_simplex)) {
|
|
161
|
+
simplex_coface.insert(simplex_coface.begin(), vertex);
|
|
162
|
+
}
|
|
163
|
+
cofaces.push_back(std::make_pair(simplex_coface, &Base::filtration_mutable(f_simplex)));
|
|
164
|
+
}
|
|
165
|
+
return cofaces;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
void compute_extended_filtration() { throw std::logic_error("Incompatible with multipers"); }
|
|
169
|
+
|
|
170
|
+
Simplex_tree_multi_interface *collapse_edges([[maybe_unused]] int nb_collapse_iteration) {
|
|
171
|
+
throw std::logic_error("Incompatible with multipers");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// ######################## MULTIPERS STUFF
|
|
175
|
+
void set_keys_to_enumerate() {
|
|
176
|
+
int count = 0;
|
|
177
|
+
for (auto sh : Base::filtration_simplex_range()) Base::assign_key(sh, count++);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
int get_key(const Simplex &simplex) { return Base::key(Base::find(simplex)); }
|
|
181
|
+
|
|
182
|
+
void set_key(const Simplex &simplex, int key) {
|
|
183
|
+
Base::assign_key(Base::find(simplex), key);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Fills a parameter with a lower-star filtration
|
|
188
|
+
void fill_lowerstar(const std::vector<typename Filtration::value_type> &filtration, int axis) {
|
|
189
|
+
/* constexpr value_type minus_inf =
|
|
190
|
+
* -1*std::numeric_limits<value_type>::infinity(); */
|
|
191
|
+
std::vector<value_type> filtration_values_of_vertex;
|
|
192
|
+
for (auto &SimplexHandle : Base::complex_simplex_range()) {
|
|
193
|
+
auto ¤t_birth = Base::filtration_mutable(SimplexHandle);
|
|
194
|
+
/* value_type to_assign = minus_inf; */
|
|
195
|
+
filtration_values_of_vertex.clear();
|
|
196
|
+
for (auto vertex : Base::simplex_vertex_range(SimplexHandle)) {
|
|
197
|
+
if constexpr (std::numeric_limits<typename Filtration::value_type>::has_quiet_NaN)
|
|
198
|
+
/* to_assign = std::max(filtration[vertex], to_assign); */
|
|
199
|
+
if (std::isnan(filtration[vertex]))
|
|
200
|
+
std::cerr << "Invalid filtration for vertex " << vertex << " !!" << std::endl;
|
|
201
|
+
filtration_values_of_vertex.push_back(filtration[vertex]);
|
|
202
|
+
}
|
|
203
|
+
value_type to_assign = *std::max_element(filtration_values_of_vertex.begin(), filtration_values_of_vertex.end());
|
|
204
|
+
/* if (to_assign >10 || to_assign < -10 ) */
|
|
205
|
+
/* std::cout <<"to_assign : "<< to_assign << std::endl; */
|
|
206
|
+
current_birth[axis] = to_assign;
|
|
207
|
+
// Base::assign_filtration(SimplexHandle, current_birth);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
using simplices_list = std::vector<std::vector<int>>;
|
|
212
|
+
|
|
213
|
+
simplices_list get_simplices_of_dimension(int dimension) {
|
|
214
|
+
simplices_list simplex_list;
|
|
215
|
+
simplex_list.reserve(Base::num_simplices());
|
|
216
|
+
for (auto simplexhandle : Base::skeleton_simplex_range(dimension)) {
|
|
217
|
+
if (Base::dimension(simplexhandle) == dimension) {
|
|
218
|
+
std::vector<int> simplex;
|
|
219
|
+
simplex.reserve(dimension + 1);
|
|
220
|
+
for (int vertex : Base::simplex_vertex_range(simplexhandle)) simplex.push_back(vertex);
|
|
221
|
+
simplex_list.push_back(simplex);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/* simplex_list.shrink_to_fit();*/
|
|
225
|
+
return simplex_list;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
using edge_list = std::vector<std::pair<std::pair<int, int>, std::pair<double, double>>>;
|
|
229
|
+
|
|
230
|
+
edge_list get_edge_list() {
|
|
231
|
+
edge_list simplex_list;
|
|
232
|
+
simplex_list.reserve(Base::num_simplices());
|
|
233
|
+
for (auto &simplexHandle : Base::skeleton_simplex_range(1)) {
|
|
234
|
+
if (Base::dimension(simplexHandle) == 1) {
|
|
235
|
+
std::pair<int, int> simplex;
|
|
236
|
+
auto it = Base::simplex_vertex_range(simplexHandle).begin();
|
|
237
|
+
simplex = {*it, *(++it)};
|
|
238
|
+
const auto &f = Base::filtration(simplexHandle);
|
|
239
|
+
simplex_list.push_back({simplex, {static_cast<double>(f[0]), static_cast<double>(f[1])}});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return simplex_list;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
void resize_all_filtrations(int num) {
|
|
246
|
+
if (num < 0) return;
|
|
247
|
+
for (const auto &SimplexHandle : Base::complex_simplex_range()) {
|
|
248
|
+
if constexpr (Filtration::is_multi_critical) {
|
|
249
|
+
for (auto &stuff : Base::filtration_mutable(SimplexHandle)) stuff.resize(num);
|
|
250
|
+
} else
|
|
251
|
+
Base::filtration_mutable(SimplexHandle).resize(num);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
void from_std(char *buffer_start, std::size_t buffer_size, int dimension, const Filtration &default_values) {
|
|
256
|
+
interface_std st;
|
|
257
|
+
st.deserialize(buffer_start, buffer_size);
|
|
258
|
+
Gudhi::multi_persistence::multify(st, *this, dimension, default_values);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
template <typename Line_like>
|
|
262
|
+
void to_std(intptr_t ptr, const Line_like &line, int dimension) {
|
|
263
|
+
interface_std &st = get_simplextree_from_pointer<interface_std>(ptr);
|
|
264
|
+
|
|
265
|
+
for (const auto &simplex_handle : this->complex_simplex_range()) {
|
|
266
|
+
std::vector<int> simplex;
|
|
267
|
+
for (auto vertex : this->simplex_vertex_range(simplex_handle)) simplex.push_back(vertex);
|
|
268
|
+
|
|
269
|
+
// Filtration as double
|
|
270
|
+
const auto &f = this->filtration(simplex_handle).template as_type<typename interface_std::Filtration_value>();
|
|
271
|
+
|
|
272
|
+
typename interface_std::Filtration_value new_filtration = line[line.compute_forward_intersection(f)][dimension];
|
|
273
|
+
st.insert_simplex(simplex, new_filtration);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
void to_std_linear_projection(intptr_t ptr, std::vector<double> linear_form) {
|
|
278
|
+
interface_std &st = get_simplextree_from_pointer<interface_std>(ptr);
|
|
279
|
+
Gudhi::multi_persistence::linear_projection(st, *this, linear_form);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
void squeeze_filtration_inplace(const std::vector<std::vector<double>> &grid, const bool coordinate_values = true) {
|
|
283
|
+
std::size_t num_parameters = this->get_number_of_parameters();
|
|
284
|
+
if (grid.size() != num_parameters) {
|
|
285
|
+
throw std::invalid_argument("Grid and simplextree do not agree on number of parameters.");
|
|
286
|
+
}
|
|
287
|
+
for (const auto &simplex_handle : this->complex_simplex_range()) {
|
|
288
|
+
auto &simplex_filtration = this->filtration_mutable(simplex_handle);
|
|
289
|
+
const auto &coords = compute_coordinates_in_grid(simplex_filtration, grid);
|
|
290
|
+
if (coordinate_values)
|
|
291
|
+
simplex_filtration = coords.template as_type<value_type>();
|
|
292
|
+
else
|
|
293
|
+
simplex_filtration = evaluate_coordinates_in_grid(coords, grid).template as_type<value_type>();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
void unsqueeze_filtration(const intptr_t grid_st_ptr,
|
|
298
|
+
const std::vector<std::vector<double>> &grid) { // TODO : this is const but GUDHI
|
|
299
|
+
if constexpr (Filtration::is_multicritical())
|
|
300
|
+
throw std::invalid_argument("Multicritical not supported yet");
|
|
301
|
+
else {
|
|
302
|
+
constexpr const bool verbose = false;
|
|
303
|
+
using int_fil_type = decltype(std::declval<Filtration>().template as_type<std::int32_t>());
|
|
304
|
+
using st_coord_type = Simplex_tree_multi_interface<int_fil_type, int32_t>;
|
|
305
|
+
st_coord_type &grid_st = *(st_coord_type *)grid_st_ptr; // TODO : maybe fix this.
|
|
306
|
+
std::vector<int> simplex_vertex;
|
|
307
|
+
int num_parameters = grid_st.get_number_of_parameters();
|
|
308
|
+
for (auto &simplex_handle : grid_st.complex_simplex_range()) {
|
|
309
|
+
const auto &simplex_filtration = grid_st.filtration(simplex_handle);
|
|
310
|
+
if constexpr (verbose) std::cout << "Filtration " << simplex_filtration << "\n";
|
|
311
|
+
Filtration splx_filtration(simplex_filtration.size(), 1.);
|
|
312
|
+
if (simplex_filtration.is_finite()) {
|
|
313
|
+
for (auto i : std::views::iota(num_parameters)) splx_filtration[i] = grid[i][simplex_filtration[i]];
|
|
314
|
+
} else if (simplex_filtration.is_plus_inf()) {
|
|
315
|
+
splx_filtration = Filtration().inf();
|
|
316
|
+
} else if (simplex_filtration.is_minus_inf()) {
|
|
317
|
+
splx_filtration = Filtration().minus_inf();
|
|
318
|
+
} else if (simplex_filtration.is_nan()) {
|
|
319
|
+
splx_filtration = Filtration().nan();
|
|
320
|
+
}
|
|
321
|
+
if constexpr (verbose) std::cout << "Filtration " << splx_filtration << "\n";
|
|
322
|
+
for (const auto s : grid_st.simplex_vertex_range(simplex_handle)) simplex_vertex.push_back(s);
|
|
323
|
+
this->insert_simplex(simplex_vertex, splx_filtration);
|
|
324
|
+
if constexpr (verbose) std::cout << "Coords in st" << this->filtration(this->find(simplex_vertex)) << std::endl;
|
|
325
|
+
simplex_vertex.clear();
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
void squeeze_filtration(const intptr_t outptr,
|
|
331
|
+
const std::vector<std::vector<double>> &grid) { // TODO : this is const but GUDHI
|
|
332
|
+
constexpr const bool verbose = false;
|
|
333
|
+
using int_fil_type = decltype(std::declval<Filtration>().template as_type<std::int32_t>());
|
|
334
|
+
using st_coord_type = Simplex_tree_multi_interface<int_fil_type, int32_t>;
|
|
335
|
+
st_coord_type &out = *(st_coord_type *)outptr; // TODO : maybe fix this.
|
|
336
|
+
std::vector<int> simplex_vertex;
|
|
337
|
+
for (const auto &simplex_handle : this->complex_simplex_range()) {
|
|
338
|
+
const auto &simplex_filtration = this->filtration(simplex_handle);
|
|
339
|
+
if constexpr (verbose) std::cout << "Filtration " << simplex_filtration << "\n";
|
|
340
|
+
const auto &coords = compute_coordinates_in_grid(simplex_filtration, grid);
|
|
341
|
+
if constexpr (verbose) std::cout << "Coords " << coords << "\n";
|
|
342
|
+
for (auto s : this->simplex_vertex_range(simplex_handle)) simplex_vertex.push_back(s);
|
|
343
|
+
out.insert_simplex(simplex_vertex, coords);
|
|
344
|
+
if constexpr (verbose) std::cout << "Coords in st" << out.filtration(out.find(simplex_vertex)) << std::endl;
|
|
345
|
+
simplex_vertex.clear();
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
std::vector<std::vector<std::vector<value_type>>> // dim, pts, param
|
|
350
|
+
get_filtration_values(const std::vector<int> °rees) {
|
|
351
|
+
using multi_filtration_grid = std::vector<std::vector<value_type>>;
|
|
352
|
+
int num_parameters = this->get_number_of_parameters();
|
|
353
|
+
std::vector<multi_filtration_grid> out(degrees.size(), multi_filtration_grid(num_parameters));
|
|
354
|
+
std::vector<int> degree_index(this->dimension() + 1);
|
|
355
|
+
int count = 0;
|
|
356
|
+
for (auto degree : degrees) {
|
|
357
|
+
degree_index[degree] = count++;
|
|
358
|
+
out[degree_index[degree]].reserve(this->num_simplices());
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
for (const auto &simplex_handle : this->complex_simplex_range()) {
|
|
362
|
+
const auto &filtration = this->filtration(simplex_handle);
|
|
363
|
+
const auto degree = this->dimension(simplex_handle);
|
|
364
|
+
if (std::find(degrees.begin(), degrees.end(), degree) == degrees.end()) continue;
|
|
365
|
+
// for (int parameter = 0; parameter < num_parameters; parameter++) {
|
|
366
|
+
// out[degree_index[degree]][parameter].push_back(filtration[parameter]);
|
|
367
|
+
// }
|
|
368
|
+
if constexpr (Filtration::is_multi_critical)
|
|
369
|
+
for (std::size_t i = 0; i < filtration.num_generators(); i++)
|
|
370
|
+
for (int parameter = 0; parameter < num_parameters; parameter++)
|
|
371
|
+
out[degree_index[degree]][parameter].push_back(filtration[i][parameter]);
|
|
372
|
+
else
|
|
373
|
+
for (int parameter = 0; parameter < num_parameters; parameter++)
|
|
374
|
+
out[degree_index[degree]][parameter].push_back(filtration[parameter]);
|
|
375
|
+
}
|
|
376
|
+
return out;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
using boundary_type = std::vector<unsigned int>;
|
|
380
|
+
using boundary_matrix = std::vector<boundary_type>;
|
|
381
|
+
|
|
382
|
+
using scc_type = mma::scc_type<SimplexTreeOptions>;
|
|
383
|
+
|
|
384
|
+
scc_type inline simplextree_to_scc() { return Gudhi::multiparameter::mma::simplextree_to_scc(*this); }
|
|
385
|
+
|
|
386
|
+
using kscc_type = mma::kscc_type<SimplexTreeOptions>;
|
|
387
|
+
|
|
388
|
+
kscc_type inline kcritical_simplextree_to_scc() {
|
|
389
|
+
if constexpr (SimplexTreeOptions::Filtration_value::is_multi_critical)
|
|
390
|
+
return Gudhi::multiparameter::mma::kcritical_simplextree_to_scc(*this);
|
|
391
|
+
else
|
|
392
|
+
return {};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
using function_scc_type = std::vector<std::pair<std::vector<std::vector<std::vector<value_type>>>, boundary_matrix>>;
|
|
396
|
+
|
|
397
|
+
function_scc_type inline function_simplextree_to_scc() {
|
|
398
|
+
return Gudhi::multiparameter::mma::function_simplextree_to_scc(*this);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
using flattened_scc_type = std::pair<std::vector<std::vector<value_type>>, std::vector<std::vector<unsigned int>>>;
|
|
402
|
+
|
|
403
|
+
flattened_scc_type inline simplextree_to_ordered_bf() {
|
|
404
|
+
return Gudhi::multiparameter::mma::simplextree_to_ordered_bf(*this);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Diff / grid stuff
|
|
408
|
+
|
|
409
|
+
using idx_map_type = std::vector<std::map<typename Filtration::value_type, int32_t>>;
|
|
410
|
+
|
|
411
|
+
inline idx_map_type build_idx_map(const std::vector<int> &simplices_dimensions) {
|
|
412
|
+
static_assert(!Filtration::is_multi_critical, "Multicritical not supported yet");
|
|
413
|
+
auto num_parameters = this->get_number_of_parameters();
|
|
414
|
+
if (static_cast<int>(simplices_dimensions.size()) < num_parameters) throw;
|
|
415
|
+
int max_dim = *std::max_element(simplices_dimensions.begin(), simplices_dimensions.end());
|
|
416
|
+
int min_dim = *std::min_element(simplices_dimensions.begin(), simplices_dimensions.end());
|
|
417
|
+
max_dim = min_dim >= 0 ? max_dim : this->dimension();
|
|
418
|
+
|
|
419
|
+
idx_map_type idx_map(num_parameters);
|
|
420
|
+
auto splx_idx = 0u;
|
|
421
|
+
for (auto sh : this->complex_simplex_range()) { // order has to be retrieved later, so I'm
|
|
422
|
+
// not sure that skeleton iterator is well
|
|
423
|
+
// suited
|
|
424
|
+
const auto &splx_filtration = this->filtration(sh);
|
|
425
|
+
const auto splx_dim = this->dimension(sh);
|
|
426
|
+
if (splx_dim <= max_dim)
|
|
427
|
+
for (auto i = 0u; i < splx_filtration.size(); i++) {
|
|
428
|
+
if (simplices_dimensions[i] != splx_dim && simplices_dimensions[i] != -1) continue;
|
|
429
|
+
auto f = splx_filtration[i];
|
|
430
|
+
idx_map[i].try_emplace(f, splx_idx);
|
|
431
|
+
}
|
|
432
|
+
splx_idx++;
|
|
433
|
+
}
|
|
434
|
+
return idx_map;
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
using pts_indices_type = std::vector<std::vector<int32_t>>;
|
|
438
|
+
|
|
439
|
+
static std::pair<pts_indices_type, pts_indices_type> inline get_pts_indices(
|
|
440
|
+
const idx_map_type &idx_map,
|
|
441
|
+
const std::vector<std::vector<typename Filtration::value_type>> &pts) {
|
|
442
|
+
static_assert(!Filtration::is_multi_critical, "Multicritical not supported yet");
|
|
443
|
+
std::size_t num_pts = pts.size();
|
|
444
|
+
std::size_t num_parameters = idx_map.size();
|
|
445
|
+
pts_indices_type out_indices(num_pts,
|
|
446
|
+
std::vector<int32_t>(num_parameters,
|
|
447
|
+
-1)); // -1 to be able from indicies to
|
|
448
|
+
// get if the pt is found or not
|
|
449
|
+
pts_indices_type out_unmapped_values;
|
|
450
|
+
for (auto pt_idx = 0u; pt_idx < num_pts; pt_idx++) {
|
|
451
|
+
auto &pt = pts[pt_idx];
|
|
452
|
+
auto &pt_indices = out_indices[pt_idx];
|
|
453
|
+
|
|
454
|
+
for (std::size_t parameter = 0u; parameter < num_parameters; parameter++) {
|
|
455
|
+
value_type f = pt[parameter];
|
|
456
|
+
const std::map<value_type, int32_t> ¶meter_map = idx_map[parameter];
|
|
457
|
+
auto it = parameter_map.find(f);
|
|
458
|
+
if (it == parameter_map.end())
|
|
459
|
+
out_unmapped_values.push_back({static_cast<int32_t>(pt_idx), static_cast<int32_t>(parameter)});
|
|
460
|
+
else
|
|
461
|
+
pt_indices[parameter] = it->second;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return {out_indices, out_unmapped_values}; // TODO return a ptr for python
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
std::pair<pts_indices_type, pts_indices_type> inline pts_to_indices(
|
|
468
|
+
const std::vector<std::vector<typename Filtration::value_type>> &pts,
|
|
469
|
+
const std::vector<int> &simplices_dimensions) {
|
|
470
|
+
return get_pts_indices(this->build_idx_map(simplices_dimensions), pts);
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
template <typename Filtration>
|
|
475
|
+
using interface_multi = Simplex_tree_multi_interface<
|
|
476
|
+
Gudhi::multi_persistence::Simplex_tree_options_multidimensional_filtration<Filtration>>;
|
|
477
|
+
|
|
478
|
+
// Wrappers of the functions in Simplex_tree_multi.h, to deal with the "pointer
|
|
479
|
+
// only" python interface
|
|
480
|
+
template <typename Filtration>
|
|
481
|
+
void inline flatten_diag_from_ptr(const uintptr_t splxptr,
|
|
482
|
+
const uintptr_t newsplxptr,
|
|
483
|
+
const std::vector<typename Filtration::value_type> basepoint,
|
|
484
|
+
int dimension) { // for python
|
|
485
|
+
auto &st = get_simplextree_from_pointer<interface_std>(newsplxptr);
|
|
486
|
+
auto &st_multi = get_simplextree_from_pointer<interface_multi<Filtration>>(splxptr);
|
|
487
|
+
flatten_diag(st, st_multi, basepoint, dimension);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
template <typename Filtration>
|
|
491
|
+
void inline multify_from_ptr(uintptr_t splxptr,
|
|
492
|
+
uintptr_t newsplxptr,
|
|
493
|
+
const int dimension,
|
|
494
|
+
const Filtration &default_values) { // for python
|
|
495
|
+
auto &st = get_simplextree_from_pointer<interface_std>(splxptr);
|
|
496
|
+
auto &st_multi = get_simplextree_from_pointer<interface_multi<Filtration>>(newsplxptr);
|
|
497
|
+
Gudhi::multi_persistence::multify(st, st_multi, dimension, default_values);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
template <typename Filtration>
|
|
501
|
+
void inline flatten_from_ptr(uintptr_t splxptr,
|
|
502
|
+
uintptr_t newsplxptr,
|
|
503
|
+
const int dimension = 0) { // for python
|
|
504
|
+
auto &st = get_simplextree_from_pointer<interface_std>(newsplxptr);
|
|
505
|
+
auto &st_multi = get_simplextree_from_pointer<interface_multi<Filtration>>(splxptr);
|
|
506
|
+
Gudhi::multi_persistence::flatten(st, st_multi, dimension);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
template <typename Filtration, typename... Args>
|
|
510
|
+
void inline linear_projection_from_ptr(const uintptr_t ptr, const uintptr_t ptr_multi, Args... args) {
|
|
511
|
+
auto &st = get_simplextree_from_pointer<interface_std>(ptr);
|
|
512
|
+
auto &st_multi = get_simplextree_from_pointer<interface_multi<Filtration>>(ptr_multi);
|
|
513
|
+
Gudhi::multi_persistence::linear_projection(st, st_multi, args...);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
template <typename Filtration = typename Gudhi::multi_filtration::One_critical_filtration<float>>
|
|
517
|
+
using options_multi = Gudhi::multi_persistence::Simplex_tree_options_multidimensional_filtration<Filtration>;
|
|
518
|
+
|
|
519
|
+
template <typename Filtration, typename... Args>
|
|
520
|
+
void inline squeeze_filtration_from_ptr(uintptr_t splxptr, Args... args) {
|
|
521
|
+
Simplex_tree<options_multi<Filtration>> &st_multi = *(Gudhi::Simplex_tree<options_multi<Filtration>> *)(splxptr);
|
|
522
|
+
squeeze_filtration(st_multi, args...);
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
template <typename Filtration, typename... Args>
|
|
527
|
+
inline std::vector<std::vector<std::vector<Filtration>>> get_filtration_values_from_ptr(uintptr_t splxptr,
|
|
528
|
+
Args... args) {
|
|
529
|
+
Simplex_tree<options_multi<Filtration>> &st_multi = *(Gudhi::Simplex_tree<options_multi<Filtration>> *)(splxptr);
|
|
530
|
+
return get_filtration_values(st_multi, args...);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// Final types
|
|
534
|
+
//
|
|
535
|
+
//
|
|
536
|
+
|
|
537
|
+
template <typename Filtration>
|
|
538
|
+
using Simplex_tree_multi_simplex_handle = typename Simplex_tree_multi_interface<Filtration>::Simplex_handle;
|
|
539
|
+
|
|
540
|
+
template <typename Filtration>
|
|
541
|
+
using Simplex_tree_multi_simplices_iterator =
|
|
542
|
+
typename Simplex_tree_multi_interface<Filtration>::Complex_simplex_iterator;
|
|
543
|
+
template <typename Filtration>
|
|
544
|
+
using Simplex_tree_multi_skeleton_iterator =
|
|
545
|
+
typename Simplex_tree_multi_interface<Filtration>::Skeleton_simplex_iterator;
|
|
546
|
+
template <typename Filtration>
|
|
547
|
+
using Simplex_tree_multi_boundary_iterator =
|
|
548
|
+
typename Simplex_tree_multi_interface<Filtration>::Boundary_simplex_iterator;
|
|
549
|
+
} // namespace python_interface
|
|
550
|
+
} // namespace multiparameter
|
|
551
|
+
} // namespace Gudhi
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#ifndef MULTIPERS_CUBICAL_CONV_H
|
|
2
|
+
#define MULTIPERS_CUBICAL_CONV_H
|
|
3
|
+
|
|
4
|
+
#include <vector>
|
|
5
|
+
#include <set>
|
|
6
|
+
|
|
7
|
+
#include <gudhi/Bitmap_cubical_complex.h>
|
|
8
|
+
|
|
9
|
+
inline void _to_boundary(const std::vector<unsigned int>& shape,
|
|
10
|
+
std::vector<std::vector<unsigned int> >& generator_maps,
|
|
11
|
+
std::vector<int>& generator_dimensions) {
|
|
12
|
+
using Bitmap_cubical_complex_base = Gudhi::cubical_complex::Bitmap_cubical_complex_base<char>;
|
|
13
|
+
using Bitmap_cubical_complex = Gudhi::cubical_complex::Bitmap_cubical_complex<Bitmap_cubical_complex_base>;
|
|
14
|
+
using Simplex_handle = Bitmap_cubical_complex::Simplex_handle;
|
|
15
|
+
|
|
16
|
+
if (shape.empty()) return;
|
|
17
|
+
|
|
18
|
+
unsigned int size = 1;
|
|
19
|
+
for (auto v : shape) size *= v;
|
|
20
|
+
|
|
21
|
+
std::vector<char> vertices(size);
|
|
22
|
+
Bitmap_cubical_complex cub(shape, vertices, false);
|
|
23
|
+
|
|
24
|
+
unsigned int dimMax = shape.size();
|
|
25
|
+
std::vector<std::vector<Simplex_handle> > faces(dimMax + 1);
|
|
26
|
+
unsigned int numberOfSimplices = 0;
|
|
27
|
+
for (unsigned int d = 0; d < dimMax + 1; ++d) {
|
|
28
|
+
for ([[maybe_unused]] auto sh : cub.skeleton_simplex_range(d)) {
|
|
29
|
+
++numberOfSimplices;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
generator_dimensions.resize(numberOfSimplices);
|
|
34
|
+
generator_maps.resize(numberOfSimplices);
|
|
35
|
+
unsigned int i = 0;
|
|
36
|
+
for (unsigned int d = 0; d < dimMax + 1; ++d) {
|
|
37
|
+
for (auto sh : cub.skeleton_simplex_range(d)) {
|
|
38
|
+
cub.assign_key(sh, i);
|
|
39
|
+
generator_dimensions[i] = d;
|
|
40
|
+
auto& col = generator_maps[i];
|
|
41
|
+
for (auto b : cub.boundary_simplex_range(sh)) col.push_back(cub.key(b));
|
|
42
|
+
std::sort(col.begin(), col.end());
|
|
43
|
+
++i;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
inline void get_vertices(unsigned int i,
|
|
49
|
+
std::set<unsigned int>& vertices,
|
|
50
|
+
const std::vector<std::vector<unsigned int> >& generator_maps) {
|
|
51
|
+
if (generator_maps[i].empty()) {
|
|
52
|
+
vertices.insert(i);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
for (auto v : generator_maps[i]) get_vertices(v, vertices, generator_maps);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#endif // MULTIPERS_CUBICAL_CONV_H
|