# numpy.linalg.svd¶

numpy.linalg.svd(a, full_matrices=1, compute_uv=1)

Singular Value Decomposition.

Factorizes the matrix a into two unitary matrices, U and Vh, and a 1-dimensional array of singular values, s (real, non-negative), such that a == U S Vh, where S is the diagonal matrix np.diag(s).

Parameters: a : array_like, shape (M, N) Matrix to decompose full_matrices : boolean, optional If True (default), U and Vh are shaped (M,M) and (N,N). Otherwise, the shapes are (M,K) and (K,N), where K = min(M,N). compute_uv : boolean Whether to compute U and Vh in addition to s. True by default. U : ndarray, shape (M, M) or (M, K) depending on full_matrices Unitary matrix. s : ndarray, shape (K,) where K = min(M, N) The singular values, sorted so that s[i] >= s[i+1]. Vh : ndarray, shape (N,N) or (K,N) depending on full_matrices Unitary matrix. LinAlgError : If SVD computation does not converge.

Notes

If a is a matrix (in contrast 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
```

numpy.linalg.qr

numpy.linalg.eig