svd — SciPy v1.15.3 Manual (original) (raw)
scipy.linalg.interpolative.
scipy.linalg.interpolative.svd(A, eps_or_k, rand=True, rng=None)[source]#
Compute SVD of a matrix via an ID.
An SVD of a matrix A is a factorization:
A = U @ np.diag(S) @ V.conj().T
where U and V have orthonormal columns and S is nonnegative.
The SVD can be computed to any relative precision or rank (depending on the value of eps_or_k).
See also interp_decomp and id_to_svd.
Parameters:
Anumpy.ndarray or scipy.sparse.linalg.LinearOperator
Matrix to be factored, given as either a numpy.ndarray or ascipy.sparse.linalg.LinearOperator with the matvec and_rmatvec_ methods (to apply the matrix and its adjoint).
eps_or_kfloat or int
Relative error (if eps_or_k < 1
) or rank (if eps_or_k >= 1
) of approximation.
randbool, optional
Whether to use random sampling if A is of type numpy.ndarray(randomized algorithms are always used if A is of typescipy.sparse.linalg.LinearOperator).
rngnumpy.random.Generator, optional
Pseudorandom number generator state. When rng is None, a newnumpy.random.Generator is created using entropy from the operating system. Types other than numpy.random.Generator are passed to numpy.random.default_rng to instantiate a Generator
. If rand is False
, the argument is ignored.
Returns:
2D array of left singular vectors.
1D array of singular values.
2D array right singular vectors.