I faced this same problem in SciDart (https://scidart.org/) and the answer of Brian Borchers helped me find an away out. But my approach was different (you can find my implementation here https://github.com/scidart/scidart/blob/9f5d4e42996b35d32976d571b2acd8804298ed4d/lib/src/numdart/linalg/decompositions/svd.dart#L84 ) and my implementation is based on JAMA library (https://math.nist.gov/javanumerics/jama/doc/Jama/SingularValueDecomposition.html):
- if $m < n$, add new $n - m$ lines to your input and fill it with zeros, you will get a $n x n$ square matrix as input;
- compute de SVD;
- if $m < n$, multiply each element of $U$ and $V$ by -1;
Where
- $m$ is the number of rows;
- $n$ is the number of columns;