I’m having difficulty coming up with the method by which a program can find the rank of a matrix. In particular, I don’t fully understand how you can make sure the program would catch all cases of linear combinations resulting in dependencies.
The general idea of how to solve this is what I’m interested in. However, if you want to take the answer a step farther, I’m specifically looking for the solution in regards to square matrices only. Also the code would be in C++.
Thanks for your time!
General process:
where
rref(matrix)is a function that does your run-of-the-mill Gaussian eliminationnumber_non_zero_rows(m2)is a function that sums the number of rows with non-zero entriesYour concern about all cases of linear combinations resulting in dependencies is taken care of with the
rref(Gaussian elimination) step. Incidentally, this works no matter what the dimensions of the matrix are.