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,147 @@
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): David Loiseaux
4
+ *
5
+ * Copyright (C) 2023 Inria
6
+ *
7
+ * Modification(s):
8
+ * - 2025/04 Hannah Schreiber: simplifications with new simplex tree constructors + name changes
9
+ * - YYYY/MM Author: Description of the modification
10
+ */
11
+
12
+ /**
13
+ * @file multi_simplex_tree_helpers.h
14
+ * @author David Loiseaux
15
+ * @brief Contains the @ref Gudhi::multi_persistence::Simplex_tree_options_multidimensional_filtration struct,
16
+ * as well as the two helper methods @ref Gudhi::multi_persistence::make_multi_dimensional and
17
+ * @ref Gudhi::multi_persistence::make_one_dimensional.
18
+ */
19
+
20
+ #ifndef MP_MULTI_SIMPLEX_TREE_HELPERS_H_
21
+ #define MP_MULTI_SIMPLEX_TREE_HELPERS_H_
22
+
23
+ #include <cstddef>
24
+ #include <type_traits>
25
+
26
+ #include <gudhi/Debug_utils.h>
27
+ #include <gudhi/Simplex_tree.h>
28
+ #include <gudhi/Simplex_tree/simplex_tree_options.h>
29
+
30
+ namespace Gudhi {
31
+ namespace multi_persistence {
32
+
33
+ /**
34
+ * @ingroup multi_persistence
35
+ *
36
+ * @brief Model of @ref SimplexTreeOptions. Same as @ref Gudhi::Simplex_tree_options_default but with a custom
37
+ * filtration value type.
38
+ *
39
+ * @tparam MultiFiltrationValue Has to respect the @ref FiltrationValue concept.
40
+ */
41
+ template <typename MultiFiltrationValue>
42
+ struct Simplex_tree_options_multidimensional_filtration : Simplex_tree_options_default {
43
+ using Filtration_value = MultiFiltrationValue;
44
+ };
45
+
46
+ /**
47
+ * @ingroup multi_persistence
48
+ *
49
+ * @brief Constructs a multi-dimensional simplex tree from the given one-dimensional simplex tree.
50
+ *
51
+ * All simplices are copied from the one-dimensional simplex tree \f$ st \f$ to the multi-dimensional simplex tree
52
+ * \f$ st_multi \f$. To begin, all filtration values of \f$ st_multi \f$ are initialized to the given default value.
53
+ * Then, all filtration values of \f$ st \f$ are projected onto \f$ st_multi \f$ at the given dimension index.
54
+ *
55
+ * @tparam MultiDimSimplexTreeOptions Options for the multi-dimensional simplex tree. Should follow the
56
+ * @ref SimplexTreeOptions concept. It has to define a @ref FiltrationValue with the additional methods:
57
+ * `num_parameters()` which returns the number of parameters, `num_generators()` which returns the number of generators
58
+ * and `operator(g, p)` which return a (modifiable) reference to the \f$ p^{th} \f$ element of the \f$ g^{th} \f$
59
+ * generator. It should also define a type `value_type` with the type of an element in the filtration value.
60
+ * @tparam OneDimSimplexTree Type of the one-dimensional @ref Gudhi::Simplex_tree. The `Filtration_value` type has to
61
+ * be convertible to the `Filtration_value::value_type` of `MultiDimSimplexTreeOptions`.
62
+ * @param st Simplex tree to project.
63
+ * @param default_value Default value of the multi-dimensional filtration values. Has therefore to contain at least
64
+ * one generator and as many parameters than the final tree should have. One of the elements of the first generator
65
+ * will take the value of the projected value, so make sure to initialize the default value such that the `operator()`
66
+ * makes the change of value possible.
67
+ * @param dimension Dimension index to which the filtration values should be projected onto.
68
+ */
69
+ template <class MultiDimSimplexTreeOptions, class OneDimSimplexTree>
70
+ Simplex_tree<MultiDimSimplexTreeOptions> make_multi_dimensional(
71
+ const OneDimSimplexTree &st,
72
+ const typename MultiDimSimplexTreeOptions::Filtration_value &default_value,
73
+ const std::size_t dimension = 0)
74
+ {
75
+ using OneDimF = typename OneDimSimplexTree::Options::Filtration_value;
76
+ using MultiDimF = typename MultiDimSimplexTreeOptions::Filtration_value;
77
+
78
+ static_assert(std::is_convertible_v<OneDimF, typename MultiDimF::value_type>,
79
+ "A filtration value of the one dimensional tree should be convertible to an element of a filtration "
80
+ "value of the multi dimensional simplex tree.");
81
+
82
+ auto num_param = default_value.num_parameters();
83
+
84
+ GUDHI_CHECK(dimension < num_param,
85
+ "Given dimension is too high, it has to be smaller than the number of parameters.");
86
+ GUDHI_CHECK(default_value.num_generators() > 0,
87
+ "The default value for the filtration values should contain at least one generator.");
88
+
89
+ auto translate = [&](const OneDimF &f) -> MultiDimF {
90
+ auto res = default_value;
91
+ res(0, dimension) = f;
92
+ return res;
93
+ };
94
+
95
+ Simplex_tree<MultiDimSimplexTreeOptions> multi_st(st, translate);
96
+ multi_st.set_num_parameters(num_param);
97
+
98
+ return multi_st;
99
+ }
100
+
101
+ /**
102
+ * @ingroup multi_persistence
103
+ *
104
+ * @brief Constructs a one-dimensional simplex tree from the given multi-dimensional simplex tree.
105
+ *
106
+ * All simplices are copied from the multi-dimensional simplex tree \f$ st \f$ to the one-dimensional simplex tree
107
+ * \f$ st_one \f$. All filtration values of \f$ st_one \f$ are initialized with the element value at given dimension
108
+ * index of the first generator of the corresponding multi-dimensional filtration value in \f$ st \f$.
109
+ *
110
+ * @tparam OneDimSimplexTreeOptions Options for the one-dimensional simplex tree. Should follow the
111
+ * @ref SimplexTreeOptions concept.
112
+ * @tparam MultiDimSimplexTree Type of the multi-dimensional @ref Gudhi::Simplex_tree. It has to define a
113
+ * @ref FiltrationValue with the additional methods: `num_parameters()` which returns the number of parameters,
114
+ * `num_generators()` which returns the number of generators and `operator(g, p)` which returns the value of the
115
+ * \f$ p^{th} \f$ element of the \f$ g^{th} \f$ generator. It should also define a type `value_type` with the type of
116
+ * an element in the filtration value, which has to be convertible to `Filtration_value` of `OneDimSimplexTreeOptions`.
117
+ * @param st Simplex tree to project.
118
+ * @param dimension Dimension index in the first generator to project.
119
+ */
120
+ template <class OneDimSimplexTreeOptions, class MultiDimSimplexTree>
121
+ Simplex_tree<OneDimSimplexTreeOptions> make_one_dimensional(const MultiDimSimplexTree &st,
122
+ const std::size_t dimension = 0)
123
+ {
124
+ using OneDimF = typename OneDimSimplexTreeOptions::Filtration_value;
125
+ using MultiDimF = typename MultiDimSimplexTree::Options::Filtration_value;
126
+
127
+ static_assert(std::is_convertible_v<typename MultiDimF::value_type, OneDimF>,
128
+ "An element of a filtration value of the multi dimensional tree should be convertible to a filtration "
129
+ "value of the one dimensional simplex tree.");
130
+
131
+ auto translate = [dimension](const MultiDimF &f) -> OneDimF {
132
+ GUDHI_CHECK(dimension < f.num_parameters(),
133
+ "Given dimension is too high, it has to be smaller than the number of parameters.");
134
+ GUDHI_CHECK(f.num_generators() > 0, "A filtration value of the multi tree should contain at least one generator.");
135
+ return f(0, dimension);
136
+ };
137
+
138
+ Simplex_tree<OneDimSimplexTreeOptions> one_st(st, translate);
139
+ one_st.set_num_parameters(1);
140
+
141
+ return one_st;
142
+ }
143
+
144
+ } // namespace multi_persistence
145
+ } // namespace Gudhi
146
+
147
+ #endif // MP_MULTI_SIMPLEX_TREE_HELPERS_H_
@@ -0,0 +1,263 @@
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) 2024 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ /**
12
+ * @file persistence_interval.h
13
+ * @author Hannah Schreiber
14
+ * @brief Contains @ref Gudhi::persistence_matrix::Persistence_interval class.
15
+ */
16
+
17
+ #ifndef PM_INTERVAL_INCLUDED
18
+ #define PM_INTERVAL_INCLUDED
19
+
20
+ #include <ostream> //std::ostream
21
+ #include <limits> //std::numeric_limits
22
+ #include <tuple>
23
+ #include <utility> //std::move
24
+
25
+ namespace Gudhi {
26
+ namespace persistence_matrix {
27
+
28
+ /**
29
+ * @class Persistence_interval persistence_interval.h gudhi/persistence_interval.h
30
+ * @ingroup persistence_matrix
31
+ *
32
+ * @brief Type for an interval in a persistent diagram or barcode. Stores the birth, death and dimension of the
33
+ * interval. It can be used as a tuple with `get`/`std::get` (birth, death and dimension in this order),
34
+ * `std::tuple_element` and `std::tuple_size`, as well as structured binding.
35
+ *
36
+ * @tparam Dimension Type of the dimension value.
37
+ * @tparam Event_value Type of the birth and death value.
38
+ */
39
+ template <typename Dimension, typename Event_value>
40
+ struct Persistence_interval {
41
+ /**
42
+ * @brief Stores the infinity value for birth and death events. Its value depends on the template parameter
43
+ * `Event_value`:
44
+ * - if `Event_value` has a native infinity value, it takes this value,
45
+ * - otherwise, if `Event_value` is a signed type, it takes value -1,
46
+ * - otherwise, if `Event_value` is a unsigned type, it takes the maximal possible value.
47
+ *
48
+ * Is also used as default value for birth and death attributes when not initialized.
49
+ */
50
+ static constexpr Event_value inf = std::numeric_limits<Event_value>::has_infinity
51
+ ? std::numeric_limits<Event_value>::infinity()
52
+ : static_cast<Event_value>(-1);
53
+
54
+ /**
55
+ * @brief Constructor.
56
+ *
57
+ * @param birth Birth value of the cycle. Default value: @ref inf.
58
+ * @param death Death value of the cycle. Default value: @ref inf.
59
+ * @param dim Dimension of the cycle. Default value: -1.
60
+ */
61
+ Persistence_interval(Event_value birth = inf, Event_value death = inf, Dimension dim = -1)
62
+ : dim(dim), birth(birth), death(death)
63
+ {}
64
+
65
+ Dimension dim; /**< Dimension of the cycle.*/
66
+ Event_value birth; /**< Birth value of the cycle. */
67
+ Event_value death; /**< Death value of the cycle. */
68
+
69
+ /**
70
+ * @brief operator<<
71
+ *
72
+ * @param stream outstream
73
+ * @param interval interval to stream
74
+ */
75
+ friend std::ostream& operator<<(std::ostream& stream, const Persistence_interval& interval)
76
+ {
77
+ stream << "[" << interval.dim << "] ";
78
+ if constexpr (std::numeric_limits<Event_value>::has_infinity) {
79
+ stream << interval.birth << " - " << interval.death;
80
+ } else {
81
+ if (interval.birth == inf)
82
+ stream << "inf";
83
+ else
84
+ stream << interval.birth;
85
+ stream << " - ";
86
+ if (interval.death == inf)
87
+ stream << "inf";
88
+ else
89
+ stream << interval.death;
90
+ }
91
+ return stream;
92
+ }
93
+
94
+ /**
95
+ * @brief Specialization of `get` for @ref Gudhi::persistence_matrix::Persistence_interval.
96
+ *
97
+ * @tparam I Index of the value to return: 0 for the birth value, 1 for the death value and 2 for the dimension.
98
+ * @return Either the birth value if @p I == 0, the death value if @p I == 1 or the dimension if @p I == 2.
99
+ */
100
+ template <std::size_t I>
101
+ constexpr auto& get() & noexcept
102
+ {
103
+ static_assert(I < 3, "Value mismatch at argument 1 in template parameter list. Maximal possible value is 2.");
104
+
105
+ if constexpr (I == 0) return birth;
106
+ if constexpr (I == 1) return death;
107
+ if constexpr (I == 2) return dim;
108
+ }
109
+
110
+ /**
111
+ * @brief Specialization of `get` for @ref Gudhi::persistence_matrix::Persistence_interval.
112
+ *
113
+ * @tparam I Index of the value to return: 0 for the birth value, 1 for the death value and 2 for the dimension.
114
+ * @return Either the birth value if @p I == 0, the death value if @p I == 1 or the dimension if @p I == 2.
115
+ */
116
+ template <std::size_t I>
117
+ constexpr const auto& get() const& noexcept
118
+ {
119
+ static_assert(I < 3, "Value mismatch at argument 1 in template parameter list. Maximal possible value is 2.");
120
+
121
+ if constexpr (I == 0) return birth;
122
+ if constexpr (I == 1) return death;
123
+ if constexpr (I == 2) return dim;
124
+ }
125
+
126
+ /**
127
+ * @brief Specialization of `get` for @ref Gudhi::persistence_matrix::Persistence_interval.
128
+ *
129
+ * @tparam I Index of the value to return: 0 for the birth value, 1 for the death value and 2 for the dimension.
130
+ * @return Either the birth value if @p I == 0, the death value if @p I == 1 or the dimension if @p I == 2.
131
+ */
132
+ template <std::size_t I>
133
+ constexpr auto&& get() && noexcept
134
+ {
135
+ static_assert(I < 3, "Value mismatch at argument 1 in template parameter list. Maximal possible value is 2.");
136
+
137
+ if constexpr (I == 0) return std::move(birth);
138
+ if constexpr (I == 1) return std::move(death);
139
+ if constexpr (I == 2) return std::move(dim);
140
+ }
141
+
142
+ /**
143
+ * @brief Specialization of `get` for @ref Gudhi::persistence_matrix::Persistence_interval.
144
+ *
145
+ * @tparam I Index of the value to return: 0 for the birth value, 1 for the death value and 2 for the dimension.
146
+ * @return Either the birth value if @p I == 0, the death value if @p I == 1 or the dimension if @p I == 2.
147
+ */
148
+ template <std::size_t I>
149
+ constexpr const auto&& get() const&& noexcept
150
+ {
151
+ static_assert(I < 3, "Value mismatch at argument 1 in template parameter list. Maximal possible value is 2.");
152
+
153
+ if constexpr (I == 0) return std::move(birth);
154
+ if constexpr (I == 1) return std::move(death);
155
+ if constexpr (I == 2) return std::move(dim);
156
+ }
157
+ };
158
+
159
+ } // namespace persistence_matrix
160
+ } // namespace Gudhi
161
+
162
+ namespace std {
163
+
164
+ /**
165
+ * @ingroup persistence_matrix
166
+ *
167
+ * @brief Partial specialization of `std::tuple_size` for @ref Gudhi::persistence_matrix::Persistence_interval.
168
+ *
169
+ * @tparam Dimension First template parameter of @ref Gudhi::persistence_matrix::Persistence_interval.
170
+ * @tparam Event_value Second template parameter of @ref Gudhi::persistence_matrix::Persistence_interval.
171
+ */
172
+ template <typename Dimension, typename Event_value>
173
+ struct tuple_size<Gudhi::persistence_matrix::Persistence_interval<Dimension, Event_value> >
174
+ : integral_constant<size_t, 3> {};
175
+
176
+ /**
177
+ * @ingroup persistence_matrix
178
+ *
179
+ * @brief Partial specialization of `std::tuple_element` for @ref Gudhi::persistence_matrix::Persistence_interval.
180
+ *
181
+ * @tparam I Index of the type to store: 0 for the birth value type, 1 for the death value type and 2 for the
182
+ * dimension value type.
183
+ * @tparam Dimension First template parameter of @ref Gudhi::persistence_matrix::Persistence_interval.
184
+ * @tparam Event_value Second template parameter of @ref Gudhi::persistence_matrix::Persistence_interval.
185
+ */
186
+ template <size_t I, typename Dimension, typename Event_value>
187
+ struct tuple_element<I, Gudhi::persistence_matrix::Persistence_interval<Dimension, Event_value> > {
188
+ static_assert(I < 3, "Value mismatch at argument 1 in template parameter list. Maximal possible value is 2.");
189
+
190
+ using type = conditional_t < I<2, Event_value, Dimension>;
191
+ };
192
+
193
+ /**
194
+ * @ingroup persistence_matrix
195
+ *
196
+ * @brief Partial specialization of `get` for @ref Gudhi::persistence_matrix::Persistence_interval.
197
+ *
198
+ * @tparam I Index of the value to return: 0 for the birth value, 1 for the death value and 2 for the dimension.
199
+ * @tparam Dimension First template parameter of @ref Gudhi::persistence_matrix::Persistence_interval.
200
+ * @tparam Event_value Second template parameter of @ref Gudhi::persistence_matrix::Persistence_interval.
201
+ * @param i Interval from which the value should be returned.
202
+ * @return Either the birth value if @p I == 0, the death value if @p I == 1 or the dimension if @p I == 2.
203
+ */
204
+ template <size_t I, typename Dimension, typename Event_value>
205
+ constexpr auto& get(Gudhi::persistence_matrix::Persistence_interval<Dimension, Event_value>& i) noexcept
206
+ {
207
+ return i.template get<I>();
208
+ }
209
+
210
+ /**
211
+ * @ingroup persistence_matrix
212
+ *
213
+ * @brief Partial specialization of `get` for @ref Gudhi::persistence_matrix::Persistence_interval.
214
+ *
215
+ * @tparam I Index of the value to return: 0 for the birth value, 1 for the death value and 2 for the dimension.
216
+ * @tparam Dimension First template parameter of @ref Gudhi::persistence_matrix::Persistence_interval.
217
+ * @tparam Event_value Second template parameter of @ref Gudhi::persistence_matrix::Persistence_interval.
218
+ * @param i Interval from which the value should be returned.
219
+ * @return Either the birth value if @p I == 0, the death value if @p I == 1 or the dimension if @p I == 2.
220
+ */
221
+ template <size_t I, typename Dimension, typename Event_value>
222
+ constexpr const auto& get(const Gudhi::persistence_matrix::Persistence_interval<Dimension, Event_value>& i) noexcept
223
+ {
224
+ return i.template get<I>();
225
+ }
226
+
227
+ /**
228
+ * @ingroup persistence_matrix
229
+ *
230
+ * @brief Partial specialization of `get` for @ref Gudhi::persistence_matrix::Persistence_interval.
231
+ *
232
+ * @tparam I Index of the value to return: 0 for the birth value, 1 for the death value and 2 for the dimension.
233
+ * @tparam Dimension First template parameter of @ref Gudhi::persistence_matrix::Persistence_interval.
234
+ * @tparam Event_value Second template parameter of @ref Gudhi::persistence_matrix::Persistence_interval.
235
+ * @param i Interval from which the value should be returned.
236
+ * @return Either the birth value if @p I == 0, the death value if @p I == 1 or the dimension if @p I == 2.
237
+ */
238
+ template <size_t I, typename Dimension, typename Event_value>
239
+ constexpr auto&& get(Gudhi::persistence_matrix::Persistence_interval<Dimension, Event_value>&& i) noexcept
240
+ {
241
+ return std::move(i).template get<I>();
242
+ }
243
+
244
+ /**
245
+ * @ingroup persistence_matrix
246
+ *
247
+ * @brief Partial specialization of `get` for @ref Gudhi::persistence_matrix::Persistence_interval.
248
+ *
249
+ * @tparam I Index of the value to return: 0 for the birth value, 1 for the death value and 2 for the dimension.
250
+ * @tparam Dimension First template parameter of @ref Gudhi::persistence_matrix::Persistence_interval.
251
+ * @tparam Event_value Second template parameter of @ref Gudhi::persistence_matrix::Persistence_interval.
252
+ * @param i Interval from which the value should be returned.
253
+ * @return Either the birth value if @p I == 0, the death value if @p I == 1 or the dimension if @p I == 2.
254
+ */
255
+ template <size_t I, typename Dimension, typename Event_value>
256
+ constexpr const auto&& get(const Gudhi::persistence_matrix::Persistence_interval<Dimension, Event_value>&& i) noexcept
257
+ {
258
+ return std::move(i).template get<I>();
259
+ }
260
+
261
+ } // namespace std
262
+
263
+ #endif // PM_INTERVAL_INCLUDED
@@ -0,0 +1,188 @@
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) 2022-24 Inria
6
+ *
7
+ * Modification(s):
8
+ * - YYYY/MM Author: Description of the modification
9
+ */
10
+
11
+ /**
12
+ * @file persistence_matrix_options.h
13
+ * @author Hannah Schreiber
14
+ * @brief Contains the options for the matrix template.
15
+ */
16
+
17
+ #ifndef PM_OPTIONS_INCLUDED
18
+ #define PM_OPTIONS_INCLUDED
19
+
20
+ #include <cstdint> // std::uint8_t
21
+
22
+ #include <gudhi/Fields/Zp_field_operators.h>
23
+
24
+ namespace Gudhi {
25
+ namespace persistence_matrix {
26
+
27
+ /**
28
+ * @ingroup persistence_matrix
29
+ *
30
+ * @brief List of column types.
31
+ */
32
+ enum class Column_types : std::uint8_t {
33
+ LIST, /**< @ref List_column "": Underlying container is a std::list<@ref Entry*>. */
34
+ SET, /**< @ref Set_column "": Underlying container is a std::set<@ref Entry*>. */
35
+ HEAP, /**< @ref Heap_column "": Underlying container is a std::vector<@ref Entry*> ordered as a heap.
36
+ Is not compatible with row access and column compression. */
37
+ VECTOR, /**< @ref Vector_column "": Underlying container is a std::vector<@ref Entry*>
38
+ with a lazy removal method. */
39
+ NAIVE_VECTOR, /**< @ref Naive_vector_column "": Underlying container is a std::vector<@ref Entry*>. */
40
+ SMALL_VECTOR, /**< @ref Naive_vector_column "": Underlying container is a
41
+ boost::container::small_vector<@ref Entry*, 8>. */
42
+ UNORDERED_SET, /**< @ref Unordered_set_column "": Underlying container is a std::unordered_set<@ref Entry*>. */
43
+ INTRUSIVE_LIST, /**< @ref Intrusive_list_column "": Underlying container is a boost::intrusive::list<@ref Entry>. */
44
+ INTRUSIVE_SET /**< @ref Intrusive_set_column "": Underlying container is a boost::intrusive::set<@ref Entry>. */
45
+ };
46
+
47
+ /**
48
+ * @ingroup persistence_matrix
49
+ *
50
+ * @brief List if indexation schemes. See @ref mp_indexation "description of indexation schemes" for more details
51
+ * about the meaning of the indexation types.
52
+ */
53
+ enum class Column_indexation_types : std::uint8_t {
54
+ CONTAINER, /**< Default use of @ref MatIdx indices. */
55
+ POSITION, /**< All input and output @ref MatIdx indices are replaced with @ref PosIdx indices. */
56
+ IDENTIFIER /**< All input and output @ref MatIdx indices are replaced with @ref IDIdx indices. */
57
+ };
58
+
59
+ /**
60
+ * @struct Default_options persistence_matrix_options.h gudhi/persistence_matrix_options.h
61
+ * @ingroup persistence_matrix
62
+ *
63
+ * @brief Default option structure for @ref Matrix class.
64
+ * See the @ref PersistenceMatrixOptions concept for a more detailed description of the fields.
65
+ * Produces a @ref basematrix "base matrix" with no enabled option.
66
+ *
67
+ * To create other matrix types, the easiest is to simply inherit from this structure and overwrite only the options
68
+ * one is interested in.
69
+ *
70
+ * @tparam col_type Column type for the matrix. Default value: @ref Column_types::INTRUSIVE_SET
71
+ * @tparam is_z2_only Flag indicating if only \f$Z_2\f$ coefficient will be used with the matrix. Set to true if it
72
+ * is the case, false otherwise. Default value: true.
73
+ * @tparam FieldOperators Field operators used by the matrix, see FieldOperators concept.
74
+ * Only necessary if @p is_z2_only is false.
75
+ * Default value: @ref Gudhi::persistence_fields::Zp_field_operators<>.
76
+ */
77
+ template <Column_types col_type = Column_types::INTRUSIVE_SET,
78
+ bool is_z2_only = true,
79
+ class FieldOperators = persistence_fields::Zp_field_operators<> >
80
+ struct Default_options {
81
+ using Field_coeff_operators = FieldOperators;
82
+ using Dimension = int;
83
+ using Index = unsigned int;
84
+
85
+ static const bool is_z2 = is_z2_only;
86
+ static const Column_types column_type = col_type;
87
+
88
+ static const Column_indexation_types column_indexation_type = Column_indexation_types::CONTAINER;
89
+
90
+ static const bool has_column_compression = false;
91
+ static const bool has_column_and_row_swaps = false;
92
+
93
+ static const bool has_map_column_container = false;
94
+ static const bool has_removable_columns = false;
95
+
96
+ static const bool has_row_access = false;
97
+ static const bool has_intrusive_rows = true;
98
+ static const bool has_removable_rows = false;
99
+
100
+ static const bool is_of_boundary_type = true;
101
+
102
+ static const bool has_matrix_maximal_dimension_access = false;
103
+ static const bool has_column_pairings = false;
104
+ static const bool has_vine_update = false;
105
+ static const bool can_retrieve_representative_cycles = false;
106
+ };
107
+
108
+ // TODO: The following structures are the one used by the other modules or debug tests.
109
+ // They will probably be removed once the module was properly integrated.
110
+
111
+ /**
112
+ * @brief Options used for the Zigzag persistence module.
113
+ *
114
+ * @tparam column_type Column type for the matrix.
115
+ */
116
+ template <Column_types column_type = Column_types::INTRUSIVE_LIST>
117
+ struct Zigzag_options : Default_options<column_type, true> {
118
+ static const bool has_row_access = true;
119
+ static const bool has_column_pairings = false;
120
+ static const bool has_vine_update = true;
121
+ static const bool is_of_boundary_type = false;
122
+ static const bool has_map_column_container = true;
123
+ static const bool has_removable_columns = true;
124
+ static const bool has_removable_rows = true;
125
+ };
126
+
127
+ /**
128
+ * @brief Options needed to use the representative cycles.
129
+ *
130
+ * @tparam col_type Column type for the matrix.
131
+ */
132
+ template <Column_types col_type = Column_types::INTRUSIVE_SET>
133
+ struct Representative_cycles_options : Default_options<col_type, true> {
134
+ static const bool has_column_pairings = true;
135
+ static const bool can_retrieve_representative_cycles = true;
136
+ };
137
+
138
+ /**
139
+ * @brief Options used by the Multipersistence module.
140
+ *
141
+ * @tparam column_type Column type for the matrix.
142
+ */
143
+ template <Column_types column_type = Column_types::INTRUSIVE_SET>
144
+ struct Multi_persistence_options : Default_options<column_type, true> {
145
+ static const bool has_column_pairings = true;
146
+ static const bool has_vine_update = true;
147
+ };
148
+
149
+ /**
150
+ * @brief Options used by the cohomology module.
151
+ *
152
+ * @tparam column_type Column type for the matrix.
153
+ * @tparam is_z2_only True if Z2.
154
+ * @tparam FieldOperators Field operator.
155
+ */
156
+ template <Column_types column_type = Column_types::INTRUSIVE_LIST,
157
+ bool is_z2_only = true,
158
+ class FieldOperators = persistence_fields::Zp_field_operators<> >
159
+ struct Cohomology_persistence_options : Default_options<column_type, is_z2_only, FieldOperators> {
160
+ static const bool has_row_access = true;
161
+ static const bool has_column_compression = true;
162
+ static const bool has_removable_rows = true;
163
+ };
164
+
165
+ /**
166
+ * @private
167
+ */
168
+ template <typename T>
169
+ class RangeTraits
170
+ {
171
+ private:
172
+ static auto check_begin(...) -> std::false_type;
173
+ template <typename U>
174
+ static auto check_begin(const U& x) -> decltype(x.begin(), std::true_type{});
175
+
176
+ static auto check_size(...) -> std::false_type;
177
+ template <typename U>
178
+ static auto check_size(const U& x) -> decltype(x.size(), std::true_type{});
179
+
180
+ public:
181
+ static constexpr bool has_begin = decltype(check_begin(std::declval<T>()))::value;
182
+ static constexpr bool has_size = decltype(check_size(std::declval<T>()))::value;
183
+ };
184
+
185
+ } // namespace persistence_matrix
186
+ } // namespace Gudhi
187
+
188
+ #endif // PM_OPTIONS_INCLUDED