I have painstakingly ported this Python source "svd.py" to C++. I confirm it works for the example it comes with. While testing another example (this one, from Wikipedia), the assert statement trips because $m < n$.
I find this somewhat of a curious constraint. It seems to fail mainly because the matrix $U$ (named $u$ in the source) is initialized as an $m \times n$ matrix (as opposed to the $m \times m$ matrix it is in the definition of a SVD). It's pretty simple to initialize $U$ instead to an $m \times m$ matrix (and, say, pad with zeroes), but this causes some of the code to break for some other examples.
Why would $U$ be an $m \times n$ matrix, and how can I fix the algorithm to work on all sizes of matrices?
EDIT: If the SVD is $M=U_1\Sigma_1 V_1^*$, I came up with the idea of computing the SVD of $M^*$ to get $M^*=V_1\Sigma_1^*U_1^*=U_2\Sigma_2 V_2^*$. From here, I use that substitution to get the desired $U_1$, $\Sigma_1$, $V_1$ out. This produces a result that multiplies back through correctly, but is it a proper SVD?