-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cxx
38 lines (29 loc) · 1.07 KB
/
main.cxx
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
#include <vector>
#include <string>
#include <cstdio>
#include <iostream>
#include "src/main.hxx"
using namespace std;
template <class G, class H>
void runPagerank(const G& x, const H& xt, int repeat) {
vector<float> *initFloat = nullptr;
vector<double> *initDouble = nullptr;
// Find pagerank using 64-bit floats.
auto a1 = pagerankMonolithicSeq(x, xt, initDouble, {repeat});
auto e1 = l1Norm(a1.ranks, a1.ranks);
printf("[%09.3f ms; %03d iters.] [%.4e err.] pagerankDouble\n", a1.time, a1.iterations, e1);
// Find pagerank using 32-bit floats.
auto a2 = pagerankMonolithicSeq(x, xt, initFloat, {repeat});
auto e2 = l1Norm(a2.ranks, a1.ranks);
printf("[%09.3f ms; %03d iters.] [%.4e err.] pagerankFloat\n", a2.time, a2.iterations, e2);
}
int main(int argc, char **argv) {
char *file = argv[1];
int repeat = argc>2? stoi(argv[2]) : 5;
printf("Loading graph %s ...\n", file);
auto x = readMtx(file); println(x);
auto xt = transposeWithDegree(x); print(xt); printf(" (transposeWithDegree)\n");
runPagerank(x, xt, repeat);
printf("\n");
return 0;
}