??! is there such a thing ? only nonsingular square matrices can be inverted. a general mxn matrix may have a “left inverse” or a “right inverse”, but i don’t think your code is computing that.
There is such a thing as a generalized inverse, in which you can invert non-square or non-full rank matrices and the generalized inverse meets many (but not all) of the properties of an inverse. The tough part is that the agreed upon set of properties does not create a unique solution for a generalized inverse like it does for the inverse, so there are multiple possibilities when someone says generalized inverse. However, the most popular is probably the Moore-Penrose inverse: https://en.wikipedia.org/wiki/Moore–Penrose_inverse
??! is there such a thing ? only nonsingular square matrices can be inverted. a general mxn matrix may have a “left inverse” or a “right inverse”, but i don’t think your code is computing that.