multipers 2.3.3b6__cp313-cp313-macosx_10_13_x86_64.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-313-darwin.so +0 -0
- multipers/function_rips.pyx +105 -0
- multipers/grids.cpython-313-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-313-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-313-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-313-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-313-darwin.so +0 -0
- multipers/point_measure.pyx +395 -0
- multipers/simplex_tree_multi.cpython-313-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-313-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
multipers/gudhi/scc_io.h
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
#ifndef MULTIPERS_SCC_IO_H
|
|
2
|
+
#define MULTIPERS_SCC_IO_H
|
|
3
|
+
|
|
4
|
+
#include <algorithm>
|
|
5
|
+
#include <cassert>
|
|
6
|
+
#include <cstddef>
|
|
7
|
+
#include <ostream>
|
|
8
|
+
#include <fstream>
|
|
9
|
+
#include <iostream>
|
|
10
|
+
#include <stdexcept>
|
|
11
|
+
#include <string>
|
|
12
|
+
#include <vector>
|
|
13
|
+
#include <limits>
|
|
14
|
+
#include <iomanip>
|
|
15
|
+
#include <cmath>
|
|
16
|
+
|
|
17
|
+
template <class Slicer>
|
|
18
|
+
inline Slicer read_scc_file(const std::string& inFilePath,
|
|
19
|
+
bool isRivetCompatible = false,
|
|
20
|
+
bool isReversed = false,
|
|
21
|
+
int shiftDimensions = 0) {
|
|
22
|
+
using Filtration_value = typename Slicer::Filtration_value;
|
|
23
|
+
|
|
24
|
+
std::string line;
|
|
25
|
+
std::ifstream file(inFilePath);
|
|
26
|
+
Slicer slicer;
|
|
27
|
+
unsigned int numberOfParameters;
|
|
28
|
+
|
|
29
|
+
if (file.is_open()) {
|
|
30
|
+
auto error = [&file](std::string msg) {
|
|
31
|
+
file.close();
|
|
32
|
+
throw std::invalid_argument(msg);
|
|
33
|
+
};
|
|
34
|
+
auto is_comment_or_empty_line = [](const std::string& line) -> bool {
|
|
35
|
+
size_t current = line.find_first_not_of(' ', 0);
|
|
36
|
+
if (current == std::string::npos) return true; // is empty line
|
|
37
|
+
if (line[current] == '#') return true; // is comment
|
|
38
|
+
return false;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
while (getline(file, line, '\n') && is_comment_or_empty_line(line));
|
|
42
|
+
if (!file) error("Empty file!");
|
|
43
|
+
|
|
44
|
+
if (isRivetCompatible && line.compare("firep") != 0) error("Wrong file format. Should start with 'firep'.");
|
|
45
|
+
if (!isRivetCompatible && line.compare("scc2020") != 0) error("Wrong file format. Should start with 'scc2020'.");
|
|
46
|
+
|
|
47
|
+
while (getline(file, line, '\n') && is_comment_or_empty_line(line));
|
|
48
|
+
if (!file) error("Premature ending of the file. Stops before numbers of parameters.");
|
|
49
|
+
|
|
50
|
+
if (isRivetCompatible) {
|
|
51
|
+
numberOfParameters = 2;
|
|
52
|
+
getline(file, line, '\n'); // second rivet label
|
|
53
|
+
} else {
|
|
54
|
+
std::size_t current = line.find_first_not_of(' ', 0);
|
|
55
|
+
std::size_t next = line.find_first_of(' ', current);
|
|
56
|
+
numberOfParameters = std::stoi(line.substr(current, next - current));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
while (getline(file, line, '\n') && is_comment_or_empty_line(line));
|
|
60
|
+
if (!file) error("Premature ending of the file. Not a single cell was specified.");
|
|
61
|
+
|
|
62
|
+
std::vector<unsigned int> counts;
|
|
63
|
+
unsigned int numberOfCells = 0;
|
|
64
|
+
counts.reserve(line.size() + shiftDimensions);
|
|
65
|
+
std::size_t current = line.find_first_not_of(' ', 0);
|
|
66
|
+
if (shiftDimensions != 0 && isReversed && current != std::string::npos) {
|
|
67
|
+
if (shiftDimensions > 0) {
|
|
68
|
+
counts.resize(shiftDimensions, 0);
|
|
69
|
+
} else {
|
|
70
|
+
for (int i = shiftDimensions; i < 0 && current != std::string::npos; ++i) {
|
|
71
|
+
std::size_t next = line.find_first_of(' ', current);
|
|
72
|
+
current = line.find_first_not_of(' ', next);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
while (current != std::string::npos) {
|
|
77
|
+
std::size_t next = line.find_first_of(' ', current);
|
|
78
|
+
counts.push_back(std::stoi(line.substr(current, next - current)));
|
|
79
|
+
numberOfCells += counts.back();
|
|
80
|
+
current = line.find_first_not_of(' ', next);
|
|
81
|
+
}
|
|
82
|
+
if (shiftDimensions != 0 && !isReversed) {
|
|
83
|
+
counts.resize(counts.size() + shiftDimensions, 0);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
std::size_t dimIt = 0;
|
|
87
|
+
while (dimIt < counts.size() && counts[dimIt] == 0) ++dimIt;
|
|
88
|
+
|
|
89
|
+
if (dimIt == counts.size()) return slicer;
|
|
90
|
+
|
|
91
|
+
std::size_t shift = isReversed ? 0 : counts[dimIt];
|
|
92
|
+
unsigned int nextShift = isReversed ? 0 : counts.size() == 1 ? 0 : counts[dimIt + 1];
|
|
93
|
+
unsigned int tmpNextShift = counts[dimIt];
|
|
94
|
+
|
|
95
|
+
auto get_boundary = [&isReversed, &numberOfCells](const std::string& line,
|
|
96
|
+
std::size_t start,
|
|
97
|
+
std::size_t shift) -> std::vector<unsigned int> {
|
|
98
|
+
std::vector<unsigned int> res;
|
|
99
|
+
res.reserve(line.size() - start);
|
|
100
|
+
std::size_t current = line.find_first_not_of(' ', start);
|
|
101
|
+
while (current != std::string::npos) {
|
|
102
|
+
std::size_t next = line.find_first_of(' ', current);
|
|
103
|
+
unsigned int idx = std::stoi(line.substr(current, next - current)) + shift;
|
|
104
|
+
res.push_back(isReversed ? idx : numberOfCells - 1 - idx);
|
|
105
|
+
current = line.find_first_not_of(' ', next);
|
|
106
|
+
}
|
|
107
|
+
std::sort(res.begin(), res.end());
|
|
108
|
+
return res;
|
|
109
|
+
};
|
|
110
|
+
auto get_filtration_value = [](const std::string& line, std::size_t end) -> Filtration_value {
|
|
111
|
+
Filtration_value res(0);
|
|
112
|
+
res.reserve(end);
|
|
113
|
+
bool isPlusInf = true;
|
|
114
|
+
bool isMinusInf = true;
|
|
115
|
+
std::size_t current = line.find_first_not_of(' ', 0);
|
|
116
|
+
while (current < end) {
|
|
117
|
+
std::size_t next = line.find_first_of(' ', current);
|
|
118
|
+
res.push_back(std::stod(line.substr(current, next - current)));
|
|
119
|
+
if (isPlusInf && res.back() != Filtration_value::T_inf) isPlusInf = false;
|
|
120
|
+
if (isMinusInf && res.back() != -Filtration_value::T_inf) isMinusInf = false;
|
|
121
|
+
current = line.find_first_not_of(' ', next);
|
|
122
|
+
}
|
|
123
|
+
if (isPlusInf) res = Filtration_value::inf();
|
|
124
|
+
if (isMinusInf) res = Filtration_value::minus_inf();
|
|
125
|
+
return res;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
std::vector<std::vector<unsigned int> > generator_maps(numberOfCells);
|
|
129
|
+
std::vector<int> generator_dimensions(numberOfCells);
|
|
130
|
+
std::vector<typename Slicer::Filtration_value> generator_filtrations(numberOfCells);
|
|
131
|
+
std::size_t i = 0;
|
|
132
|
+
// because of possible negative dimension shifts, the document should not always be read to the end
|
|
133
|
+
// therefore `dimIt < counts.size()` is also a stop condition
|
|
134
|
+
while (getline(file, line, '\n') && dimIt < counts.size()) {
|
|
135
|
+
if (!is_comment_or_empty_line(line)) {
|
|
136
|
+
std::size_t sep = line.find_first_of(';', 0);
|
|
137
|
+
generator_filtrations[i] = get_filtration_value(line, sep);
|
|
138
|
+
if (generator_filtrations[i].is_finite() && generator_filtrations[i].num_parameters() != numberOfParameters)
|
|
139
|
+
error("Wrong format. The number of parameters does not match.");
|
|
140
|
+
generator_maps[i] = get_boundary(line, sep + 1, shift);
|
|
141
|
+
generator_dimensions[i] = isReversed ? dimIt : counts.size() - 1 - dimIt;
|
|
142
|
+
|
|
143
|
+
--counts[dimIt];
|
|
144
|
+
while (dimIt < counts.size() && counts[dimIt] == 0) {
|
|
145
|
+
++dimIt;
|
|
146
|
+
if (dimIt != counts.size()) {
|
|
147
|
+
shift += nextShift;
|
|
148
|
+
nextShift = isReversed ? tmpNextShift : dimIt < counts.size() - 1 ? counts[dimIt + 1] : 0;
|
|
149
|
+
tmpNextShift = counts[dimIt];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
++i;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (!isReversed) { // to order by dimension
|
|
157
|
+
std::reverse(generator_dimensions.begin(), generator_dimensions.end());
|
|
158
|
+
std::reverse(generator_maps.begin(), generator_maps.end());
|
|
159
|
+
std::reverse(generator_filtrations.begin(), generator_filtrations.end());
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
slicer = Slicer(generator_maps, generator_dimensions, generator_filtrations);
|
|
163
|
+
|
|
164
|
+
file.close();
|
|
165
|
+
} else {
|
|
166
|
+
std::cerr << "Unable to open input file: " << inFilePath << std::endl;
|
|
167
|
+
file.setstate(std::ios::failbit);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return slicer;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
template <class Slicer>
|
|
174
|
+
inline void write_scc_file(const std::string& outFilePath,
|
|
175
|
+
const Slicer& slicer,
|
|
176
|
+
int numberOfParameters = -1,
|
|
177
|
+
int degree = -1,
|
|
178
|
+
bool rivetCompatible = false,
|
|
179
|
+
bool IgnoreLastGenerators = false,
|
|
180
|
+
bool stripComments = false,
|
|
181
|
+
bool reverse = false) {
|
|
182
|
+
constexpr bool verbose = false;
|
|
183
|
+
if (numberOfParameters < 0) {
|
|
184
|
+
numberOfParameters = slicer.num_parameters();
|
|
185
|
+
}
|
|
186
|
+
assert(numberOfParameters > 0 && "Invalid number of parameters!");
|
|
187
|
+
|
|
188
|
+
std::ofstream file(outFilePath);
|
|
189
|
+
|
|
190
|
+
if (rivetCompatible)
|
|
191
|
+
file << "firep\n";
|
|
192
|
+
else
|
|
193
|
+
file << "scc2020\n";
|
|
194
|
+
|
|
195
|
+
if (!stripComments && !rivetCompatible)
|
|
196
|
+
file << "# This file was generated by multipers (https://github.com/DavidLapous/multipers).\n";
|
|
197
|
+
|
|
198
|
+
if (!stripComments && !rivetCompatible) file << "# Number of parameters\n";
|
|
199
|
+
|
|
200
|
+
if (rivetCompatible) {
|
|
201
|
+
assert(numberOfParameters == 2 && "Rivet only handles bifiltrations.");
|
|
202
|
+
file << "Filtration 1\n";
|
|
203
|
+
file << "Filtration 2\n";
|
|
204
|
+
} else {
|
|
205
|
+
file << std::to_string(numberOfParameters) << "\n";
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (!stripComments) file << "# Sizes of generating sets\n";
|
|
209
|
+
|
|
210
|
+
using Filtration_value = typename Slicer::Filtration_value;
|
|
211
|
+
|
|
212
|
+
const auto& boundaries = slicer.get_structure();
|
|
213
|
+
int maxDim = boundaries.max_dimension();
|
|
214
|
+
int minDim = maxDim;
|
|
215
|
+
|
|
216
|
+
std::vector<std::vector<std::size_t> > indicesByDim(maxDim + 1);
|
|
217
|
+
std::vector<std::size_t> shiftedIndices(boundaries.size());
|
|
218
|
+
for (std::size_t i = 0; i < boundaries.size(); ++i) {
|
|
219
|
+
auto dim = boundaries.dimension(i);
|
|
220
|
+
minDim = dim < minDim ? dim : minDim;
|
|
221
|
+
auto& atDim = indicesByDim[reverse ? dim : maxDim - dim];
|
|
222
|
+
shiftedIndices[i] = atDim.size();
|
|
223
|
+
atDim.push_back(i);
|
|
224
|
+
}
|
|
225
|
+
if (degree < 0) degree = minDim;
|
|
226
|
+
int minIndex = reverse ? degree - 1 : 0;
|
|
227
|
+
int maxIndex = reverse ? maxDim : maxDim - degree + 1;
|
|
228
|
+
if (maxIndex < -1) maxIndex = -1;
|
|
229
|
+
if (IgnoreLastGenerators) maxIndex--;
|
|
230
|
+
if (rivetCompatible)
|
|
231
|
+
minIndex = maxIndex -2;
|
|
232
|
+
|
|
233
|
+
if constexpr (verbose) {
|
|
234
|
+
std::cout << "minDim = " << minDim << " maxDim = " << maxDim << " minIndex = " << minIndex
|
|
235
|
+
<< " maxIndex = " << maxIndex << " degree = " << degree << std::endl;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
auto print_fil_values = [&](const Filtration_value& fil) {
|
|
239
|
+
if (fil.is_finite()) {
|
|
240
|
+
if constexpr (Filtration_value::is_multicritical()) {
|
|
241
|
+
for (const auto& ifil : fil) {
|
|
242
|
+
for (auto f : ifil) file << f << " ";
|
|
243
|
+
}
|
|
244
|
+
} else {
|
|
245
|
+
assert(fil.size() == static_cast<unsigned int>(numberOfParameters));
|
|
246
|
+
for (auto f : fil) file << f << " ";
|
|
247
|
+
}
|
|
248
|
+
} else {
|
|
249
|
+
// assert(fil.size() == 1);
|
|
250
|
+
for (int p = 0; p < numberOfParameters; ++p) file << fil[0] << " ";
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
if (minIndex < 0) file << 0 << " ";
|
|
255
|
+
for (int i = 0; i < minIndex; ++i) file << 0 << " ";
|
|
256
|
+
for (int i = std::max(minIndex, 0); i <= std::min(maxDim, maxIndex); ++i) {
|
|
257
|
+
file << indicesByDim[i].size() << " ";
|
|
258
|
+
}
|
|
259
|
+
if (!rivetCompatible)
|
|
260
|
+
for (int i = maxIndex + 1; i <= maxDim; ++i) file << 0 << " ";
|
|
261
|
+
if (maxIndex > maxDim) file << 0;
|
|
262
|
+
file << "\n";
|
|
263
|
+
|
|
264
|
+
file << std::setprecision(std::numeric_limits<typename Filtration_value::value_type>::digits);
|
|
265
|
+
|
|
266
|
+
std::size_t startIndex = reverse ? minIndex + 1 : minIndex;
|
|
267
|
+
std::size_t endIndex = reverse ? maxIndex : maxIndex - 1;
|
|
268
|
+
const auto& filtValues = slicer.get_filtrations();
|
|
269
|
+
int currDim;
|
|
270
|
+
if (reverse)
|
|
271
|
+
currDim = minIndex == -1 ? 0 : minIndex;
|
|
272
|
+
else
|
|
273
|
+
currDim = maxIndex == maxDim + 1 ? maxDim + 1 : maxDim;
|
|
274
|
+
|
|
275
|
+
if (reverse) {
|
|
276
|
+
if (!stripComments) file << "# Block of dimension " << currDim++ << "\n";
|
|
277
|
+
if (minIndex >= 0) {
|
|
278
|
+
for (auto index : indicesByDim[minIndex]) {
|
|
279
|
+
print_fil_values(filtValues[index]);
|
|
280
|
+
file << ";\n";
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
for (std::size_t i = startIndex; i <= endIndex; ++i) {
|
|
285
|
+
if (!stripComments) {
|
|
286
|
+
file << "# Block of dimension " << currDim << "\n";
|
|
287
|
+
if (reverse)
|
|
288
|
+
++currDim;
|
|
289
|
+
else
|
|
290
|
+
--currDim;
|
|
291
|
+
}
|
|
292
|
+
for (auto index : indicesByDim[i]) {
|
|
293
|
+
print_fil_values(filtValues[index]);
|
|
294
|
+
file << "; ";
|
|
295
|
+
for (auto b : boundaries[index]) file << shiftedIndices[b] << " ";
|
|
296
|
+
file << "\n";
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (!reverse) {
|
|
300
|
+
if (!stripComments) file << "# Block of dimension " << currDim << "\n";
|
|
301
|
+
if (maxIndex <= maxDim) {
|
|
302
|
+
for (auto index : indicesByDim[maxIndex]) {
|
|
303
|
+
print_fil_values(filtValues[index]);
|
|
304
|
+
file << ";\n";
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
#endif // MULTIPERS_SCC_IO_H
|