-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
36 lines (32 loc) · 1.13 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
#include <iostream>
#include <vector>
#include "gauss_elimination.h"
using namespace std;
int main()
{
int iDim;
std::vector<float> _scale;
std::cout.precision(4); //set precision
std::cout.setf(ios::fixed); //display using the fixed precision
std::cout << "\nEnter the no. of equations\n";
std::cin >> iDim; //input the no. of equations
float *p[iDim];
float arrA[iDim][iDim+1]; //Array declaration to store the augmented-matrix elements
std::cout << "\nEnter the elements of the augmented-matrix row-wise:\n";
for (int i = 0; i < iDim; i++)
for (int j = 0; j <= iDim; j++)
{
std::cout << "A[" << i << "][" << j << "]=";
std::cin >> arrA[i][j];
};
for (int i = 0; i < iDim; ++i)
p[i] = arrA[i];
GaussElimination matrix = GaussElimination();
std::cout << "\nThis is the matrix to be solved\n";
matrix.printMatrix(p, iDim);
matrix.selectMax(p, iDim, _scale);
for (int step = 0; step < iDim-1; step++)
matrix.solve(p, iDim,_scale, step);
matrix.backwardSubstitution(p, iDim);
return 0;
}