-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathminimize.cpp
More file actions
44 lines (33 loc) · 1.34 KB
/
minimize.cpp
File metadata and controls
44 lines (33 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <grlina/graded_linalg.hpp>
#include <iostream>
#include <filesystem>
using namespace graded_linalg;
void compute_minimization(std::filesystem::path input_path, std::filesystem::path output_path) {
R2GradedSparseMatrix<int> presentation = R2GradedSparseMatrix<int>(input_path.string());
presentation.sort_columns_lexicographically();
presentation.sort_rows_lexicographically();
presentation.minimize();
std::ofstream output_file(output_path);
if (!output_file.is_open()) {
std::cerr << "Error: Unable to open output file " << output_path << std::endl;
return;
} else {
presentation.to_stream(output_file);
output_file.close();
std::cout << "Minimimal subpresentation computed and saved to: " << output_path << std::endl;
}
}
int main(int argc, char** argv) {
std::string filepath;
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " <file_path>" << std::endl;
filepath = "/home/wsljan/AIDA/tests/test_presentations/davids_annulus.scc";
} else {
filepath = argv[1];
}
std::filesystem::path input_path(filepath);
std::string modified_path = insert_suffix_before_extension(filepath, "_min");
std::filesystem::path output_path(modified_path);
compute_minimization(input_path, output_path);
return 0;
} // main