cupyx.scipy.sparse.linalg.svds#

cupyx.scipy.sparse.linalg.svds(a, k=6, *, ncv=None, tol=0, which='LM', v0=None, maxiter=None, return_singular_vectors=True, rng=None)[source]#

Finds the largest k singular values/vectors for a sparse matrix.

Parameters:
  • a (ndarray, spmatrix or LinearOperator) – A real or complex array with dimension (m, n). a must cupy.ndarray, cupyx.scipy.sparse.spmatrix or cupyx.scipy.sparse.linalg.LinearOperator.

  • k (int) – The number of singular values/vectors to compute. Must be 1 <= k < min(m, n).

  • ncv (int) – The number of Lanczos vectors generated. Must be k < ncv <= min(m, n). If None, default value is used.

  • tol (float) – Tolerance for singular values. If 0, machine precision is used.

  • which (str) – Only ‘LM’ is supported. ‘LM’: finds k largest singular values.

  • v0 (ndarray) – Starting vector for iteration, of length min(a.shape) as in scipy.sparse.linalg.svds(). If None, a random vector drawn from rng is used.

  • maxiter (int) – Maximum number of Lanczos update iterations. If None, default value is used.

  • return_singular_vectors (bool) – If True, returns singular vectors in addition to singular values.

  • rng (int or generator) – Source of the default start vector when v0 is None, and of the orthonormal columns that complete the singular vectors of a rank-deficient input. Accepts the same values as eigsh(); None (the default) draws from a fresh cupy.random.default_rng(), so repeated calls start differently; pass an int for a reproducible result.

Returns:

If return_singular_vectors is True, it returns u, s and vt where u is left singular vectors, s is singular values and vt is right singular vectors. Otherwise, it returns only s.

Return type:

tuple

Note

This is a naive implementation using cupyx.scipy.sparse.linalg.eigsh as an eigensolver on a.H @ a or a @ a.H.