Linear Equations Solver
1.0
Using Gaussian elimination
|
Implementation of computational functions for solving linear systems. More...
#include "methods.h"
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
Go to the source code of this file.
Functions | |
int | Pivoting (const vector< vector< double > > &m, int current_row, int total_rows) |
Performs partial pivoting and returns the row index with the maximum pivot. | |
void | Exchange (vector< vector< double > > &m, int row1, int row2) |
Swaps two rows in the matrix and outputs the action. | |
bool | Eliminate (vector< vector< double > > &m, int current_row, int total_rows, int total_cols) |
Performs elimination on the matrix to form an upper triangular matrix. | |
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. | |
int | DetermineRank (const vector< vector< double > > &m, int rows, int cols) |
Determines the rank of the coefficient matrix A (excluding augmented column). | |
void | ShowGeneralSolution (const vector< vector< double > > &m, int rows, int cols, int rank) |
Displays the general solution for systems with infinitely many solutions. | |
vector< int > | IdentifyPivots (const vector< vector< double > > &m, int rows, int cols) |
Identifies the pivot columns in the matrix. | |
Implementation of computational functions for solving linear systems.
This file implements key algorithms such as Gaussian elimination with partial pivoting, back-substitution, and rank determination. It also includes functionality to display the general solution when the system has infinitely many solutions.
Definition in file methods.cpp.
bool BackSubstitution | ( | const vector< vector< double > > & | m, |
int | rows, | ||
int | cols, | ||
vector< double > & | solution ) |
Performs back-substitution to find the solution vector.
m | The upper triangular matrix after Gaussian elimination. |
rows | Number of rows in the matrix. |
cols | Number of columns in the matrix (including augmented column). |
solution | Reference to store the solution vector. |
Definition at line 137 of file methods.cpp.
int DetermineRank | ( | const vector< vector< double > > & | m, |
int | rows, | ||
int | cols ) |
Determines the rank of the coefficient matrix A (excluding augmented column).
m | The augmented matrix [A|b]. |
rows | Number of rows in the matrix. |
cols | Number of columns in the matrix (including augmented column). |
Definition at line 188 of file methods.cpp.
bool Eliminate | ( | vector< vector< double > > & | m, |
int | current_row, | ||
int | total_rows, | ||
int | total_cols ) |
Performs elimination on the matrix to form an upper triangular matrix.
Definition at line 47 of file methods.cpp.
void Exchange | ( | vector< vector< double > > & | m, |
int | row1, | ||
int | row2 ) |
Swaps two rows in the matrix and outputs the action.
Definition at line 40 of file methods.cpp.
int GaussianElimination | ( | vector< vector< double > > & | m, |
int | rows, | ||
int | cols ) |
Performs Gaussian elimination on the augmented matrix with partial pivoting.
m | Reference to the augmented matrix [A|b] to be modified. |
rows | Number of rows in the matrix. |
cols | Number of columns in the matrix (including augmented column). |
Definition at line 75 of file methods.cpp.
vector< int > IdentifyPivots | ( | const vector< vector< double > > & | m, |
int | rows, | ||
int | cols ) |
Identifies the pivot columns in the matrix.
m | The matrix after Gaussian elimination. |
rows | Number of rows in the matrix. |
cols | Number of columns in the matrix (including augmented column). |
Definition at line 320 of file methods.cpp.
int Pivoting | ( | const vector< vector< double > > & | m, |
int | current_row, | ||
int | total_rows ) |
Performs partial pivoting and returns the row index with the maximum pivot.
Definition at line 23 of file methods.cpp.
void ShowGeneralSolution | ( | const vector< vector< double > > & | m, |
int | rows, | ||
int | cols, | ||
int | rank ) |
Displays the general solution for systems with infinitely many solutions.
m | The matrix after Gaussian elimination. |
rows | Number of rows in the matrix. |
cols | Number of columns in the matrix (including augmented column). |
rank | The rank of the coefficient matrix A. |
Definition at line 211 of file methods.cpp.