A. Wali Jr.
A. Wali Jr.

Reputation: 25

numpy.linalg.inv() doesn't work

I am trying to invert a 2-D matrix using the numpy.linalg.inv() function. However whenever I run it, it just seems to stop. Since I was using a matrix of dimensions 40989x52, I initially thought that this was an issue due to the so I tried waiting for it to process, but it just didn't proceed even after 30+mins. I later tried calling the inv() function with a 3x2 matrix but it surprisingly didn't work either.

I am using python3.6 with Anaconda libraries on 64-bit Ubuntu.

Could this be a library issue or is it an issue with my system?

Upvotes: 1

Views: 2424

Answers (1)

Robert F. Dickerson
Robert F. Dickerson

Reputation: 483

Whenever a matrix has more rows than columns (the system of equations has more equations than unknowns), the system could be overdetermined- in other words, there is no exact solution. In fact, you cannot take an inverse of a non-square matrix.

You might want to check the rank of the matrix.

However, practically, we end up using the pseudo-inverse for this scenario. You can look into using pinv.

https://docs.scipy.org/doc/numpy-1.14.0/reference/generated/numpy.linalg.pinv.html

Upvotes: 1

Related Questions