bundles / scipy latest / scipy / linalg / interpolative / svd
function
scipy.linalg.interpolative:svd
source: build-install/usr/lib/python3.14/site-packages/scipy/linalg/interpolative.py:776
Signature
def svd(A, eps_or_k, rand = True, rng = None)Summary
Compute SVD of a matrix via an ID.
Extended Summary
An SVD of a matrix A is a factorization
A = U @ np.diag(S) @ V.conj().Twhere 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
A: :class:`numpy.ndarray` or :class:`scipy.sparse.linalg.LinearOperator`Matrix to be factored, given as either a numpy.ndarray or a scipy.sparse.linalg.LinearOperator with the
matvecandrmatvecmethods (to apply the matrix and its adjoint).eps_or_k: float or intRelative error (if
eps_or_k < 1) or rank (ifeps_or_k >= 1) of approximation.rand: bool, optionalWhether to use random sampling if
Ais of type numpy.ndarray (randomized algorithms are always used ifAis of type scipy.sparse.linalg.LinearOperator).rng: `numpy.random.Generator`, optionalPseudorandom number generator state. When
rngis None, a new numpy.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 aGenerator. If rand isFalse, the argument is ignored.
Returns
U: :class:`numpy.ndarray`2D array of left singular vectors.
S: :class:`numpy.ndarray`1D array of singular values.
V: :class:`numpy.ndarray`2D array right singular vectors.
Examples
import numpy as np from scipy.linalg.interpolative import svd rng = np.random.default_rng() A = rng.standard_normal((20, 5)) @ rng.standard_normal((5, 10)) U, S, V = svd(A, 5) U.shape S.shape V.shape np.allclose(A, U @ np.diag(S) @ V.T)✓
True
Aliases
scipy.linalg.interpolative.svd