-
Notifications
You must be signed in to change notification settings - Fork 1
/
inver_aug_test.cpp
56 lines (42 loc) · 1.24 KB
/
inver_aug_test.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
53
54
55
56
#include<iostream>
#include<fstream>
#include<cmath>
#include "inver_aug.h"
typedef float GoldenType;
using namespace std;
int main() {
MatInputType inputArr[N][N];
GoldenType goldenArr[N][N];
InvType invArr[N][N];
float totalError = 0.0;
ifstream ifileMat("matrices.dat", ios::in | ios::binary);
ifstream ifileGold("golden.dat", ios::in | ios::binary);
while (ifileMat.read(reinterpret_cast<char*>(inputArr), N * N * sizeof(MatInputType))) {
for (int i = 0; i < N; i++) {
ifileGold.read(reinterpret_cast<char*>(goldenArr[i]), N * sizeof(GoldenType));
}
maintoAXI(inputArr, invArr);
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
float invArrVal = static_cast<float>(invArr[i][j]);
totalError += abs(goldenArr[i][j] - invArrVal);
}
}
cout<< "The golden matrix is: "<< endl;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
cout<<goldenArr[i][j]<<"\t";
}
cout<<endl;
}
cout<< "The inverted matrix is "<<endl;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
cout<<invArr[i][j]<<"\t";
}
cout<<endl;
}
}
cout<<"The total absolute error is: "<< totalError << endl;
//Error is currently zero since we are using float
}