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.
Files changed (184) hide show
  1. multipers/.dylibs/libboost_timer.dylib +0 -0
  2. multipers/.dylibs/libc++.1.0.dylib +0 -0
  3. multipers/.dylibs/libtbb.12.17.dylib +0 -0
  4. multipers/__init__.py +33 -0
  5. multipers/_signed_measure_meta.py +426 -0
  6. multipers/_slicer_meta.py +231 -0
  7. multipers/array_api/__init__.py +62 -0
  8. multipers/array_api/numpy.py +124 -0
  9. multipers/array_api/torch.py +133 -0
  10. multipers/data/MOL2.py +458 -0
  11. multipers/data/UCR.py +18 -0
  12. multipers/data/__init__.py +1 -0
  13. multipers/data/graphs.py +466 -0
  14. multipers/data/immuno_regions.py +27 -0
  15. multipers/data/minimal_presentation_to_st_bf.py +0 -0
  16. multipers/data/pytorch2simplextree.py +91 -0
  17. multipers/data/shape3d.py +101 -0
  18. multipers/data/synthetic.py +113 -0
  19. multipers/distances.py +202 -0
  20. multipers/filtration_conversions.pxd +736 -0
  21. multipers/filtration_conversions.pxd.tp +226 -0
  22. multipers/filtrations/__init__.py +21 -0
  23. multipers/filtrations/density.py +529 -0
  24. multipers/filtrations/filtrations.py +480 -0
  25. multipers/filtrations.pxd +534 -0
  26. multipers/filtrations.pxd.tp +332 -0
  27. multipers/function_rips.cpython-312-darwin.so +0 -0
  28. multipers/function_rips.pyx +104 -0
  29. multipers/grids.cpython-312-darwin.so +0 -0
  30. multipers/grids.pyx +538 -0
  31. multipers/gudhi/Persistence_slices_interface.h +213 -0
  32. multipers/gudhi/Simplex_tree_interface.h +274 -0
  33. multipers/gudhi/Simplex_tree_multi_interface.h +648 -0
  34. multipers/gudhi/gudhi/Bitmap_cubical_complex.h +450 -0
  35. multipers/gudhi/gudhi/Bitmap_cubical_complex_base.h +1070 -0
  36. multipers/gudhi/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h +579 -0
  37. multipers/gudhi/gudhi/Debug_utils.h +52 -0
  38. multipers/gudhi/gudhi/Degree_rips_bifiltration.h +2307 -0
  39. multipers/gudhi/gudhi/Dynamic_multi_parameter_filtration.h +2524 -0
  40. multipers/gudhi/gudhi/Fields/Multi_field.h +453 -0
  41. multipers/gudhi/gudhi/Fields/Multi_field_operators.h +460 -0
  42. multipers/gudhi/gudhi/Fields/Multi_field_shared.h +444 -0
  43. multipers/gudhi/gudhi/Fields/Multi_field_small.h +584 -0
  44. multipers/gudhi/gudhi/Fields/Multi_field_small_operators.h +490 -0
  45. multipers/gudhi/gudhi/Fields/Multi_field_small_shared.h +580 -0
  46. multipers/gudhi/gudhi/Fields/Z2_field.h +391 -0
  47. multipers/gudhi/gudhi/Fields/Z2_field_operators.h +389 -0
  48. multipers/gudhi/gudhi/Fields/Zp_field.h +493 -0
  49. multipers/gudhi/gudhi/Fields/Zp_field_operators.h +384 -0
  50. multipers/gudhi/gudhi/Fields/Zp_field_shared.h +492 -0
  51. multipers/gudhi/gudhi/Flag_complex_edge_collapser.h +337 -0
  52. multipers/gudhi/gudhi/Matrix.h +2200 -0
  53. multipers/gudhi/gudhi/Multi_filtration/Multi_parameter_generator.h +1712 -0
  54. multipers/gudhi/gudhi/Multi_filtration/multi_filtration_conversions.h +237 -0
  55. multipers/gudhi/gudhi/Multi_filtration/multi_filtration_utils.h +225 -0
  56. multipers/gudhi/gudhi/Multi_parameter_filtered_complex.h +485 -0
  57. multipers/gudhi/gudhi/Multi_parameter_filtration.h +2643 -0
  58. multipers/gudhi/gudhi/Multi_persistence/Box.h +233 -0
  59. multipers/gudhi/gudhi/Multi_persistence/Line.h +309 -0
  60. multipers/gudhi/gudhi/Multi_persistence/Multi_parameter_filtered_complex_pcoh_interface.h +268 -0
  61. multipers/gudhi/gudhi/Multi_persistence/Persistence_interface_cohomology.h +159 -0
  62. multipers/gudhi/gudhi/Multi_persistence/Persistence_interface_matrix.h +463 -0
  63. multipers/gudhi/gudhi/Multi_persistence/Point.h +853 -0
  64. multipers/gudhi/gudhi/Off_reader.h +173 -0
  65. multipers/gudhi/gudhi/Persistence_matrix/Base_matrix.h +834 -0
  66. multipers/gudhi/gudhi/Persistence_matrix/Base_matrix_with_column_compression.h +838 -0
  67. multipers/gudhi/gudhi/Persistence_matrix/Boundary_matrix.h +833 -0
  68. multipers/gudhi/gudhi/Persistence_matrix/Chain_matrix.h +1367 -0
  69. multipers/gudhi/gudhi/Persistence_matrix/Id_to_index_overlay.h +1157 -0
  70. multipers/gudhi/gudhi/Persistence_matrix/Position_to_index_overlay.h +869 -0
  71. multipers/gudhi/gudhi/Persistence_matrix/RU_matrix.h +905 -0
  72. multipers/gudhi/gudhi/Persistence_matrix/allocators/entry_constructors.h +122 -0
  73. multipers/gudhi/gudhi/Persistence_matrix/base_pairing.h +260 -0
  74. multipers/gudhi/gudhi/Persistence_matrix/base_swap.h +288 -0
  75. multipers/gudhi/gudhi/Persistence_matrix/chain_pairing.h +170 -0
  76. multipers/gudhi/gudhi/Persistence_matrix/chain_rep_cycles.h +247 -0
  77. multipers/gudhi/gudhi/Persistence_matrix/chain_vine_swap.h +571 -0
  78. multipers/gudhi/gudhi/Persistence_matrix/columns/chain_column_extra_properties.h +182 -0
  79. multipers/gudhi/gudhi/Persistence_matrix/columns/column_dimension_holder.h +130 -0
  80. multipers/gudhi/gudhi/Persistence_matrix/columns/column_utilities.h +235 -0
  81. multipers/gudhi/gudhi/Persistence_matrix/columns/entry_types.h +312 -0
  82. multipers/gudhi/gudhi/Persistence_matrix/columns/heap_column.h +1092 -0
  83. multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_list_column.h +923 -0
  84. multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_set_column.h +914 -0
  85. multipers/gudhi/gudhi/Persistence_matrix/columns/list_column.h +930 -0
  86. multipers/gudhi/gudhi/Persistence_matrix/columns/naive_vector_column.h +1071 -0
  87. multipers/gudhi/gudhi/Persistence_matrix/columns/row_access.h +203 -0
  88. multipers/gudhi/gudhi/Persistence_matrix/columns/set_column.h +886 -0
  89. multipers/gudhi/gudhi/Persistence_matrix/columns/unordered_set_column.h +984 -0
  90. multipers/gudhi/gudhi/Persistence_matrix/columns/vector_column.h +1213 -0
  91. multipers/gudhi/gudhi/Persistence_matrix/index_mapper.h +58 -0
  92. multipers/gudhi/gudhi/Persistence_matrix/matrix_dimension_holders.h +227 -0
  93. multipers/gudhi/gudhi/Persistence_matrix/matrix_row_access.h +200 -0
  94. multipers/gudhi/gudhi/Persistence_matrix/ru_pairing.h +166 -0
  95. multipers/gudhi/gudhi/Persistence_matrix/ru_rep_cycles.h +319 -0
  96. multipers/gudhi/gudhi/Persistence_matrix/ru_vine_swap.h +562 -0
  97. multipers/gudhi/gudhi/Persistence_on_a_line.h +152 -0
  98. multipers/gudhi/gudhi/Persistence_on_rectangle.h +617 -0
  99. multipers/gudhi/gudhi/Persistent_cohomology/Field_Zp.h +118 -0
  100. multipers/gudhi/gudhi/Persistent_cohomology/Multi_field.h +173 -0
  101. multipers/gudhi/gudhi/Persistent_cohomology/Persistent_cohomology_column.h +128 -0
  102. multipers/gudhi/gudhi/Persistent_cohomology.h +769 -0
  103. multipers/gudhi/gudhi/Points_off_io.h +171 -0
  104. multipers/gudhi/gudhi/Projective_cover_kernel.h +379 -0
  105. multipers/gudhi/gudhi/Simple_object_pool.h +69 -0
  106. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_iterators.h +559 -0
  107. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +83 -0
  108. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_siblings.h +121 -0
  109. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_star_simplex_iterators.h +277 -0
  110. multipers/gudhi/gudhi/Simplex_tree/filtration_value_utils.h +155 -0
  111. multipers/gudhi/gudhi/Simplex_tree/hooks_simplex_base.h +62 -0
  112. multipers/gudhi/gudhi/Simplex_tree/indexing_tag.h +27 -0
  113. multipers/gudhi/gudhi/Simplex_tree/serialization_utils.h +60 -0
  114. multipers/gudhi/gudhi/Simplex_tree/simplex_tree_options.h +105 -0
  115. multipers/gudhi/gudhi/Simplex_tree.h +3170 -0
  116. multipers/gudhi/gudhi/Slicer.h +848 -0
  117. multipers/gudhi/gudhi/Thread_safe_slicer.h +393 -0
  118. multipers/gudhi/gudhi/distance_functions.h +62 -0
  119. multipers/gudhi/gudhi/graph_simplicial_complex.h +104 -0
  120. multipers/gudhi/gudhi/multi_simplex_tree_helpers.h +147 -0
  121. multipers/gudhi/gudhi/persistence_interval.h +263 -0
  122. multipers/gudhi/gudhi/persistence_matrix_options.h +188 -0
  123. multipers/gudhi/gudhi/reader_utils.h +367 -0
  124. multipers/gudhi/gudhi/simple_mdspan.h +484 -0
  125. multipers/gudhi/gudhi/slicer_helpers.h +779 -0
  126. multipers/gudhi/tmp_h0_pers/mma_interface_h0.h +223 -0
  127. multipers/gudhi/tmp_h0_pers/naive_merge_tree.h +536 -0
  128. multipers/io.cpython-312-darwin.so +0 -0
  129. multipers/io.pyx +472 -0
  130. multipers/ml/__init__.py +0 -0
  131. multipers/ml/accuracies.py +90 -0
  132. multipers/ml/invariants_with_persistable.py +79 -0
  133. multipers/ml/kernels.py +176 -0
  134. multipers/ml/mma.py +713 -0
  135. multipers/ml/one.py +472 -0
  136. multipers/ml/point_clouds.py +352 -0
  137. multipers/ml/signed_measures.py +1667 -0
  138. multipers/ml/sliced_wasserstein.py +461 -0
  139. multipers/ml/tools.py +113 -0
  140. multipers/mma_structures.cpython-312-darwin.so +0 -0
  141. multipers/mma_structures.pxd +134 -0
  142. multipers/mma_structures.pyx +1483 -0
  143. multipers/mma_structures.pyx.tp +1126 -0
  144. multipers/multi_parameter_rank_invariant/diff_helpers.h +85 -0
  145. multipers/multi_parameter_rank_invariant/euler_characteristic.h +95 -0
  146. multipers/multi_parameter_rank_invariant/function_rips.h +317 -0
  147. multipers/multi_parameter_rank_invariant/hilbert_function.h +761 -0
  148. multipers/multi_parameter_rank_invariant/persistence_slices.h +149 -0
  149. multipers/multi_parameter_rank_invariant/rank_invariant.h +350 -0
  150. multipers/multiparameter_edge_collapse.py +41 -0
  151. multipers/multiparameter_module_approximation/approximation.h +2541 -0
  152. multipers/multiparameter_module_approximation/debug.h +107 -0
  153. multipers/multiparameter_module_approximation/format_python-cpp.h +292 -0
  154. multipers/multiparameter_module_approximation/utilities.h +428 -0
  155. multipers/multiparameter_module_approximation.cpython-312-darwin.so +0 -0
  156. multipers/multiparameter_module_approximation.pyx +286 -0
  157. multipers/ops.cpython-312-darwin.so +0 -0
  158. multipers/ops.pyx +231 -0
  159. multipers/pickle.py +89 -0
  160. multipers/plots.py +550 -0
  161. multipers/point_measure.cpython-312-darwin.so +0 -0
  162. multipers/point_measure.pyx +409 -0
  163. multipers/simplex_tree_multi.cpython-312-darwin.so +0 -0
  164. multipers/simplex_tree_multi.pxd +136 -0
  165. multipers/simplex_tree_multi.pyx +11719 -0
  166. multipers/simplex_tree_multi.pyx.tp +2102 -0
  167. multipers/slicer.cpython-312-darwin.so +0 -0
  168. multipers/slicer.pxd +2097 -0
  169. multipers/slicer.pxd.tp +263 -0
  170. multipers/slicer.pyx +13042 -0
  171. multipers/slicer.pyx.tp +1259 -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 +70 -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/vector_interface.pxd +46 -0
  180. multipers-2.4.0b1.dist-info/METADATA +131 -0
  181. multipers-2.4.0b1.dist-info/RECORD +184 -0
  182. multipers-2.4.0b1.dist-info/WHEEL +6 -0
  183. multipers-2.4.0b1.dist-info/licenses/LICENSE +21 -0
  184. multipers-2.4.0b1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,121 @@
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
+ typedef typename MapContainer::const_iterator Dictionary_const_it;
45
+
46
+ /* Default constructor.*/
47
+ Simplex_tree_siblings()
48
+ : oncles_(nullptr),
49
+ parent_(-1),
50
+ members_() {
51
+ }
52
+
53
+ /* Constructor with values.*/
54
+ Simplex_tree_siblings(Simplex_tree_siblings * oncles, Vertex_handle parent)
55
+ : oncles_(oncles),
56
+ parent_(parent),
57
+ members_() {
58
+ }
59
+
60
+ /** \brief Constructor with initialized set of members.
61
+ *
62
+ * 'members' must be sorted and unique.*/
63
+ template<typename RandomAccessVertexRange>
64
+ Simplex_tree_siblings(Simplex_tree_siblings * oncles, Vertex_handle parent, const RandomAccessVertexRange & members)
65
+ : oncles_(oncles),
66
+ parent_(parent),
67
+ members_(boost::container::ordered_unique_range, members.begin(),
68
+ members.end()) {
69
+ for (auto& map_el : members_) {
70
+ map_el.second.assign_children(this);
71
+ }
72
+ }
73
+
74
+ Dictionary_it find(Vertex_handle v) {
75
+ return members_.find(v);
76
+ }
77
+ Dictionary_const_it find(Vertex_handle v) const {
78
+ return members_.find(v);
79
+ }
80
+
81
+ Simplex_tree_siblings * oncles() {
82
+ return oncles_;
83
+ }
84
+ const Simplex_tree_siblings * oncles() const {
85
+ return oncles_;
86
+ }
87
+
88
+ Vertex_handle parent() const {
89
+ return parent_;
90
+ }
91
+
92
+ Dictionary & members() {
93
+ return members_;
94
+ }
95
+
96
+ const Dictionary & members() const {
97
+ return members_;
98
+ }
99
+
100
+ size_t size() const {
101
+ return members_.size();
102
+ }
103
+
104
+ void erase(const Dictionary_it iterator) {
105
+ members_.erase(iterator);
106
+ }
107
+
108
+ Dictionary_it to_non_const_it(Dictionary_const_it it) {
109
+ return members_.erase(it, it);
110
+ }
111
+
112
+ Simplex_tree_siblings * oncles_;
113
+ Vertex_handle parent_;
114
+ Dictionary members_;
115
+ };
116
+
117
+ /** @}*/ // end addtogroup simplex_tree
118
+
119
+ } // namespace Gudhi
120
+
121
+ #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 const* 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()(const typename SimplexTree::Hooks_simplex_base& curr_hooks) {
76
+ const Node& curr_node = static_cast<const 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 const* 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::const_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 const* 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
+ const 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
+ const Node& curr_node = static_cast<const 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
+ const Node& curr_node = static_cast<const 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 const* 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 const* 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 const* 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 const* sib_; //
269
+ // Save children in a list to avoid calling sib_->members().find(.)
270
+ std::vector<Siblings const*> 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,155 @@
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): Hannah Schreiber
4
+ *
5
+ * Copyright (C) 2025 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ #ifndef SIMPLEX_TREE_FILTRATION_VALUE_UTILS_H_
12
+ #define SIMPLEX_TREE_FILTRATION_VALUE_UTILS_H_
13
+
14
+ #include <cstddef> // std::size_t
15
+ #include <limits> // std::numeric_limits
16
+ #include <cmath> // std::isnan
17
+
18
+ #include <gudhi/Simplex_tree/serialization_utils.h>
19
+
20
+ namespace Gudhi {
21
+
22
+ namespace simplex_tree {
23
+
24
+ /**
25
+ * @ingroup simplex_tree
26
+ * @brief Returns `Filtration_value(0)` when converted to `Filtration_value`.
27
+ */
28
+ inline struct empty_filtration_value_t {
29
+ template <class T> explicit operator T() const { return T(0); }
30
+ } empty_filtration_value;
31
+
32
+ } // namespace simplex_tree
33
+
34
+ /**
35
+ * @ingroup simplex_tree
36
+ * @brief Returns true if and only if the given filtration value is at infinity.
37
+ * This is the overload for when @ref FiltrationValue is an arithmetic type, like double, int etc. It simply
38
+ * tests equality with `std::numeric_limits<FiltrationValue>::infinity()` if defined or with
39
+ * `std::numeric_limits<FiltrationValue>::max()` otherwise. Can therefore be also used with other classes
40
+ * as long as infinity is defined that way.
41
+ */
42
+ template <typename Arithmetic_filtration_value>
43
+ bool is_positive_infinity(const Arithmetic_filtration_value& f)
44
+ {
45
+ if constexpr (std::numeric_limits<Arithmetic_filtration_value>::has_infinity) {
46
+ return f == std::numeric_limits<Arithmetic_filtration_value>::infinity();
47
+ } else {
48
+ return f == std::numeric_limits<Arithmetic_filtration_value>::max();
49
+ }
50
+ }
51
+
52
+ /**
53
+ * @ingroup simplex_tree
54
+ * @brief Given two filtration values at which a simplex exists, stores in the first value the minimal union of births
55
+ * generating a lifetime including those two values.
56
+ * This is the overload for when @ref FiltrationValue is an arithmetic type, like double, int etc.
57
+ * Because the filtration values are totally ordered then, the union is simply the minimum of the two values.
58
+ *
59
+ * NaN values are not supported.
60
+ */
61
+ template <typename Arithmetic_filtration_value>
62
+ bool unify_lifetimes(Arithmetic_filtration_value& f1, const Arithmetic_filtration_value& f2)
63
+ {
64
+ if (f2 < f1){
65
+ f1 = f2;
66
+ return true;
67
+ }
68
+ return false;
69
+ }
70
+
71
+ /**
72
+ * @ingroup simplex_tree
73
+ * @brief Given two filtration values, stores in the first value the lowest common upper bound of the two values.
74
+ * If a filtration value has value `NaN`, it should be considered as the lowest value possible.
75
+ * This is the overload for when @ref FiltrationValue is an arithmetic type, like double, float, int etc.
76
+ * Because the filtration values are totally ordered then, the upper bound is always the maximum of the two values.
77
+ */
78
+ template <typename Arithmetic_filtration_value>
79
+ bool intersect_lifetimes(Arithmetic_filtration_value& f1, const Arithmetic_filtration_value& f2)
80
+ {
81
+ if constexpr (std::numeric_limits<Arithmetic_filtration_value>::has_quiet_NaN) {
82
+ if (std::isnan(f1)) {
83
+ f1 = f2;
84
+ return !std::isnan(f2);
85
+ }
86
+
87
+ // Computes the max while handling NaN as lowest value.
88
+ if (!(f1 < f2)) return false;
89
+
90
+ f1 = f2;
91
+ return true;
92
+ } else {
93
+ // NaN not possible.
94
+ if (f1 < f2){
95
+ f1 = f2;
96
+ return true;
97
+ }
98
+ return false;
99
+ }
100
+ }
101
+
102
+ /**
103
+ * @private
104
+ * @ingroup simplex_tree
105
+ * @brief Serialize the given value and insert it at start position using
106
+ * @ref Gudhi::simplex_tree::serialize_trivial "".
107
+ *
108
+ * @tparam Trivial_filtration_value Type which can trivially be serialized with byte to byte copy of the content
109
+ * of the holding variable. E.g., native arithmetic types.
110
+ * @param[in] value The value to serialize.
111
+ * @param[in] start Start position where the value is serialized.
112
+ * @return The new position in the array of char for the next serialization.
113
+ *
114
+ * @warning It is the user's responsibility to provide a pointer to a buffer with enough memory space.
115
+ */
116
+ template <typename Trivial_filtration_value>
117
+ char* serialize_value_to_char_buffer(Trivial_filtration_value value, char* start) {
118
+ return Gudhi::simplex_tree::serialize_trivial(value, start);
119
+ }
120
+
121
+ /**
122
+ * @private
123
+ * @ingroup simplex_tree
124
+ * @brief Deserialize at the start position in an array of char and sets the value with it using
125
+ * @ref Gudhi::simplex_tree::deserialize_trivial "".
126
+ *
127
+ * @tparam Trivial_filtration_value Type which can trivially be serialized with byte to byte copy of the content
128
+ * of the holding variable. E.g., native arithmetic types.
129
+ * @param[in] value The value where to deserialize based on its type.
130
+ * @param[in] start Start position where the value is serialized.
131
+ * @return The new position in the array of char for the next deserialization.
132
+ *
133
+ * @warning It is the user's responsibility to ensure that the pointer will not go out of bounds.
134
+ */
135
+ template <typename Trivial_filtration_value>
136
+ const char* deserialize_value_from_char_buffer(Trivial_filtration_value& value, const char* start) {
137
+ return Gudhi::simplex_tree::deserialize_trivial(value, start);
138
+ }
139
+
140
+ /**
141
+ * @private
142
+ * @ingroup simplex_tree
143
+ * @brief Returns the size of the template type `Trivial_filtration_value`.
144
+ *
145
+ * @tparam Trivial_filtration_value Type which can trivially be serialized with byte to byte copy of the content
146
+ * of the holding variable. E.g., native arithmetic types.
147
+ */
148
+ template<typename Trivial_filtration_value>
149
+ constexpr std::size_t get_serialization_size_of([[maybe_unused]] Trivial_filtration_value value) {
150
+ return sizeof(Trivial_filtration_value);
151
+ }
152
+
153
+ } // namespace Gudhi
154
+
155
+ #endif // SIMPLEX_TREE_FILTRATION_VALUE_UTILS_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_