Given a matrix, A, that can be square, but, is most likely rectangular; and given that an identity matrix can be formed on the Rank(A) left most columns, is there a nice way to row swap to achieve this identity matrix?
For example, starting with
import numpy as np
row1 = np.array([1, 0, 0, 2, 3])
row2 = np.array([0, 0, 1, 4, 5])
row3 = np.array([0, 1, 0, 6, 7])
A = np.array([row1, row2, row3])
I would like to have
row1 = np.array([1, 0, 0, 2, 3])
row2 = np.array([0, 1, 0, 6, 7])
row3 = np.array([0, 0, 1, 4, 5])
A = np.array([row1, row2, row3])
I would like for this to be general, more than 1 row may need to be swapped, and there is no limit to the size of the matrix. Nor is there any guarantee the swap will be neighboring rows. Time does not matter i.e., efficiency is not important. Columns will not need to be swapped. The columns making up the Rank(A) identity matrix will on the left side.
A harder "test case" is
row1 = np.array([0, 0, 0, 0, 1, 5, 6, 7])
row2 = np.array([0, 0, 1, 0, 0, 1, 4, 2])
row3 = np.array([0, 0, 0, 1, 0, 6, 8, 4])
row4 = np.array([0, 1, 0, 0, 0, 1, 1, 1])
row5 = np.array([1, 0, 0, 0, 0, 6, 8, 4])
A = np.array([row1, row2, row3, row4, row5])