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,914 @@
|
|
|
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 intrusive_set_column.h
|
|
13
|
+
* @author Hannah Schreiber
|
|
14
|
+
* @brief Contains the @ref Gudhi::persistence_matrix::Intrusive_set_column class.
|
|
15
|
+
* Also defines the std::hash method for @ref Gudhi::persistence_matrix::Intrusive_set_column.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#ifndef PM_INTRUSIVE_SET_COLUMN_H
|
|
19
|
+
#define PM_INTRUSIVE_SET_COLUMN_H
|
|
20
|
+
|
|
21
|
+
#include <vector>
|
|
22
|
+
#include <stdexcept>
|
|
23
|
+
#include <type_traits>
|
|
24
|
+
#include <utility> //std::swap, std::move & std::exchange
|
|
25
|
+
|
|
26
|
+
#include <boost/intrusive/set.hpp>
|
|
27
|
+
|
|
28
|
+
#include <gudhi/Debug_utils.h>
|
|
29
|
+
#include <gudhi/Persistence_matrix/allocators/entry_constructors.h>
|
|
30
|
+
#include <gudhi/Persistence_matrix/columns/column_utilities.h>
|
|
31
|
+
|
|
32
|
+
namespace Gudhi {
|
|
33
|
+
namespace persistence_matrix {
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @class Intrusive_set_column intrusive_set_column.h gudhi/Persistence_matrix/columns/intrusive_set_column.h
|
|
37
|
+
* @ingroup persistence_matrix
|
|
38
|
+
*
|
|
39
|
+
* @brief Column class following the @ref PersistenceMatrixColumn concept.
|
|
40
|
+
*
|
|
41
|
+
* Column based on a intrusive set structure. The entries are ordered by row index and only non-zero values
|
|
42
|
+
* are stored uniquely in the underlying container.
|
|
43
|
+
*
|
|
44
|
+
* @tparam Master_matrix An instantiation of @ref Matrix from which all types and options are deduced.
|
|
45
|
+
*/
|
|
46
|
+
template <class Master_matrix>
|
|
47
|
+
class Intrusive_set_column : public Master_matrix::Row_access_option,
|
|
48
|
+
public Master_matrix::Column_dimension_option,
|
|
49
|
+
public Master_matrix::Chain_column_option
|
|
50
|
+
{
|
|
51
|
+
public:
|
|
52
|
+
using Master = Master_matrix;
|
|
53
|
+
using Index = typename Master_matrix::Index;
|
|
54
|
+
using ID_index = typename Master_matrix::ID_index;
|
|
55
|
+
using Dimension = typename Master_matrix::Dimension;
|
|
56
|
+
using Field_element = typename Master_matrix::Element;
|
|
57
|
+
using Entry = typename Master_matrix::Matrix_entry;
|
|
58
|
+
using Column_settings = typename Master_matrix::Column_settings;
|
|
59
|
+
|
|
60
|
+
private:
|
|
61
|
+
using Field_operators = typename Master_matrix::Field_operators;
|
|
62
|
+
using Column_support =
|
|
63
|
+
boost::intrusive::set<Entry,
|
|
64
|
+
boost::intrusive::constant_time_size<false>,
|
|
65
|
+
boost::intrusive::base_hook<typename Master_matrix::Base_hook_matrix_set_column> >;
|
|
66
|
+
using Entry_constructor = typename Master_matrix::Entry_constructor;
|
|
67
|
+
|
|
68
|
+
public:
|
|
69
|
+
using iterator = typename Column_support::iterator;
|
|
70
|
+
using const_iterator = typename Column_support::const_iterator;
|
|
71
|
+
using reverse_iterator = typename Column_support::reverse_iterator;
|
|
72
|
+
using const_reverse_iterator = typename Column_support::const_reverse_iterator;
|
|
73
|
+
using Content_range = const Column_support&;
|
|
74
|
+
|
|
75
|
+
Intrusive_set_column(Column_settings* colSettings = nullptr);
|
|
76
|
+
template <class Container = typename Master_matrix::Boundary>
|
|
77
|
+
Intrusive_set_column(const Container& nonZeroRowIndices, Column_settings* colSettings);
|
|
78
|
+
template <class Container = typename Master_matrix::Boundary, class Row_container>
|
|
79
|
+
Intrusive_set_column(Index columnIndex,
|
|
80
|
+
const Container& nonZeroRowIndices,
|
|
81
|
+
Row_container* rowContainer,
|
|
82
|
+
Column_settings* colSettings);
|
|
83
|
+
template <class Container = typename Master_matrix::Boundary,
|
|
84
|
+
class = std::enable_if_t<!std::is_arithmetic_v<Container> > >
|
|
85
|
+
Intrusive_set_column(const Container& nonZeroRowIndices, Dimension dimension, Column_settings* colSettings);
|
|
86
|
+
template <class Container = typename Master_matrix::Boundary,
|
|
87
|
+
class Row_container,
|
|
88
|
+
class = std::enable_if_t<!std::is_arithmetic_v<Container> > >
|
|
89
|
+
Intrusive_set_column(Index columnIndex,
|
|
90
|
+
const Container& nonZeroRowIndices,
|
|
91
|
+
Dimension dimension,
|
|
92
|
+
Row_container* rowContainer,
|
|
93
|
+
Column_settings* colSettings);
|
|
94
|
+
Intrusive_set_column(ID_index idx, Dimension dimension, Column_settings* colSettings);
|
|
95
|
+
Intrusive_set_column(ID_index idx,
|
|
96
|
+
Field_element e,
|
|
97
|
+
Dimension dimension,
|
|
98
|
+
Column_settings* colSettings);
|
|
99
|
+
template <class Row_container>
|
|
100
|
+
Intrusive_set_column(Index columnIndex,
|
|
101
|
+
ID_index idx,
|
|
102
|
+
Dimension dimension,
|
|
103
|
+
Row_container* rowContainer,
|
|
104
|
+
Column_settings* colSettings);
|
|
105
|
+
template <class Row_container>
|
|
106
|
+
Intrusive_set_column(Index columnIndex,
|
|
107
|
+
ID_index idx,
|
|
108
|
+
Field_element e,
|
|
109
|
+
Dimension dimension,
|
|
110
|
+
Row_container* rowContainer,
|
|
111
|
+
Column_settings* colSettings);
|
|
112
|
+
Intrusive_set_column(const Intrusive_set_column& column, Column_settings* colSettings = nullptr);
|
|
113
|
+
template <class Row_container>
|
|
114
|
+
Intrusive_set_column(const Intrusive_set_column& column,
|
|
115
|
+
Index columnIndex,
|
|
116
|
+
Row_container* rowContainer,
|
|
117
|
+
Column_settings* colSettings = nullptr);
|
|
118
|
+
Intrusive_set_column(Intrusive_set_column&& column) noexcept;
|
|
119
|
+
~Intrusive_set_column();
|
|
120
|
+
|
|
121
|
+
std::vector<Field_element> get_content(int columnLength = -1) const;
|
|
122
|
+
bool is_non_zero(ID_index rowIndex) const;
|
|
123
|
+
[[nodiscard]] bool is_empty() const;
|
|
124
|
+
[[nodiscard]] std::size_t size() const;
|
|
125
|
+
|
|
126
|
+
template <class Row_index_map>
|
|
127
|
+
void reorder(const Row_index_map& valueMap,
|
|
128
|
+
[[maybe_unused]] Index columnIndex = Master_matrix::template get_null_value<Index>());
|
|
129
|
+
void clear();
|
|
130
|
+
void clear(ID_index rowIndex);
|
|
131
|
+
|
|
132
|
+
ID_index get_pivot() const;
|
|
133
|
+
Field_element get_pivot_value() const;
|
|
134
|
+
|
|
135
|
+
iterator begin() noexcept;
|
|
136
|
+
const_iterator begin() const noexcept;
|
|
137
|
+
iterator end() noexcept;
|
|
138
|
+
const_iterator end() const noexcept;
|
|
139
|
+
reverse_iterator rbegin() noexcept;
|
|
140
|
+
const_reverse_iterator rbegin() const noexcept;
|
|
141
|
+
reverse_iterator rend() noexcept;
|
|
142
|
+
const_reverse_iterator rend() const noexcept;
|
|
143
|
+
|
|
144
|
+
Content_range get_non_zero_content_range() const;
|
|
145
|
+
|
|
146
|
+
template <class Entry_range>
|
|
147
|
+
Intrusive_set_column& operator+=(const Entry_range& column);
|
|
148
|
+
Intrusive_set_column& operator+=(Intrusive_set_column& column);
|
|
149
|
+
|
|
150
|
+
Intrusive_set_column& operator*=(const Field_element& v);
|
|
151
|
+
|
|
152
|
+
// this = v * this + column
|
|
153
|
+
template <class Entry_range>
|
|
154
|
+
Intrusive_set_column& multiply_target_and_add(const Field_element& val, const Entry_range& column);
|
|
155
|
+
Intrusive_set_column& multiply_target_and_add(const Field_element& val, Intrusive_set_column& column);
|
|
156
|
+
// this = this + column * v
|
|
157
|
+
template <class Entry_range>
|
|
158
|
+
Intrusive_set_column& multiply_source_and_add(const Entry_range& column, const Field_element& val);
|
|
159
|
+
Intrusive_set_column& multiply_source_and_add(Intrusive_set_column& column, const Field_element& val);
|
|
160
|
+
|
|
161
|
+
void push_back(const Entry& entry);
|
|
162
|
+
|
|
163
|
+
friend bool operator==(const Intrusive_set_column& c1, const Intrusive_set_column& c2)
|
|
164
|
+
{
|
|
165
|
+
if (&c1 == &c2) return true;
|
|
166
|
+
|
|
167
|
+
return std::equal(c1.column_.begin(),
|
|
168
|
+
c1.column_.end(),
|
|
169
|
+
c2.column_.begin(),
|
|
170
|
+
c2.column_.end(),
|
|
171
|
+
[](const Entry& e1, const Entry& e2) {
|
|
172
|
+
return e1.get_row_index() == e2.get_row_index() && e1.get_element() == e2.get_element();
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
friend bool operator<(const Intrusive_set_column& c1, const Intrusive_set_column& c2)
|
|
177
|
+
{
|
|
178
|
+
if (&c1 == &c2) return false;
|
|
179
|
+
|
|
180
|
+
return std::lexicographical_compare(c1.column_.begin(),
|
|
181
|
+
c1.column_.end(),
|
|
182
|
+
c2.column_.begin(),
|
|
183
|
+
c2.column_.end(),
|
|
184
|
+
[](const Entry& e1, const Entry& e2) {
|
|
185
|
+
if (e1.get_row_index() != e2.get_row_index())
|
|
186
|
+
return e1.get_row_index() < e2.get_row_index();
|
|
187
|
+
if (e1.get_element() != e2.get_element())
|
|
188
|
+
return e1.get_element() < e2.get_element();
|
|
189
|
+
return false;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Disabled with row access.
|
|
194
|
+
Intrusive_set_column& operator=(const Intrusive_set_column& other);
|
|
195
|
+
Intrusive_set_column& operator=(Intrusive_set_column&& other) noexcept;
|
|
196
|
+
|
|
197
|
+
friend void swap(Intrusive_set_column& col1, Intrusive_set_column& col2) noexcept
|
|
198
|
+
{
|
|
199
|
+
swap(static_cast<typename Master_matrix::Row_access_option&>(col1),
|
|
200
|
+
static_cast<typename Master_matrix::Row_access_option&>(col2));
|
|
201
|
+
swap(static_cast<typename Master_matrix::Column_dimension_option&>(col1),
|
|
202
|
+
static_cast<typename Master_matrix::Column_dimension_option&>(col2));
|
|
203
|
+
swap(static_cast<typename Master_matrix::Chain_column_option&>(col1),
|
|
204
|
+
static_cast<typename Master_matrix::Chain_column_option&>(col2));
|
|
205
|
+
col1.column_.swap(col2.column_);
|
|
206
|
+
std::swap(col1.operators_, col2.operators_);
|
|
207
|
+
std::swap(col1.entryPool_, col2.entryPool_);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
private:
|
|
211
|
+
using RA_opt = typename Master_matrix::Row_access_option;
|
|
212
|
+
using Dim_opt = typename Master_matrix::Column_dimension_option;
|
|
213
|
+
using Chain_opt = typename Master_matrix::Chain_column_option;
|
|
214
|
+
|
|
215
|
+
// Cloner object function for boost intrusive container
|
|
216
|
+
struct New_cloner {
|
|
217
|
+
New_cloner(Entry_constructor* entryPool) : entryPool_(entryPool) {};
|
|
218
|
+
|
|
219
|
+
Entry* operator()(const Entry& clone_this) { return entryPool_->construct(clone_this); }
|
|
220
|
+
|
|
221
|
+
Entry_constructor* entryPool_;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// The disposer object function for boost intrusive container
|
|
225
|
+
struct Delete_disposer {
|
|
226
|
+
Delete_disposer() = default;
|
|
227
|
+
Delete_disposer(Intrusive_set_column* col) : col_(col) {};
|
|
228
|
+
|
|
229
|
+
void operator()(Entry* delete_this)
|
|
230
|
+
{
|
|
231
|
+
if constexpr (Master_matrix::Option_list::has_row_access) col_->unlink(delete_this);
|
|
232
|
+
col_->entryPool_->destroy(delete_this);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
Intrusive_set_column* col_;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
Column_support column_;
|
|
239
|
+
Field_operators const* operators_;
|
|
240
|
+
Entry_constructor* entryPool_;
|
|
241
|
+
|
|
242
|
+
template <class Column, class Entry_iterator, typename F1, typename F2, typename F3, typename F4>
|
|
243
|
+
friend void _generic_merge_entry_to_column(Column& targetColumn,
|
|
244
|
+
Entry_iterator& itSource,
|
|
245
|
+
typename Column::Column_support::iterator& itTarget,
|
|
246
|
+
F1&& process_target,
|
|
247
|
+
F2&& process_source,
|
|
248
|
+
F3&& update_target1,
|
|
249
|
+
F4&& update_target2,
|
|
250
|
+
bool& pivotIsZeroed);
|
|
251
|
+
template <class Column, class Entry_range, typename F1, typename F2, typename F3, typename F4, typename F5>
|
|
252
|
+
friend bool _generic_add_to_column(const Entry_range& source,
|
|
253
|
+
Column& targetColumn,
|
|
254
|
+
F1&& process_target,
|
|
255
|
+
F2&& process_source,
|
|
256
|
+
F3&& update_target1,
|
|
257
|
+
F4&& update_target2,
|
|
258
|
+
F5&& finish_target);
|
|
259
|
+
template <class Column, class Entry_range>
|
|
260
|
+
friend bool _add_to_column(const Entry_range& source, Column& targetColumn);
|
|
261
|
+
template <class Column, class Entry_range>
|
|
262
|
+
friend bool _multiply_target_and_add_to_column(const typename Column::Field_element& val,
|
|
263
|
+
const Entry_range& source,
|
|
264
|
+
Column& targetColumn);
|
|
265
|
+
template <class Column, class Entry_range>
|
|
266
|
+
friend bool _multiply_source_and_add_to_column(const typename Column::Field_element& val,
|
|
267
|
+
const Entry_range& source,
|
|
268
|
+
Column& targetColumn);
|
|
269
|
+
|
|
270
|
+
void _delete_entry(iterator& it);
|
|
271
|
+
Entry* _insert_entry(const iterator& position, ID_index rowIndex, const Field_element& value);
|
|
272
|
+
template <class Entry_range>
|
|
273
|
+
bool _add(const Entry_range& column);
|
|
274
|
+
template <class Entry_range>
|
|
275
|
+
bool _multiply_target_and_add(const Field_element& val, const Entry_range& column);
|
|
276
|
+
template <class Entry_range>
|
|
277
|
+
bool _multiply_source_and_add(const Entry_range& column, const Field_element& val);
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
template <class Master_matrix>
|
|
281
|
+
inline Intrusive_set_column<Master_matrix>::Intrusive_set_column(Column_settings* colSettings)
|
|
282
|
+
: RA_opt(),
|
|
283
|
+
Dim_opt(),
|
|
284
|
+
Chain_opt(),
|
|
285
|
+
operators_(Master_matrix::get_operator_ptr(colSettings)),
|
|
286
|
+
entryPool_(colSettings == nullptr ? nullptr : &(colSettings->entryConstructor))
|
|
287
|
+
{}
|
|
288
|
+
|
|
289
|
+
template <class Master_matrix>
|
|
290
|
+
template <class Container>
|
|
291
|
+
inline Intrusive_set_column<Master_matrix>::Intrusive_set_column(const Container& nonZeroRowIndices,
|
|
292
|
+
Column_settings* colSettings)
|
|
293
|
+
: Intrusive_set_column(nonZeroRowIndices,
|
|
294
|
+
nonZeroRowIndices.size() == 0 ? 0 : nonZeroRowIndices.size() - 1,
|
|
295
|
+
colSettings)
|
|
296
|
+
{
|
|
297
|
+
static_assert(!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type,
|
|
298
|
+
"Constructor not available for chain columns, please specify the dimension of the chain.");
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
template <class Master_matrix>
|
|
302
|
+
template <class Container, class Row_container>
|
|
303
|
+
inline Intrusive_set_column<Master_matrix>::Intrusive_set_column(Index columnIndex,
|
|
304
|
+
const Container& nonZeroRowIndices,
|
|
305
|
+
Row_container* rowContainer,
|
|
306
|
+
Column_settings* colSettings)
|
|
307
|
+
: Intrusive_set_column(columnIndex,
|
|
308
|
+
nonZeroRowIndices,
|
|
309
|
+
nonZeroRowIndices.size() == 0 ? 0 : nonZeroRowIndices.size() - 1,
|
|
310
|
+
rowContainer,
|
|
311
|
+
colSettings)
|
|
312
|
+
{
|
|
313
|
+
static_assert(!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type,
|
|
314
|
+
"Constructor not available for chain columns, please specify the dimension of the chain.");
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
template <class Master_matrix>
|
|
318
|
+
template <class Container, class>
|
|
319
|
+
inline Intrusive_set_column<Master_matrix>::Intrusive_set_column(const Container& nonZeroRowIndices,
|
|
320
|
+
Dimension dimension,
|
|
321
|
+
Column_settings* colSettings)
|
|
322
|
+
: RA_opt(),
|
|
323
|
+
Dim_opt(dimension),
|
|
324
|
+
Chain_opt(nonZeroRowIndices.begin() == nonZeroRowIndices.end()
|
|
325
|
+
? Master_matrix::template get_null_value<ID_index>()
|
|
326
|
+
: Master_matrix::get_row_index(*std::prev(nonZeroRowIndices.end()))),
|
|
327
|
+
operators_(Master_matrix::get_operator_ptr(colSettings)),
|
|
328
|
+
entryPool_(&(colSettings->entryConstructor))
|
|
329
|
+
{
|
|
330
|
+
for (const auto& id : nonZeroRowIndices) {
|
|
331
|
+
_insert_entry(column_.end(),
|
|
332
|
+
Master_matrix::get_row_index(id),
|
|
333
|
+
Master_matrix::get_coefficient_value(Master_matrix::get_element(id), operators_));
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
template <class Master_matrix>
|
|
338
|
+
template <class Container, class Row_container, class>
|
|
339
|
+
inline Intrusive_set_column<Master_matrix>::Intrusive_set_column(Index columnIndex,
|
|
340
|
+
const Container& nonZeroRowIndices,
|
|
341
|
+
Dimension dimension,
|
|
342
|
+
Row_container* rowContainer,
|
|
343
|
+
Column_settings* colSettings)
|
|
344
|
+
: RA_opt(columnIndex, rowContainer),
|
|
345
|
+
Dim_opt(dimension),
|
|
346
|
+
Chain_opt(nonZeroRowIndices.begin() == nonZeroRowIndices.end()
|
|
347
|
+
? Master_matrix::template get_null_value<ID_index>()
|
|
348
|
+
: Master_matrix::get_row_index(*std::prev(nonZeroRowIndices.end()))),
|
|
349
|
+
operators_(Master_matrix::get_operator_ptr(colSettings)),
|
|
350
|
+
entryPool_(&(colSettings->entryConstructor))
|
|
351
|
+
{
|
|
352
|
+
for (const auto& id : nonZeroRowIndices) {
|
|
353
|
+
_insert_entry(column_.end(),
|
|
354
|
+
Master_matrix::get_row_index(id),
|
|
355
|
+
Master_matrix::get_coefficient_value(Master_matrix::get_element(id), operators_));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
template <class Master_matrix>
|
|
360
|
+
inline Intrusive_set_column<Master_matrix>::Intrusive_set_column(ID_index idx,
|
|
361
|
+
Dimension dimension,
|
|
362
|
+
Column_settings* colSettings)
|
|
363
|
+
: RA_opt(), Dim_opt(dimension), Chain_opt(idx), operators_(nullptr), entryPool_(&(colSettings->entryConstructor))
|
|
364
|
+
{
|
|
365
|
+
static_assert(Master_matrix::Option_list::is_z2,
|
|
366
|
+
"Constructor not available for Zp != Z2. Please specify the coefficient.");
|
|
367
|
+
_insert_entry(column_.end(), idx, 1);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
template <class Master_matrix>
|
|
371
|
+
inline Intrusive_set_column<Master_matrix>::Intrusive_set_column(ID_index idx,
|
|
372
|
+
Field_element e,
|
|
373
|
+
Dimension dimension,
|
|
374
|
+
Column_settings* colSettings)
|
|
375
|
+
: RA_opt(),
|
|
376
|
+
Dim_opt(dimension),
|
|
377
|
+
Chain_opt(idx),
|
|
378
|
+
operators_(&(colSettings->operators)),
|
|
379
|
+
entryPool_(&(colSettings->entryConstructor))
|
|
380
|
+
{
|
|
381
|
+
static_assert(!Master_matrix::Option_list::is_z2,
|
|
382
|
+
"Constructor not available for Zp == Z2. Please do not specify any coefficient.");
|
|
383
|
+
_insert_entry(column_.end(), idx, operators_->get_value(e));
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
template <class Master_matrix>
|
|
387
|
+
template <class Row_container>
|
|
388
|
+
inline Intrusive_set_column<Master_matrix>::Intrusive_set_column(Index columnIndex,
|
|
389
|
+
ID_index idx,
|
|
390
|
+
Dimension dimension,
|
|
391
|
+
Row_container* rowContainer,
|
|
392
|
+
Column_settings* colSettings)
|
|
393
|
+
: RA_opt(columnIndex, rowContainer),
|
|
394
|
+
Dim_opt(dimension),
|
|
395
|
+
Chain_opt(idx),
|
|
396
|
+
operators_(nullptr),
|
|
397
|
+
entryPool_(&(colSettings->entryConstructor))
|
|
398
|
+
{
|
|
399
|
+
static_assert(Master_matrix::Option_list::is_z2,
|
|
400
|
+
"Constructor not available for Zp != Z2. Please specify the coefficient.");
|
|
401
|
+
_insert_entry(column_.end(), idx, 1);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
template <class Master_matrix>
|
|
405
|
+
template <class Row_container>
|
|
406
|
+
inline Intrusive_set_column<Master_matrix>::Intrusive_set_column(Index columnIndex,
|
|
407
|
+
ID_index idx,
|
|
408
|
+
Field_element e,
|
|
409
|
+
Dimension dimension,
|
|
410
|
+
Row_container* rowContainer,
|
|
411
|
+
Column_settings* colSettings)
|
|
412
|
+
: RA_opt(columnIndex, rowContainer),
|
|
413
|
+
Dim_opt(dimension),
|
|
414
|
+
Chain_opt(idx),
|
|
415
|
+
operators_(&(colSettings->operators)),
|
|
416
|
+
entryPool_(&(colSettings->entryConstructor))
|
|
417
|
+
{
|
|
418
|
+
static_assert(!Master_matrix::Option_list::is_z2,
|
|
419
|
+
"Constructor not available for Zp == Z2. Please do not specify any coefficient.");
|
|
420
|
+
_insert_entry(column_.end(), idx, operators_->get_value(e));
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
template <class Master_matrix>
|
|
424
|
+
inline Intrusive_set_column<Master_matrix>::Intrusive_set_column(const Intrusive_set_column& column,
|
|
425
|
+
Column_settings* colSettings)
|
|
426
|
+
: RA_opt(),
|
|
427
|
+
Dim_opt(static_cast<const Dim_opt&>(column)),
|
|
428
|
+
Chain_opt(static_cast<const Chain_opt&>(column)),
|
|
429
|
+
operators_(colSettings == nullptr ? column.operators_ : Master_matrix::get_operator_ptr(colSettings)),
|
|
430
|
+
entryPool_(colSettings == nullptr ? column.entryPool_ : &(colSettings->entryConstructor))
|
|
431
|
+
{
|
|
432
|
+
static_assert(!Master_matrix::Option_list::has_row_access,
|
|
433
|
+
"Simple copy constructor not available when row access option enabled. Please specify the new column "
|
|
434
|
+
"index and the row container.");
|
|
435
|
+
|
|
436
|
+
column_.clone_from(column.column_, New_cloner(entryPool_), Delete_disposer(this));
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
template <class Master_matrix>
|
|
440
|
+
template <class Row_container>
|
|
441
|
+
inline Intrusive_set_column<Master_matrix>::Intrusive_set_column(const Intrusive_set_column& column,
|
|
442
|
+
Index columnIndex,
|
|
443
|
+
Row_container* rowContainer,
|
|
444
|
+
Column_settings* colSettings)
|
|
445
|
+
: RA_opt(columnIndex, rowContainer),
|
|
446
|
+
Dim_opt(static_cast<const Dim_opt&>(column)),
|
|
447
|
+
Chain_opt(static_cast<const Chain_opt&>(column)),
|
|
448
|
+
operators_(colSettings == nullptr ? column.operators_ : Master_matrix::get_operator_ptr(colSettings)),
|
|
449
|
+
entryPool_(colSettings == nullptr ? column.entryPool_ : &(colSettings->entryConstructor))
|
|
450
|
+
{
|
|
451
|
+
for (const Entry& entry : column.column_) {
|
|
452
|
+
_insert_entry(column_.end(), entry.get_row_index(), entry.get_element());
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
template <class Master_matrix>
|
|
457
|
+
inline Intrusive_set_column<Master_matrix>::Intrusive_set_column(Intrusive_set_column&& column) noexcept
|
|
458
|
+
: RA_opt(std::move(static_cast<RA_opt&>(column))),
|
|
459
|
+
Dim_opt(std::move(static_cast<Dim_opt&>(column))),
|
|
460
|
+
Chain_opt(std::move(static_cast<Chain_opt&>(column))),
|
|
461
|
+
column_(std::move(column.column_)),
|
|
462
|
+
operators_(std::exchange(column.operators_, nullptr)),
|
|
463
|
+
entryPool_(std::exchange(column.entryPool_, nullptr))
|
|
464
|
+
{}
|
|
465
|
+
|
|
466
|
+
template <class Master_matrix>
|
|
467
|
+
inline Intrusive_set_column<Master_matrix>::~Intrusive_set_column()
|
|
468
|
+
{
|
|
469
|
+
column_.clear_and_dispose(Delete_disposer(this));
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
template <class Master_matrix>
|
|
473
|
+
inline std::vector<typename Intrusive_set_column<Master_matrix>::Field_element>
|
|
474
|
+
Intrusive_set_column<Master_matrix>::get_content(int columnLength) const
|
|
475
|
+
{
|
|
476
|
+
if (columnLength < 0 && column_.size() > 0)
|
|
477
|
+
columnLength = column_.rbegin()->get_row_index() + 1;
|
|
478
|
+
else if (columnLength < 0)
|
|
479
|
+
return std::vector<Field_element>();
|
|
480
|
+
|
|
481
|
+
std::vector<Field_element> container(columnLength);
|
|
482
|
+
for (auto it = column_.begin(); it != column_.end() && it->get_row_index() < static_cast<ID_index>(columnLength);
|
|
483
|
+
++it) {
|
|
484
|
+
container[it->get_row_index()] = Master_matrix::get_element(*it);
|
|
485
|
+
}
|
|
486
|
+
return container;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
template <class Master_matrix>
|
|
490
|
+
inline bool Intrusive_set_column<Master_matrix>::is_non_zero(ID_index rowIndex) const
|
|
491
|
+
{
|
|
492
|
+
return column_.find(Entry(rowIndex)) != column_.end();
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
template <class Master_matrix>
|
|
496
|
+
inline bool Intrusive_set_column<Master_matrix>::is_empty() const
|
|
497
|
+
{
|
|
498
|
+
return column_.empty();
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
template <class Master_matrix>
|
|
502
|
+
inline std::size_t Intrusive_set_column<Master_matrix>::size() const
|
|
503
|
+
{
|
|
504
|
+
return column_.size();
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
template <class Master_matrix>
|
|
508
|
+
template <class Row_index_map>
|
|
509
|
+
inline void Intrusive_set_column<Master_matrix>::reorder(const Row_index_map& valueMap,
|
|
510
|
+
[[maybe_unused]] Index columnIndex)
|
|
511
|
+
{
|
|
512
|
+
static_assert(!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type,
|
|
513
|
+
"Method not available for chain columns.");
|
|
514
|
+
|
|
515
|
+
Column_support newSet;
|
|
516
|
+
|
|
517
|
+
if constexpr (Master_matrix::Option_list::has_row_access) {
|
|
518
|
+
for (auto it = column_.begin(); it != column_.end();) {
|
|
519
|
+
Entry* newEntry = entryPool_->construct(
|
|
520
|
+
columnIndex == Master_matrix::template get_null_value<Index>() ? RA_opt::get_column_index() : columnIndex,
|
|
521
|
+
valueMap.at(it->get_row_index()));
|
|
522
|
+
newEntry->set_element(it->get_element());
|
|
523
|
+
newSet.insert(newSet.end(), *newEntry);
|
|
524
|
+
_delete_entry(it); // increases it
|
|
525
|
+
if constexpr (Master_matrix::Option_list::has_intrusive_rows) // intrusive list
|
|
526
|
+
RA_opt::insert_entry(newEntry->get_row_index(), newEntry);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// when row is a set, all entries have to be deleted first, to avoid colliding when inserting
|
|
530
|
+
if constexpr (!Master_matrix::Option_list::has_intrusive_rows) { // set
|
|
531
|
+
for (Entry& entry : newSet) {
|
|
532
|
+
RA_opt::insert_entry(entry.get_row_index(), &entry);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
} else {
|
|
536
|
+
for (auto it = column_.begin(); it != column_.end();) {
|
|
537
|
+
Entry* newEntry = entryPool_->construct(valueMap.at(it->get_row_index()));
|
|
538
|
+
newEntry->set_element(it->get_element());
|
|
539
|
+
newSet.insert(newSet.end(), *newEntry);
|
|
540
|
+
_delete_entry(it); // increases it
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
column_.swap(newSet);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
template <class Master_matrix>
|
|
548
|
+
inline void Intrusive_set_column<Master_matrix>::clear()
|
|
549
|
+
{
|
|
550
|
+
static_assert(!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type,
|
|
551
|
+
"Method not available for chain columns as a base element should not be empty.");
|
|
552
|
+
|
|
553
|
+
column_.clear_and_dispose(Delete_disposer(this));
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
template <class Master_matrix>
|
|
557
|
+
inline void Intrusive_set_column<Master_matrix>::clear(ID_index rowIndex)
|
|
558
|
+
{
|
|
559
|
+
static_assert(!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type,
|
|
560
|
+
"Method not available for chain columns.");
|
|
561
|
+
|
|
562
|
+
auto it = column_.find(Entry(rowIndex));
|
|
563
|
+
if (it != column_.end()) {
|
|
564
|
+
_delete_entry(it);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
template <class Master_matrix>
|
|
569
|
+
inline typename Intrusive_set_column<Master_matrix>::ID_index Intrusive_set_column<Master_matrix>::get_pivot() const
|
|
570
|
+
{
|
|
571
|
+
static_assert(Master_matrix::isNonBasic,
|
|
572
|
+
"Method not available for base columns."); // could technically be, but is the notion useful then?
|
|
573
|
+
|
|
574
|
+
if constexpr (Master_matrix::Option_list::is_of_boundary_type) {
|
|
575
|
+
if (column_.empty()) return Master_matrix::template get_null_value<ID_index>();
|
|
576
|
+
return column_.rbegin()->get_row_index();
|
|
577
|
+
} else {
|
|
578
|
+
return Chain_opt::_get_pivot();
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
template <class Master_matrix>
|
|
583
|
+
inline typename Intrusive_set_column<Master_matrix>::Field_element
|
|
584
|
+
Intrusive_set_column<Master_matrix>::get_pivot_value() const
|
|
585
|
+
{
|
|
586
|
+
static_assert(Master_matrix::isNonBasic,
|
|
587
|
+
"Method not available for base columns."); // could technically be, but is the notion useful then?
|
|
588
|
+
|
|
589
|
+
if constexpr (Master_matrix::Option_list::is_z2) {
|
|
590
|
+
return 1;
|
|
591
|
+
} else {
|
|
592
|
+
if constexpr (Master_matrix::Option_list::is_of_boundary_type) {
|
|
593
|
+
if (column_.empty()) return 0;
|
|
594
|
+
return column_.rbegin()->get_element();
|
|
595
|
+
} else {
|
|
596
|
+
if (Chain_opt::_get_pivot() == Master_matrix::template get_null_value<ID_index>()) return 0;
|
|
597
|
+
auto it = column_.find(Entry(Chain_opt::_get_pivot()));
|
|
598
|
+
GUDHI_CHECK(it != column_.end(),
|
|
599
|
+
"Intrusive_set_column::get_pivot_value - Pivot not found only if the column was misused.");
|
|
600
|
+
return it->get_element();
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
template <class Master_matrix>
|
|
606
|
+
inline typename Intrusive_set_column<Master_matrix>::iterator Intrusive_set_column<Master_matrix>::begin() noexcept
|
|
607
|
+
{
|
|
608
|
+
return column_.begin();
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
template <class Master_matrix>
|
|
612
|
+
inline typename Intrusive_set_column<Master_matrix>::const_iterator Intrusive_set_column<Master_matrix>::begin()
|
|
613
|
+
const noexcept
|
|
614
|
+
{
|
|
615
|
+
return column_.begin();
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
template <class Master_matrix>
|
|
619
|
+
inline typename Intrusive_set_column<Master_matrix>::iterator Intrusive_set_column<Master_matrix>::end() noexcept
|
|
620
|
+
{
|
|
621
|
+
return column_.end();
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
template <class Master_matrix>
|
|
625
|
+
inline typename Intrusive_set_column<Master_matrix>::const_iterator Intrusive_set_column<Master_matrix>::end()
|
|
626
|
+
const noexcept
|
|
627
|
+
{
|
|
628
|
+
return column_.end();
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
template <class Master_matrix>
|
|
632
|
+
inline typename Intrusive_set_column<Master_matrix>::reverse_iterator
|
|
633
|
+
Intrusive_set_column<Master_matrix>::rbegin() noexcept
|
|
634
|
+
{
|
|
635
|
+
return column_.rbegin();
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
template <class Master_matrix>
|
|
639
|
+
inline typename Intrusive_set_column<Master_matrix>::const_reverse_iterator
|
|
640
|
+
Intrusive_set_column<Master_matrix>::rbegin() const noexcept
|
|
641
|
+
{
|
|
642
|
+
return column_.rbegin();
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
template <class Master_matrix>
|
|
646
|
+
inline typename Intrusive_set_column<Master_matrix>::reverse_iterator
|
|
647
|
+
Intrusive_set_column<Master_matrix>::rend() noexcept
|
|
648
|
+
{
|
|
649
|
+
return column_.rend();
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
template <class Master_matrix>
|
|
653
|
+
inline typename Intrusive_set_column<Master_matrix>::const_reverse_iterator Intrusive_set_column<Master_matrix>::rend()
|
|
654
|
+
const noexcept
|
|
655
|
+
{
|
|
656
|
+
return column_.rend();
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
template <class Master_matrix>
|
|
660
|
+
inline typename Intrusive_set_column<Master_matrix>::Content_range
|
|
661
|
+
Intrusive_set_column<Master_matrix>::get_non_zero_content_range() const
|
|
662
|
+
{
|
|
663
|
+
return column_;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
template <class Master_matrix>
|
|
667
|
+
template <class Entry_range>
|
|
668
|
+
inline Intrusive_set_column<Master_matrix>& Intrusive_set_column<Master_matrix>::operator+=(const Entry_range& column)
|
|
669
|
+
{
|
|
670
|
+
static_assert((!Master_matrix::isNonBasic || std::is_same_v<Entry_range, Intrusive_set_column>),
|
|
671
|
+
"For boundary columns, the range has to be a column of same type to help ensure the validity of the "
|
|
672
|
+
"base element."); // could be removed, if we give the responsibility to the user.
|
|
673
|
+
static_assert((!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type),
|
|
674
|
+
"For chain columns, the given column cannot be constant.");
|
|
675
|
+
|
|
676
|
+
_add(column);
|
|
677
|
+
|
|
678
|
+
return *this;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
template <class Master_matrix>
|
|
682
|
+
inline Intrusive_set_column<Master_matrix>& Intrusive_set_column<Master_matrix>::operator+=(
|
|
683
|
+
Intrusive_set_column& column)
|
|
684
|
+
{
|
|
685
|
+
if constexpr (Master_matrix::isNonBasic && !Master_matrix::Option_list::is_of_boundary_type) {
|
|
686
|
+
// assumes that the addition never zeros out this column.
|
|
687
|
+
if (_add(column)) {
|
|
688
|
+
Chain_opt::_swap_pivots(column);
|
|
689
|
+
Dim_opt::_swap_dimension(column);
|
|
690
|
+
}
|
|
691
|
+
} else {
|
|
692
|
+
_add(column);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
return *this;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
template <class Master_matrix>
|
|
699
|
+
inline Intrusive_set_column<Master_matrix>& Intrusive_set_column<Master_matrix>::operator*=(const Field_element& v)
|
|
700
|
+
{
|
|
701
|
+
Field_element val = Master_matrix::get_coefficient_value(v, operators_);
|
|
702
|
+
|
|
703
|
+
if (val == Field_operators::get_additive_identity()) {
|
|
704
|
+
if constexpr (Master_matrix::isNonBasic && !Master_matrix::Option_list::is_of_boundary_type) {
|
|
705
|
+
throw std::invalid_argument("A chain column should not be multiplied by 0.");
|
|
706
|
+
} else {
|
|
707
|
+
clear();
|
|
708
|
+
}
|
|
709
|
+
return *this;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
if (val == Field_operators::get_multiplicative_identity()) return *this;
|
|
713
|
+
|
|
714
|
+
// multiply_inplace needs a non-const reference to element, so even if Z2 never reaches here, it won't compile
|
|
715
|
+
// without the constexpr, as we are not storing a dummy value just for this purpose.
|
|
716
|
+
if constexpr (!Master_matrix::Option_list::is_z2) {
|
|
717
|
+
for (Entry& entry : column_) {
|
|
718
|
+
operators_->multiply_inplace(entry.get_element(), val);
|
|
719
|
+
if constexpr (Master_matrix::Option_list::has_row_access) RA_opt::update_entry(entry);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
return *this;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
template <class Master_matrix>
|
|
727
|
+
template <class Entry_range>
|
|
728
|
+
inline Intrusive_set_column<Master_matrix>& Intrusive_set_column<Master_matrix>::multiply_target_and_add(
|
|
729
|
+
const Field_element& val,
|
|
730
|
+
const Entry_range& column)
|
|
731
|
+
{
|
|
732
|
+
static_assert((!Master_matrix::isNonBasic || std::is_same_v<Entry_range, Intrusive_set_column>),
|
|
733
|
+
"For boundary columns, the range has to be a column of same type to help ensure the validity of the "
|
|
734
|
+
"base element."); // could be removed, if we give the responsibility to the user.
|
|
735
|
+
static_assert((!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type),
|
|
736
|
+
"For chain columns, the given column cannot be constant.");
|
|
737
|
+
|
|
738
|
+
_multiply_target_and_add(Master_matrix::get_coefficient_value(val, operators_), column);
|
|
739
|
+
|
|
740
|
+
return *this;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
template <class Master_matrix>
|
|
744
|
+
inline Intrusive_set_column<Master_matrix>& Intrusive_set_column<Master_matrix>::multiply_target_and_add(
|
|
745
|
+
const Field_element& val,
|
|
746
|
+
Intrusive_set_column& column)
|
|
747
|
+
{
|
|
748
|
+
if constexpr (Master_matrix::isNonBasic && !Master_matrix::Option_list::is_of_boundary_type) {
|
|
749
|
+
// assumes that the addition never zeros out this column.
|
|
750
|
+
if (_multiply_target_and_add(Master_matrix::get_coefficient_value(val, operators_), column)) {
|
|
751
|
+
Chain_opt::_swap_pivots(column);
|
|
752
|
+
Dim_opt::_swap_dimension(column);
|
|
753
|
+
}
|
|
754
|
+
} else {
|
|
755
|
+
_multiply_target_and_add(Master_matrix::get_coefficient_value(val, operators_), column);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
return *this;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
template <class Master_matrix>
|
|
762
|
+
template <class Entry_range>
|
|
763
|
+
inline Intrusive_set_column<Master_matrix>& Intrusive_set_column<Master_matrix>::multiply_source_and_add(
|
|
764
|
+
const Entry_range& column,
|
|
765
|
+
const Field_element& val)
|
|
766
|
+
{
|
|
767
|
+
static_assert((!Master_matrix::isNonBasic || std::is_same_v<Entry_range, Intrusive_set_column>),
|
|
768
|
+
"For boundary columns, the range has to be a column of same type to help ensure the validity of the "
|
|
769
|
+
"base element."); // could be removed, if we give the responsibility to the user.
|
|
770
|
+
static_assert((!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type),
|
|
771
|
+
"For chain columns, the given column cannot be constant.");
|
|
772
|
+
|
|
773
|
+
_multiply_source_and_add(column, Master_matrix::get_coefficient_value(val, operators_));
|
|
774
|
+
|
|
775
|
+
return *this;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
template <class Master_matrix>
|
|
779
|
+
inline Intrusive_set_column<Master_matrix>& Intrusive_set_column<Master_matrix>::multiply_source_and_add(
|
|
780
|
+
Intrusive_set_column& column,
|
|
781
|
+
const Field_element& val)
|
|
782
|
+
{
|
|
783
|
+
if constexpr (Master_matrix::isNonBasic && !Master_matrix::Option_list::is_of_boundary_type) {
|
|
784
|
+
// assumes that the addition never zeros out this column.
|
|
785
|
+
if (_multiply_source_and_add(column, Master_matrix::get_coefficient_value(val, operators_))) {
|
|
786
|
+
Chain_opt::_swap_pivots(column);
|
|
787
|
+
Dim_opt::_swap_dimension(column);
|
|
788
|
+
}
|
|
789
|
+
} else {
|
|
790
|
+
_multiply_source_and_add(column, Master_matrix::get_coefficient_value(val, operators_));
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
return *this;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
template <class Master_matrix>
|
|
797
|
+
inline void Intrusive_set_column<Master_matrix>::push_back(const Entry& entry)
|
|
798
|
+
{
|
|
799
|
+
static_assert(Master_matrix::Option_list::is_of_boundary_type, "`push_back` is not available for Chain matrices.");
|
|
800
|
+
|
|
801
|
+
GUDHI_CHECK(entry.get_row_index() > get_pivot(), "The new row index has to be higher than the current pivot.");
|
|
802
|
+
|
|
803
|
+
_insert_entry(column_.end(), entry.get_row_index(), entry.get_element());
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
template <class Master_matrix>
|
|
807
|
+
inline Intrusive_set_column<Master_matrix>& Intrusive_set_column<Master_matrix>::operator=(
|
|
808
|
+
const Intrusive_set_column& other)
|
|
809
|
+
{
|
|
810
|
+
static_assert(!Master_matrix::Option_list::has_row_access, "= assignment not enabled with row access option.");
|
|
811
|
+
|
|
812
|
+
// otherwise the column will be destroyed before copying itself...
|
|
813
|
+
if (this == &other) return *this;
|
|
814
|
+
|
|
815
|
+
Dim_opt::operator=(other);
|
|
816
|
+
Chain_opt::operator=(other);
|
|
817
|
+
|
|
818
|
+
// order is important
|
|
819
|
+
column_.clear_and_dispose(Delete_disposer(this));
|
|
820
|
+
operators_ = other.operators_;
|
|
821
|
+
entryPool_ = other.entryPool_;
|
|
822
|
+
column_.clone_from(other.column_, New_cloner(entryPool_), Delete_disposer(this));
|
|
823
|
+
|
|
824
|
+
return *this;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
template <class Master_matrix>
|
|
828
|
+
inline Intrusive_set_column<Master_matrix>& Intrusive_set_column<Master_matrix>::operator=(
|
|
829
|
+
Intrusive_set_column&& other) noexcept
|
|
830
|
+
{
|
|
831
|
+
static_assert(!Master_matrix::Option_list::has_row_access, "= assignment not enabled with row access option.");
|
|
832
|
+
|
|
833
|
+
// to avoid destroying the column before building from it-self...
|
|
834
|
+
if (&column_ == &(other.column_)) return *this;
|
|
835
|
+
|
|
836
|
+
Dim_opt::operator=(std::move(other));
|
|
837
|
+
Chain_opt::operator=(std::move(other));
|
|
838
|
+
|
|
839
|
+
column_.clear_and_dispose(Delete_disposer(this));
|
|
840
|
+
|
|
841
|
+
operators_ = std::exchange(other.operators_, nullptr);
|
|
842
|
+
entryPool_ = std::exchange(other.entryPool_, nullptr);
|
|
843
|
+
column_ = std::move(other.column_);
|
|
844
|
+
|
|
845
|
+
return *this;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
template <class Master_matrix>
|
|
849
|
+
inline void Intrusive_set_column<Master_matrix>::_delete_entry(iterator& it)
|
|
850
|
+
{
|
|
851
|
+
it = column_.erase_and_dispose(it, Delete_disposer(this));
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
template <class Master_matrix>
|
|
855
|
+
inline typename Intrusive_set_column<Master_matrix>::Entry* Intrusive_set_column<Master_matrix>::_insert_entry(
|
|
856
|
+
const iterator& position,
|
|
857
|
+
ID_index rowIndex,
|
|
858
|
+
const Field_element& value)
|
|
859
|
+
{
|
|
860
|
+
Entry* newEntry;
|
|
861
|
+
if constexpr (Master_matrix::Option_list::has_row_access) {
|
|
862
|
+
newEntry = entryPool_->construct(RA_opt::get_column_index(), rowIndex);
|
|
863
|
+
} else {
|
|
864
|
+
newEntry = entryPool_->construct(rowIndex);
|
|
865
|
+
}
|
|
866
|
+
newEntry->set_element(value);
|
|
867
|
+
column_.insert(position, *newEntry);
|
|
868
|
+
if constexpr (Master_matrix::Option_list::has_row_access) RA_opt::insert_entry(rowIndex, newEntry);
|
|
869
|
+
return newEntry;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
template <class Master_matrix>
|
|
873
|
+
template <class Entry_range>
|
|
874
|
+
inline bool Intrusive_set_column<Master_matrix>::_add(const Entry_range& column)
|
|
875
|
+
{
|
|
876
|
+
return _add_to_column(column, *this);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
template <class Master_matrix>
|
|
880
|
+
template <class Entry_range>
|
|
881
|
+
inline bool Intrusive_set_column<Master_matrix>::_multiply_target_and_add(const Field_element& val,
|
|
882
|
+
const Entry_range& column)
|
|
883
|
+
{
|
|
884
|
+
return _multiply_target_and_add_to_column(val, column, *this);
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
template <class Master_matrix>
|
|
888
|
+
template <class Entry_range>
|
|
889
|
+
inline bool Intrusive_set_column<Master_matrix>::_multiply_source_and_add(const Entry_range& column,
|
|
890
|
+
const Field_element& val)
|
|
891
|
+
{
|
|
892
|
+
return _multiply_source_and_add_to_column(val, column, *this);
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
} // namespace persistence_matrix
|
|
896
|
+
} // namespace Gudhi
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* @ingroup persistence_matrix
|
|
900
|
+
*
|
|
901
|
+
* @brief Hash method for @ref Gudhi::persistence_matrix::Intrusive_set_column.
|
|
902
|
+
*
|
|
903
|
+
* @tparam Master_matrix Template parameter of @ref Gudhi::persistence_matrix::Intrusive_set_column.
|
|
904
|
+
* @tparam Entry_constructor Template parameter of @ref Gudhi::persistence_matrix::Intrusive_set_column.
|
|
905
|
+
*/
|
|
906
|
+
template <class Master_matrix>
|
|
907
|
+
struct std::hash<Gudhi::persistence_matrix::Intrusive_set_column<Master_matrix> > {
|
|
908
|
+
std::size_t operator()(const Gudhi::persistence_matrix::Intrusive_set_column<Master_matrix>& column) const
|
|
909
|
+
{
|
|
910
|
+
return Gudhi::persistence_matrix::hash_column(column);
|
|
911
|
+
}
|
|
912
|
+
};
|
|
913
|
+
|
|
914
|
+
#endif // PM_INTRUSIVE_SET_COLUMN_H
|