multipers 2.3.3b6__cp312-cp312-macosx_10_13_x86_64.whl

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

Potentially problematic release.


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

Files changed (183) hide show
  1. multipers/.dylibs/libc++.1.0.dylib +0 -0
  2. multipers/.dylibs/libtbb.12.16.dylib +0 -0
  3. multipers/__init__.py +33 -0
  4. multipers/_signed_measure_meta.py +453 -0
  5. multipers/_slicer_meta.py +211 -0
  6. multipers/array_api/__init__.py +45 -0
  7. multipers/array_api/numpy.py +41 -0
  8. multipers/array_api/torch.py +58 -0
  9. multipers/data/MOL2.py +458 -0
  10. multipers/data/UCR.py +18 -0
  11. multipers/data/__init__.py +1 -0
  12. multipers/data/graphs.py +466 -0
  13. multipers/data/immuno_regions.py +27 -0
  14. multipers/data/minimal_presentation_to_st_bf.py +0 -0
  15. multipers/data/pytorch2simplextree.py +91 -0
  16. multipers/data/shape3d.py +101 -0
  17. multipers/data/synthetic.py +113 -0
  18. multipers/distances.py +202 -0
  19. multipers/filtration_conversions.pxd +229 -0
  20. multipers/filtration_conversions.pxd.tp +84 -0
  21. multipers/filtrations/__init__.py +18 -0
  22. multipers/filtrations/density.py +574 -0
  23. multipers/filtrations/filtrations.py +361 -0
  24. multipers/filtrations.pxd +224 -0
  25. multipers/function_rips.cpython-312-darwin.so +0 -0
  26. multipers/function_rips.pyx +105 -0
  27. multipers/grids.cpython-312-darwin.so +0 -0
  28. multipers/grids.pyx +433 -0
  29. multipers/gudhi/Persistence_slices_interface.h +132 -0
  30. multipers/gudhi/Simplex_tree_interface.h +239 -0
  31. multipers/gudhi/Simplex_tree_multi_interface.h +551 -0
  32. multipers/gudhi/cubical_to_boundary.h +59 -0
  33. multipers/gudhi/gudhi/Bitmap_cubical_complex.h +450 -0
  34. multipers/gudhi/gudhi/Bitmap_cubical_complex_base.h +1070 -0
  35. multipers/gudhi/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h +579 -0
  36. multipers/gudhi/gudhi/Debug_utils.h +45 -0
  37. multipers/gudhi/gudhi/Fields/Multi_field.h +484 -0
  38. multipers/gudhi/gudhi/Fields/Multi_field_operators.h +455 -0
  39. multipers/gudhi/gudhi/Fields/Multi_field_shared.h +450 -0
  40. multipers/gudhi/gudhi/Fields/Multi_field_small.h +531 -0
  41. multipers/gudhi/gudhi/Fields/Multi_field_small_operators.h +507 -0
  42. multipers/gudhi/gudhi/Fields/Multi_field_small_shared.h +531 -0
  43. multipers/gudhi/gudhi/Fields/Z2_field.h +355 -0
  44. multipers/gudhi/gudhi/Fields/Z2_field_operators.h +376 -0
  45. multipers/gudhi/gudhi/Fields/Zp_field.h +420 -0
  46. multipers/gudhi/gudhi/Fields/Zp_field_operators.h +400 -0
  47. multipers/gudhi/gudhi/Fields/Zp_field_shared.h +418 -0
  48. multipers/gudhi/gudhi/Flag_complex_edge_collapser.h +337 -0
  49. multipers/gudhi/gudhi/Matrix.h +2107 -0
  50. multipers/gudhi/gudhi/Multi_critical_filtration.h +1038 -0
  51. multipers/gudhi/gudhi/Multi_persistence/Box.h +174 -0
  52. multipers/gudhi/gudhi/Multi_persistence/Line.h +282 -0
  53. multipers/gudhi/gudhi/Off_reader.h +173 -0
  54. multipers/gudhi/gudhi/One_critical_filtration.h +1441 -0
  55. multipers/gudhi/gudhi/Persistence_matrix/Base_matrix.h +769 -0
  56. multipers/gudhi/gudhi/Persistence_matrix/Base_matrix_with_column_compression.h +686 -0
  57. multipers/gudhi/gudhi/Persistence_matrix/Boundary_matrix.h +842 -0
  58. multipers/gudhi/gudhi/Persistence_matrix/Chain_matrix.h +1350 -0
  59. multipers/gudhi/gudhi/Persistence_matrix/Id_to_index_overlay.h +1105 -0
  60. multipers/gudhi/gudhi/Persistence_matrix/Position_to_index_overlay.h +859 -0
  61. multipers/gudhi/gudhi/Persistence_matrix/RU_matrix.h +910 -0
  62. multipers/gudhi/gudhi/Persistence_matrix/allocators/entry_constructors.h +139 -0
  63. multipers/gudhi/gudhi/Persistence_matrix/base_pairing.h +230 -0
  64. multipers/gudhi/gudhi/Persistence_matrix/base_swap.h +211 -0
  65. multipers/gudhi/gudhi/Persistence_matrix/boundary_cell_position_to_id_mapper.h +60 -0
  66. multipers/gudhi/gudhi/Persistence_matrix/boundary_face_position_to_id_mapper.h +60 -0
  67. multipers/gudhi/gudhi/Persistence_matrix/chain_pairing.h +136 -0
  68. multipers/gudhi/gudhi/Persistence_matrix/chain_rep_cycles.h +190 -0
  69. multipers/gudhi/gudhi/Persistence_matrix/chain_vine_swap.h +616 -0
  70. multipers/gudhi/gudhi/Persistence_matrix/columns/chain_column_extra_properties.h +150 -0
  71. multipers/gudhi/gudhi/Persistence_matrix/columns/column_dimension_holder.h +106 -0
  72. multipers/gudhi/gudhi/Persistence_matrix/columns/column_utilities.h +219 -0
  73. multipers/gudhi/gudhi/Persistence_matrix/columns/entry_types.h +327 -0
  74. multipers/gudhi/gudhi/Persistence_matrix/columns/heap_column.h +1140 -0
  75. multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_list_column.h +934 -0
  76. multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_set_column.h +934 -0
  77. multipers/gudhi/gudhi/Persistence_matrix/columns/list_column.h +980 -0
  78. multipers/gudhi/gudhi/Persistence_matrix/columns/naive_vector_column.h +1092 -0
  79. multipers/gudhi/gudhi/Persistence_matrix/columns/row_access.h +192 -0
  80. multipers/gudhi/gudhi/Persistence_matrix/columns/set_column.h +921 -0
  81. multipers/gudhi/gudhi/Persistence_matrix/columns/small_vector_column.h +1093 -0
  82. multipers/gudhi/gudhi/Persistence_matrix/columns/unordered_set_column.h +1012 -0
  83. multipers/gudhi/gudhi/Persistence_matrix/columns/vector_column.h +1244 -0
  84. multipers/gudhi/gudhi/Persistence_matrix/matrix_dimension_holders.h +186 -0
  85. multipers/gudhi/gudhi/Persistence_matrix/matrix_row_access.h +164 -0
  86. multipers/gudhi/gudhi/Persistence_matrix/ru_pairing.h +156 -0
  87. multipers/gudhi/gudhi/Persistence_matrix/ru_rep_cycles.h +376 -0
  88. multipers/gudhi/gudhi/Persistence_matrix/ru_vine_swap.h +540 -0
  89. multipers/gudhi/gudhi/Persistent_cohomology/Field_Zp.h +118 -0
  90. multipers/gudhi/gudhi/Persistent_cohomology/Multi_field.h +173 -0
  91. multipers/gudhi/gudhi/Persistent_cohomology/Persistent_cohomology_column.h +128 -0
  92. multipers/gudhi/gudhi/Persistent_cohomology.h +745 -0
  93. multipers/gudhi/gudhi/Points_off_io.h +171 -0
  94. multipers/gudhi/gudhi/Simple_object_pool.h +69 -0
  95. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_iterators.h +463 -0
  96. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +83 -0
  97. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_siblings.h +106 -0
  98. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_star_simplex_iterators.h +277 -0
  99. multipers/gudhi/gudhi/Simplex_tree/hooks_simplex_base.h +62 -0
  100. multipers/gudhi/gudhi/Simplex_tree/indexing_tag.h +27 -0
  101. multipers/gudhi/gudhi/Simplex_tree/serialization_utils.h +62 -0
  102. multipers/gudhi/gudhi/Simplex_tree/simplex_tree_options.h +157 -0
  103. multipers/gudhi/gudhi/Simplex_tree.h +2794 -0
  104. multipers/gudhi/gudhi/Simplex_tree_multi.h +152 -0
  105. multipers/gudhi/gudhi/distance_functions.h +62 -0
  106. multipers/gudhi/gudhi/graph_simplicial_complex.h +104 -0
  107. multipers/gudhi/gudhi/persistence_interval.h +253 -0
  108. multipers/gudhi/gudhi/persistence_matrix_options.h +170 -0
  109. multipers/gudhi/gudhi/reader_utils.h +367 -0
  110. multipers/gudhi/mma_interface_coh.h +256 -0
  111. multipers/gudhi/mma_interface_h0.h +223 -0
  112. multipers/gudhi/mma_interface_matrix.h +293 -0
  113. multipers/gudhi/naive_merge_tree.h +536 -0
  114. multipers/gudhi/scc_io.h +310 -0
  115. multipers/gudhi/truc.h +1403 -0
  116. multipers/io.cpython-312-darwin.so +0 -0
  117. multipers/io.pyx +644 -0
  118. multipers/ml/__init__.py +0 -0
  119. multipers/ml/accuracies.py +90 -0
  120. multipers/ml/invariants_with_persistable.py +79 -0
  121. multipers/ml/kernels.py +176 -0
  122. multipers/ml/mma.py +713 -0
  123. multipers/ml/one.py +472 -0
  124. multipers/ml/point_clouds.py +352 -0
  125. multipers/ml/signed_measures.py +1589 -0
  126. multipers/ml/sliced_wasserstein.py +461 -0
  127. multipers/ml/tools.py +113 -0
  128. multipers/mma_structures.cpython-312-darwin.so +0 -0
  129. multipers/mma_structures.pxd +128 -0
  130. multipers/mma_structures.pyx +2786 -0
  131. multipers/mma_structures.pyx.tp +1094 -0
  132. multipers/multi_parameter_rank_invariant/diff_helpers.h +84 -0
  133. multipers/multi_parameter_rank_invariant/euler_characteristic.h +97 -0
  134. multipers/multi_parameter_rank_invariant/function_rips.h +322 -0
  135. multipers/multi_parameter_rank_invariant/hilbert_function.h +769 -0
  136. multipers/multi_parameter_rank_invariant/persistence_slices.h +148 -0
  137. multipers/multi_parameter_rank_invariant/rank_invariant.h +369 -0
  138. multipers/multiparameter_edge_collapse.py +41 -0
  139. multipers/multiparameter_module_approximation/approximation.h +2330 -0
  140. multipers/multiparameter_module_approximation/combinatory.h +129 -0
  141. multipers/multiparameter_module_approximation/debug.h +107 -0
  142. multipers/multiparameter_module_approximation/euler_curves.h +0 -0
  143. multipers/multiparameter_module_approximation/format_python-cpp.h +286 -0
  144. multipers/multiparameter_module_approximation/heap_column.h +238 -0
  145. multipers/multiparameter_module_approximation/images.h +79 -0
  146. multipers/multiparameter_module_approximation/list_column.h +174 -0
  147. multipers/multiparameter_module_approximation/list_column_2.h +232 -0
  148. multipers/multiparameter_module_approximation/ru_matrix.h +347 -0
  149. multipers/multiparameter_module_approximation/set_column.h +135 -0
  150. multipers/multiparameter_module_approximation/structure_higher_dim_barcode.h +36 -0
  151. multipers/multiparameter_module_approximation/unordered_set_column.h +166 -0
  152. multipers/multiparameter_module_approximation/utilities.h +403 -0
  153. multipers/multiparameter_module_approximation/vector_column.h +223 -0
  154. multipers/multiparameter_module_approximation/vector_matrix.h +331 -0
  155. multipers/multiparameter_module_approximation/vineyards.h +464 -0
  156. multipers/multiparameter_module_approximation/vineyards_trajectories.h +649 -0
  157. multipers/multiparameter_module_approximation.cpython-312-darwin.so +0 -0
  158. multipers/multiparameter_module_approximation.pyx +235 -0
  159. multipers/pickle.py +90 -0
  160. multipers/plots.py +456 -0
  161. multipers/point_measure.cpython-312-darwin.so +0 -0
  162. multipers/point_measure.pyx +395 -0
  163. multipers/simplex_tree_multi.cpython-312-darwin.so +0 -0
  164. multipers/simplex_tree_multi.pxd +134 -0
  165. multipers/simplex_tree_multi.pyx +10840 -0
  166. multipers/simplex_tree_multi.pyx.tp +2009 -0
  167. multipers/slicer.cpython-312-darwin.so +0 -0
  168. multipers/slicer.pxd +3034 -0
  169. multipers/slicer.pxd.tp +234 -0
  170. multipers/slicer.pyx +20481 -0
  171. multipers/slicer.pyx.tp +1088 -0
  172. multipers/tensor/tensor.h +672 -0
  173. multipers/tensor.pxd +13 -0
  174. multipers/test.pyx +44 -0
  175. multipers/tests/__init__.py +62 -0
  176. multipers/torch/__init__.py +1 -0
  177. multipers/torch/diff_grids.py +240 -0
  178. multipers/torch/rips_density.py +310 -0
  179. multipers-2.3.3b6.dist-info/METADATA +128 -0
  180. multipers-2.3.3b6.dist-info/RECORD +183 -0
  181. multipers-2.3.3b6.dist-info/WHEEL +6 -0
  182. multipers-2.3.3b6.dist-info/licenses/LICENSE +21 -0
  183. multipers-2.3.3b6.dist-info/top_level.txt +1 -0
