Singular Value Decomposition.
Factors the matrix a into u * np.diag(s) * v.H, where u and v are unitary (i.e., u.H = inv(u) and similarly for v), .H is the conjugate transpose operator (which is the ordinary transpose for real-valued matrices), and s is a 1-D array of a‘s singular values.
Parameters: | a : array_like
full_matrices : bool, optional
compute_uv : bool, optional
|
---|---|
Returns: | u : ndarray
s : ndarray
v.H : ndarray
|
Raises: | LinAlgError :
|
Notes
If a is a matrix object (as opposed to an ndarray), then so are all the return values.
Examples
>>> a = np.random.randn(9, 6) + 1j*np.random.randn(9, 6)
>>> U, s, Vh = np.linalg.svd(a)
>>> U.shape, Vh.shape, s.shape
((9, 9), (6, 6), (6,))
>>> U, s, Vh = np.linalg.svd(a, full_matrices=False)
>>> U.shape, Vh.shape, s.shape
((9, 6), (6, 6), (6,))
>>> S = np.diag(s)
>>> np.allclose(a, np.dot(U, np.dot(S, Vh)))
True
>>> s2 = np.linalg.svd(a, compute_uv=False)
>>> np.allclose(s, s2)
True