User:Trieu/Method of matrix rank

Suppose we want to write program to find out the rank of a matrix Arxc, where 'r' and 'c' are the number of rows and columns of matrix A.

By any available programming languages, one should be able to define an 2 dimensions array, say A[1->r,1->c] to keep all elements of matrix Arxc that we are going to find a rank.

Here, the method merely does similar to the process that everyone often do to work out the rank by hand. 

function make(i,j,a);           // assign value "a" to A[i,j].

if (a==0) { for (m=j->c) { if (j==1) { A[i,m]=A[i,m]+(-A[i,m]*A[1,m]); } // end of (j==1) if (j!=1) { A[i,m]=A[i,m]+(-A[i,m]*A[i-1,m]); } // end of (j!=1) } // end for } // end if if (a==1) { for (m=j->c) { A[i,m]=A[i,m]/A[i,j]; } // end for } // end if } // end function for (j=1->c) { for (i=j->r) { if (i==j) { make(i,j,1); } if (i!=j) { make(i,j,0); } } } Then, Arxc is now rewritten in echelon form!

We count the non-zero rows by writting such as:  zero=true; count=0; for (i=1->r) { for (j=1->c) { if (A[i,j]!=0) { zero=false; } if (zero==true) { count++;  } zero=true; } } Notes: The above illustration does not conform to any programming language, one should match the algorithm appropriate with the language you are using.