forked from jcchurch/C-Linear-Algebra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
invtest.c
executable file
·44 lines (39 loc) · 982 Bytes
/
invtest.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
#include <stdio.h>
#include "matrix.h"
#include "matrixadv.h"
int main(int argc, char** argv) {
matrix* l = NULL;
matrix* u = NULL;
matrix* x;
matrix* i;
matrix* p;
matrix* q;
matrix* a = readMatrix(argv[1]);
printf("Original -----------------\n");
printMatrix(a);
i = eyeMatrix(a->width);
printf("Eye ----------------------\n");
printMatrix(i);
LUdecomposition(a, &l, &u);
p = multiplyMatrix(l, u);
x = solver(a, i);
q = multiplyMatrix(a, x);
printf("Lower --------------------\n");
printMatrix(l);
printf("Upper --------------------\n");
printMatrix(u);
printf("Product ------------------\n");
printMatrix(p);
printf("Solver with Identity -----\n");
printMatrix(x);
printf("Identity -----------------\n");
printMatrix(q);
freeMatrix(i);
freeMatrix(q);
freeMatrix(x);
freeMatrix(a);
freeMatrix(p);
freeMatrix(l);
freeMatrix(u);
return 0;
}