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
mustcupy.ndarray
,cupyx.scipy.sparse.spmatrix
orcupyx.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)
. IfNone
, 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
isTrue
, it returnsu
,s
andvt
whereu
is left singular vectors,s
is singular values andvt
is right singular vectors. Otherwise, it returns onlys
.- Return type:
See also
Note
This is a naive implementation using cupyx.scipy.sparse.linalg.eigsh as an eigensolver on
a.H @ a
ora @ a.H
.