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,122 @@
|
|
|
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 entry_constructors.h
|
|
13
|
+
* @author Hannah Schreiber
|
|
14
|
+
* @brief Contains different versions of @ref Gudhi::persistence_matrix::Entry factories.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#ifndef PM_COLUMN_ENTRY_CONSTRUCTORS_H
|
|
18
|
+
#define PM_COLUMN_ENTRY_CONSTRUCTORS_H
|
|
19
|
+
|
|
20
|
+
#include <utility> //std::swap
|
|
21
|
+
|
|
22
|
+
#include <gudhi/Simple_object_pool.h>
|
|
23
|
+
|
|
24
|
+
namespace Gudhi {
|
|
25
|
+
namespace persistence_matrix {
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @private
|
|
29
|
+
* @ingroup persistence_matrix
|
|
30
|
+
*
|
|
31
|
+
* @brief @ref Entry factory. Constructs and destroys entry pointers with new and delete.
|
|
32
|
+
*
|
|
33
|
+
* @tparam Entry @ref Entry with the right templates.
|
|
34
|
+
*/
|
|
35
|
+
template <class Entry>
|
|
36
|
+
struct New_entry_constructor {
|
|
37
|
+
/**
|
|
38
|
+
* @brief Default constructor.
|
|
39
|
+
*/
|
|
40
|
+
New_entry_constructor() = default;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @brief Constructs an entry with the given entry arguments.
|
|
44
|
+
*
|
|
45
|
+
* @param u Arguments forwarded to the @ref Entry constructor.
|
|
46
|
+
* @return @ref Entry pointer.
|
|
47
|
+
*/
|
|
48
|
+
template <class... U>
|
|
49
|
+
Entry* construct(U&&... u) const
|
|
50
|
+
{
|
|
51
|
+
return new Entry(std::forward<U>(u)...);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @brief Destroys the given entry.
|
|
56
|
+
*
|
|
57
|
+
* @param entry @ref Entry pointer.
|
|
58
|
+
*/
|
|
59
|
+
void destroy(Entry* entry) const { delete entry; }
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @brief Swap operator.
|
|
63
|
+
*/
|
|
64
|
+
friend void swap([[maybe_unused]] New_entry_constructor& col1,
|
|
65
|
+
[[maybe_unused]] New_entry_constructor& col2) noexcept {}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @private
|
|
70
|
+
* @ingroup persistence_matrix
|
|
71
|
+
*
|
|
72
|
+
* @brief @ref Entry factory. Uses @ref Gudhi::Simple_object_pool, which is based on boost::object_pool,
|
|
73
|
+
* to construct and destroy entry pointer.
|
|
74
|
+
*
|
|
75
|
+
* @tparam Entry @ref Entry with the right templates.
|
|
76
|
+
*/
|
|
77
|
+
template <class Entry>
|
|
78
|
+
struct Pool_entry_constructor {
|
|
79
|
+
public:
|
|
80
|
+
/**
|
|
81
|
+
* @brief Default constructor.
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
Pool_entry_constructor() : entryPool_() {}
|
|
85
|
+
|
|
86
|
+
// TODO: what does happen when the pool is copied?
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @brief Constructs an entry with the given entry arguments.
|
|
90
|
+
*
|
|
91
|
+
* @param u Arguments forwarded to the @ref Entry constructor.
|
|
92
|
+
* @return @ref Entry pointer.
|
|
93
|
+
*/
|
|
94
|
+
template <class... U>
|
|
95
|
+
Entry* construct(U&&... u)
|
|
96
|
+
{
|
|
97
|
+
return entryPool_.construct(std::forward<U>(u)...);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @brief Destroys the given entry.
|
|
102
|
+
*
|
|
103
|
+
* @param entry @ref Entry pointer.
|
|
104
|
+
*/
|
|
105
|
+
void destroy(Entry* entry) { entryPool_.destroy(entry); }
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @brief Swap operator.
|
|
109
|
+
*/
|
|
110
|
+
friend void swap(Pool_entry_constructor& col1, Pool_entry_constructor& col2) noexcept
|
|
111
|
+
{
|
|
112
|
+
std::swap(col1.entryPool_, col2.entryPool_);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private:
|
|
116
|
+
Simple_object_pool<Entry> entryPool_; /**< Entry pool. */
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
} // namespace persistence_matrix
|
|
120
|
+
} // namespace Gudhi
|
|
121
|
+
|
|
122
|
+
#endif // PM_COLUMN_ENTRY_CONSTRUCTORS_H
|
|
@@ -0,0 +1,260 @@
|
|
|
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 base_pairing.h
|
|
13
|
+
* @author Hannah Schreiber
|
|
14
|
+
* @brief Contains the @ref Gudhi::persistence_matrix::Base_pairing class and
|
|
15
|
+
* @ref Gudhi::persistence_matrix::Dummy_base_pairing structure.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#ifndef PM_BASE_PAIRING_H
|
|
19
|
+
#define PM_BASE_PAIRING_H
|
|
20
|
+
|
|
21
|
+
#include <utility> //std::swap & std::move
|
|
22
|
+
#include <unordered_map>
|
|
23
|
+
#include <algorithm>
|
|
24
|
+
#include <vector>
|
|
25
|
+
|
|
26
|
+
#include <gudhi/Persistence_matrix/index_mapper.h>
|
|
27
|
+
|
|
28
|
+
namespace Gudhi {
|
|
29
|
+
namespace persistence_matrix {
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @ingroup persistence_matrix
|
|
33
|
+
*
|
|
34
|
+
* @brief Empty structure.
|
|
35
|
+
* Inherited instead of @ref Base_pairing, when the computation of the barcode was not enabled or if the pairing
|
|
36
|
+
* is already managed by the vine update classes.
|
|
37
|
+
*/
|
|
38
|
+
struct Dummy_base_pairing {
|
|
39
|
+
friend void swap([[maybe_unused]] Dummy_base_pairing& d1, [[maybe_unused]] Dummy_base_pairing& d2) noexcept {}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @class Base_pairing base_pairing.h gudhi/Persistence_matrix/base_pairing.h
|
|
44
|
+
* @ingroup persistence_matrix
|
|
45
|
+
*
|
|
46
|
+
* @brief Class managing the barcode for @ref Boundary_matrix if the option was enabled.
|
|
47
|
+
*
|
|
48
|
+
* @tparam Master_matrix An instantiation of @ref Matrix from which all types and options are deduced.
|
|
49
|
+
*/
|
|
50
|
+
template <class Master_matrix>
|
|
51
|
+
class Base_pairing
|
|
52
|
+
: protected std::conditional_t<
|
|
53
|
+
Master_matrix::Option_list::has_removable_columns,
|
|
54
|
+
Index_mapper<std::unordered_map<typename Master_matrix::Pos_index, typename Master_matrix::ID_index> >,
|
|
55
|
+
Dummy_index_mapper>
|
|
56
|
+
{
|
|
57
|
+
protected:
|
|
58
|
+
using Pos_index = typename Master_matrix::Pos_index;
|
|
59
|
+
using ID_index = typename Master_matrix::ID_index;
|
|
60
|
+
// PIDM = Position to ID Map
|
|
61
|
+
using PIDM = std::conditional_t<Master_matrix::Option_list::has_removable_columns,
|
|
62
|
+
Index_mapper<std::unordered_map<Pos_index, ID_index> >,
|
|
63
|
+
Dummy_index_mapper>;
|
|
64
|
+
|
|
65
|
+
public:
|
|
66
|
+
using Bar = typename Master_matrix::Bar; /**< Bar type. */
|
|
67
|
+
using Barcode = typename Master_matrix::Barcode; /**< Barcode type. */
|
|
68
|
+
using Column = typename Master_matrix::Column; /**< Column type. */
|
|
69
|
+
using Index = typename Master_matrix::Index; /**< Container index type. */
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @brief Default constructor.
|
|
73
|
+
*/
|
|
74
|
+
Base_pairing();
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @brief Reduces the matrix stored in @ref Boundary_matrix and computes the corresponding barcode.
|
|
78
|
+
*
|
|
79
|
+
* @warning The barcode will not be recomputed if the matrix is modified later after calling this method
|
|
80
|
+
* for the first time. So call it only once the matrix is finalized. This behaviour could be changed in the future,
|
|
81
|
+
* if the need is mentioned.
|
|
82
|
+
*
|
|
83
|
+
* @return Const reference to the barcode.
|
|
84
|
+
*/
|
|
85
|
+
const Barcode& get_current_barcode();
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @brief Swap operator.
|
|
89
|
+
*/
|
|
90
|
+
friend void swap(Base_pairing& pairing1, Base_pairing& pairing2) noexcept
|
|
91
|
+
{
|
|
92
|
+
if constexpr (Master_matrix::Option_list::has_removable_columns) {
|
|
93
|
+
swap(static_cast<PIDM&>(pairing1), static_cast<PIDM&>(pairing2));
|
|
94
|
+
}
|
|
95
|
+
pairing1.barcode_.swap(pairing2.barcode_);
|
|
96
|
+
pairing1.deathToBar_.swap(pairing2.deathToBar_);
|
|
97
|
+
pairing1.idToPosition_.swap(pairing2.idToPosition_);
|
|
98
|
+
std::swap(pairing1.isReduced_, pairing2.isReduced_);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
protected:
|
|
102
|
+
void _remove_last(Pos_index columnIndex);
|
|
103
|
+
void _insert_id_position(ID_index id, Pos_index pos);
|
|
104
|
+
void _reset();
|
|
105
|
+
|
|
106
|
+
private:
|
|
107
|
+
using Dictionary = typename Master_matrix::Bar_dictionary;
|
|
108
|
+
using Base_matrix = typename Master_matrix::Master_boundary_matrix;
|
|
109
|
+
|
|
110
|
+
Barcode barcode_; /**< Bar container. */
|
|
111
|
+
Dictionary deathToBar_; /**< Map from death index to bar index. */
|
|
112
|
+
bool isReduced_; /**< True if `_reduce()` was called. */
|
|
113
|
+
/**
|
|
114
|
+
* @brief Map from cell ID to cell position. Only stores a pair if ID != position.
|
|
115
|
+
*/
|
|
116
|
+
std::unordered_map<ID_index, Pos_index> idToPosition_; // TODO: test other map types
|
|
117
|
+
|
|
118
|
+
void _reduce();
|
|
119
|
+
void _reduce_column_with(Column& toReduce, Column& toAdd);
|
|
120
|
+
|
|
121
|
+
// access to inheriting Boundary_matrix class
|
|
122
|
+
constexpr Base_matrix* _matrix() { return static_cast<Base_matrix*>(this); }
|
|
123
|
+
|
|
124
|
+
constexpr const Base_matrix* _matrix() const { return static_cast<const Base_matrix*>(this); }
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
template <class Master_matrix>
|
|
128
|
+
inline Base_pairing<Master_matrix>::Base_pairing() : PIDM(), isReduced_(false)
|
|
129
|
+
{}
|
|
130
|
+
|
|
131
|
+
template <class Master_matrix>
|
|
132
|
+
inline const typename Base_pairing<Master_matrix>::Barcode& Base_pairing<Master_matrix>::get_current_barcode()
|
|
133
|
+
{
|
|
134
|
+
if (!isReduced_) _reduce();
|
|
135
|
+
return barcode_;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
template <class Master_matrix>
|
|
139
|
+
inline void Base_pairing<Master_matrix>::_reduce()
|
|
140
|
+
{
|
|
141
|
+
constexpr const Pos_index nullDeath = Master_matrix::template get_null_value<Pos_index>();
|
|
142
|
+
constexpr const Index nullIndex = Master_matrix::template get_null_value<Index>();
|
|
143
|
+
constexpr const ID_index nullPivot = Master_matrix::template get_null_value<ID_index>();
|
|
144
|
+
|
|
145
|
+
std::unordered_map<Index, Index> negativeColumns(_matrix()->get_number_of_columns());
|
|
146
|
+
|
|
147
|
+
auto dim = _matrix()->get_max_dimension();
|
|
148
|
+
std::vector<std::vector<Index> > columnsByDim(dim + 1);
|
|
149
|
+
for (auto& v : columnsByDim) v.reserve(_matrix()->get_number_of_columns());
|
|
150
|
+
for (unsigned int i = 0; i < _matrix()->get_number_of_columns(); i++) {
|
|
151
|
+
columnsByDim[dim - _matrix()->get_column_dimension(i)].push_back(i);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
for (const auto& cols : columnsByDim) {
|
|
155
|
+
for (Index i : cols) {
|
|
156
|
+
auto& curr = _matrix()->get_column(i);
|
|
157
|
+
if (curr.is_empty()) {
|
|
158
|
+
if (negativeColumns.find(i) == negativeColumns.end()) {
|
|
159
|
+
barcode_.emplace_back(i, nullDeath, dim);
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
ID_index pivot = curr.get_pivot();
|
|
163
|
+
auto it = idToPosition_.find(pivot);
|
|
164
|
+
Index pivotColumnNumber = it == idToPosition_.end() ? pivot : it->second;
|
|
165
|
+
auto itNeg = negativeColumns.find(pivotColumnNumber);
|
|
166
|
+
Index pivotKiller = itNeg == negativeColumns.end() ? nullIndex : itNeg->second;
|
|
167
|
+
|
|
168
|
+
while (pivot != nullPivot && pivotKiller != nullIndex) {
|
|
169
|
+
_reduce_column_with(curr, _matrix()->get_column(pivotKiller));
|
|
170
|
+
pivot = curr.get_pivot();
|
|
171
|
+
it = idToPosition_.find(pivot);
|
|
172
|
+
pivotColumnNumber = it == idToPosition_.end() ? pivot : it->second;
|
|
173
|
+
itNeg = negativeColumns.find(pivotColumnNumber);
|
|
174
|
+
pivotKiller = itNeg == negativeColumns.end() ? nullIndex : itNeg->second;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (pivot != nullPivot) {
|
|
178
|
+
negativeColumns.emplace(pivotColumnNumber, i);
|
|
179
|
+
_matrix()->get_column(pivotColumnNumber).clear();
|
|
180
|
+
barcode_.emplace_back(pivotColumnNumber, i, dim - 1);
|
|
181
|
+
} else {
|
|
182
|
+
curr.clear();
|
|
183
|
+
barcode_.emplace_back(i, nullDeath, dim);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
--dim;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if constexpr (Master_matrix::Option_list::has_removable_columns) {
|
|
191
|
+
// sort barcode by birth such that a removal is trivial
|
|
192
|
+
std::sort(barcode_.begin(), barcode_.end(), [](const Bar& b1, const Bar& b2) { return b1.birth < b2.birth; });
|
|
193
|
+
// map can only be constructed once barcode is sorted
|
|
194
|
+
for (Index i = 0; i < barcode_.size(); ++i) {
|
|
195
|
+
auto d = barcode_[i].death;
|
|
196
|
+
if (d != Master_matrix::template get_null_value<Pos_index>()) {
|
|
197
|
+
deathToBar_.emplace(d, i);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
isReduced_ = true;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
template <class Master_matrix>
|
|
206
|
+
inline void Base_pairing<Master_matrix>::_reduce_column_with(Column& toReduce, Column& toAdd)
|
|
207
|
+
{
|
|
208
|
+
if constexpr (Master_matrix::Option_list::is_z2) {
|
|
209
|
+
toReduce += toAdd;
|
|
210
|
+
} else {
|
|
211
|
+
typename Master_matrix::Element coeff = toAdd.get_pivot_value();
|
|
212
|
+
auto& operators = _matrix()->colSettings_->operators;
|
|
213
|
+
coeff = operators.get_inverse(coeff);
|
|
214
|
+
operators.multiply_inplace(coeff, operators.get_characteristic() - toReduce.get_pivot_value());
|
|
215
|
+
toReduce.multiply_source_and_add(toAdd, coeff);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
template <class Master_matrix>
|
|
220
|
+
inline void Base_pairing<Master_matrix>::_remove_last(Pos_index columnIndex)
|
|
221
|
+
{
|
|
222
|
+
static_assert(Master_matrix::Option_list::has_removable_columns, "remove_last not available.");
|
|
223
|
+
|
|
224
|
+
if (isReduced_) {
|
|
225
|
+
auto it = deathToBar_.find(columnIndex);
|
|
226
|
+
|
|
227
|
+
if (it == deathToBar_.end()) { // birth
|
|
228
|
+
barcode_.pop_back(); // sorted by birth and columnIndex has to be the highest one
|
|
229
|
+
} else { // death
|
|
230
|
+
barcode_[it->second].death = Master_matrix::template get_null_value<Pos_index>();
|
|
231
|
+
deathToBar_.erase(it);
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
auto it = PIDM::map_.find(columnIndex);
|
|
236
|
+
if (it != PIDM::map_.end()) {
|
|
237
|
+
idToPosition_.erase(it->second);
|
|
238
|
+
PIDM::map_.erase(it);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
template <class Master_matrix>
|
|
243
|
+
inline void Base_pairing<Master_matrix>::_insert_id_position(ID_index id, Pos_index pos)
|
|
244
|
+
{
|
|
245
|
+
idToPosition_.emplace(id, pos);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
template <class Master_matrix>
|
|
249
|
+
inline void Base_pairing<Master_matrix>::_reset()
|
|
250
|
+
{
|
|
251
|
+
barcode_.clear();
|
|
252
|
+
deathToBar_.clear();
|
|
253
|
+
isReduced_ = false;
|
|
254
|
+
idToPosition_.clear();
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
} // namespace persistence_matrix
|
|
258
|
+
} // namespace Gudhi
|
|
259
|
+
|
|
260
|
+
#endif // PM_BASE_PAIRING_H
|
|
@@ -0,0 +1,288 @@
|
|
|
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-23 Inria
|
|
6
|
+
*
|
|
7
|
+
* Modification(s):
|
|
8
|
+
* - YYYY/MM Author: Description of the modification
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @file base_swap.h
|
|
13
|
+
* @author Hannah Schreiber
|
|
14
|
+
* @brief Contains the @ref Gudhi::persistence_matrix::Base_swap class and
|
|
15
|
+
* @ref Gudhi::persistence_matrix::Dummy_base_swap structure.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#ifndef PM_BASE_SWAP_H
|
|
19
|
+
#define PM_BASE_SWAP_H
|
|
20
|
+
|
|
21
|
+
#include <utility> //std::swap, std::move & std::exchange
|
|
22
|
+
#include <algorithm> //std::max
|
|
23
|
+
|
|
24
|
+
namespace Gudhi {
|
|
25
|
+
namespace persistence_matrix {
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @ingroup persistence_matrix
|
|
29
|
+
*
|
|
30
|
+
* @brief Empty structure.
|
|
31
|
+
* Inherited instead of @ref Base_swap, when the column and row swaps are not enabled.
|
|
32
|
+
*/
|
|
33
|
+
struct Dummy_base_swap {
|
|
34
|
+
friend void swap([[maybe_unused]] Dummy_base_swap& d1, [[maybe_unused]] Dummy_base_swap& d2) noexcept {}
|
|
35
|
+
|
|
36
|
+
Dummy_base_swap([[maybe_unused]] unsigned int numberOfColumns = 0) {}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @class Base_swap base_swap.h gudhi/Persistence_matrix/base_swap.h
|
|
41
|
+
* @ingroup persistence_matrix
|
|
42
|
+
*
|
|
43
|
+
* @brief Class managing the column and row swaps in @ref Base_matrix and @ref Boundary_matrix.
|
|
44
|
+
*
|
|
45
|
+
* @tparam Master_matrix An instantiation of @ref Matrix from which all types and options are deduced.
|
|
46
|
+
* @tparam Base_matrix Either @ref Base_matrix or @ref Boundary_matrix.
|
|
47
|
+
*/
|
|
48
|
+
template <class Master_matrix, class Base_matrix>
|
|
49
|
+
class Base_swap
|
|
50
|
+
{
|
|
51
|
+
public:
|
|
52
|
+
using Column_container = typename Master_matrix::Column_container; /**< Column container type. */
|
|
53
|
+
using Index = typename Master_matrix::Index; /**< Container index type. */
|
|
54
|
+
using ID_index = typename Master_matrix::ID_index; /**< @ref IDIdx index type. */
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @brief Default constructor.
|
|
58
|
+
*/
|
|
59
|
+
Base_swap();
|
|
60
|
+
/**
|
|
61
|
+
* @brief As default constructor, but reserves spaces for @p numberOfColumns columns.
|
|
62
|
+
*
|
|
63
|
+
* @param numberOfColumns Number of columns to reserve space for.
|
|
64
|
+
*/
|
|
65
|
+
Base_swap(unsigned int numberOfColumns);
|
|
66
|
+
/**
|
|
67
|
+
* @brief Copy constructor.
|
|
68
|
+
*
|
|
69
|
+
* @param matrixToCopy Matrix to copy.
|
|
70
|
+
*/
|
|
71
|
+
Base_swap(const Base_swap& matrixToCopy) = default;
|
|
72
|
+
/**
|
|
73
|
+
* @brief Move constructor.
|
|
74
|
+
*
|
|
75
|
+
* @param other Matrix to move.
|
|
76
|
+
*/
|
|
77
|
+
Base_swap(Base_swap&& other) noexcept;
|
|
78
|
+
|
|
79
|
+
~Base_swap() = default;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @brief Swaps the two columns at given indices in the column container. Does not updates the column index value,
|
|
83
|
+
* potentially stored in the entries. This will be done when calling `_orderRows()`.
|
|
84
|
+
*
|
|
85
|
+
* @param columnIndex1 First @ref MatIdx column index.
|
|
86
|
+
* @param columnIndex2 Second @ref MatIdx column index.
|
|
87
|
+
*/
|
|
88
|
+
void swap_columns(Index columnIndex1, Index columnIndex2);
|
|
89
|
+
/**
|
|
90
|
+
* @brief Swaps the two rows at the given indices, but in a lazy manner. That is, the swap is registered but not
|
|
91
|
+
* executed. The reordering will be done when calling `_orderRows()`.
|
|
92
|
+
*
|
|
93
|
+
* @param rowIndex1 First row index.
|
|
94
|
+
* @param rowIndex2 Second row index.
|
|
95
|
+
*/
|
|
96
|
+
void swap_rows(ID_index rowIndex1, ID_index rowIndex2);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @brief Assign operator.
|
|
100
|
+
*/
|
|
101
|
+
Base_swap& operator=(const Base_swap& other) = default;
|
|
102
|
+
/**
|
|
103
|
+
* @brief Move assign operator.
|
|
104
|
+
*/
|
|
105
|
+
Base_swap& operator=(Base_swap&& other) noexcept;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @brief Swap operator.
|
|
109
|
+
*/
|
|
110
|
+
friend void swap(Base_swap& base1, Base_swap& base2) noexcept
|
|
111
|
+
{
|
|
112
|
+
base1.indexToRow_.swap(base2.indexToRow_);
|
|
113
|
+
base1.rowToIndex_.swap(base2.rowToIndex_);
|
|
114
|
+
std::swap(base1.rowSwapped_, base2.rowSwapped_);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
protected:
|
|
118
|
+
void _orderRows();
|
|
119
|
+
void _initialize_row_index(Index index);
|
|
120
|
+
Index _erase_row(Index index);
|
|
121
|
+
Index _get_row_index(Index index) const;
|
|
122
|
+
bool _row_were_swapped() const;
|
|
123
|
+
void _reset();
|
|
124
|
+
|
|
125
|
+
private:
|
|
126
|
+
using Index_dictionary = typename Master_matrix::template Dictionary<Index>;
|
|
127
|
+
using Row_dictionary = typename Master_matrix::template Dictionary<ID_index>;
|
|
128
|
+
|
|
129
|
+
Index_dictionary indexToRow_; /**< Map from row index to actual index in row container. */
|
|
130
|
+
Row_dictionary rowToIndex_; /**< Map from index in row container to "public" row index. */
|
|
131
|
+
bool rowSwapped_; /**< True if any rows were swapped since last call to `_orderRows()`. */
|
|
132
|
+
|
|
133
|
+
// access to inheriting matrix class
|
|
134
|
+
constexpr Base_matrix* _matrix() { return static_cast<Base_matrix*>(this); }
|
|
135
|
+
|
|
136
|
+
constexpr const Base_matrix* _matrix() const { return static_cast<const Base_matrix*>(this); }
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
template <class Master_matrix, class Base_matrix>
|
|
140
|
+
inline Base_swap<Master_matrix, Base_matrix>::Base_swap() : rowSwapped_(false)
|
|
141
|
+
{
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
template <class Master_matrix, class Base_matrix>
|
|
145
|
+
inline Base_swap<Master_matrix, Base_matrix>::Base_swap(unsigned int numberOfColumns)
|
|
146
|
+
: indexToRow_(numberOfColumns), rowToIndex_(numberOfColumns), rowSwapped_(false)
|
|
147
|
+
{
|
|
148
|
+
for (Index i = 0; i < numberOfColumns; i++) {
|
|
149
|
+
indexToRow_[i] = i;
|
|
150
|
+
rowToIndex_[i] = i;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
template <class Master_matrix, class Base_matrix>
|
|
155
|
+
inline Base_swap<Master_matrix, Base_matrix>::Base_swap(Base_swap&& other) noexcept
|
|
156
|
+
: indexToRow_(std::move(other.indexToRow_)),
|
|
157
|
+
rowToIndex_(std::move(other.rowToIndex_)),
|
|
158
|
+
rowSwapped_(std::exchange(other.rowSwapped_, false))
|
|
159
|
+
{
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
template <class Master_matrix, class Base_matrix>
|
|
163
|
+
inline void Base_swap<Master_matrix, Base_matrix>::swap_columns(Index columnIndex1, Index columnIndex2)
|
|
164
|
+
{
|
|
165
|
+
swap(_matrix()->matrix_.at(columnIndex1), _matrix()->matrix_.at(columnIndex2));
|
|
166
|
+
if constexpr (Master_matrix::Option_list::has_row_access) rowSwapped_ = true; // to update column index in entries.
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
template <class Master_matrix, class Base_matrix>
|
|
170
|
+
inline void Base_swap<Master_matrix, Base_matrix>::swap_rows(ID_index rowIndex1, ID_index rowIndex2)
|
|
171
|
+
{
|
|
172
|
+
rowSwapped_ = true;
|
|
173
|
+
|
|
174
|
+
if constexpr (Master_matrix::Option_list::has_map_column_container) {
|
|
175
|
+
auto it1 = indexToRow_.find(rowIndex1);
|
|
176
|
+
auto it2 = indexToRow_.find(rowIndex2);
|
|
177
|
+
|
|
178
|
+
if (it1 == indexToRow_.end() && it2 == indexToRow_.end()) return;
|
|
179
|
+
|
|
180
|
+
if (it1 == indexToRow_.end()) {
|
|
181
|
+
indexToRow_.emplace(rowIndex1, it2->second);
|
|
182
|
+
rowToIndex_.at(it2->second) = rowIndex1;
|
|
183
|
+
indexToRow_.erase(it2->second);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (it2 == indexToRow_.end()) {
|
|
188
|
+
indexToRow_.emplace(rowIndex2, it1->second);
|
|
189
|
+
rowToIndex_.at(it1->second) = rowIndex2;
|
|
190
|
+
indexToRow_.erase(it1);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
std::swap(rowToIndex_.at(it1->second), rowToIndex_.at(it2->second));
|
|
195
|
+
std::swap(it1->second, it2->second);
|
|
196
|
+
} else {
|
|
197
|
+
for (auto i = indexToRow_.size(); i <= std::max(rowIndex1, rowIndex2); ++i) indexToRow_.push_back(i);
|
|
198
|
+
|
|
199
|
+
std::swap(rowToIndex_[indexToRow_[rowIndex1]], rowToIndex_[indexToRow_[rowIndex2]]);
|
|
200
|
+
std::swap(indexToRow_[rowIndex1], indexToRow_[rowIndex2]);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
template <class Master_matrix, class Base_matrix>
|
|
205
|
+
inline Base_swap<Master_matrix, Base_matrix>& Base_swap<Master_matrix, Base_matrix>::operator=(
|
|
206
|
+
Base_swap&& other) noexcept
|
|
207
|
+
{
|
|
208
|
+
if (this == &other) return *this;
|
|
209
|
+
|
|
210
|
+
indexToRow_ = std::move(other.indexToRow_);
|
|
211
|
+
rowToIndex_ = std::move(other.rowToIndex_);
|
|
212
|
+
rowSwapped_ = std::exchange(other.rowSwapped_, false);
|
|
213
|
+
return *this;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
template <class Master_matrix, class Base_matrix>
|
|
217
|
+
inline void Base_swap<Master_matrix, Base_matrix>::_orderRows()
|
|
218
|
+
{
|
|
219
|
+
for (unsigned int i = 0; i < _matrix()->get_number_of_columns(); i++) {
|
|
220
|
+
_matrix()->matrix_.at(i).reorder(rowToIndex_, i);
|
|
221
|
+
}
|
|
222
|
+
for (Index i = 0; i < _matrix()->get_number_of_columns(); i++) {
|
|
223
|
+
indexToRow_[i] = i;
|
|
224
|
+
rowToIndex_[i] = i;
|
|
225
|
+
}
|
|
226
|
+
rowSwapped_ = false;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
template <class Master_matrix, class Base_matrix>
|
|
230
|
+
inline void Base_swap<Master_matrix, Base_matrix>::_initialize_row_index(Index index)
|
|
231
|
+
{
|
|
232
|
+
if constexpr (Master_matrix::Option_list::has_map_column_container) {
|
|
233
|
+
indexToRow_.emplace(index, index);
|
|
234
|
+
rowToIndex_.emplace(index, index);
|
|
235
|
+
} else {
|
|
236
|
+
indexToRow_.reserve(index + 1);
|
|
237
|
+
rowToIndex_.reserve(index + 1);
|
|
238
|
+
for (Index i = indexToRow_.size(); i <= index; ++i) {
|
|
239
|
+
indexToRow_.push_back(i);
|
|
240
|
+
rowToIndex_.push_back(i);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
template <class Master_matrix, class Base_matrix>
|
|
246
|
+
inline typename Base_swap<Master_matrix, Base_matrix>::Index Base_swap<Master_matrix, Base_matrix>::_erase_row(
|
|
247
|
+
Index index)
|
|
248
|
+
{
|
|
249
|
+
if constexpr (Master_matrix::Option_list::has_map_column_container) {
|
|
250
|
+
auto it = indexToRow_.find(index);
|
|
251
|
+
auto rowID = it->second;
|
|
252
|
+
rowToIndex_.erase(rowID);
|
|
253
|
+
indexToRow_.erase(it);
|
|
254
|
+
return rowID;
|
|
255
|
+
} else {
|
|
256
|
+
return indexToRow_[index];
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
template <class Master_matrix, class Base_matrix>
|
|
261
|
+
inline typename Base_swap<Master_matrix, Base_matrix>::Index Base_swap<Master_matrix, Base_matrix>::_get_row_index(
|
|
262
|
+
Index index) const
|
|
263
|
+
{
|
|
264
|
+
if constexpr (Master_matrix::Option_list::has_map_column_container) {
|
|
265
|
+
return indexToRow_.at(index);
|
|
266
|
+
} else {
|
|
267
|
+
return indexToRow_[index];
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
template <class Master_matrix, class Base_matrix>
|
|
272
|
+
inline bool Base_swap<Master_matrix, Base_matrix>::_row_were_swapped() const
|
|
273
|
+
{
|
|
274
|
+
return rowSwapped_;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
template <class Master_matrix, class Base_matrix>
|
|
278
|
+
inline void Base_swap<Master_matrix, Base_matrix>::_reset()
|
|
279
|
+
{
|
|
280
|
+
indexToRow_.clear();
|
|
281
|
+
rowToIndex_.clear();
|
|
282
|
+
rowSwapped_ = false;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
} // namespace persistence_matrix
|
|
286
|
+
} // namespace Gudhi
|
|
287
|
+
|
|
288
|
+
#endif // PM_BASE_SWAP_H
|