Files
Crossflip/GaussianEliminationAlgorithm.txt
Patrick Stevens 55b6393437 Upload complete Crossflip project
I used Subversion to create my Crossflip solution, but my account on
that repository expired; I am transferring it to Github.
2013-09-20 21:08:05 +01:00

25 lines
869 B
Plaintext
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

A is n by m binary matrix
i := 1 // row and column index
for i := 1 to m do // for every column
// find non-zero element in column i, starting in row i:
maxi := i
for k := i to n do
if A[k,i] = 1 then
maxi := k
end for
if A[maxi,i] = 1 then
swap rows i and maxi in A and b, but do not change the value of i
//Now A[i,i] will contain the old value of A[maxi,i], that is 1
for u := i+1 to m do
Add A[u,i] * row i to row u, do this for BOTH, matrix A and RHS vector b
//Now A[u,i] will be 0
end for
else
declare error more than one solution exist
end if
end for
if n>m and if you can find zero row in A with nonzero RHS element, then
declare error no solution.
end if
// now, matrix A is in upper triangular form and solution can be found
use back substitution to find vector x