multipers 2.4.0b1__cp312-cp312-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- multipers/.dylibs/libboost_timer.dylib +0 -0
- multipers/.dylibs/libc++.1.0.dylib +0 -0
- multipers/.dylibs/libtbb.12.17.dylib +0 -0
- multipers/__init__.py +33 -0
- multipers/_signed_measure_meta.py +426 -0
- multipers/_slicer_meta.py +231 -0
- multipers/array_api/__init__.py +62 -0
- multipers/array_api/numpy.py +124 -0
- multipers/array_api/torch.py +133 -0
- multipers/data/MOL2.py +458 -0
- multipers/data/UCR.py +18 -0
- multipers/data/__init__.py +1 -0
- multipers/data/graphs.py +466 -0
- multipers/data/immuno_regions.py +27 -0
- multipers/data/minimal_presentation_to_st_bf.py +0 -0
- multipers/data/pytorch2simplextree.py +91 -0
- multipers/data/shape3d.py +101 -0
- multipers/data/synthetic.py +113 -0
- multipers/distances.py +202 -0
- multipers/filtration_conversions.pxd +736 -0
- multipers/filtration_conversions.pxd.tp +226 -0
- multipers/filtrations/__init__.py +21 -0
- multipers/filtrations/density.py +529 -0
- multipers/filtrations/filtrations.py +480 -0
- multipers/filtrations.pxd +534 -0
- multipers/filtrations.pxd.tp +332 -0
- multipers/function_rips.cpython-312-darwin.so +0 -0
- multipers/function_rips.pyx +104 -0
- multipers/grids.cpython-312-darwin.so +0 -0
- multipers/grids.pyx +538 -0
- multipers/gudhi/Persistence_slices_interface.h +213 -0
- multipers/gudhi/Simplex_tree_interface.h +274 -0
- multipers/gudhi/Simplex_tree_multi_interface.h +648 -0
- multipers/gudhi/gudhi/Bitmap_cubical_complex.h +450 -0
- multipers/gudhi/gudhi/Bitmap_cubical_complex_base.h +1070 -0
- multipers/gudhi/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h +579 -0
- multipers/gudhi/gudhi/Debug_utils.h +52 -0
- multipers/gudhi/gudhi/Degree_rips_bifiltration.h +2307 -0
- multipers/gudhi/gudhi/Dynamic_multi_parameter_filtration.h +2524 -0
- multipers/gudhi/gudhi/Fields/Multi_field.h +453 -0
- multipers/gudhi/gudhi/Fields/Multi_field_operators.h +460 -0
- multipers/gudhi/gudhi/Fields/Multi_field_shared.h +444 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small.h +584 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small_operators.h +490 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small_shared.h +580 -0
- multipers/gudhi/gudhi/Fields/Z2_field.h +391 -0
- multipers/gudhi/gudhi/Fields/Z2_field_operators.h +389 -0
- multipers/gudhi/gudhi/Fields/Zp_field.h +493 -0
- multipers/gudhi/gudhi/Fields/Zp_field_operators.h +384 -0
- multipers/gudhi/gudhi/Fields/Zp_field_shared.h +492 -0
- multipers/gudhi/gudhi/Flag_complex_edge_collapser.h +337 -0
- multipers/gudhi/gudhi/Matrix.h +2200 -0
- multipers/gudhi/gudhi/Multi_filtration/Multi_parameter_generator.h +1712 -0
- multipers/gudhi/gudhi/Multi_filtration/multi_filtration_conversions.h +237 -0
- multipers/gudhi/gudhi/Multi_filtration/multi_filtration_utils.h +225 -0
- multipers/gudhi/gudhi/Multi_parameter_filtered_complex.h +485 -0
- multipers/gudhi/gudhi/Multi_parameter_filtration.h +2643 -0
- multipers/gudhi/gudhi/Multi_persistence/Box.h +233 -0
- multipers/gudhi/gudhi/Multi_persistence/Line.h +309 -0
- multipers/gudhi/gudhi/Multi_persistence/Multi_parameter_filtered_complex_pcoh_interface.h +268 -0
- multipers/gudhi/gudhi/Multi_persistence/Persistence_interface_cohomology.h +159 -0
- multipers/gudhi/gudhi/Multi_persistence/Persistence_interface_matrix.h +463 -0
- multipers/gudhi/gudhi/Multi_persistence/Point.h +853 -0
- multipers/gudhi/gudhi/Off_reader.h +173 -0
- multipers/gudhi/gudhi/Persistence_matrix/Base_matrix.h +834 -0
- multipers/gudhi/gudhi/Persistence_matrix/Base_matrix_with_column_compression.h +838 -0
- multipers/gudhi/gudhi/Persistence_matrix/Boundary_matrix.h +833 -0
- multipers/gudhi/gudhi/Persistence_matrix/Chain_matrix.h +1367 -0
- multipers/gudhi/gudhi/Persistence_matrix/Id_to_index_overlay.h +1157 -0
- multipers/gudhi/gudhi/Persistence_matrix/Position_to_index_overlay.h +869 -0
- multipers/gudhi/gudhi/Persistence_matrix/RU_matrix.h +905 -0
- multipers/gudhi/gudhi/Persistence_matrix/allocators/entry_constructors.h +122 -0
- multipers/gudhi/gudhi/Persistence_matrix/base_pairing.h +260 -0
- multipers/gudhi/gudhi/Persistence_matrix/base_swap.h +288 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_pairing.h +170 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_rep_cycles.h +247 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_vine_swap.h +571 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/chain_column_extra_properties.h +182 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/column_dimension_holder.h +130 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/column_utilities.h +235 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/entry_types.h +312 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/heap_column.h +1092 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_list_column.h +923 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_set_column.h +914 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/list_column.h +930 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/naive_vector_column.h +1071 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/row_access.h +203 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/set_column.h +886 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/unordered_set_column.h +984 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/vector_column.h +1213 -0
- multipers/gudhi/gudhi/Persistence_matrix/index_mapper.h +58 -0
- multipers/gudhi/gudhi/Persistence_matrix/matrix_dimension_holders.h +227 -0
- multipers/gudhi/gudhi/Persistence_matrix/matrix_row_access.h +200 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_pairing.h +166 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_rep_cycles.h +319 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_vine_swap.h +562 -0
- multipers/gudhi/gudhi/Persistence_on_a_line.h +152 -0
- multipers/gudhi/gudhi/Persistence_on_rectangle.h +617 -0
- multipers/gudhi/gudhi/Persistent_cohomology/Field_Zp.h +118 -0
- multipers/gudhi/gudhi/Persistent_cohomology/Multi_field.h +173 -0
- multipers/gudhi/gudhi/Persistent_cohomology/Persistent_cohomology_column.h +128 -0
- multipers/gudhi/gudhi/Persistent_cohomology.h +769 -0
- multipers/gudhi/gudhi/Points_off_io.h +171 -0
- multipers/gudhi/gudhi/Projective_cover_kernel.h +379 -0
- multipers/gudhi/gudhi/Simple_object_pool.h +69 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_iterators.h +559 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +83 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_siblings.h +121 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_star_simplex_iterators.h +277 -0
- multipers/gudhi/gudhi/Simplex_tree/filtration_value_utils.h +155 -0
- multipers/gudhi/gudhi/Simplex_tree/hooks_simplex_base.h +62 -0
- multipers/gudhi/gudhi/Simplex_tree/indexing_tag.h +27 -0
- multipers/gudhi/gudhi/Simplex_tree/serialization_utils.h +60 -0
- multipers/gudhi/gudhi/Simplex_tree/simplex_tree_options.h +105 -0
- multipers/gudhi/gudhi/Simplex_tree.h +3170 -0
- multipers/gudhi/gudhi/Slicer.h +848 -0
- multipers/gudhi/gudhi/Thread_safe_slicer.h +393 -0
- multipers/gudhi/gudhi/distance_functions.h +62 -0
- multipers/gudhi/gudhi/graph_simplicial_complex.h +104 -0
- multipers/gudhi/gudhi/multi_simplex_tree_helpers.h +147 -0
- multipers/gudhi/gudhi/persistence_interval.h +263 -0
- multipers/gudhi/gudhi/persistence_matrix_options.h +188 -0
- multipers/gudhi/gudhi/reader_utils.h +367 -0
- multipers/gudhi/gudhi/simple_mdspan.h +484 -0
- multipers/gudhi/gudhi/slicer_helpers.h +779 -0
- multipers/gudhi/tmp_h0_pers/mma_interface_h0.h +223 -0
- multipers/gudhi/tmp_h0_pers/naive_merge_tree.h +536 -0
- multipers/io.cpython-312-darwin.so +0 -0
- multipers/io.pyx +472 -0
- multipers/ml/__init__.py +0 -0
- multipers/ml/accuracies.py +90 -0
- multipers/ml/invariants_with_persistable.py +79 -0
- multipers/ml/kernels.py +176 -0
- multipers/ml/mma.py +713 -0
- multipers/ml/one.py +472 -0
- multipers/ml/point_clouds.py +352 -0
- multipers/ml/signed_measures.py +1667 -0
- multipers/ml/sliced_wasserstein.py +461 -0
- multipers/ml/tools.py +113 -0
- multipers/mma_structures.cpython-312-darwin.so +0 -0
- multipers/mma_structures.pxd +134 -0
- multipers/mma_structures.pyx +1483 -0
- multipers/mma_structures.pyx.tp +1126 -0
- multipers/multi_parameter_rank_invariant/diff_helpers.h +85 -0
- multipers/multi_parameter_rank_invariant/euler_characteristic.h +95 -0
- multipers/multi_parameter_rank_invariant/function_rips.h +317 -0
- multipers/multi_parameter_rank_invariant/hilbert_function.h +761 -0
- multipers/multi_parameter_rank_invariant/persistence_slices.h +149 -0
- multipers/multi_parameter_rank_invariant/rank_invariant.h +350 -0
- multipers/multiparameter_edge_collapse.py +41 -0
- multipers/multiparameter_module_approximation/approximation.h +2541 -0
- multipers/multiparameter_module_approximation/debug.h +107 -0
- multipers/multiparameter_module_approximation/format_python-cpp.h +292 -0
- multipers/multiparameter_module_approximation/utilities.h +428 -0
- multipers/multiparameter_module_approximation.cpython-312-darwin.so +0 -0
- multipers/multiparameter_module_approximation.pyx +286 -0
- multipers/ops.cpython-312-darwin.so +0 -0
- multipers/ops.pyx +231 -0
- multipers/pickle.py +89 -0
- multipers/plots.py +550 -0
- multipers/point_measure.cpython-312-darwin.so +0 -0
- multipers/point_measure.pyx +409 -0
- multipers/simplex_tree_multi.cpython-312-darwin.so +0 -0
- multipers/simplex_tree_multi.pxd +136 -0
- multipers/simplex_tree_multi.pyx +11719 -0
- multipers/simplex_tree_multi.pyx.tp +2102 -0
- multipers/slicer.cpython-312-darwin.so +0 -0
- multipers/slicer.pxd +2097 -0
- multipers/slicer.pxd.tp +263 -0
- multipers/slicer.pyx +13042 -0
- multipers/slicer.pyx.tp +1259 -0
- multipers/tensor/tensor.h +672 -0
- multipers/tensor.pxd +13 -0
- multipers/test.pyx +44 -0
- multipers/tests/__init__.py +70 -0
- multipers/torch/__init__.py +1 -0
- multipers/torch/diff_grids.py +240 -0
- multipers/torch/rips_density.py +310 -0
- multipers/vector_interface.pxd +46 -0
- multipers-2.4.0b1.dist-info/METADATA +131 -0
- multipers-2.4.0b1.dist-info/RECORD +184 -0
- multipers-2.4.0b1.dist-info/WHEEL +6 -0
- multipers-2.4.0b1.dist-info/licenses/LICENSE +21 -0
- multipers-2.4.0b1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,319 @@
|
|
|
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 ru_rep_cycles.h
|
|
13
|
+
* @author Hannah Schreiber
|
|
14
|
+
* @brief Contains the @ref Gudhi::persistence_matrix::RU_representative_cycles class and
|
|
15
|
+
* @ref Gudhi::persistence_matrix::Dummy_ru_representative_cycles structure.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#ifndef PM_RU_REP_CYCLES_H
|
|
19
|
+
#define PM_RU_REP_CYCLES_H
|
|
20
|
+
|
|
21
|
+
#include <utility> //std::move
|
|
22
|
+
#include <algorithm> //std::sort
|
|
23
|
+
#include <vector>
|
|
24
|
+
|
|
25
|
+
#ifdef GUDHI_USE_TBB
|
|
26
|
+
#include <tbb/parallel_for.h>
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
#include <gudhi/persistence_matrix_options.h>
|
|
30
|
+
|
|
31
|
+
namespace Gudhi {
|
|
32
|
+
namespace persistence_matrix {
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @ingroup persistence_matrix
|
|
36
|
+
*
|
|
37
|
+
* @brief Empty structure.
|
|
38
|
+
* Inherited instead of @ref RU_representative_cycles, when the computation of the representative cycles
|
|
39
|
+
* were not enabled.
|
|
40
|
+
*/
|
|
41
|
+
struct Dummy_ru_representative_cycles {
|
|
42
|
+
friend void swap([[maybe_unused]] Dummy_ru_representative_cycles& d1,
|
|
43
|
+
[[maybe_unused]] Dummy_ru_representative_cycles& d2) noexcept
|
|
44
|
+
{}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @class RU_representative_cycles ru_rep_cycles.h gudhi/Persistence_matrix/ru_rep_cycles.h
|
|
49
|
+
* @ingroup persistence_matrix
|
|
50
|
+
*
|
|
51
|
+
* @brief Class managing the representative cycles for @ref RU_matrix if the option was enabled.
|
|
52
|
+
*
|
|
53
|
+
* @tparam Master_matrix An instantiation of @ref Matrix from which all types and options are deduced.
|
|
54
|
+
*/
|
|
55
|
+
template <class Master_matrix>
|
|
56
|
+
class RU_representative_cycles
|
|
57
|
+
{
|
|
58
|
+
public:
|
|
59
|
+
using Index = typename Master_matrix::Index; /**< @ref MatIdx index type. */
|
|
60
|
+
using Bar = typename Master_matrix::Bar; /**< Bar type. */
|
|
61
|
+
using Cycle = typename Master_matrix::Cycle; /**< Cycle type. */
|
|
62
|
+
using Dimension = typename Master_matrix::Dimension; /**< Dimension type. */
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @brief Default constructor.
|
|
66
|
+
*/
|
|
67
|
+
RU_representative_cycles() = default;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @brief Computes the current representative cycles of the matrix.
|
|
71
|
+
*
|
|
72
|
+
* @param dim If different from default value, only the cycles of the given dimension are updated.
|
|
73
|
+
* All others are erased.
|
|
74
|
+
*/
|
|
75
|
+
void update_representative_cycles(Dimension dim = Master_matrix::template get_null_value<Dimension>());
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @brief Computes the current representative cycle of the given bar. All other cycles already computed are left
|
|
79
|
+
* untouched (and therefore they could be unvalid for the current matrix).
|
|
80
|
+
*
|
|
81
|
+
* @param bar Bar corresponding to the wanted representative cycle.
|
|
82
|
+
*/
|
|
83
|
+
void update_representative_cycle(const Bar& bar);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @brief Returns the current representative cycles. If the matrix was modified since the last call,
|
|
87
|
+
* @ref update_representative_cycles has to be called to update the returned cycles.
|
|
88
|
+
*
|
|
89
|
+
* @return A const reference to a vector of @ref Matrix::Cycle containing all representative cycles.
|
|
90
|
+
*/
|
|
91
|
+
const std::vector<Cycle>& get_representative_cycles();
|
|
92
|
+
/**
|
|
93
|
+
* @brief Returns the representative cycle corresponding to the given bar.
|
|
94
|
+
* If the matrix was modified since the last call, @ref update_representative_cycles or
|
|
95
|
+
* @ref update_representative_cycle has to be called to update the returned cycle.
|
|
96
|
+
*
|
|
97
|
+
* @param bar Bar corresponding to the wanted representative cycle.
|
|
98
|
+
* @return A const reference to the representative cycle.
|
|
99
|
+
*/
|
|
100
|
+
const Cycle& get_representative_cycle(const Bar& bar);
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @brief Swap operator.
|
|
104
|
+
*/
|
|
105
|
+
friend void swap(RU_representative_cycles& base1, RU_representative_cycles& base2) noexcept
|
|
106
|
+
{
|
|
107
|
+
base1.representativeCycles_.swap(base2.representativeCycles_);
|
|
108
|
+
base1.birthToCycle_.swap(base2.birthToCycle_);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
protected:
|
|
112
|
+
void _reset();
|
|
113
|
+
|
|
114
|
+
private:
|
|
115
|
+
using Master_RU_matrix = typename Master_matrix::Master_RU_matrix;
|
|
116
|
+
using Inverse_column = Cycle;
|
|
117
|
+
using Content_range = typename Master_matrix::Column::Content_range;
|
|
118
|
+
|
|
119
|
+
std::vector<Cycle> representativeCycles_; /**< Cycle container. */
|
|
120
|
+
std::vector<Index> birthToCycle_; /**< Map from birth index to cycle index. */
|
|
121
|
+
|
|
122
|
+
constexpr Master_RU_matrix* _matrix() { return static_cast<Master_RU_matrix*>(this); }
|
|
123
|
+
constexpr const Master_RU_matrix* _matrix() const { return static_cast<const Master_RU_matrix*>(this); }
|
|
124
|
+
|
|
125
|
+
void _retrieve_cycle_from_r(Index colIdx, Index repIdx);
|
|
126
|
+
void _retrieve_cycle_from_u(Index colIdx, Index repIdx);
|
|
127
|
+
Inverse_column _get_inverse(Index c);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
template <class Master_matrix>
|
|
131
|
+
inline void RU_representative_cycles<Master_matrix>::update_representative_cycles(Dimension dim)
|
|
132
|
+
{
|
|
133
|
+
Index nberColumns = _matrix()->reducedMatrixR_.get_number_of_columns();
|
|
134
|
+
Index nullValue = Master_matrix::template get_null_value<Index>();
|
|
135
|
+
representativeCycles_.clear();
|
|
136
|
+
birthToCycle_.clear();
|
|
137
|
+
birthToCycle_.resize(nberColumns, nullValue);
|
|
138
|
+
|
|
139
|
+
Index c = 0;
|
|
140
|
+
for (Index i = 0; i < nberColumns; i++) {
|
|
141
|
+
if ((dim == Master_matrix::template get_null_value<Dimension>() ||
|
|
142
|
+
_matrix()->reducedMatrixR_.get_column_dimension(i) == dim) &&
|
|
143
|
+
_matrix()->reducedMatrixR_.is_zero_column(i)) {
|
|
144
|
+
birthToCycle_[i] = c;
|
|
145
|
+
++c;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
representativeCycles_.resize(c);
|
|
150
|
+
#ifdef GUDHI_USE_TBB
|
|
151
|
+
tbb::parallel_for(static_cast<Index>(0), nberColumns, [&](Index i) {
|
|
152
|
+
if (birthToCycle_[i] != nullValue) {
|
|
153
|
+
Index colIdx = _matrix()->_get_column_with_pivot(i);
|
|
154
|
+
if (colIdx == nullValue) {
|
|
155
|
+
_retrieve_cycle_from_u(i, birthToCycle_[i]);
|
|
156
|
+
} else {
|
|
157
|
+
_retrieve_cycle_from_r(colIdx, birthToCycle_[i]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
#else
|
|
162
|
+
for (Index i = 0; i < nberColumns; ++i) {
|
|
163
|
+
if (birthToCycle_[i] != nullValue) {
|
|
164
|
+
Index colIdx = _matrix()->_get_column_with_pivot(i);
|
|
165
|
+
if (colIdx == nullValue) {
|
|
166
|
+
_retrieve_cycle_from_u(i, birthToCycle_[i]);
|
|
167
|
+
} else {
|
|
168
|
+
_retrieve_cycle_from_r(colIdx, birthToCycle_[i]);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
#endif
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
template <class Master_matrix>
|
|
176
|
+
inline void RU_representative_cycles<Master_matrix>::update_representative_cycle(const Bar& bar)
|
|
177
|
+
{
|
|
178
|
+
Index nullValue = Master_matrix::template get_null_value<Index>();
|
|
179
|
+
|
|
180
|
+
if (birthToCycle_.size() <= bar.birth) {
|
|
181
|
+
birthToCycle_.resize(bar.birth + 1, nullValue);
|
|
182
|
+
}
|
|
183
|
+
if (birthToCycle_[bar.birth] == nullValue) {
|
|
184
|
+
birthToCycle_[bar.birth] = representativeCycles_.size();
|
|
185
|
+
representativeCycles_.resize(representativeCycles_.size() + 1);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
Index colIdx = _matrix()->_get_column_with_pivot(bar.birth);
|
|
189
|
+
if (colIdx == nullValue) {
|
|
190
|
+
_retrieve_cycle_from_u(bar.birth, birthToCycle_[bar.birth]);
|
|
191
|
+
} else {
|
|
192
|
+
_retrieve_cycle_from_r(colIdx, birthToCycle_[bar.birth]);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
template <class Master_matrix>
|
|
197
|
+
inline const std::vector<typename RU_representative_cycles<Master_matrix>::Cycle>&
|
|
198
|
+
RU_representative_cycles<Master_matrix>::get_representative_cycles()
|
|
199
|
+
{
|
|
200
|
+
return representativeCycles_;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
template <class Master_matrix>
|
|
204
|
+
inline const typename RU_representative_cycles<Master_matrix>::Cycle&
|
|
205
|
+
RU_representative_cycles<Master_matrix>::get_representative_cycle(const Bar& bar)
|
|
206
|
+
{
|
|
207
|
+
return representativeCycles_[birthToCycle_[bar.birth]];
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
template <class Master_matrix>
|
|
211
|
+
inline void RU_representative_cycles<Master_matrix>::_retrieve_cycle_from_r(Index colIdx, Index repIdx)
|
|
212
|
+
{
|
|
213
|
+
auto& col = _matrix()->reducedMatrixR_.get_column(colIdx);
|
|
214
|
+
representativeCycles_[repIdx] = Master_matrix::build_cycle_from_range(col.get_non_zero_content_range());
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
template <class Master_matrix>
|
|
218
|
+
inline void RU_representative_cycles<Master_matrix>::_retrieve_cycle_from_u(Index colIdx, Index repIdx)
|
|
219
|
+
{
|
|
220
|
+
// TODO: if rep_cycles true but not vineyards, this could be avoided by directly computing V instead of U
|
|
221
|
+
representativeCycles_[repIdx] = _get_inverse(colIdx);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
template <class Master_matrix>
|
|
225
|
+
inline typename RU_representative_cycles<Master_matrix>::Inverse_column
|
|
226
|
+
RU_representative_cycles<Master_matrix>::_get_inverse(Index c)
|
|
227
|
+
{
|
|
228
|
+
using E = typename Master_matrix::Element;
|
|
229
|
+
auto& matrix = _matrix()->mirrorMatrixU_;
|
|
230
|
+
auto size = matrix.get_number_of_columns();
|
|
231
|
+
[[maybe_unused]] const auto& op = _matrix()->operators_;
|
|
232
|
+
Inverse_column res;
|
|
233
|
+
|
|
234
|
+
auto _last_diagonal_value = [&]() -> E {
|
|
235
|
+
auto& col = matrix.get_column(size - 1);
|
|
236
|
+
if (col.is_empty()) return 0; // happens only if the user multiplied by 0 a column in R
|
|
237
|
+
// if column not empty, pivot has to be on the diagonal
|
|
238
|
+
if constexpr (Master_matrix::Option_list::is_z2) {
|
|
239
|
+
return 1;
|
|
240
|
+
} else {
|
|
241
|
+
return op->get_inverse(matrix.get_column(size - 1).get_pivot_value());
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
auto _push_cell = [&](auto i, E e) -> void {
|
|
246
|
+
if constexpr (Master_matrix::Option_list::is_z2) {
|
|
247
|
+
if (e) res.push_back(i);
|
|
248
|
+
} else {
|
|
249
|
+
if (e != op->get_additive_identity()) res.push_back({i, e});
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
auto _substract = [&](E& e, auto resIt, const auto& cell) -> void {
|
|
254
|
+
if (resIt != res.rend() && Master_matrix::get_row_index(*resIt) == cell.get_row_index()) {
|
|
255
|
+
if constexpr (Master_matrix::Option_list::is_z2) {
|
|
256
|
+
e = !e;
|
|
257
|
+
} else {
|
|
258
|
+
op->subtract_inplace_front(e, cell.get_element() * Master_matrix::get_element(*resIt));
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
auto _multiply = [&](E& e, E m) -> void {
|
|
264
|
+
if constexpr (Master_matrix::Option_list::is_z2) {
|
|
265
|
+
e = m && e; // just in case, but m is only possibly 0 if the user multiplied by 0 a column in R
|
|
266
|
+
} else {
|
|
267
|
+
op->multiply_inplace(e, op->get_inverse(m));
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
auto _translate = [&](std::size_t i) -> void {
|
|
272
|
+
const auto& map = _matrix()->positionToID_;
|
|
273
|
+
auto& idx = Master_matrix::get_row_index(res[i]);
|
|
274
|
+
auto it = map.find(idx);
|
|
275
|
+
if (it != map.end()) idx = it->second;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
if (c == size - 1) _push_cell(size - 1, _last_diagonal_value());
|
|
279
|
+
for (int i = size - 2; i >= 0; --i) {
|
|
280
|
+
E e = static_cast<int>(c) == i;
|
|
281
|
+
auto& line = matrix.get_column(i);
|
|
282
|
+
Content_range r = line.get_non_zero_content_range();
|
|
283
|
+
auto resIt = res.rbegin();
|
|
284
|
+
auto lineIt = r.begin();
|
|
285
|
+
E diag(0);
|
|
286
|
+
if (static_cast<int>(lineIt->get_row_index()) == i) {
|
|
287
|
+
diag = lineIt->get_element();
|
|
288
|
+
++lineIt;
|
|
289
|
+
}
|
|
290
|
+
while (lineIt != r.end() && resIt != res.rend()) {
|
|
291
|
+
while (resIt != res.rend() && Master_matrix::get_row_index(*resIt) < lineIt->get_row_index()) ++resIt;
|
|
292
|
+
_substract(e, resIt, *lineIt);
|
|
293
|
+
++lineIt;
|
|
294
|
+
}
|
|
295
|
+
_multiply(e, diag);
|
|
296
|
+
_push_cell(i, e);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// reverse order + PosIdx to IDIdx translation
|
|
300
|
+
for (std::size_t incr = 0, decr = res.size() - 1; incr < decr; ++incr, --decr) {
|
|
301
|
+
_translate(incr);
|
|
302
|
+
_translate(decr);
|
|
303
|
+
std::swap(res[incr], res[decr]);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return res;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
template <class Master_matrix>
|
|
310
|
+
inline void RU_representative_cycles<Master_matrix>::_reset()
|
|
311
|
+
{
|
|
312
|
+
representativeCycles_.clear();
|
|
313
|
+
birthToCycle_.clear();
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
} // namespace persistence_matrix
|
|
317
|
+
} // namespace Gudhi
|
|
318
|
+
|
|
319
|
+
#endif // PM_RU_REP_CYCLES_H
|