-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
75 lines (60 loc) · 1.76 KB
/
main.cpp
File metadata and controls
75 lines (60 loc) · 1.76 KB
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
72
73
74
75
#include <iostream>
#include <vector>
#include "MapMatrix.hpp"
#include "DenseMatrix.hpp"
#include "FredholmMatrix.hpp"
#include "VectorArithmetics.hpp"
#include <cstdlib>
using namespace std;
void input(int options[], int argc, char* argv[]){
/* Managing user's options.
options[0]: MinResSolve.
options[1]: Plot Graph 1.
options[2]: Plot Graph 2.
*/
if (argc == 4){
options[0] = atoi(argv[1]);
options[1] = atoi(argv[2]);
options[2] = atoi(argv[3]);
} else {
options[0] = 1;
options[1] = 0;
options[2] = 0;
}
}
int main(int argc, char* argv[]){
int options[3];
input(options, argc, argv);
if (options[0]){
/* Testing the minimal residual linear solving function.
[1 0 0] [1]
A = [0 1 0] + [1 1 1] * [1]
[0 0 1] [1]
*/
cout << endl << "Testing ResMinSolve." << endl;
vector<double> u1 = {1, 1, 1};
vector<double> v1 = {1, 1, 1};
FredholmMatrix A(3);
A.insert(0, 0, 1);
A.insert(1, 1, 1);
A.insert(2, 2, 1);
A.insert(u1, v1);
cout << A << endl;
vector<double> b = {1, 2, 3};
vector<double> x = MinResSolve(A, b);
cout << x << endl;
}
if (options[1]){
cout << endl << "Plotting Graph 1." << endl;
std::cout.precision(5);
PlotGraph(10);
cout << endl << "Graph 1 plotted." << endl << endl;
}
if (options[2]){
cout << endl << "Plotting Graph 2." << endl;
std::cout.precision(5);
PlotGraph("matrix.txt");
cout << endl << "Graph 2 plotted." << endl << endl;
}
return 0;
}