-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.cpp
52 lines (43 loc) · 2.23 KB
/
example.cpp
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
#include <vector>
#include <iterator>
#include <chrono>
#include <iostream>
#include <zle.h>
int main() {
// Example usage
int n = 8;
std::vector<std::string> s = get_symbols(n);
std::vector<std::vector<SymX>> A = {
{symx(1, s[0]), symx(1, s[1]), symx(1, s[2]), symx(1, s[3]), symx(1, s[4]), symx(1, s[5]), symx(1, s[6]), symx(1, s[7])},
{symx(1, s[1]), symx(1, s[0]), symx(1, s[2]), symx(1, s[4]), symx(1, s[3]), symx(1, s[6]), symx(1, s[5]), symx(1, s[7])},
{symx(1, s[2]), symx(1, s[1]), symx(1, s[0]), symx(1, s[3]), symx(1, s[4]), symx(1, s[7]), symx(1, s[6]), symx(1, s[5])},
{symx(1, s[3]), symx(1, s[4]), symx(1, s[2]), symx(1, s[0]), symx(1, s[1]), symx(1, s[5]), symx(1, s[6]), symx(1, s[7])},
{symx(1, s[4]), symx(1, s[3]), symx(1, s[2]), symx(1, s[1]), symx(1, s[0]), symx(1, s[6]), symx(1, s[5]), symx(1, s[7])},
{symx(1, s[5]), symx(1, s[6]), symx(1, s[7]), symx(1, s[3]), symx(1, s[4]), symx(1, s[0]), symx(1, s[1]), symx(1, s[2])},
{symx(1, s[6]), symx(1, s[5]), symx(1, s[7]), symx(1, s[4]), symx(1, s[3]), symx(1, s[1]), symx(1, s[0]), symx(1, s[2])},
{symx(1, s[7]), symx(1, s[6]), symx(1, s[5]), symx(1, s[3]), symx(1, s[4]), symx(1, s[2]), symx(1, s[1]), symx(1, s[0])}
};
int batch_size = 8;
int stagger = 0;
int base = 10;
auto start = std::chrono::high_resolution_clock::now();
std::vector<std::vector<int>> result = zle_eigs(A, s, batch_size, stagger, base);
auto end = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
std::cout << "finished in " << duration.count() << " milliseconds" << std::endl;
// Print results. Each element in the axis dimension is an eigenvalue.
// Each element in the second axis is the coefficient on the corresponding
// symbol of the same index from s
std::cout << "consolidated final result:" << std::endl;
std::cout << "[";
for (int i = 0; i < n; ++i) {
std::cout << "[";
for (int j = 0; j < n; ++j) {
int coeff = result[i][j];
std::cout << coeff << ",";
}
std::cout << "]," << std::endl;
}
std::cout << "]" << std::endl;
return 0;
}