@@ -0,0 +1,83 @@
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): Clément Maria
4
+ *
5
+ * Copyright (C) 2014 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ #ifndef SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
12
+ #define SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
13
+
14
+ // Empty base optimization for MSVC - https://learn.microsoft.com/en-us/cpp/cpp/empty-bases
15
+ #if _MSC_VER
16
+ #define GUDHI_EMPTY_BASE_CLASS_OPTIMIZATION __declspec(empty_bases)
17
+ #else
18
+ #define GUDHI_EMPTY_BASE_CLASS_OPTIMIZATION
19
+ #endif
20
+
21
+ #include <boost/core/empty_value.hpp>
22
+
23
+ namespace Gudhi {
24
+
25
+ /** \addtogroup simplex_tree
26
+ * Represents a node of a Simplex_tree.
27
+ * @{
28
+ */
29
+
30
+ /** \brief Node of a simplex tree with filtration value
31
+ * and simplex key.
32
+ *
33
+ * It stores explicitly its own filtration value and its own Simplex_key.
34
+ */
35
+ template <class SimplexTree>
36
+ struct GUDHI_EMPTY_BASE_CLASS_OPTIMIZATION Simplex_tree_node_explicit_storage
37
+ : SimplexTree::Filtration_simplex_base,
38
+ SimplexTree::Key_simplex_base,
39
+ SimplexTree::Hooks_simplex_base,
40
+ boost::empty_value<typename SimplexTree::Simplex_data> {
41
+ typedef typename SimplexTree::Siblings Siblings;
42
+ typedef typename SimplexTree::Filtration_value Filtration_value;
43
+ typedef typename SimplexTree::Simplex_key Simplex_key;
44
+ typedef typename SimplexTree::Simplex_data Simplex_data;
45
+
46
+ // Simplex_tree_node_explicit_storage() : children_(nullptr) {}
47
+
48
+ // Simplex_tree_node_explicit_storage(Siblings* sib, const Filtration_value& filtration) : children_(sib)
49
+ // {
50
+ // this->assign_filtration(filtration);
51
+ // }
52
+ Simplex_tree_node_explicit_storage(Siblings* sib = nullptr, const Filtration_value& filtration = Filtration_value())
53
+ : SimplexTree::Filtration_simplex_base(filtration), children_(sib)
54
+ {}
55
+
56
+ //will fail to compile when called with SimplexTree::Options::store_key is false.
57
+ Simplex_tree_node_explicit_storage(Siblings* sib, Filtration_value filtration, Simplex_key key)
58
+ : SimplexTree::Filtration_simplex_base(filtration), SimplexTree::Key_simplex_base(key), children_(sib)
59
+ {}
60
+
61
+ /*
62
+ * Assign children to the node
63
+ */
64
+ void assign_children(Siblings * children) {
65
+ children_ = children;
66
+ }
67
+
68
+ /* Careful -> children_ can be NULL*/
69
+ Siblings * children() {
70
+ return children_;
71
+ }
72
+
73
+ Simplex_data& data() { return boost::empty_value<Simplex_data>::get(); }
74
+
75
+ private:
76
+ Siblings * children_;
77
+ };
78
+
79
+ /** @}*/ // end addtogroup simplex_tree
80
+
81
+ } // namespace Gudhi
82
+
83
+ #endif // SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
@@ -0,0 +1,106 @@
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): Clément Maria
4
+ *
5
+ * Copyright (C) 2014 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ #ifndef SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_
12
+ #define SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_
13
+
14
+ #include <gudhi/Simplex_tree/simplex_tree_options.h>
15
+ #include <gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h>
16
+
17
+ #include <boost/container/flat_map.hpp>
18
+
19
+ namespace Gudhi {
20
+
21
+ /** \addtogroup simplex_tree
22
+ * Represents a set of node of a Simplex_tree that share the same parent.
23
+ * @{
24
+ */
25
+
26
+ /** \brief Data structure to store a set of nodes in a SimplexTree sharing
27
+ * the same parent node.*/
28
+ template<class SimplexTree, class MapContainer>
29
+ class Simplex_tree_siblings {
30
+ // private:
31
+ // friend SimplexTree;
32
+ public:
33
+ template<class T> friend class Simplex_tree_simplex_vertex_iterator;
34
+ template<class T> friend class Simplex_tree_boundary_simplex_iterator;
35
+ template<class T> friend class Simplex_tree_complex_simplex_iterator;
36
+ template<class T> friend class Simplex_tree_skeleton_simplex_iterator;
37
+ template<class T> friend class Simplex_tree_boundary_opposite_vertex_simplex_iterator;
38
+
39
+ typedef typename SimplexTree::Vertex_handle Vertex_handle;
40
+ typedef typename SimplexTree::Filtration_value Filtration_value;
41
+ typedef typename SimplexTree::Node Node;
42
+ typedef MapContainer Dictionary;
43
+ typedef typename MapContainer::iterator Dictionary_it;
44
+
45
+ /* Default constructor.*/
46
+ Simplex_tree_siblings()
47
+ : oncles_(nullptr),
48
+ parent_(-1),
49
+ members_() {
50
+ }
51
+
52
+ /* Constructor with values.*/
53
+ Simplex_tree_siblings(Simplex_tree_siblings * oncles, Vertex_handle parent)
54
+ : oncles_(oncles),
55
+ parent_(parent),
56
+ members_() {
57
+ }
58
+
59
+ /** \brief Constructor with initialized set of members.
60
+ *
61
+ * 'members' must be sorted and unique.*/
62
+ template<typename RandomAccessVertexRange>
63
+ Simplex_tree_siblings(Simplex_tree_siblings * oncles, Vertex_handle parent, const RandomAccessVertexRange & members)
64
+ : oncles_(oncles),
65
+ parent_(parent),
66
+ members_(boost::container::ordered_unique_range, members.begin(),
67
+ members.end()) {
68
+ for (auto& map_el : members_) {
69
+ map_el.second.assign_children(this);
70
+ }
71
+ }
72
+
73
+ Dictionary_it find(Vertex_handle v) {
74
+ return members_.find(v);
75
+ }
76
+
77
+ Simplex_tree_siblings * oncles() {
78
+ return oncles_;
79
+ }
80
+
81
+ Vertex_handle parent() const {
82
+ return parent_;
83
+ }
84
+
85
+ Dictionary & members() {
86
+ return members_;
87
+ }
88
+
89
+ size_t size() const {
90
+ return members_.size();
91
+ }
92
+
93
+ void erase(const Dictionary_it iterator) {
94
+ members_.erase(iterator);
95
+ }
96
+
97
+ Simplex_tree_siblings * oncles_;
98
+ Vertex_handle parent_;
99
+ Dictionary members_;
100
+ };
101
+
102
+ /** @}*/ // end addtogroup simplex_tree
103
+
104
+ } // namespace Gudhi
105
+
106
+ #endif // SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_
@@ -0,0 +1,277 @@
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): Clément Maria
4
+ *
5
+ * Copyright (C) 2020 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ #ifndef SIMPLEX_TREE_SIMPLEX_TREE_STAR_SIMPLEX_ITERATORS_H_
12
+ #define SIMPLEX_TREE_SIMPLEX_TREE_STAR_SIMPLEX_ITERATORS_H_
13
+
14
+ #include <gudhi/Debug_utils.h>
15
+ #include <boost/iterator/iterator_facade.hpp>
16
+ #include <boost/version.hpp>
17
+ #include <boost/iterator/filter_iterator.hpp>
18
+
19
+ #include <vector>
20
+ #include <stdexcept>
21
+ #include <utility> // for std::move
22
+ #include <functional> // for std::greater
23
+ #include <algorithm> // for std::includes
24
+
25
+ namespace Gudhi {
26
+
27
+ /** \private
28
+ * \brief Iterator over all the roots of subtrees containing cofaces of all
29
+ * dimension of a given simplex.
30
+ *
31
+ * Specifically, consider a simplex \f$\sigma\f$ whose vertices have maximal label
32
+ * u. A maximal subtree of cofaces for \f$\sigma\f$ is a subtree of the simplex tree
33
+ * rooted at a Node of label u, for which the root represents itself a coface of
34
+ * \f$\sigma\f$.
35
+ *
36
+ * \details All Nodes of the simplex must store intrusive list hooks (option
37
+ * link_nodes_by_label == true) in order to connect all nodes with a fixed label u
38
+ * into a list.
39
+ *
40
+ * Forward iterator, value_type is SimplexTree::Simplex_handle.
41
+ *
42
+ * The implementation uses a filter iterator on all Nodes of label u, checking
43
+ * whether they represent a coface of \f$\sigma\f$ or not.
44
+ */
45
+ template <class SimplexTree>
46
+ class Simplex_tree_optimized_cofaces_rooted_subtrees_simplex_iterator
47
+ : public boost::iterator_facade<Simplex_tree_optimized_cofaces_rooted_subtrees_simplex_iterator<SimplexTree>,
48
+ typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
49
+ public:
50
+ using Simplex_handle = typename SimplexTree::Simplex_handle;
51
+ using Siblings = typename SimplexTree::Siblings;
52
+ using Vertex_handle = typename SimplexTree::Vertex_handle;
53
+ using Node = typename SimplexTree::Node;
54
+ using Static_vertex_vector = typename SimplexTree::Static_vertex_vector;
55
+
56
+ /** \brief Predicate to check whether an input SimplexTree::Node represents a
57
+ * coface of a simplex simp_, stored as a std::vector of
58
+ * SimplexTree::Vertex_handle sorted in decreasing Vertex_handle order.
59
+ *
60
+ * \details Given a SimplexHandle in a simplex tree cpx_, traverses the tree
61
+ * upwards
62
+ * to find the sequence of Vertex_handle of simp_ as a subsequence of labels
63
+ * encountered.
64
+ * Does not test sh itself.
65
+ * Used for filter_iterator in the optimized algorithm for
66
+ * star_simplex_range.
67
+ */
68
+ class is_coface {
69
+ public:
70
+ is_coface() : cpx_(nullptr) {}
71
+ is_coface(SimplexTree* cpx, Static_vertex_vector&& simp) : cpx_(cpx), simp_(simp) {}
72
+
73
+ // Return true iff traversing the Node upwards to the root reads a
74
+ // coface of simp_
75
+ bool operator()(typename SimplexTree::Hooks_simplex_base& curr_hooks) {
76
+ Node& curr_node = static_cast<Node&>(curr_hooks);
77
+ Simplex_handle sh = cpx_->simplex_handle_from_node(curr_node);
78
+ // first Node must always have label simp_.begin(); we assume it is true
79
+ auto&& rng = cpx_->simplex_vertex_range(sh);
80
+ auto rng_it = rng.begin();
81
+ GUDHI_CHECK(*rng_it == simp_.front(), std::invalid_argument("first Node must always have label simp_.begin()"));
82
+ auto simp_it = simp_.begin();
83
+ // is simp_ a face of the simplex defined by sh ?
84
+ return std::includes(++rng_it, rng.end(), ++simp_it, simp_.end(), std::greater<Vertex_handle>());
85
+ }
86
+
87
+ private:
88
+ SimplexTree* cpx_;
89
+ Static_vertex_vector simp_; // vertices of simplex, in reverse order
90
+ };
91
+
92
+ typedef boost::filter_iterator<is_coface, typename SimplexTree::List_max_vertex::iterator>
93
+ Filtered_cofaces_simplex_iterator;
94
+ // any end() iterator
95
+ Simplex_tree_optimized_cofaces_rooted_subtrees_simplex_iterator() : predicate_(), st_(nullptr) {}
96
+
97
+ Simplex_tree_optimized_cofaces_rooted_subtrees_simplex_iterator(SimplexTree* cpx,
98
+ Static_vertex_vector&& simp)
99
+ : predicate_(cpx, std::move(simp)), st_(cpx) {
100
+ GUDHI_CHECK(!simp.empty(), std::invalid_argument("cannot call for cofaces of an empty simplex"));
101
+ auto list_ptr = st_->nodes_by_label(simp.front());
102
+ GUDHI_CHECK(list_ptr != nullptr, std::runtime_error("invalid call to cofaces forest"));
103
+
104
+ it_ = boost::make_filter_iterator(predicate_, list_ptr->begin(), list_ptr->end());
105
+ end_ = boost::make_filter_iterator(predicate_, list_ptr->end(), list_ptr->end());
106
+ Node& curr_node = static_cast<Node&>(*it_);
107
+ sh_ = st_->simplex_handle_from_node(curr_node);
108
+ }
109
+
110
+ private:
111
+ friend class boost::iterator_core_access;
112
+
113
+ // valid when iterating along the SAME list of max vertex.
114
+ bool equal(Simplex_tree_optimized_cofaces_rooted_subtrees_simplex_iterator const& other) const {
115
+ if (other.st_ == nullptr) {
116
+ return (st_ == nullptr);
117
+ }
118
+ if (st_ == nullptr) {
119
+ return false;
120
+ }
121
+ return (it_ == other.it_);
122
+ }
123
+
124
+ Simplex_handle const& dereference() const { return sh_; }
125
+
126
+ void increment() {
127
+ if (++it_ == end_) {
128
+ st_ = nullptr;
129
+ } //== end
130
+ else { // update sh_
131
+ Node& curr_node = static_cast<Node&>(*it_);
132
+ sh_ = st_->simplex_handle_from_node(curr_node);
133
+ }
134
+ }
135
+
136
+ // given a Node of label max_v, returns true if the associated simplex is a coface of the simplex {..., max_v}. The
137
+ // predicate stores the vertices of the simplex whose star we compute.
138
+ is_coface predicate_;
139
+ SimplexTree* st_;
140
+ // filtered iterators over Nodes, filtered with predicate_
141
+ Filtered_cofaces_simplex_iterator it_;
142
+ Filtered_cofaces_simplex_iterator end_;
143
+ // current Simplex_handle corresponding to Node pointed at by it_
144
+ Simplex_handle sh_;
145
+ };
146
+
147
+ /** \brief Iterator over the simplices of the star of a simplex.
148
+ *
149
+ * \details All Nodes of the simplex must store intrusive list hooks (option
150
+ * link_nodes_by_label == true) in order to connect all nodes with a fixed label u
151
+ * into a list.
152
+ *
153
+ * Forward iterator, value_type is SimplexTree::Simplex_handle.
154
+ *
155
+ * The implementation uses a
156
+ * Simplex_tree_optimized_cofaces_rooted_subtrees_simplex_iterator to iterate through all
157
+ * roots of cofaces Nodes, and traverses each such subtree of the simplex tree.
158
+ */
159
+ template <class SimplexTree>
160
+ class Simplex_tree_optimized_star_simplex_iterator
161
+ : public boost::iterator_facade<Simplex_tree_optimized_star_simplex_iterator<SimplexTree>,
162
+ typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
163
+ public:
164
+ using Simplex_handle = typename SimplexTree::Simplex_handle;
165
+ using Siblings = typename SimplexTree::Siblings;
166
+ using Vertex_handle = typename SimplexTree::Vertex_handle;
167
+ using Node = typename SimplexTree::Node;
168
+ using Static_vertex_vector = typename SimplexTree::Static_vertex_vector;
169
+
170
+ // any end() iterator
171
+ Simplex_tree_optimized_star_simplex_iterator() : st_(nullptr) {}
172
+
173
+ Simplex_tree_optimized_star_simplex_iterator(SimplexTree* cpx, Static_vertex_vector&& simp)
174
+ : st_(cpx), it_(cpx, std::move(simp)), end_(), sh_(*it_), sib_(st_->self_siblings(sh_)), children_stack_() {
175
+ if (it_ == end_) {
176
+ st_ = nullptr;
177
+ return;
178
+ } // no coface subtree => end()
179
+ is_root_ = true;
180
+ sh_ = *it_; // sh_ is the root
181
+ sib_ = st_->self_siblings(sh_); // Siblings containing sh_
182
+ if (st_->has_children(sh_)) {
183
+ children_stack_.push_back(st_->children(sh_));
184
+ }
185
+ return; // first root of coface subtree
186
+ }
187
+
188
+ private:
189
+ friend class boost::iterator_core_access;
190
+
191
+ // valid when iterating along the SAME list of max vertex.
192
+ bool equal(Simplex_tree_optimized_star_simplex_iterator const& other) const {
193
+ if (other.st_ == nullptr) {
194
+ return (st_ == nullptr);
195
+ }
196
+ if (st_ == nullptr) {
197
+ return false;
198
+ }
199
+ return (&(sh_->second) == &(other.sh_->second));
200
+ }
201
+
202
+ Simplex_handle const& dereference() const { return sh_; }
203
+
204
+ /* Go to the next valid Simplex_handle for a coface, using a breadth first
205
+ * search approach.
206
+ *
207
+ * Invariant:
208
+ *
209
+ * sh_ is a coface,
210
+ * sib_ the Siblings containing sh_,
211
+ * it_ the root of a coface subtree, such that dim_root_ <= exact_dim_cofaces_.
212
+ * bfs_queue contains Siblings inside the coface subtree.
213
+ *
214
+ * Additionally,
215
+ *
216
+ * - computing all cofaces: sh_ points to a coface of any dimension. bfs_queue
217
+ * contains a collection of Siblings* that must be considered (as well as there
218
+ * children). These are all sets of children of simplices in
219
+ * [ sib_->members().begin(), sh_ ]
220
+ */
221
+ void increment_all_cofaces() {
222
+ ++sh_; // next sibling
223
+ // if no more sibling or root of coface tree, go down or to next subtree
224
+ if (is_root_ || sh_ == sib_->members().end()) {
225
+ is_root_ = false;
226
+ if (!children_stack_.empty()) {
227
+ sib_ = children_stack_.back();
228
+ children_stack_.pop_back();
229
+ sh_ = sib_->members().begin(); // don't track dimensions
230
+ if (st_->has_children(sh_)) {
231
+ children_stack_.push_back(st_->children(sh_));
232
+ }
233
+ } else { // bfs_queue == empty, go to root of next coface subtree
234
+ if (++it_ == end_) {
235
+ st_ = nullptr;
236
+ return;
237
+ } // no more subtree => end()
238
+ is_root_ = true;
239
+ sh_ = *it_; // sh_ is the root
240
+ sib_ = st_->self_siblings(sh_); // Siblings containing sh_
241
+ if (st_->has_children(sh_)) {
242
+ children_stack_.push_back(st_->children(sh_));
243
+ }
244
+ return; // next root of coface
245
+ }
246
+ } else { // sh_ is valid, simply add its children to the queue
247
+ if (st_->has_children(sh_)) {
248
+ children_stack_.push_back(st_->children(sh_));
249
+ }
250
+ }
251
+ }
252
+
253
+ // For cofaces, enumerating all the star and testing which simplices have the right dimension is suboptimal.
254
+ // This could be optimized later.
255
+ void increment() { increment_all_cofaces(); }
256
+
257
+ // Let s be the simplex in a complex C whose star is
258
+ // iterated through. Let max_v denote the maximal label of vertices in s.
259
+ SimplexTree* st_; // Simplex tree for complex C
260
+ // The cofaces of s form a subforest of the simplex tree. The roots of trees in this
261
+ // forest have label max_v.
262
+ //[it_,end_) == range of Simplex_handles of the roots of the cofaces trees (any dim)
263
+ Simplex_tree_optimized_cofaces_rooted_subtrees_simplex_iterator<SimplexTree> it_;
264
+ Simplex_tree_optimized_cofaces_rooted_subtrees_simplex_iterator<SimplexTree> end_;
265
+ // curr Simplex_handle, returned by operator*, pointing to a coface of s
266
+ Simplex_handle sh_;
267
+ // set of siblings containing sh_ in the Simplex_tree
268
+ Siblings* sib_; //
269
+ // Save children in a list to avoid calling sib_->members().find(.)
270
+ std::vector<Siblings*> children_stack_;
271
+ // true iff sh_ points to the root of a coface subtree
272
+ bool is_root_;
273
+ };
274
+
275
+ } // namespace Gudhi
276
+
277
+ #endif // SIMPLEX_TREE_SIMPLEX_TREE_STAR_SIMPLEX_ITERATORS_H_
@@ -0,0 +1,62 @@
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): Clément Maria
4
+ *
5
+ * Copyright (C) 2020 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ #ifndef SIMPLEX_TREE_HOOKS_SIMPLEX_BASE_H_
12
+ #define SIMPLEX_TREE_HOOKS_SIMPLEX_BASE_H_
13
+
14
+ #include <boost/intrusive/list.hpp>
15
+ #include <stdexcept>
16
+
17
+ namespace Gudhi {
18
+ /** \brief No hook when SimplexTreeOptions::link_nodes_by_label is false.
19
+ */
20
+ struct Hooks_simplex_base_dummy {};
21
+
22
+ /** \brief Data structure to put all simplex tree nodes with same label into a list.
23
+ *
24
+ * Allows one to access all subtrees of the simplex tree rooted at a node with a given label.
25
+ * Used in particular for fast cofaces location, and fast insertion and deletion of edges in a flag complex.
26
+ *
27
+ * Only if SimplexTreeOptions::link_nodes_by_label is true.
28
+ */
29
+ struct Hooks_simplex_base_link_nodes {
30
+ public:
31
+ Hooks_simplex_base_link_nodes() {}
32
+ // The following 2 functions are conceptually wrong, but when copying a Simplex_tree it is more convenient to have
33
+ // them (and fix things asap after they are called).
34
+ // copy constructor, inherited by the Node class, requires to copy hooks
35
+ Hooks_simplex_base_link_nodes(const Hooks_simplex_base_link_nodes&)
36
+ : list_max_vertex_hook_() { }
37
+ // copy assignment
38
+ Hooks_simplex_base_link_nodes& operator=(const Hooks_simplex_base_link_nodes&) {
39
+ throw std::logic_error("Should not happen");
40
+ }
41
+ // move constructor
42
+ Hooks_simplex_base_link_nodes(Hooks_simplex_base_link_nodes&& other) {
43
+ list_max_vertex_hook_.swap_nodes(other.list_max_vertex_hook_);
44
+ }
45
+ // move assignment
46
+ Hooks_simplex_base_link_nodes& operator=(Hooks_simplex_base_link_nodes&& other) {
47
+ list_max_vertex_hook_.swap_nodes(other.list_max_vertex_hook_);
48
+ return *this;
49
+ }
50
+ void unlink_hooks() { list_max_vertex_hook_.unlink(); }
51
+ ~Hooks_simplex_base_link_nodes() {} // unlink_hooks(); }
52
+
53
+ typedef boost::intrusive::list_member_hook< // allows .unlink()
54
+ boost::intrusive::link_mode<boost::intrusive::auto_unlink>>
55
+ Member_hook_t;
56
+
57
+ Member_hook_t list_max_vertex_hook_;
58
+ };
59
+
60
+ } // namespace Gudhi
61
+
62
+ #endif // SIMPLEX_TREE_HOOKS_SIMPLEX_BASE_H_
@@ -0,0 +1,27 @@
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): Clément Maria
4
+ *
5
+ * Copyright (C) 2014 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ #ifndef SIMPLEX_TREE_INDEXING_TAG_H_
12
+ #define SIMPLEX_TREE_INDEXING_TAG_H_
13
+
14
+ namespace Gudhi {
15
+
16
+ /** \brief Tag for a linear ordering of simplices.
17
+ *
18
+ * \implements IndexingTag
19
+ */
20
+ struct linear_indexing_tag {
21
+ };
22
+
23
+ /** \brief Tag for a zigzag ordering of simplices. */
24
+ // struct zigzag_indexing_tag {};
25
+ } // namespace Gudhi
26
+
27
+ #endif // SIMPLEX_TREE_INDEXING_TAG_H_
@@ -0,0 +1,62 @@
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) 2023 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ #ifndef SIMPLEX_TREE_SERIALIZATION_UTILS_H_
12
+ #define SIMPLEX_TREE_SERIALIZATION_UTILS_H_
13
+
14
+ #include <cstring> // for memcpy and std::size_t
15
+
16
+ namespace Gudhi {
17
+
18
+ namespace simplex_tree {
19
+
20
+ /** \brief Serialize the given value and insert it at start position.
21
+ *
22
+ * @param[in] value The value to serialize.
23
+ * @param[in] start Start position where the value is serialized.
24
+ * @return The new position in the array of char for the next serialization.
25
+ *
26
+ * @warning It is the user's responsibility to provide a pointer to a buffer with enough memory space.
27
+ */
28
+ template<class ArgumentType>
29
+ char* serialize_trivial(ArgumentType value, char* start) {
30
+ std::size_t arg_size = sizeof(ArgumentType);
31
+ memcpy(start, &value, arg_size);
32
+ return start + arg_size;
33
+ }
34
+
35
+ /** \brief Deserialize at the start position in an array of char and sets the value with it.
36
+ *
37
+ * @param[in] value The value where to deserialize based on its type.
38
+ * @param[in] start Start position where the value is serialized.
39
+ * @return The new position in the array of char for the next deserialization.
40
+ *
41
+ * @warning It is the user's responsibility to ensure that the pointer will not go out of bounds.
42
+ */
43
+ template<class ArgumentType>
44
+ const char* deserialize_trivial(ArgumentType& value, const char* start) {
45
+ std::size_t arg_size = sizeof(ArgumentType);
46
+ memcpy(&value, start, arg_size);
47
+ return (start + arg_size);
48
+ }
49
+
50
+ /**
51
+ * @brief Returns the size of the serialization of the given object.
52
+ */
53
+ template<class ArgumentType>
54
+ constexpr std::size_t get_serialization_size_of([[maybe_unused]] ArgumentType value) {
55
+ return sizeof(ArgumentType);
56
+ }
57
+
58
+ } // namespace simplex_tree
59
+
60
+ } // namespace Gudhi
61
+
62
+ #endif // SIMPLEX_TREE_SERIALIZATION_UTILS_H_