Note that numpy.linalg.svd
and scipy.linalg.svd
are returned in descending order, while scipy.sparse.linalg.svds
is returned in ascending order. I got hooked.
# coding: utf-8
import numpy as np
import scipy.linalg
import scipy.sparse.linalg
x = np.random.rand(7, 7)
U, S1, V = np.linalg.svd(x)
print S1
U, S2, V = scipy.linalg.svd(x)
print S2
U, S3, V = scipy.sparse.linalg.svds(x)
print S3
# S1,Equal to S2
print S3[::-1]
http://stackoverflow.com/questions/24498854/singular-values-sorted-in-descending-order-using-svds-from-scipy-sparse-linalg
A. Write by yourself (I didn't have the option to sort in descending order