Im currently computing an SVD on a large matrix (an image, to be exact) using numpy.linalg’s svd function. The documentation and examples that I’ve found all seem to indicate that the Sigma values that are returned are ordered in descending order (Implying the correct ordering of U and V^T).
However, in my testing the sigma values appear unordered. So my question is whether for some reason something is going wrong in my linalg (highly unlikely I know), or if it simply returns the sigma’s as unordered?
A follow-up question is then the best way to sort the sigma’s so that the order in U and V^T also reflect the change.
Since
linalg.svdis just an interface to LAPACKdgesddthe singular values should be ordered.If you get unordered results check if the result is correct, like in the example above. If not you may have a lapack bug or (less likely) a numpy bug.