-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathminimize_pres.cpp
More file actions
50 lines (38 loc) · 1.64 KB
/
Copy pathminimize_pres.cpp
File metadata and controls
50 lines (38 loc) · 1.64 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
45
46
47
48
49
50
#include "grlina/r2graded_matrix.hpp"
#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.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 << "Resolution computed and saved to: " << output_path << std::endl;
}
}
std::string insert_suffix_before_extension(const std::string& filepath, const std::string& suffix) {
std::filesystem::path path(filepath);
std::string stem = path.stem().string(); // filename without extension
std::string extension = path.extension().string(); // e.g., ".txt"
std::filesystem::path new_path = path.parent_path() / (stem + suffix + extension);
return new_path.string();
}
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_min.sccsum";
} 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);
return 0;
} // main