Is there a way where I can calculate the inverse of a mxn non-square matrix using numpy? Since using la.inv(S) seems to give me an error of ValueError: expected square matrix



To calculate the non square matrix mxn, We can use np.linalg.pinv(S), here s is the data you want to pass.

You are watching: Can a non square matrix have an inverse

For square matrix we use np.linalg.inv(S), The inverse of a matrix is such that if it is multiplied by the original matrix, it results in identity matrix.

note: np is numpy

We can also use np.linalg.inv(S) for non square matrix but in order to not get any error you need to slice the data S.

For more details on np.linalg.pinv :

Improve this answer
edited Sep 5 at 13:59
answered Sep 4 at 12:03

Ramahanisha GundaRamahanisha Gunda
1133 bronze badges
Add a comment |

Your Answer

Thanks for contributing an answer to Stack Overflow!

Please be sure to answer the question. Provide details and share your research!

But avoid

Asking for help, clarification, or responding to other answers.Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

See more: 16 Oz Sour Cream To Cups - How Many Cup Is 16 Oz Of Sour Cream

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Facebook
Sign up using Email and Password

Post as a guest

Email Required, but never shown

Post as a guest


Required, but never shown

Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged numpy matrix linear-algebra or ask your own question.

The Overflow Blog
Featured on Meta
Visit chat
How do I create an empty array/matrix in NumPy?
Numpy matrix to array
What are the differences between numpy arrays and matrices? Which one should I use?
How to calculate rolling / moving average using python + NumPy / SciPy?
What does -1 mean in numpy reshape?
Calculate inverse of a non-square matrix in R
Inverse of a matrix using numpy
Difference between numpy.array shape (R, 1) and (R,)
Most efficient way to map function over numpy array
Hot Network Questions more hot questions

Question feed
Subscribe to RSS
Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader.


Stack Overflow
Stack Exchange Network
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev2021.9.21.40262

Stack Overflow works best with JavaScript enabled

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.