Gaussian elimination is designed to solve systems of linear algebraic equations,
[A][X] =
This program reads input from a file which is passed as an argument when calling the program. Say the matrix is in file name matrix.txt so we call the program in this way:
-------------------------
gauss matrix.txt
------------------------
In the matrix.txt file the inputs should be in this way:
1. first the dimension of the matrix n, this program works ONLY with square matrices.
2. The coeffiecients of the variables of the equations
3. The constants of the equations, respectively.
For example a sample input file would be like this
------------------------------------------
3
3 -0.1 -0.2
0.1 7 -0.3
0.3 -0.2 10
7.85
-19.3
71.4
------------------------------------------
Entries just need to be white-space separated.
About the algorithm:
This program includes modules for the three primary operations of the Gauss elimination algorithm: forward elimination, back substitution, and partial pivoting.
It implements scaled partial pivoting to avoid division by zero, and during pivoting it also checks if any diagonal entry is zero, thus detecting a singular system.
The equations are not scaled, but scaled values are used to determine the best partial pivoting possible.
Matrices are allocated in such a way so that the index starts from 1, not from zero. So the first element of a matrix A is A[1][1],
not A[0][0].
The co-efficient matrix must be a square one. The constant matrix has been implemented as a column. Although it could have been implemented as an n x 1 matrix, I chose not to.