42{
43 char choice;
44 do
45 {
47 if (selected_file.empty())
48 {
49 return 1;
50 }
51
52
54
55 vector<vector<double>> matrix;
56 int rows, cols;
57 if (!
InitMatrix(matrix, selected_file, rows, cols))
58 {
59 return 1;
60 }
61
63 cout << "Starting Gaussian elimination process..." << endl;
65 cout << "Gaussian elimination completed." << endl
66 << endl;
67
70
71 if (!consistent)
72 {
73 cout << "The system of equations is inconsistent and has no solution." << endl;
74 }
75 else if (rank < (cols - 1))
76 {
78 }
79 else
80 {
81 vector<double> solution;
83 if (solvable)
84 {
86 }
87 else
88 {
89 cout << "The system of equations is inconsistent and has no solution." << endl;
90 }
91 }
92
93
96
97 } while (choice == 'y' || choice == 'Y');
98
100 return 0;
101}
string SelectInputFile()
Allows the user to select an input .in file from the current directory.Returns an empty string if no ...
char AskRunAgain()
Return char The user's choice ('y', 'Y', 'n', 'N').
void WaitForExit()
Waits for the user to press Enter before exiting.
int DetermineRank(const vector< vector< double > > &m, int rows, int cols)
Determines the rank of the coefficient matrix A (excluding augmented column).
int GaussianElimination(vector< vector< double > > &m, int rows, int cols)
Performs Gaussian elimination on the augmented matrix with partial pivoting.
bool BackSubstitution(const vector< vector< double > > &m, int rows, int cols, vector< double > &solution)
Performs back-substitution to find the solution vector.
void ShowGeneralSolution(const vector< vector< double > > &m, int rows, int cols, int rank)
Displays the general solution for systems with infinitely many solutions.
void DisplaySolution(const vector< double > &solution)
Displays the unique solution.
void StopTimer(const chrono::steady_clock::time_point &start)
bool InitMatrix(vector< vector< double > > &m, const string &filename, int &rows, int &cols)
Initializes the matrix by reading from a .in file.
void ShowEquations(const vector< vector< double > > &m, int rows, int cols)
Displays the system of linear equations.
chrono::steady_clock::time_point StartTimer()
bool CheckConsistency(const vector< vector< double > > &m, int rows, int cols)
Checks the consistency of the system of equations.