-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
64 lines (52 loc) · 2.21 KB
/
main.cpp
File metadata and controls
64 lines (52 loc) · 2.21 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <chrono>
#include "matrix.hpp"
#include "sq_matrix.hpp"
#include "chain.hpp"
#include "ui.hpp"
#include "cmd_parser.hpp"
#include "test_lazy.hpp"
using namespace std;
using namespace matrixes;
using std::chrono::high_resolution_clock;
using std::chrono::duration_cast;
using std::chrono::duration;
using std::chrono::milliseconds;
int main (int argc, const char *argv[])
{
arguments_t parsed_args = parse_cmd_args(argc, argv);
if (!parsed_args.parsed)
return 0;
if (parsed_args.lvl1) {
auto n_elems_data = get_user_data();
sq_matrix_t<double> matrix {n_elems_data.first,
n_elems_data.second.begin(),
};
auto det_status = matrix.det();
cout << det_status.first << endl;
} else if (parsed_args.lvl2) {
if (parsed_args.multiply_mxes) {
auto elems = get_matrixes();
auto chain = create_matrix_chain(elems);
auto t1 = high_resolution_clock::now();
auto ans_matrix = chain.optimal_mul();
auto t2 = high_resolution_clock::now();
duration<double, std::milli> delta_time = t2 - t1;
cout << "optimal_mul result: " << delta_time.count() << "ms\n";
t1 = high_resolution_clock::now();
auto dummy_ans_matrix = chain.dummy_mul();
t2 = high_resolution_clock::now();
delta_time = t2 - t1;
cout << "dummy_mul result: " << delta_time.count() << " ms\n";
} else {
auto n_elems_data = get_user_chain_data();
matrix_chain_t<double> chain {};
chain.print_optimal_sequence(n_elems_data.second);
}
} else { // lvl3
TESTER.enable_mem_tracker();
test_lazy_matrix(std::cout);
TESTER.disable_mem_tracker();
}
return 0;
}