-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
46 lines (35 loc) · 919 Bytes
/
main.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
//
// main.cpp
// gauss-jordan
//
// Created by mndx on 17/04/2022.
//
#include "lib_gauss.hpp"
#include "lib_mat.hpp"
#include "lib_mem.hpp"
#include "user_types.hpp"
int main(int argc, char * argv[]) {
// Declarations
int n = 5;
// Allocate space for matrices
double ** mat = mat2D(n);
double ** mat_inv = mat2D(n);
double ** mat_prod = mat2D(n);
double ** mat_store = mat2D(n);
// Populate matrix mat with some data
init_mat(n, mat);
// Store initial matrix mat
set_mat(mat, n, mat_store);
// Compute inverse using Gauss-Jordan method
gauss_jordan(mat, n, mat_inv);
// Verify computation
mat_mult_sq(mat_store, mat_inv, n, mat_prod);
// Print results
print_mat(mat_prod, n);
// Free allocated space
free_mat2D(mat, n);
free_mat2D(mat_inv, n);
free_mat2D(mat_prod, n);
free_mat2D(mat_store, n);
return 0;
}