-
Notifications
You must be signed in to change notification settings - Fork 11
/
main.c
50 lines (43 loc) · 1.27 KB
/
main.c
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 <time.h>
#include <stdio.h>
#include "tests.h"
#include "vector.h"
#include "matrix.h"
#include "rand.h"
/*
void time_matrix_multiply() {
struct matrix* P;
struct matrix* M = matrix_random_uniform(1000, 1000, 0, 1);
struct matrix* N = matrix_random_uniform(1000, 1000, 0, 1);
for(int cache = 0; cache < 1000; cache += 50) {
clock_t start = clock(), diff;
if(cache > 0) {
P = matrix_multiply_cache(M, N, cache);
} else {
P = matrix_multiply(M, N);
}
diff = clock() - start;
int msec = diff * 1000 / CLOCKS_PER_SEC;
printf("With cache size %d took %d seconds and %d milliseconds.\n",
cache, msec / 1000, msec % 1000
);
}
matrix_free(M); matrix_free(N); matrix_free(P);
}
*/
void time_qr_decomp() {
clock_t start = clock(), diff;
struct matrix* M = matrix_random_uniform(100000, 200, 0, 1);
struct qr_decomp* qr = matrix_qr_decomposition(M);
matrix_free(M); qr_decomp_free(qr);
diff = clock() - start;
int msec = diff * 1000 / CLOCKS_PER_SEC;
printf("Qr decomp took %d seconds and %d milliseconds.\n",
msec / 1000, msec % 1000
);
}
int main(int argc, char** argv) {
init_random();
run_all();
return 0;
}