-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
71 lines (64 loc) · 1.58 KB
/
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include "headers/GaussElimination.h"
#include <math.h>
#include <vector>
#include <fstream>
#include "BL.h"
using std::cout;
using std::cin;
int main()
{
cout << "Enter n: ";
int a = 0;
int b = 2;
int n = 50;
cin >> n;
float **arrayB;
arrayB = new float *[n];
for (int i = 0; i < n; ++i) {
arrayB[i] = new float[n];
}
float arrayL[n];
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
// always calculate the only 3 relevant values, rest is zeroes
if (abs(i-j) < 2){
arrayB[i][j] = B(i,j,n,a,b);
}else{
arrayB[i][j] = 0;
}
}
arrayL[i] = L(i, n, a, b);
// printf("%f \n", ((float)i)/(float)n);
}
// printf("\n");
// for(int i; i<n; ++i){
// printf("%f ", arrayL[i]);
// }
// printf("\n");
// for (int i = 0; i < n; ++i) {
// for (int j = 0; j < n; ++j) {
// printf("%f ", arrayB[i][j]);
// }
// printf("\n");
// }
float *result = gaussElimination(n, arrayB, arrayL);
for (int i = 0; i < n; ++i) {
printf("%f ", result[i]);
}
std::ofstream outfile;
outfile.open("../result.txt", std::ofstream::out | std::ofstream::trunc);//std::ios_base::app
outfile << n;
outfile <<";";
outfile << a;
outfile << ";";
outfile << b;
outfile << ";";
for (int i = 0; i < n; ++i) {
outfile << result[i];
if (i != n-1)
outfile << ";";
}
outfile.close();
system("python ../graph.py");
}