-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
27 lines (22 loc) · 831 Bytes
/
Copy pathmain.cpp
File metadata and controls
27 lines (22 loc) · 831 Bytes
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
#include <iostream>
#include<math.h>
#include "MyLinearSystemSolver.h"
int main() {
std::size_t n;
std::cout<<"please input the dimension of the equations"<<std::endl;
std::cin>>n;
std::cout<<"please input the parameters of linear equations"<<std::endl;
MyLinearSystemSolver matrix(n,n+1);
for (std::size_t row=0; row< matrix.nrows(); ++row){
for (std::size_t col=0; col < matrix.ncols(); ++col){
std::cin>>matrix(row,col);
}
}
MyLinearSystemSolver a = matrix;
a.GaussianElimination();
MyLinearSystemSolver solution =
a.BackSub();
std::cout << "The solution is: \n"<< solution << std::endl;
//using verify function to calculate value of A*sol-b
std::cout<<"The verify result A * sol - b is: \n"<< matrix.verify(solution)<<std::endl;
}