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 : https://numpy.org/doc/stable/reference/generated/numpy.linalg.pinv.html

Share
Follow
edited Sep 5 at 13:59 Ramahanisha GundaRamahanisha Gunda
2

Thanks for contributing an answer to Stack Overflow!

But avoid

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

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

Draft saved

Submit

### Post as a guest

Name
Email Required, but never shown

### Post as a guest

Name
Email

Required, but never shown

## 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
Related
371
How do I create an empty array/matrix in NumPy?
179
Numpy matrix to array
392
What are the differences between numpy arrays and matrices? Which one should I use?
164
How to calculate rolling / moving average using python + NumPy / SciPy?
548
What does -1 mean in numpy reshape?
4
Calculate inverse of a non-square matrix in R
78
Inverse of a matrix using numpy
372
Difference between numpy.array shape (R, 1) and (R,)
493
Most efficient way to map function over numpy array
Hot Network Questions more hot questions

Question feed lang-py
Stack Overflow
Products
Company
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 