Reputation: 183
I have a matrix A = np.array([[1,1,1],[1,2,3],[4,4,4]]) and I want only the linearly independent rows in my new matrix. The answer might be A_new = np.array([1,1,1],[1,2,3]]) or A_new = np.array([1,2,3],[4,4,4])
Since I have a very large matrix so I need to decompose the matrix into smaller linearly independent full rank matrix. Can someone please help?
Upvotes: 7
Views: 3614
Reputation: 919
The questioner asked how to do this when the array is not square.
I have a partial solution
Complete the square. Then use the solution above or this approach How to find linearly independent rows from a matrix
A.shape
(222,324)
data2= np.zeros((324,324))
data2[:222,:] = A
lambdas, V = np.linalg.qr(data2)
linearly_independent_indices = np.abs(np.diag(V))>=1e-10
This correctly flagged linear dependencies among the first 222 columns. However, it did not provide useful feedback for the final 102 columns.
Shifting the column order and repeating may help, but a better solution awaits
Upvotes: 0