multipers 2.3.3b6__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.
Potentially problematic release.
This version of multipers might be problematic. Click here for more details.
- multipers/.dylibs/libc++.1.0.dylib +0 -0
- multipers/.dylibs/libtbb.12.16.dylib +0 -0
- multipers/__init__.py +33 -0
- multipers/_signed_measure_meta.py +453 -0
- multipers/_slicer_meta.py +211 -0
- multipers/array_api/__init__.py +45 -0
- multipers/array_api/numpy.py +41 -0
- multipers/array_api/torch.py +58 -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 +229 -0
- multipers/filtration_conversions.pxd.tp +84 -0
- multipers/filtrations/__init__.py +18 -0
- multipers/filtrations/density.py +574 -0
- multipers/filtrations/filtrations.py +361 -0
- multipers/filtrations.pxd +224 -0
- multipers/function_rips.cpython-312-darwin.so +0 -0
- multipers/function_rips.pyx +105 -0
- multipers/grids.cpython-312-darwin.so +0 -0
- multipers/grids.pyx +433 -0
- multipers/gudhi/Persistence_slices_interface.h +132 -0
- multipers/gudhi/Simplex_tree_interface.h +239 -0
- multipers/gudhi/Simplex_tree_multi_interface.h +551 -0
- multipers/gudhi/cubical_to_boundary.h +59 -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 +45 -0
- multipers/gudhi/gudhi/Fields/Multi_field.h +484 -0
- multipers/gudhi/gudhi/Fields/Multi_field_operators.h +455 -0
- multipers/gudhi/gudhi/Fields/Multi_field_shared.h +450 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small.h +531 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small_operators.h +507 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small_shared.h +531 -0
- multipers/gudhi/gudhi/Fields/Z2_field.h +355 -0
- multipers/gudhi/gudhi/Fields/Z2_field_operators.h +376 -0
- multipers/gudhi/gudhi/Fields/Zp_field.h +420 -0
- multipers/gudhi/gudhi/Fields/Zp_field_operators.h +400 -0
- multipers/gudhi/gudhi/Fields/Zp_field_shared.h +418 -0
- multipers/gudhi/gudhi/Flag_complex_edge_collapser.h +337 -0
- multipers/gudhi/gudhi/Matrix.h +2107 -0
- multipers/gudhi/gudhi/Multi_critical_filtration.h +1038 -0
- multipers/gudhi/gudhi/Multi_persistence/Box.h +174 -0
- multipers/gudhi/gudhi/Multi_persistence/Line.h +282 -0
- multipers/gudhi/gudhi/Off_reader.h +173 -0
- multipers/gudhi/gudhi/One_critical_filtration.h +1441 -0
- multipers/gudhi/gudhi/Persistence_matrix/Base_matrix.h +769 -0
- multipers/gudhi/gudhi/Persistence_matrix/Base_matrix_with_column_compression.h +686 -0
- multipers/gudhi/gudhi/Persistence_matrix/Boundary_matrix.h +842 -0
- multipers/gudhi/gudhi/Persistence_matrix/Chain_matrix.h +1350 -0
- multipers/gudhi/gudhi/Persistence_matrix/Id_to_index_overlay.h +1105 -0
- multipers/gudhi/gudhi/Persistence_matrix/Position_to_index_overlay.h +859 -0
- multipers/gudhi/gudhi/Persistence_matrix/RU_matrix.h +910 -0
- multipers/gudhi/gudhi/Persistence_matrix/allocators/entry_constructors.h +139 -0
- multipers/gudhi/gudhi/Persistence_matrix/base_pairing.h +230 -0
- multipers/gudhi/gudhi/Persistence_matrix/base_swap.h +211 -0
- multipers/gudhi/gudhi/Persistence_matrix/boundary_cell_position_to_id_mapper.h +60 -0
- multipers/gudhi/gudhi/Persistence_matrix/boundary_face_position_to_id_mapper.h +60 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_pairing.h +136 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_rep_cycles.h +190 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_vine_swap.h +616 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/chain_column_extra_properties.h +150 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/column_dimension_holder.h +106 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/column_utilities.h +219 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/entry_types.h +327 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/heap_column.h +1140 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_list_column.h +934 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_set_column.h +934 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/list_column.h +980 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/naive_vector_column.h +1092 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/row_access.h +192 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/set_column.h +921 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/small_vector_column.h +1093 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/unordered_set_column.h +1012 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/vector_column.h +1244 -0
- multipers/gudhi/gudhi/Persistence_matrix/matrix_dimension_holders.h +186 -0
- multipers/gudhi/gudhi/Persistence_matrix/matrix_row_access.h +164 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_pairing.h +156 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_rep_cycles.h +376 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_vine_swap.h +540 -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 +745 -0
- multipers/gudhi/gudhi/Points_off_io.h +171 -0
- multipers/gudhi/gudhi/Simple_object_pool.h +69 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_iterators.h +463 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +83 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_siblings.h +106 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_star_simplex_iterators.h +277 -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 +62 -0
- multipers/gudhi/gudhi/Simplex_tree/simplex_tree_options.h +157 -0
- multipers/gudhi/gudhi/Simplex_tree.h +2794 -0
- multipers/gudhi/gudhi/Simplex_tree_multi.h +152 -0
- multipers/gudhi/gudhi/distance_functions.h +62 -0
- multipers/gudhi/gudhi/graph_simplicial_complex.h +104 -0
- multipers/gudhi/gudhi/persistence_interval.h +253 -0
- multipers/gudhi/gudhi/persistence_matrix_options.h +170 -0
- multipers/gudhi/gudhi/reader_utils.h +367 -0
- multipers/gudhi/mma_interface_coh.h +256 -0
- multipers/gudhi/mma_interface_h0.h +223 -0
- multipers/gudhi/mma_interface_matrix.h +293 -0
- multipers/gudhi/naive_merge_tree.h +536 -0
- multipers/gudhi/scc_io.h +310 -0
- multipers/gudhi/truc.h +1403 -0
- multipers/io.cpython-312-darwin.so +0 -0
- multipers/io.pyx +644 -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 +1589 -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 +128 -0
- multipers/mma_structures.pyx +2786 -0
- multipers/mma_structures.pyx.tp +1094 -0
- multipers/multi_parameter_rank_invariant/diff_helpers.h +84 -0
- multipers/multi_parameter_rank_invariant/euler_characteristic.h +97 -0
- multipers/multi_parameter_rank_invariant/function_rips.h +322 -0
- multipers/multi_parameter_rank_invariant/hilbert_function.h +769 -0
- multipers/multi_parameter_rank_invariant/persistence_slices.h +148 -0
- multipers/multi_parameter_rank_invariant/rank_invariant.h +369 -0
- multipers/multiparameter_edge_collapse.py +41 -0
- multipers/multiparameter_module_approximation/approximation.h +2330 -0
- multipers/multiparameter_module_approximation/combinatory.h +129 -0
- multipers/multiparameter_module_approximation/debug.h +107 -0
- multipers/multiparameter_module_approximation/euler_curves.h +0 -0
- multipers/multiparameter_module_approximation/format_python-cpp.h +286 -0
- multipers/multiparameter_module_approximation/heap_column.h +238 -0
- multipers/multiparameter_module_approximation/images.h +79 -0
- multipers/multiparameter_module_approximation/list_column.h +174 -0
- multipers/multiparameter_module_approximation/list_column_2.h +232 -0
- multipers/multiparameter_module_approximation/ru_matrix.h +347 -0
- multipers/multiparameter_module_approximation/set_column.h +135 -0
- multipers/multiparameter_module_approximation/structure_higher_dim_barcode.h +36 -0
- multipers/multiparameter_module_approximation/unordered_set_column.h +166 -0
- multipers/multiparameter_module_approximation/utilities.h +403 -0
- multipers/multiparameter_module_approximation/vector_column.h +223 -0
- multipers/multiparameter_module_approximation/vector_matrix.h +331 -0
- multipers/multiparameter_module_approximation/vineyards.h +464 -0
- multipers/multiparameter_module_approximation/vineyards_trajectories.h +649 -0
- multipers/multiparameter_module_approximation.cpython-312-darwin.so +0 -0
- multipers/multiparameter_module_approximation.pyx +235 -0
- multipers/pickle.py +90 -0
- multipers/plots.py +456 -0
- multipers/point_measure.cpython-312-darwin.so +0 -0
- multipers/point_measure.pyx +395 -0
- multipers/simplex_tree_multi.cpython-312-darwin.so +0 -0
- multipers/simplex_tree_multi.pxd +134 -0
- multipers/simplex_tree_multi.pyx +10840 -0
- multipers/simplex_tree_multi.pyx.tp +2009 -0
- multipers/slicer.cpython-312-darwin.so +0 -0
- multipers/slicer.pxd +3034 -0
- multipers/slicer.pxd.tp +234 -0
- multipers/slicer.pyx +20481 -0
- multipers/slicer.pyx.tp +1088 -0
- multipers/tensor/tensor.h +672 -0
- multipers/tensor.pxd +13 -0
- multipers/test.pyx +44 -0
- multipers/tests/__init__.py +62 -0
- multipers/torch/__init__.py +1 -0
- multipers/torch/diff_grids.py +240 -0
- multipers/torch/rips_density.py +310 -0
- multipers-2.3.3b6.dist-info/METADATA +128 -0
- multipers-2.3.3b6.dist-info/RECORD +183 -0
- multipers-2.3.3b6.dist-info/WHEEL +6 -0
- multipers-2.3.3b6.dist-info/licenses/LICENSE +21 -0
- multipers-2.3.3b6.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,859 @@
|
|
|
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 Position_to_index_overlay.h
|
|
13
|
+
* @author Hannah Schreiber
|
|
14
|
+
* @brief Contains the @ref Gudhi::persistence_matrix::Position_to_index_overlay class.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#ifndef PM_POS_TO_ID_TRANSLATION_H
|
|
18
|
+
#define PM_POS_TO_ID_TRANSLATION_H
|
|
19
|
+
|
|
20
|
+
#include <vector>
|
|
21
|
+
#include <utility> //std::swap, std::move & std::exchange
|
|
22
|
+
#include <algorithm> //std::transform
|
|
23
|
+
|
|
24
|
+
namespace Gudhi {
|
|
25
|
+
namespace persistence_matrix {
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @class Position_to_index_overlay Position_to_index_overlay.h gudhi/Persistence_matrix/Position_to_index_overlay.h
|
|
29
|
+
* @ingroup persistence_matrix
|
|
30
|
+
*
|
|
31
|
+
* @brief Overlay for @ref chainmatrix "chain matrices" replacing all input and output @ref MatIdx indices of the
|
|
32
|
+
* original methods with @ref PosIdx indices. The overlay is useless for @ref boundarymatrix "boundary matrices"
|
|
33
|
+
* as @ref MatIdx == @ref PosIdx for them.
|
|
34
|
+
*
|
|
35
|
+
* @tparam %Underlying_matrix Matrix type taking the overlay.
|
|
36
|
+
* @tparam Master_matrix An instantiation of @ref Matrix from which all types and options are deduced.
|
|
37
|
+
*/
|
|
38
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
39
|
+
class Position_to_index_overlay
|
|
40
|
+
{
|
|
41
|
+
public:
|
|
42
|
+
using Index = typename Master_matrix::Index; /**< @ref MatIdx index type. */
|
|
43
|
+
using ID_index = typename Master_matrix::ID_index; /**< @ref IDIdx index type. */
|
|
44
|
+
using Pos_index = typename Master_matrix::Pos_index; /**< @ref PosIdx index type. */
|
|
45
|
+
using Dimension = typename Master_matrix::Dimension; /**< Dimension value type. */
|
|
46
|
+
/**
|
|
47
|
+
* @brief Field operators class. Necessary only if @ref PersistenceMatrixOptions::is_z2 is false.
|
|
48
|
+
*/
|
|
49
|
+
using Field_operators = typename Master_matrix::Field_operators;
|
|
50
|
+
using Field_element = typename Master_matrix::Element; /**< Type of an field element. */
|
|
51
|
+
using Boundary = typename Master_matrix::Boundary; /**< Type of an input column. */
|
|
52
|
+
using Column = typename Master_matrix::Column; /**< Column type. */
|
|
53
|
+
using Row = typename Master_matrix::Row; /**< Row type, only
|
|
54
|
+
necessary with row access option. */
|
|
55
|
+
using Bar = typename Master_matrix::Bar; /**< Bar type. */
|
|
56
|
+
using Barcode = typename Master_matrix::Barcode; /**< Barcode type. */
|
|
57
|
+
using Cycle = typename Master_matrix::Cycle; /**< Cycle type. */
|
|
58
|
+
using Entry_representative = typename Master_matrix::Entry_representative; /**< %Entry content representative. */
|
|
59
|
+
using Entry_constructor = typename Master_matrix::Entry_constructor; /**< Factory of @ref Entry classes. */
|
|
60
|
+
using Column_settings = typename Master_matrix::Column_settings; /**< Structure giving access to the columns
|
|
61
|
+
to necessary external classes. */
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @brief Constructs an empty matrix.
|
|
65
|
+
*
|
|
66
|
+
* @param colSettings Pointer to an existing setting structure for the columns. The structure should contain all
|
|
67
|
+
* the necessary external classes specifically necessary for the choosen column type, such as custom allocators.
|
|
68
|
+
*/
|
|
69
|
+
Position_to_index_overlay(Column_settings* colSettings);
|
|
70
|
+
/**
|
|
71
|
+
* @brief Constructs a new matrix from the given ranges of @ref Matrix::Entry_representative. Each range corresponds
|
|
72
|
+
* to a column (the order of the ranges are preserved). The content of the ranges is assumed to be sorted by
|
|
73
|
+
* increasing IDs. The IDs of the simplices are also assumed to be consecutive, ordered by filtration value, starting
|
|
74
|
+
* with 0.
|
|
75
|
+
*
|
|
76
|
+
* @tparam Boundary_range Range type for @ref Matrix::Entry_representative ranges.
|
|
77
|
+
* Assumed to have a begin(), end() and size() method.
|
|
78
|
+
* @param orderedBoundaries Range of boundaries: @p orderedBoundaries is interpreted as a boundary matrix of a
|
|
79
|
+
* filtered **simplicial** complex, whose boundaries are ordered by filtration order.
|
|
80
|
+
* Therefore, `orderedBoundaries[i]` should store the boundary of the \f$ i^{th} \f$ simplex in the filtration,
|
|
81
|
+
* as an ordered list of indices of its facets (again those indices correspond to their respective position
|
|
82
|
+
* in the matrix). That is why the indices of the simplices are assumed to be consecutive and starting with 0
|
|
83
|
+
* (an empty boundary is interpreted as a vertex boundary and not as a non existing simplex).
|
|
84
|
+
* All dimensions up to the maximal dimension of interest have to be present. If only a higher dimension is of
|
|
85
|
+
* interest and not everything should be stored, then use the @ref insert_boundary method instead (after creating the
|
|
86
|
+
* matrix with the @ref Position_to_index_overlay(unsigned int, Column_settings*)
|
|
87
|
+
* constructor preferably).
|
|
88
|
+
* @param colSettings Pointer to an existing setting structure for the columns. The structure should contain all
|
|
89
|
+
* the necessary external classes specifically necessary for the choosen column type, such as custom allocators.
|
|
90
|
+
*/
|
|
91
|
+
template <class Boundary_range = Boundary>
|
|
92
|
+
Position_to_index_overlay(const std::vector<Boundary_range>& orderedBoundaries,
|
|
93
|
+
Column_settings* colSettings);
|
|
94
|
+
/**
|
|
95
|
+
* @brief Constructs a new empty matrix and reserves space for the given number of columns.
|
|
96
|
+
*
|
|
97
|
+
* @param numberOfColumns Number of columns to reserve space for.
|
|
98
|
+
* @param colSettings Pointer to an existing setting structure for the columns. The structure should contain all
|
|
99
|
+
* the necessary external classes specifically necessary for the choosen column type, such as custom allocators.
|
|
100
|
+
*/
|
|
101
|
+
Position_to_index_overlay(unsigned int numberOfColumns,
|
|
102
|
+
Column_settings* colSettings);
|
|
103
|
+
/**
|
|
104
|
+
* @brief Only available for @ref chainmatrix "chain matrices". Constructs an empty matrix and stores the given
|
|
105
|
+
* comparators.
|
|
106
|
+
*
|
|
107
|
+
* @warning If @ref PersistenceMatrixOptions::has_vine_update is false, the comparators are not used.
|
|
108
|
+
* And if @ref PersistenceMatrixOptions::has_vine_update is true, but
|
|
109
|
+
* @ref PersistenceMatrixOptions::has_column_pairings is also true, the comparators are ignored and
|
|
110
|
+
* the current barcode is used to compare birth and deaths. Therefore it is useless to provide them in those cases.
|
|
111
|
+
*
|
|
112
|
+
* @tparam BirthComparatorFunction Type of the birth comparator: (@ref Pos_index, @ref Pos_index) -> bool
|
|
113
|
+
* @tparam DeathComparatorFunction Type of the death comparator: (@ref Pos_index, @ref Pos_index) -> bool
|
|
114
|
+
* @param colSettings Pointer to an existing setting structure for the columns. The structure should contain all
|
|
115
|
+
* the necessary external classes specifically necessary for the choosen column type, such as custom allocators.
|
|
116
|
+
* @param birthComparator Method taking two @ref PosIdx indices as input and returning true if and only if
|
|
117
|
+
* the birth associated to the first position is strictly less than birth associated to
|
|
118
|
+
* the second one with respect to some self defined order. It is used while swapping two unpaired or
|
|
119
|
+
* two negative columns.
|
|
120
|
+
* @param deathComparator Method taking two @ref PosIdx indices as input and returning true if and only if
|
|
121
|
+
* the death associated to the first position is strictly less than death associated to
|
|
122
|
+
* the second one with respect to some self defined order. It is used while swapping two positive but paired
|
|
123
|
+
* columns.
|
|
124
|
+
*/
|
|
125
|
+
template <typename BirthComparatorFunction, typename DeathComparatorFunction>
|
|
126
|
+
Position_to_index_overlay(Column_settings* colSettings,
|
|
127
|
+
const BirthComparatorFunction& birthComparator,
|
|
128
|
+
const DeathComparatorFunction& deathComparator);
|
|
129
|
+
/**
|
|
130
|
+
* @brief Only available for @ref chainmatrix "chain matrices".
|
|
131
|
+
* Constructs a new matrix from the given ranges of @ref Matrix::Entry_representative. Each range corresponds to a
|
|
132
|
+
* column (the order of the ranges are preserved). The content of the ranges is assumed to be sorted by increasing
|
|
133
|
+
* IDs. The IDs of the simplices are also assumed to be consecutive, ordered by filtration value, starting with 0.
|
|
134
|
+
*
|
|
135
|
+
* @warning If @ref PersistenceMatrixOptions::has_vine_update is false, the comparators are not used.
|
|
136
|
+
* And if @ref PersistenceMatrixOptions::has_vine_update is true, but
|
|
137
|
+
* @ref PersistenceMatrixOptions::has_column_pairings is also true, the comparators are ignored and
|
|
138
|
+
* the current barcode is used to compare birth and deaths. Therefore it is useless to provide them in those cases.
|
|
139
|
+
*
|
|
140
|
+
* @tparam BirthComparatorFunction Type of the birth comparator: (@ref Pos_index, @ref Pos_index) -> bool
|
|
141
|
+
* @tparam DeathComparatorFunction Type of the death comparator: (@ref Pos_index, @ref Pos_index) -> bool
|
|
142
|
+
* @tparam Boundary_range Range type for @ref Matrix::Entry_representative ranges.
|
|
143
|
+
* Assumed to have a begin(), end() and size() method.
|
|
144
|
+
* @param orderedBoundaries Range of boundaries: @p orderedBoundaries is interpreted as a boundary matrix of a
|
|
145
|
+
* filtered **simplicial** complex, whose boundaries are ordered by filtration order.
|
|
146
|
+
* Therefore, `orderedBoundaries[i]` should store the boundary of the \f$ i^{th} \f$ simplex in the filtration,
|
|
147
|
+
* as an ordered list of indices of its facets (again those indices correspond to their respective position
|
|
148
|
+
* in the matrix). That is why the indices of the simplices are assumed to be consecutive and starting with 0
|
|
149
|
+
* (an empty boundary is interpreted as a vertex boundary and not as a non existing simplex).
|
|
150
|
+
* All dimensions up to the maximal dimension of interest have to be present. If only a higher dimension is of
|
|
151
|
+
* interest and not everything should be stored, then use the @ref insert_boundary method instead
|
|
152
|
+
* (after creating the matrix with the @ref Position_to_index_overlay(unsigned int, Column_settings*,
|
|
153
|
+
* const BirthComparatorFunction&, const DeathComparatorFunction&) constructor preferably).
|
|
154
|
+
* @param colSettings Pointer to an existing setting structure for the columns. The structure should contain all
|
|
155
|
+
* the necessary external classes specifically necessary for the choosen column type, such as custom allocators.
|
|
156
|
+
* @param birthComparator Method taking two @ref PosIdx indices as input and returning true if and only if
|
|
157
|
+
* the birth associated to the first position is strictly less than birth associated to
|
|
158
|
+
* the second one with respect to some self defined order. It is used while swapping two unpaired or
|
|
159
|
+
* two negative columns.
|
|
160
|
+
* @param deathComparator Method taking two @ref PosIdx indices as input and returning true if and only if
|
|
161
|
+
* the death associated to the first position is strictly less than death associated to
|
|
162
|
+
* the second one with respect to some self defined order. It is used while swapping two positive but paired
|
|
163
|
+
* columns.
|
|
164
|
+
*/
|
|
165
|
+
template <typename BirthComparatorFunction, typename DeathComparatorFunction, class Boundary_range>
|
|
166
|
+
Position_to_index_overlay(const std::vector<Boundary_range>& orderedBoundaries,
|
|
167
|
+
Column_settings* colSettings,
|
|
168
|
+
const BirthComparatorFunction& birthComparator,
|
|
169
|
+
const DeathComparatorFunction& deathComparator);
|
|
170
|
+
/**
|
|
171
|
+
* @brief Only available for @ref chainmatrix "chain matrices".
|
|
172
|
+
* Constructs a new empty matrix and reserves space for the given number of columns.
|
|
173
|
+
*
|
|
174
|
+
* @warning If @ref PersistenceMatrixOptions::has_vine_update is false, the comparators are not used.
|
|
175
|
+
* And if @ref PersistenceMatrixOptions::has_vine_update is true, but
|
|
176
|
+
* @ref PersistenceMatrixOptions::has_column_pairings is also true, the comparators are ignored and
|
|
177
|
+
* the current barcode is used to compare birth and deaths. Therefore it is useless to provide them in those cases.
|
|
178
|
+
*
|
|
179
|
+
* @tparam BirthComparatorFunction Type of the birth comparator: (@ref Pos_index, @ref Pos_index) -> bool
|
|
180
|
+
* @tparam DeathComparatorFunction Type of the death comparator: (@ref Pos_index, @ref Pos_index) -> bool
|
|
181
|
+
* @param numberOfColumns Number of columns to reserve space for.
|
|
182
|
+
* @param colSettings Pointer to an existing setting structure for the columns. The structure should contain all
|
|
183
|
+
* the necessary external classes specifically necessary for the choosen column type, such as custom allocators.
|
|
184
|
+
* @param birthComparator Method taking two @ref PosIdx indices as input and returning true if and only if
|
|
185
|
+
* the birth associated to the first position is strictly less than birth associated to
|
|
186
|
+
* the second one with respect to some self defined order. It is used while swapping two unpaired or
|
|
187
|
+
* two negative columns.
|
|
188
|
+
* @param deathComparator Method taking two @ref PosIdx indices as input and returning true if and only if
|
|
189
|
+
* the death associated to the first position is strictly less than death associated to
|
|
190
|
+
* the second one with respect to some self defined order. It is used while swapping two positive but paired
|
|
191
|
+
* columns.
|
|
192
|
+
*/
|
|
193
|
+
template <typename BirthComparatorFunction, typename DeathComparatorFunction>
|
|
194
|
+
Position_to_index_overlay(unsigned int numberOfColumns,
|
|
195
|
+
Column_settings* colSettings,
|
|
196
|
+
const BirthComparatorFunction& birthComparator,
|
|
197
|
+
const DeathComparatorFunction& deathComparator);
|
|
198
|
+
/**
|
|
199
|
+
* @brief Copy constructor. If @p colSettings is not a null pointer, its value is kept
|
|
200
|
+
* instead of the one in the copied matrix.
|
|
201
|
+
*
|
|
202
|
+
* @param matrixToCopy Matrix to copy.
|
|
203
|
+
* @param colSettings Either a pointer to an existing setting structure for the columns or a null pointer.
|
|
204
|
+
* The structure should contain all the necessary external classes specifically necessary for the choosen column type,
|
|
205
|
+
* such as custom allocators. If null pointer, the pointer stored in @p matrixToCopy is used instead.
|
|
206
|
+
*/
|
|
207
|
+
Position_to_index_overlay(const Position_to_index_overlay& matrixToCopy,
|
|
208
|
+
Column_settings* colSettings = nullptr);
|
|
209
|
+
/**
|
|
210
|
+
* @brief Move constructor.
|
|
211
|
+
*
|
|
212
|
+
* @param other Matrix to move.
|
|
213
|
+
*/
|
|
214
|
+
Position_to_index_overlay(Position_to_index_overlay&& other) noexcept;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @brief Inserts at the end of the matrix a new ordered column corresponding to the given boundary.
|
|
218
|
+
* This means that it is assumed that this method is called on boundaries in the order of the filtration.
|
|
219
|
+
* It also assumes that the cells in the given boundary are identified by their relative position in the filtration,
|
|
220
|
+
* starting at 0. If it is not the case, use the other
|
|
221
|
+
* @ref insert_boundary(ID_index, const Boundary_range&, Dimension) "insert_boundary" instead by indicating the
|
|
222
|
+
* cell ID used in the boundaries when the cell is inserted.
|
|
223
|
+
*
|
|
224
|
+
* Different to the constructor, the boundaries do not have to come from a simplicial complex, but also from
|
|
225
|
+
* a more general entry complex. This includes cubical complexes or Morse complexes for example.
|
|
226
|
+
*
|
|
227
|
+
* When inserted, the given boundary is reduced and from the reduction process, the column is deduced in the form of:
|
|
228
|
+
* `IDIdx + linear combination of older column IDIdxs`. If the barcode is stored, it will be updated.
|
|
229
|
+
*
|
|
230
|
+
* @tparam Boundary_range Range of @ref Matrix::Entry_representative. Assumed to have a begin(), end() and size()
|
|
231
|
+
* method.
|
|
232
|
+
* @param boundary Boundary generating the new column. The content should be ordered by ID.
|
|
233
|
+
* @param dim Dimension of the cell whose boundary is given. If the complex is simplicial,
|
|
234
|
+
* this parameter can be omitted as it can be deduced from the size of the boundary.
|
|
235
|
+
*/
|
|
236
|
+
template <class Boundary_range = Boundary>
|
|
237
|
+
void insert_boundary(const Boundary_range& boundary, Dimension dim = -1);
|
|
238
|
+
/**
|
|
239
|
+
* @brief It does the same as the other version, but allows the boundary cells to be identified without restrictions
|
|
240
|
+
* except that all IDs have to be strictly increasing in the order of filtration. Note that you should avoid then
|
|
241
|
+
* to use the other insertion method to avoid overwriting IDs.
|
|
242
|
+
*
|
|
243
|
+
* As a cell has to be inserted before one of its cofaces in a valid filtration (recall that it is assumed that
|
|
244
|
+
* the cells are inserted by order of filtration), it is sufficient to indicate the ID of the cell being inserted.
|
|
245
|
+
*
|
|
246
|
+
* @tparam Boundary_range Range of @ref Matrix::Entry_representative. Assumed to have a begin(), end() and size()
|
|
247
|
+
* method.
|
|
248
|
+
* @param cellIndex @ref IDIdx index to use to identify the new cell.
|
|
249
|
+
* @param boundary Boundary generating the new column. The indices of the boundary have to correspond to the
|
|
250
|
+
* @p cellID values of precedent calls of the method for the corresponding cells and should be ordered in
|
|
251
|
+
* increasing order.
|
|
252
|
+
* @param dim Dimension of the cell whose boundary is given. If the complex is simplicial,
|
|
253
|
+
* this parameter can be omitted as it can be deduced from the size of the boundary.
|
|
254
|
+
*/
|
|
255
|
+
template <class Boundary_range = Boundary>
|
|
256
|
+
void insert_boundary(ID_index cellIndex, const Boundary_range& boundary, Dimension dim = -1);
|
|
257
|
+
/**
|
|
258
|
+
* @brief Returns the column at the given @ref PosIdx index.
|
|
259
|
+
* The type of the column depends on the choosen options, see @ref PersistenceMatrixOptions::column_type.
|
|
260
|
+
*
|
|
261
|
+
* @param position @ref PosIdx index of the column to return.
|
|
262
|
+
* @return Reference to the column.
|
|
263
|
+
*/
|
|
264
|
+
Column& get_column(Pos_index position);
|
|
265
|
+
/**
|
|
266
|
+
* @brief Returns the column at the given @ref PosIdx index.
|
|
267
|
+
* The type of the column depends on the choosen options, see @ref PersistenceMatrixOptions::column_type.
|
|
268
|
+
*
|
|
269
|
+
* @param position @ref PosIdx index of the column to return.
|
|
270
|
+
* @return Const reference to the column.
|
|
271
|
+
*/
|
|
272
|
+
const Column& get_column(Pos_index position) const;
|
|
273
|
+
/**
|
|
274
|
+
* @brief Only available if @ref PersistenceMatrixOptions::has_row_access is true.
|
|
275
|
+
* Returns the row at the given @ref rowindex "row index".
|
|
276
|
+
* The type of the row depends on the choosen options, see @ref PersistenceMatrixOptions::has_intrusive_rows.
|
|
277
|
+
*
|
|
278
|
+
* @param rowIndex @ref rowindex "Row index" of the row to return.
|
|
279
|
+
* @return Reference to the row.
|
|
280
|
+
*/
|
|
281
|
+
Row& get_row(ID_index rowIndex);
|
|
282
|
+
/**
|
|
283
|
+
* @brief Only available if @ref PersistenceMatrixOptions::has_row_access is true.
|
|
284
|
+
* Returns the row at the given @ref rowindex "row index".
|
|
285
|
+
* The type of the row depends on the choosen options, see @ref PersistenceMatrixOptions::has_intrusive_rows.
|
|
286
|
+
*
|
|
287
|
+
* @param rowIndex @ref rowindex "Row index" of the row to return.
|
|
288
|
+
* @return Const reference to the row.
|
|
289
|
+
*/
|
|
290
|
+
const Row& get_row(ID_index rowIndex) const;
|
|
291
|
+
/**
|
|
292
|
+
* @brief Only available if @ref PersistenceMatrixOptions::has_row_access and
|
|
293
|
+
* @ref PersistenceMatrixOptions::has_removable_rows are true.
|
|
294
|
+
* Assumes that the row is empty and removes it.
|
|
295
|
+
*
|
|
296
|
+
* @warning The removed rows are always assumed to be empty. If it is not the case, the deleted row entries are not
|
|
297
|
+
* removed from their columns. And in the case of intrusive rows, this will generate a segmentation fault when
|
|
298
|
+
* the column entries are destroyed later. The row access is just meant as a "read only" access to the rows and the
|
|
299
|
+
* @ref erase_empty_row method just as a way to specify that a row is empty and can therefore be removed from
|
|
300
|
+
* dictionaries. This allows to avoid testing the emptiness of a row at each column entry removal, what can be
|
|
301
|
+
* quite frequent.
|
|
302
|
+
*
|
|
303
|
+
* @param rowIndex @ref rowindex "Row index" of the empty row to remove.
|
|
304
|
+
*/
|
|
305
|
+
void erase_empty_row(ID_index rowIndex);
|
|
306
|
+
/**
|
|
307
|
+
* @brief Only available if @ref PersistenceMatrixOptions::has_removable_columns,
|
|
308
|
+
* @ref PersistenceMatrixOptions::has_vine_update and @ref PersistenceMatrixOptions::has_map_column_container
|
|
309
|
+
* are true.
|
|
310
|
+
* Assumes that the cell is maximal in the current complex and removes it such that the matrix remains consistent
|
|
311
|
+
* (i.e., the matrix is still a compatible bases of the chain complex in the sense of @cite zigzag).
|
|
312
|
+
* The maximality of the cell is not verified.
|
|
313
|
+
* Also updates the barcode if it was computed.
|
|
314
|
+
*
|
|
315
|
+
* See also @ref remove_last.
|
|
316
|
+
*
|
|
317
|
+
* @param position @ref PosIdx index of the cell to remove.
|
|
318
|
+
*/
|
|
319
|
+
void remove_maximal_cell(Pos_index position);
|
|
320
|
+
/**
|
|
321
|
+
* @brief Only available if @ref PersistenceMatrixOptions::has_removable_columns is true and,
|
|
322
|
+
* if @ref PersistenceMatrixOptions::has_map_column_container is true or
|
|
323
|
+
* @ref PersistenceMatrixOptions::has_vine_update is false.
|
|
324
|
+
* Removes the last cell in the filtration from the matrix and updates the barcode if it is stored.
|
|
325
|
+
*
|
|
326
|
+
* See also @ref remove_maximal_cell.
|
|
327
|
+
*/
|
|
328
|
+
void remove_last();
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* @brief Returns the maximal dimension of a cell stored in the matrix. Only available
|
|
332
|
+
* if @ref PersistenceMatrixOptions::has_matrix_maximal_dimension_access is true.
|
|
333
|
+
*
|
|
334
|
+
* @return The maximal dimension.
|
|
335
|
+
*/
|
|
336
|
+
Dimension get_max_dimension() const;
|
|
337
|
+
/**
|
|
338
|
+
* @brief Returns the current number of columns in the matrix.
|
|
339
|
+
*
|
|
340
|
+
* @return The number of columns.
|
|
341
|
+
*/
|
|
342
|
+
Index get_number_of_columns() const;
|
|
343
|
+
/**
|
|
344
|
+
* @brief Returns the dimension of the given cell.
|
|
345
|
+
*
|
|
346
|
+
* @param position @ref PosIdx index of the cell.
|
|
347
|
+
* @return Dimension of the cell.
|
|
348
|
+
*/
|
|
349
|
+
Dimension get_column_dimension(Pos_index position) const;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* @brief Adds column corresponding to @p sourcePosition onto the column corresponding to @p targetPosition.
|
|
353
|
+
*
|
|
354
|
+
* @warning They will be no verification to ensure that the addition makes sense for the validity of the matrix.
|
|
355
|
+
* For example, a right-to-left addition could corrupt the computation of the barcode if done blindly.
|
|
356
|
+
* So should be used with care.
|
|
357
|
+
*
|
|
358
|
+
* @param sourcePosition @ref PosIdx index of the source column.
|
|
359
|
+
* @param targetPosition @ref PosIdx index of the target column.
|
|
360
|
+
*/
|
|
361
|
+
void add_to(Pos_index sourcePosition, Pos_index targetPosition);
|
|
362
|
+
/**
|
|
363
|
+
* @brief Multiplies the target column with the coefficient and then adds the source column to it.
|
|
364
|
+
* That is: `targetColumn = (targetColumn * coefficient) + sourceColumn`.
|
|
365
|
+
*
|
|
366
|
+
* @warning They will be no verification to ensure that the addition makes sense for the validity of the matrix.
|
|
367
|
+
* For example, a right-to-left addition could corrupt the computation of the barcode if done blindly.
|
|
368
|
+
* So should be used with care.
|
|
369
|
+
*
|
|
370
|
+
* @param sourcePosition @ref PosIdx index of the source column.
|
|
371
|
+
* @param coefficient Value to multiply.
|
|
372
|
+
* @param targetPosition @ref PosIdx index of the target column.
|
|
373
|
+
*/
|
|
374
|
+
void multiply_target_and_add_to(Pos_index sourcePosition,
|
|
375
|
+
const Field_element& coefficient,
|
|
376
|
+
Pos_index targetPosition);
|
|
377
|
+
/**
|
|
378
|
+
* @brief Multiplies the source column with the coefficient before adding it to the target column.
|
|
379
|
+
* That is: `targetColumn += (coefficient * sourceColumn)`. The source column will **not** be modified.
|
|
380
|
+
*
|
|
381
|
+
* @warning They will be no verification to ensure that the addition makes sense for the validity of the matrix.
|
|
382
|
+
* For example, a right-to-left addition could corrupt the computation of the barcode if done blindly.
|
|
383
|
+
* So should be used with care.
|
|
384
|
+
*
|
|
385
|
+
* @param coefficient Value to multiply.
|
|
386
|
+
* @param sourcePosition @ref PosIdx index of the source column.
|
|
387
|
+
* @param targetPosition @ref PosIdx index of the target column.
|
|
388
|
+
*/
|
|
389
|
+
void multiply_source_and_add_to(const Field_element& coefficient,
|
|
390
|
+
Pos_index sourcePosition,
|
|
391
|
+
Pos_index targetPosition);
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* @brief Indicates if the entry at given coordinates has value zero.
|
|
395
|
+
*
|
|
396
|
+
* @param position @ref PosIdx index of the cell corresponding to the column of the entry.
|
|
397
|
+
* @param rowIndex @ref rowindex "Row index" of the row of the entry.
|
|
398
|
+
* @return true If the entry has value zero.
|
|
399
|
+
* @return false Otherwise.
|
|
400
|
+
*/
|
|
401
|
+
bool is_zero_entry(Pos_index position, ID_index rowIndex) const;
|
|
402
|
+
/**
|
|
403
|
+
* @brief Indicates if the column at given index has value zero.
|
|
404
|
+
*
|
|
405
|
+
* Note that this method should always return false, as a valid @ref chainmatrix "chain matrix" never has
|
|
406
|
+
* empty columns.
|
|
407
|
+
*
|
|
408
|
+
* @param position @ref PosIdx index of the cell corresponding to the column.
|
|
409
|
+
* @return true If the column has value zero.
|
|
410
|
+
* @return false Otherwise.
|
|
411
|
+
*/
|
|
412
|
+
bool is_zero_column(Pos_index position);
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* @brief Returns the @ref PosIdx index of the column which has the given @ref rowindex "row index" as pivot.
|
|
416
|
+
* Assumes that the pivot exists.
|
|
417
|
+
*
|
|
418
|
+
* @param cellIndex @ref rowindex "Row index" of the pivot.
|
|
419
|
+
* @return @ref PosIdx index of the column with the given pivot.
|
|
420
|
+
*/
|
|
421
|
+
Pos_index get_column_with_pivot(ID_index cellIndex) const; // assumes that pivot exists
|
|
422
|
+
/**
|
|
423
|
+
* @brief Returns the @ref rowindex "row index" of the pivot of the given column.
|
|
424
|
+
*
|
|
425
|
+
* @param position @ref PosIdx index of the cell corresponding to the column.
|
|
426
|
+
* @return The @ref rowindex "row index" of the pivot.
|
|
427
|
+
*/
|
|
428
|
+
ID_index get_pivot(Pos_index position);
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* @brief Resets the matrix to an empty matrix.
|
|
432
|
+
*
|
|
433
|
+
* @param colSettings Pointer to an existing setting structure for the columns. The structure should contain all
|
|
434
|
+
* the necessary external classes specifically necessary for the choosen column type, such as custom allocators.
|
|
435
|
+
*/
|
|
436
|
+
void reset(Column_settings* colSettings) {
|
|
437
|
+
matrix_.reset(colSettings);
|
|
438
|
+
positionToIndex_.clear();
|
|
439
|
+
nextPosition_ = 0;
|
|
440
|
+
nextIndex_ = 0;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// void set_operators(Field_operators* operators) { matrix_.set_operators(operators); }
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* @brief Assign operator.
|
|
447
|
+
*/
|
|
448
|
+
Position_to_index_overlay& operator=(const Position_to_index_overlay& other);
|
|
449
|
+
/**
|
|
450
|
+
* @brief Swap operator.
|
|
451
|
+
*/
|
|
452
|
+
friend void swap(Position_to_index_overlay& matrix1, Position_to_index_overlay& matrix2) {
|
|
453
|
+
swap(matrix1.matrix_, matrix2.matrix_);
|
|
454
|
+
matrix1.positionToIndex_.swap(matrix2.positionToIndex_);
|
|
455
|
+
std::swap(matrix1.nextPosition_, matrix2.nextPosition_);
|
|
456
|
+
std::swap(matrix1.nextIndex_, matrix2.nextIndex_);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
void print(); // for debug
|
|
460
|
+
|
|
461
|
+
// access to optional methods
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* @brief Returns the current barcode of the matrix.
|
|
465
|
+
* Available only if @ref PersistenceMatrixOptions::has_column_pairings is true.
|
|
466
|
+
*
|
|
467
|
+
* Recall that we assume that the boundaries were inserted in the order of filtration for the barcode to be valid.
|
|
468
|
+
*
|
|
469
|
+
* @return A reference to the barcode. The barcode is a vector of @ref Matrix::Bar. A bar stores three informations:
|
|
470
|
+
* the @ref PosIdx birth index, the @ref PosIdx death index and the dimension of the bar.
|
|
471
|
+
*/
|
|
472
|
+
const Barcode& get_current_barcode() const;
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* @brief Only available if @ref PersistenceMatrixOptions::can_retrieve_representative_cycles is true. Pre-computes
|
|
476
|
+
* the representative cycles of the current state of the filtration represented by the matrix.
|
|
477
|
+
* It does not need to be called before `get_representative_cycles` is called for the first time, but needs to be
|
|
478
|
+
* called before calling `get_representative_cycles` again if the matrix was modified in between. Otherwise the
|
|
479
|
+
* old cycles will be returned.
|
|
480
|
+
*/
|
|
481
|
+
void update_representative_cycles();
|
|
482
|
+
/**
|
|
483
|
+
* @brief Only available if @ref PersistenceMatrixOptions::can_retrieve_representative_cycles is true.
|
|
484
|
+
* Returns all representative cycles of the current filtration.
|
|
485
|
+
*
|
|
486
|
+
* @return A const reference to the vector of representative cycles.
|
|
487
|
+
*/
|
|
488
|
+
const std::vector<Cycle>& get_representative_cycles();
|
|
489
|
+
/**
|
|
490
|
+
* @brief Only available if @ref PersistenceMatrixOptions::can_retrieve_representative_cycles is true.
|
|
491
|
+
* Returns the cycle representing the given bar.
|
|
492
|
+
*
|
|
493
|
+
* @param bar A bar from the current barcode.
|
|
494
|
+
* @return A const reference to the cycle representing @p bar.
|
|
495
|
+
*/
|
|
496
|
+
const Cycle& get_representative_cycle(const Bar& bar);
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* @brief Only available if @ref PersistenceMatrixOptions::has_vine_update is true.
|
|
500
|
+
* Does the same than @ref vine_swap, but assumes that the swap is non trivial and
|
|
501
|
+
* therefore skips a part of the case study.
|
|
502
|
+
*
|
|
503
|
+
* @param position @ref PosIdx index of the first cell to swap. The second one has to be at `position + 1`.
|
|
504
|
+
* @return true If the barcode changed from the swap.
|
|
505
|
+
* @return false Otherwise.
|
|
506
|
+
*/
|
|
507
|
+
bool vine_swap_with_z_eq_1_case(Pos_index position);
|
|
508
|
+
/**
|
|
509
|
+
* @brief Only available if @ref PersistenceMatrixOptions::has_vine_update is true.
|
|
510
|
+
* Does a vine swap between two cells which are consecutive in the filtration. Roughly, if \f$ F \f$ is the current
|
|
511
|
+
* filtration represented by the matrix, the method modifies the matrix such that the new state corresponds to
|
|
512
|
+
* a valid state for the filtration \f$ F' \f$ equal to \f$ F \f$ but with the two cells at position `position`
|
|
513
|
+
* and `position + 1` swapped. Of course, the two cells should not have a face/coface relation which each other ;
|
|
514
|
+
* \f$ F' \f$ has to be a valid filtration.
|
|
515
|
+
* See @cite vineyards for more information about vine and vineyards.
|
|
516
|
+
*
|
|
517
|
+
* @param position @ref PosIdx index of the first cell to swap. The second one has to be at `position + 1`.
|
|
518
|
+
* @return true If the barcode changed from the swap.
|
|
519
|
+
* @return false Otherwise.
|
|
520
|
+
*/
|
|
521
|
+
bool vine_swap(Pos_index position);
|
|
522
|
+
|
|
523
|
+
private:
|
|
524
|
+
Underlying_matrix matrix_; /**< Interfaced matrix. */
|
|
525
|
+
std::vector<Index> positionToIndex_; /**< Map from @ref PosIdx index to @ref MatIdx index. */
|
|
526
|
+
Pos_index nextPosition_; /**< Next unused position. */
|
|
527
|
+
Index nextIndex_; /**< Next unused index. */
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
531
|
+
inline Position_to_index_overlay<Underlying_matrix, Master_matrix>::Position_to_index_overlay(
|
|
532
|
+
Column_settings* colSettings)
|
|
533
|
+
: matrix_(colSettings), nextPosition_(0), nextIndex_(0)
|
|
534
|
+
{}
|
|
535
|
+
|
|
536
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
537
|
+
template <class Boundary_range>
|
|
538
|
+
inline Position_to_index_overlay<Underlying_matrix, Master_matrix>::Position_to_index_overlay(
|
|
539
|
+
const std::vector<Boundary_range>& orderedBoundaries, Column_settings* colSettings)
|
|
540
|
+
: matrix_(orderedBoundaries, colSettings),
|
|
541
|
+
positionToIndex_(orderedBoundaries.size()),
|
|
542
|
+
nextPosition_(orderedBoundaries.size()),
|
|
543
|
+
nextIndex_(orderedBoundaries.size())
|
|
544
|
+
{
|
|
545
|
+
for (Index i = 0; i < orderedBoundaries.size(); i++) {
|
|
546
|
+
positionToIndex_[i] = i;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
551
|
+
inline Position_to_index_overlay<Underlying_matrix, Master_matrix>::Position_to_index_overlay(
|
|
552
|
+
unsigned int numberOfColumns, Column_settings* colSettings)
|
|
553
|
+
: matrix_(numberOfColumns, colSettings),
|
|
554
|
+
positionToIndex_(numberOfColumns),
|
|
555
|
+
nextPosition_(0),
|
|
556
|
+
nextIndex_(0)
|
|
557
|
+
{}
|
|
558
|
+
|
|
559
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
560
|
+
template <typename BirthComparatorFunction, typename DeathComparatorFunction>
|
|
561
|
+
inline Position_to_index_overlay<Underlying_matrix, Master_matrix>::Position_to_index_overlay(
|
|
562
|
+
Column_settings* colSettings,
|
|
563
|
+
const BirthComparatorFunction& birthComparator,
|
|
564
|
+
const DeathComparatorFunction& deathComparator)
|
|
565
|
+
: matrix_(colSettings, birthComparator, deathComparator), nextPosition_(0), nextIndex_(0)
|
|
566
|
+
{}
|
|
567
|
+
|
|
568
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
569
|
+
template <typename BirthComparatorFunction, typename DeathComparatorFunction, class Boundary_range>
|
|
570
|
+
inline Position_to_index_overlay<Underlying_matrix, Master_matrix>::Position_to_index_overlay(
|
|
571
|
+
const std::vector<Boundary_range>& orderedBoundaries,
|
|
572
|
+
Column_settings* colSettings,
|
|
573
|
+
const BirthComparatorFunction& birthComparator,
|
|
574
|
+
const DeathComparatorFunction& deathComparator)
|
|
575
|
+
: matrix_(orderedBoundaries, colSettings, birthComparator, deathComparator),
|
|
576
|
+
positionToIndex_(orderedBoundaries.size()),
|
|
577
|
+
nextPosition_(orderedBoundaries.size()),
|
|
578
|
+
nextIndex_(orderedBoundaries.size())
|
|
579
|
+
{
|
|
580
|
+
for (Index i = 0; i < orderedBoundaries.size(); i++) {
|
|
581
|
+
positionToIndex_[i] = i;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
586
|
+
template <typename BirthComparatorFunction, typename DeathComparatorFunction>
|
|
587
|
+
inline Position_to_index_overlay<Underlying_matrix, Master_matrix>::Position_to_index_overlay(
|
|
588
|
+
unsigned int numberOfColumns,
|
|
589
|
+
Column_settings* colSettings,
|
|
590
|
+
const BirthComparatorFunction& birthComparator,
|
|
591
|
+
const DeathComparatorFunction& deathComparator)
|
|
592
|
+
: matrix_(numberOfColumns, colSettings, birthComparator, deathComparator),
|
|
593
|
+
positionToIndex_(numberOfColumns),
|
|
594
|
+
nextPosition_(0),
|
|
595
|
+
nextIndex_(0)
|
|
596
|
+
{}
|
|
597
|
+
|
|
598
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
599
|
+
inline Position_to_index_overlay<Underlying_matrix, Master_matrix>::Position_to_index_overlay(
|
|
600
|
+
const Position_to_index_overlay& matrixToCopy, Column_settings* colSettings)
|
|
601
|
+
: matrix_(matrixToCopy.matrix_, colSettings),
|
|
602
|
+
positionToIndex_(matrixToCopy.positionToIndex_),
|
|
603
|
+
nextPosition_(matrixToCopy.nextPosition_),
|
|
604
|
+
nextIndex_(matrixToCopy.nextIndex_)
|
|
605
|
+
{}
|
|
606
|
+
|
|
607
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
608
|
+
inline Position_to_index_overlay<Underlying_matrix, Master_matrix>::Position_to_index_overlay(
|
|
609
|
+
Position_to_index_overlay&& other) noexcept
|
|
610
|
+
: matrix_(std::move(other.matrix_)),
|
|
611
|
+
positionToIndex_(std::move(other.positionToIndex_)),
|
|
612
|
+
nextPosition_(std::exchange(other.nextPosition_, 0)),
|
|
613
|
+
nextIndex_(std::exchange(other.nextIndex_, 0))
|
|
614
|
+
{}
|
|
615
|
+
|
|
616
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
617
|
+
template <class Boundary_range>
|
|
618
|
+
inline void Position_to_index_overlay<Underlying_matrix, Master_matrix>::insert_boundary(const Boundary_range& boundary,
|
|
619
|
+
Dimension dim)
|
|
620
|
+
{
|
|
621
|
+
if (positionToIndex_.size() <= nextPosition_) {
|
|
622
|
+
positionToIndex_.resize(nextPosition_ * 2 + 1);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
positionToIndex_[nextPosition_++] = nextIndex_++;
|
|
626
|
+
|
|
627
|
+
matrix_.insert_boundary(boundary, dim);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
631
|
+
template <class Boundary_range>
|
|
632
|
+
inline void Position_to_index_overlay<Underlying_matrix, Master_matrix>::insert_boundary(ID_index cellIndex,
|
|
633
|
+
const Boundary_range& boundary,
|
|
634
|
+
Dimension dim)
|
|
635
|
+
{
|
|
636
|
+
if (positionToIndex_.size() <= nextPosition_) {
|
|
637
|
+
positionToIndex_.resize(nextPosition_ * 2 + 1);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
positionToIndex_[nextPosition_++] = nextIndex_++;
|
|
641
|
+
|
|
642
|
+
matrix_.insert_boundary(cellIndex, boundary, dim);
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
646
|
+
inline typename Position_to_index_overlay<Underlying_matrix, Master_matrix>::Column&
|
|
647
|
+
Position_to_index_overlay<Underlying_matrix, Master_matrix>::get_column(Pos_index position)
|
|
648
|
+
{
|
|
649
|
+
return matrix_.get_column(positionToIndex_[position]);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
653
|
+
inline const typename Position_to_index_overlay<Underlying_matrix, Master_matrix>::Column&
|
|
654
|
+
Position_to_index_overlay<Underlying_matrix, Master_matrix>::get_column(Pos_index position) const
|
|
655
|
+
{
|
|
656
|
+
return matrix_.get_column(positionToIndex_[position]);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
660
|
+
inline typename Position_to_index_overlay<Underlying_matrix, Master_matrix>::Row&
|
|
661
|
+
Position_to_index_overlay<Underlying_matrix, Master_matrix>::get_row(ID_index rowIndex)
|
|
662
|
+
{
|
|
663
|
+
return matrix_.get_row(rowIndex);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
667
|
+
inline const typename Position_to_index_overlay<Underlying_matrix, Master_matrix>::Row&
|
|
668
|
+
Position_to_index_overlay<Underlying_matrix, Master_matrix>::get_row(ID_index rowIndex) const
|
|
669
|
+
{
|
|
670
|
+
return matrix_.get_row(rowIndex);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
674
|
+
inline void Position_to_index_overlay<Underlying_matrix, Master_matrix>::erase_empty_row(ID_index rowIndex)
|
|
675
|
+
{
|
|
676
|
+
return matrix_.erase_empty_row(rowIndex);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
680
|
+
inline void Position_to_index_overlay<Underlying_matrix, Master_matrix>::remove_maximal_cell(Pos_index position)
|
|
681
|
+
{
|
|
682
|
+
--nextPosition_;
|
|
683
|
+
|
|
684
|
+
ID_index pivot = matrix_.get_pivot(positionToIndex_[position]);
|
|
685
|
+
std::vector<Index> columnsToSwap(nextPosition_ - position);
|
|
686
|
+
|
|
687
|
+
if (nextPosition_ != position) {
|
|
688
|
+
positionToIndex_[position] = positionToIndex_[position + 1];
|
|
689
|
+
for (Pos_index p = position + 1; p < nextPosition_; ++p) {
|
|
690
|
+
columnsToSwap[p - position - 1] = positionToIndex_[p];
|
|
691
|
+
positionToIndex_[p] = positionToIndex_[p + 1];
|
|
692
|
+
}
|
|
693
|
+
columnsToSwap.back() = positionToIndex_[nextPosition_];
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
matrix_.remove_maximal_cell(pivot, columnsToSwap);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
700
|
+
inline void Position_to_index_overlay<Underlying_matrix, Master_matrix>::remove_last()
|
|
701
|
+
{
|
|
702
|
+
--nextPosition_;
|
|
703
|
+
if constexpr (Master_matrix::Option_list::has_vine_update) {
|
|
704
|
+
std::vector<Index> columnsToSwap;
|
|
705
|
+
matrix_.remove_maximal_cell(matrix_.get_pivot(positionToIndex_[nextPosition_]), columnsToSwap);
|
|
706
|
+
} else {
|
|
707
|
+
matrix_.remove_last(); // linear with vine updates, so it is better to use remove_maximal_cell
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
712
|
+
inline typename Position_to_index_overlay<Underlying_matrix, Master_matrix>::Dimension
|
|
713
|
+
Position_to_index_overlay<Underlying_matrix, Master_matrix>::get_max_dimension() const
|
|
714
|
+
{
|
|
715
|
+
return matrix_.get_max_dimension();
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
719
|
+
inline typename Position_to_index_overlay<Underlying_matrix, Master_matrix>::Index
|
|
720
|
+
Position_to_index_overlay<Underlying_matrix, Master_matrix>::get_number_of_columns() const
|
|
721
|
+
{
|
|
722
|
+
return matrix_.get_number_of_columns();
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
726
|
+
inline typename Position_to_index_overlay<Underlying_matrix, Master_matrix>::Dimension
|
|
727
|
+
Position_to_index_overlay<Underlying_matrix, Master_matrix>::get_column_dimension(Pos_index position) const
|
|
728
|
+
{
|
|
729
|
+
return matrix_.get_column_dimension(positionToIndex_[position]);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
733
|
+
inline void Position_to_index_overlay<Underlying_matrix, Master_matrix>::add_to(Pos_index sourcePosition,
|
|
734
|
+
Pos_index targetPosition)
|
|
735
|
+
{
|
|
736
|
+
return matrix_.add_to(positionToIndex_[sourcePosition], positionToIndex_[targetPosition]);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
740
|
+
inline void Position_to_index_overlay<Underlying_matrix, Master_matrix>::multiply_target_and_add_to(
|
|
741
|
+
Pos_index sourcePosition, const Field_element& coefficient, Pos_index targetPosition)
|
|
742
|
+
{
|
|
743
|
+
return matrix_.multiply_target_and_add_to(positionToIndex_[sourcePosition],
|
|
744
|
+
coefficient,
|
|
745
|
+
positionToIndex_[targetPosition]);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
749
|
+
inline void Position_to_index_overlay<Underlying_matrix, Master_matrix>::multiply_source_and_add_to(
|
|
750
|
+
const Field_element& coefficient, Pos_index sourcePosition, Pos_index targetPosition)
|
|
751
|
+
{
|
|
752
|
+
return matrix_.multiply_source_and_add_to(coefficient,
|
|
753
|
+
positionToIndex_[sourcePosition],
|
|
754
|
+
positionToIndex_[targetPosition]);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
758
|
+
inline bool Position_to_index_overlay<Underlying_matrix, Master_matrix>::is_zero_entry(Pos_index position,
|
|
759
|
+
ID_index rowIndex) const
|
|
760
|
+
{
|
|
761
|
+
return matrix_.is_zero_entry(positionToIndex_[position], rowIndex);
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
765
|
+
inline bool Position_to_index_overlay<Underlying_matrix, Master_matrix>::is_zero_column(Pos_index position)
|
|
766
|
+
{
|
|
767
|
+
return matrix_.is_zero_column(positionToIndex_[position]);
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
771
|
+
inline typename Position_to_index_overlay<Underlying_matrix, Master_matrix>::Pos_index
|
|
772
|
+
Position_to_index_overlay<Underlying_matrix, Master_matrix>::get_column_with_pivot(ID_index cellIndex) const
|
|
773
|
+
{
|
|
774
|
+
Index id = matrix_.get_column_with_pivot(cellIndex);
|
|
775
|
+
Pos_index i = 0;
|
|
776
|
+
while (positionToIndex_[i] != id) ++i;
|
|
777
|
+
return i;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
781
|
+
inline typename Position_to_index_overlay<Underlying_matrix, Master_matrix>::ID_index
|
|
782
|
+
Position_to_index_overlay<Underlying_matrix, Master_matrix>::get_pivot(Pos_index position)
|
|
783
|
+
{
|
|
784
|
+
return matrix_.get_pivot(positionToIndex_[position]);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
788
|
+
inline Position_to_index_overlay<Underlying_matrix, Master_matrix>&
|
|
789
|
+
Position_to_index_overlay<Underlying_matrix, Master_matrix>::operator=(const Position_to_index_overlay& other)
|
|
790
|
+
{
|
|
791
|
+
matrix_ = other.matrix_;
|
|
792
|
+
positionToIndex_ = other.positionToIndex_;
|
|
793
|
+
nextPosition_ = other.nextPosition_;
|
|
794
|
+
nextIndex_ = other.nextIndex_;
|
|
795
|
+
|
|
796
|
+
return *this;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
800
|
+
inline void Position_to_index_overlay<Underlying_matrix, Master_matrix>::print()
|
|
801
|
+
{
|
|
802
|
+
return matrix_.print();
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
806
|
+
inline const typename Position_to_index_overlay<Underlying_matrix, Master_matrix>::Barcode&
|
|
807
|
+
Position_to_index_overlay<Underlying_matrix, Master_matrix>::get_current_barcode() const
|
|
808
|
+
{
|
|
809
|
+
return matrix_.get_current_barcode();
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
813
|
+
inline void Position_to_index_overlay<Underlying_matrix, Master_matrix>::update_representative_cycles()
|
|
814
|
+
{
|
|
815
|
+
matrix_.update_representative_cycles();
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
819
|
+
inline const std::vector<typename Position_to_index_overlay<Underlying_matrix, Master_matrix>::Cycle>&
|
|
820
|
+
Position_to_index_overlay<Underlying_matrix, Master_matrix>::get_representative_cycles()
|
|
821
|
+
{
|
|
822
|
+
return matrix_.get_representative_cycles();
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
826
|
+
inline const typename Position_to_index_overlay<Underlying_matrix, Master_matrix>::Cycle&
|
|
827
|
+
Position_to_index_overlay<Underlying_matrix, Master_matrix>::get_representative_cycle(const Bar& bar)
|
|
828
|
+
{
|
|
829
|
+
return matrix_.get_representative_cycle(bar);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
833
|
+
inline bool Position_to_index_overlay<Underlying_matrix, Master_matrix>::vine_swap_with_z_eq_1_case(Pos_index position)
|
|
834
|
+
{
|
|
835
|
+
Index next = matrix_.vine_swap_with_z_eq_1_case(positionToIndex_[position], positionToIndex_[position + 1]);
|
|
836
|
+
if (next == positionToIndex_[position]) {
|
|
837
|
+
std::swap(positionToIndex_[position], positionToIndex_[position + 1]);
|
|
838
|
+
return true;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
return false;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
template <class Underlying_matrix, class Master_matrix>
|
|
845
|
+
inline bool Position_to_index_overlay<Underlying_matrix, Master_matrix>::vine_swap(Pos_index position)
|
|
846
|
+
{
|
|
847
|
+
Index next = matrix_.vine_swap(positionToIndex_[position], positionToIndex_[position + 1]);
|
|
848
|
+
if (next == positionToIndex_[position]) {
|
|
849
|
+
std::swap(positionToIndex_[position], positionToIndex_[position + 1]);
|
|
850
|
+
return true;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
return false;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
} // namespace persistence_matrix
|
|
857
|
+
} // namespace Gudhi
|
|
858
|
+
|
|
859
|
+
#endif // PM_POS_TO_ID_TRANSLATION_H
|