multipers 2.3.3b6__cp310-cp310-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.

Files changed (183) hide show
  1. multipers/.dylibs/libc++.1.0.dylib +0 -0
  2. multipers/.dylibs/libtbb.12.16.dylib +0 -0
  3. multipers/__init__.py +33 -0
  4. multipers/_signed_measure_meta.py +453 -0
  5. multipers/_slicer_meta.py +211 -0
  6. multipers/array_api/__init__.py +45 -0
  7. multipers/array_api/numpy.py +41 -0
  8. multipers/array_api/torch.py +58 -0
  9. multipers/data/MOL2.py +458 -0
  10. multipers/data/UCR.py +18 -0
  11. multipers/data/__init__.py +1 -0
  12. multipers/data/graphs.py +466 -0
  13. multipers/data/immuno_regions.py +27 -0
  14. multipers/data/minimal_presentation_to_st_bf.py +0 -0
  15. multipers/data/pytorch2simplextree.py +91 -0
  16. multipers/data/shape3d.py +101 -0
  17. multipers/data/synthetic.py +113 -0
  18. multipers/distances.py +202 -0
  19. multipers/filtration_conversions.pxd +229 -0
  20. multipers/filtration_conversions.pxd.tp +84 -0
  21. multipers/filtrations/__init__.py +18 -0
  22. multipers/filtrations/density.py +574 -0
  23. multipers/filtrations/filtrations.py +361 -0
  24. multipers/filtrations.pxd +224 -0
  25. multipers/function_rips.cpython-310-darwin.so +0 -0
  26. multipers/function_rips.pyx +105 -0
  27. multipers/grids.cpython-310-darwin.so +0 -0
  28. multipers/grids.pyx +433 -0
  29. multipers/gudhi/Persistence_slices_interface.h +132 -0
  30. multipers/gudhi/Simplex_tree_interface.h +239 -0
  31. multipers/gudhi/Simplex_tree_multi_interface.h +551 -0
  32. multipers/gudhi/cubical_to_boundary.h +59 -0
  33. multipers/gudhi/gudhi/Bitmap_cubical_complex.h +450 -0
  34. multipers/gudhi/gudhi/Bitmap_cubical_complex_base.h +1070 -0
  35. multipers/gudhi/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h +579 -0
  36. multipers/gudhi/gudhi/Debug_utils.h +45 -0
  37. multipers/gudhi/gudhi/Fields/Multi_field.h +484 -0
  38. multipers/gudhi/gudhi/Fields/Multi_field_operators.h +455 -0
  39. multipers/gudhi/gudhi/Fields/Multi_field_shared.h +450 -0
  40. multipers/gudhi/gudhi/Fields/Multi_field_small.h +531 -0
  41. multipers/gudhi/gudhi/Fields/Multi_field_small_operators.h +507 -0
  42. multipers/gudhi/gudhi/Fields/Multi_field_small_shared.h +531 -0
  43. multipers/gudhi/gudhi/Fields/Z2_field.h +355 -0
  44. multipers/gudhi/gudhi/Fields/Z2_field_operators.h +376 -0
  45. multipers/gudhi/gudhi/Fields/Zp_field.h +420 -0
  46. multipers/gudhi/gudhi/Fields/Zp_field_operators.h +400 -0
  47. multipers/gudhi/gudhi/Fields/Zp_field_shared.h +418 -0
  48. multipers/gudhi/gudhi/Flag_complex_edge_collapser.h +337 -0
  49. multipers/gudhi/gudhi/Matrix.h +2107 -0
  50. multipers/gudhi/gudhi/Multi_critical_filtration.h +1038 -0
  51. multipers/gudhi/gudhi/Multi_persistence/Box.h +174 -0
  52. multipers/gudhi/gudhi/Multi_persistence/Line.h +282 -0
  53. multipers/gudhi/gudhi/Off_reader.h +173 -0
  54. multipers/gudhi/gudhi/One_critical_filtration.h +1441 -0
  55. multipers/gudhi/gudhi/Persistence_matrix/Base_matrix.h +769 -0
  56. multipers/gudhi/gudhi/Persistence_matrix/Base_matrix_with_column_compression.h +686 -0
  57. multipers/gudhi/gudhi/Persistence_matrix/Boundary_matrix.h +842 -0
  58. multipers/gudhi/gudhi/Persistence_matrix/Chain_matrix.h +1350 -0
  59. multipers/gudhi/gudhi/Persistence_matrix/Id_to_index_overlay.h +1105 -0
  60. multipers/gudhi/gudhi/Persistence_matrix/Position_to_index_overlay.h +859 -0
  61. multipers/gudhi/gudhi/Persistence_matrix/RU_matrix.h +910 -0
  62. multipers/gudhi/gudhi/Persistence_matrix/allocators/entry_constructors.h +139 -0
  63. multipers/gudhi/gudhi/Persistence_matrix/base_pairing.h +230 -0
  64. multipers/gudhi/gudhi/Persistence_matrix/base_swap.h +211 -0
  65. multipers/gudhi/gudhi/Persistence_matrix/boundary_cell_position_to_id_mapper.h +60 -0
  66. multipers/gudhi/gudhi/Persistence_matrix/boundary_face_position_to_id_mapper.h +60 -0
  67. multipers/gudhi/gudhi/Persistence_matrix/chain_pairing.h +136 -0
  68. multipers/gudhi/gudhi/Persistence_matrix/chain_rep_cycles.h +190 -0
  69. multipers/gudhi/gudhi/Persistence_matrix/chain_vine_swap.h +616 -0
  70. multipers/gudhi/gudhi/Persistence_matrix/columns/chain_column_extra_properties.h +150 -0
  71. multipers/gudhi/gudhi/Persistence_matrix/columns/column_dimension_holder.h +106 -0
  72. multipers/gudhi/gudhi/Persistence_matrix/columns/column_utilities.h +219 -0
  73. multipers/gudhi/gudhi/Persistence_matrix/columns/entry_types.h +327 -0
  74. multipers/gudhi/gudhi/Persistence_matrix/columns/heap_column.h +1140 -0
  75. multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_list_column.h +934 -0
  76. multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_set_column.h +934 -0
  77. multipers/gudhi/gudhi/Persistence_matrix/columns/list_column.h +980 -0
  78. multipers/gudhi/gudhi/Persistence_matrix/columns/naive_vector_column.h +1092 -0
  79. multipers/gudhi/gudhi/Persistence_matrix/columns/row_access.h +192 -0
  80. multipers/gudhi/gudhi/Persistence_matrix/columns/set_column.h +921 -0
  81. multipers/gudhi/gudhi/Persistence_matrix/columns/small_vector_column.h +1093 -0
  82. multipers/gudhi/gudhi/Persistence_matrix/columns/unordered_set_column.h +1012 -0
  83. multipers/gudhi/gudhi/Persistence_matrix/columns/vector_column.h +1244 -0
  84. multipers/gudhi/gudhi/Persistence_matrix/matrix_dimension_holders.h +186 -0
  85. multipers/gudhi/gudhi/Persistence_matrix/matrix_row_access.h +164 -0
  86. multipers/gudhi/gudhi/Persistence_matrix/ru_pairing.h +156 -0
  87. multipers/gudhi/gudhi/Persistence_matrix/ru_rep_cycles.h +376 -0
  88. multipers/gudhi/gudhi/Persistence_matrix/ru_vine_swap.h +540 -0
  89. multipers/gudhi/gudhi/Persistent_cohomology/Field_Zp.h +118 -0
  90. multipers/gudhi/gudhi/Persistent_cohomology/Multi_field.h +173 -0
  91. multipers/gudhi/gudhi/Persistent_cohomology/Persistent_cohomology_column.h +128 -0
  92. multipers/gudhi/gudhi/Persistent_cohomology.h +745 -0
  93. multipers/gudhi/gudhi/Points_off_io.h +171 -0
  94. multipers/gudhi/gudhi/Simple_object_pool.h +69 -0
  95. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_iterators.h +463 -0
  96. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +83 -0
  97. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_siblings.h +106 -0
  98. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_star_simplex_iterators.h +277 -0
  99. multipers/gudhi/gudhi/Simplex_tree/hooks_simplex_base.h +62 -0
  100. multipers/gudhi/gudhi/Simplex_tree/indexing_tag.h +27 -0
  101. multipers/gudhi/gudhi/Simplex_tree/serialization_utils.h +62 -0
  102. multipers/gudhi/gudhi/Simplex_tree/simplex_tree_options.h +157 -0
  103. multipers/gudhi/gudhi/Simplex_tree.h +2794 -0
  104. multipers/gudhi/gudhi/Simplex_tree_multi.h +152 -0
  105. multipers/gudhi/gudhi/distance_functions.h +62 -0
  106. multipers/gudhi/gudhi/graph_simplicial_complex.h +104 -0
  107. multipers/gudhi/gudhi/persistence_interval.h +253 -0
  108. multipers/gudhi/gudhi/persistence_matrix_options.h +170 -0
  109. multipers/gudhi/gudhi/reader_utils.h +367 -0
  110. multipers/gudhi/mma_interface_coh.h +256 -0
  111. multipers/gudhi/mma_interface_h0.h +223 -0
  112. multipers/gudhi/mma_interface_matrix.h +293 -0
  113. multipers/gudhi/naive_merge_tree.h +536 -0
  114. multipers/gudhi/scc_io.h +310 -0
  115. multipers/gudhi/truc.h +1403 -0
  116. multipers/io.cpython-310-darwin.so +0 -0
  117. multipers/io.pyx +644 -0
  118. multipers/ml/__init__.py +0 -0
  119. multipers/ml/accuracies.py +90 -0
  120. multipers/ml/invariants_with_persistable.py +79 -0
  121. multipers/ml/kernels.py +176 -0
  122. multipers/ml/mma.py +713 -0
  123. multipers/ml/one.py +472 -0
  124. multipers/ml/point_clouds.py +352 -0
  125. multipers/ml/signed_measures.py +1589 -0
  126. multipers/ml/sliced_wasserstein.py +461 -0
  127. multipers/ml/tools.py +113 -0
  128. multipers/mma_structures.cpython-310-darwin.so +0 -0
  129. multipers/mma_structures.pxd +128 -0
  130. multipers/mma_structures.pyx +2786 -0
  131. multipers/mma_structures.pyx.tp +1094 -0
  132. multipers/multi_parameter_rank_invariant/diff_helpers.h +84 -0
  133. multipers/multi_parameter_rank_invariant/euler_characteristic.h +97 -0
  134. multipers/multi_parameter_rank_invariant/function_rips.h +322 -0
  135. multipers/multi_parameter_rank_invariant/hilbert_function.h +769 -0
  136. multipers/multi_parameter_rank_invariant/persistence_slices.h +148 -0
  137. multipers/multi_parameter_rank_invariant/rank_invariant.h +369 -0
  138. multipers/multiparameter_edge_collapse.py +41 -0
  139. multipers/multiparameter_module_approximation/approximation.h +2330 -0
  140. multipers/multiparameter_module_approximation/combinatory.h +129 -0
  141. multipers/multiparameter_module_approximation/debug.h +107 -0
  142. multipers/multiparameter_module_approximation/euler_curves.h +0 -0
  143. multipers/multiparameter_module_approximation/format_python-cpp.h +286 -0
  144. multipers/multiparameter_module_approximation/heap_column.h +238 -0
  145. multipers/multiparameter_module_approximation/images.h +79 -0
  146. multipers/multiparameter_module_approximation/list_column.h +174 -0
  147. multipers/multiparameter_module_approximation/list_column_2.h +232 -0
  148. multipers/multiparameter_module_approximation/ru_matrix.h +347 -0
  149. multipers/multiparameter_module_approximation/set_column.h +135 -0
  150. multipers/multiparameter_module_approximation/structure_higher_dim_barcode.h +36 -0
  151. multipers/multiparameter_module_approximation/unordered_set_column.h +166 -0
  152. multipers/multiparameter_module_approximation/utilities.h +403 -0
  153. multipers/multiparameter_module_approximation/vector_column.h +223 -0
  154. multipers/multiparameter_module_approximation/vector_matrix.h +331 -0
  155. multipers/multiparameter_module_approximation/vineyards.h +464 -0
  156. multipers/multiparameter_module_approximation/vineyards_trajectories.h +649 -0
  157. multipers/multiparameter_module_approximation.cpython-310-darwin.so +0 -0
  158. multipers/multiparameter_module_approximation.pyx +235 -0
  159. multipers/pickle.py +90 -0
  160. multipers/plots.py +456 -0
  161. multipers/point_measure.cpython-310-darwin.so +0 -0
  162. multipers/point_measure.pyx +395 -0
  163. multipers/simplex_tree_multi.cpython-310-darwin.so +0 -0
  164. multipers/simplex_tree_multi.pxd +134 -0
  165. multipers/simplex_tree_multi.pyx +10840 -0
  166. multipers/simplex_tree_multi.pyx.tp +2009 -0
  167. multipers/slicer.cpython-310-darwin.so +0 -0
  168. multipers/slicer.pxd +3034 -0
  169. multipers/slicer.pxd.tp +234 -0
  170. multipers/slicer.pyx +20481 -0
  171. multipers/slicer.pyx.tp +1088 -0
  172. multipers/tensor/tensor.h +672 -0
  173. multipers/tensor.pxd +13 -0
  174. multipers/test.pyx +44 -0
  175. multipers/tests/__init__.py +62 -0
  176. multipers/torch/__init__.py +1 -0
  177. multipers/torch/diff_grids.py +240 -0
  178. multipers/torch/rips_density.py +310 -0
  179. multipers-2.3.3b6.dist-info/METADATA +128 -0
  180. multipers-2.3.3b6.dist-info/RECORD +183 -0
  181. multipers-2.3.3b6.dist-info/WHEEL +6 -0
  182. multipers-2.3.3b6.dist-info/licenses/LICENSE +21 -0
  183. multipers-2.3.3b6.dist-info/top_level.txt +1 -0
@@ -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