scipy.sparse.linalg.svds returns singular values in ascending order

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.

Code for operation check

# 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]

If you want to descend

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

Recommended Posts

scipy.sparse.linalg.svds returns singular values in ascending order
[python] Get the rank of the values in List in ascending / descending order
[Python] How to output the list values in order
Natural order in python