cupyx.scipy.sparse.linalg.svds#

cupyx.scipy.sparse.linalg.svds(a, k=6, *, ncv=None, tol=0, which='LM', maxiter=None, return_singular_vectors=True)[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 + 1 < 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.

  • 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.

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.