MCPcopy
hub / github.com/numpy/numpy / svd

Function svd

numpy/linalg/_linalg.py:1667–1852  ·  view source on GitHub ↗

Singular Value Decomposition. When `a` is a 2D array, and ``full_matrices=False``, then it is factorized as ``u @ np.diag(s) @ vh = (u * s) @ vh``, where `u` and the Hermitian transpose of `vh` are 2D arrays with orthonormal columns and `s` is a 1D array of `a`'s singular v

(a, full_matrices=True, compute_uv=True, hermitian=False)

Source from the content-addressed store, hash-verified

1665
1666@array_function_dispatch(_svd_dispatcher)
1667def svd(a, full_matrices=True, compute_uv=True, hermitian=False):
1668 """
1669 Singular Value Decomposition.
1670
1671 When `a` is a 2D array, and ``full_matrices=False``, then it is
1672 factorized as ``u @ np.diag(s) @ vh = (u * s) @ vh``, where
1673 `u` and the Hermitian transpose of `vh` are 2D arrays with
1674 orthonormal columns and `s` is a 1D array of `a`'s singular
1675 values. When `a` is higher-dimensional, SVD is applied in
1676 stacked mode as explained below.
1677
1678 Parameters
1679 ----------
1680 a : (..., M, N) array_like
1681 A real or complex array with ``a.ndim >= 2``.
1682 full_matrices : bool, optional
1683 If True (default), `u` and `vh` have the shapes ``(..., M, M)`` and
1684 ``(..., N, N)``, respectively. Otherwise, the shapes are
1685 ``(..., M, K)`` and ``(..., K, N)``, respectively, where
1686 ``K = min(M, N)``.
1687 compute_uv : bool, optional
1688 Whether or not to compute `u` and `vh` in addition to `s`. True
1689 by default.
1690 hermitian : bool, optional
1691 If True, `a` is assumed to be Hermitian (symmetric if real-valued),
1692 enabling a more efficient method for finding singular values.
1693 Defaults to False.
1694
1695 Returns
1696 -------
1697 U : { (..., M, M), (..., M, K) } array
1698 Unitary array(s). The first ``a.ndim - 2`` dimensions have the same
1699 size as those of the input `a`. The size of the last two dimensions
1700 depends on the value of `full_matrices`. Only returned when
1701 `compute_uv` is True.
1702 S : (..., K) array
1703 Vector(s) with the singular values, within each vector sorted in
1704 descending order. The first ``a.ndim - 2`` dimensions have the same
1705 size as those of the input `a`.
1706 Vh : { (..., N, N), (..., K, N) } array
1707 Unitary array(s). The first ``a.ndim - 2`` dimensions have the same
1708 size as those of the input `a`. The size of the last two dimensions
1709 depends on the value of `full_matrices`. Only returned when
1710 `compute_uv` is True.
1711
1712 Raises
1713 ------
1714 LinAlgError
1715 If SVD computation does not converge.
1716
1717 See Also
1718 --------
1719 scipy.linalg.svd : Similar function in SciPy.
1720 scipy.linalg.svdvals : Compute singular values of a matrix.
1721
1722 Notes
1723 -----
1724 When `compute_uv` is True, the result is a namedtuple with the following

Callers 5

svdvalsFunction · 0.85
condFunction · 0.85
matrix_rankFunction · 0.85
pinvFunction · 0.85
_multi_svd_normFunction · 0.85

Calls 15

argsortFunction · 0.90
sortFunction · 0.90
errstateClass · 0.90
_makearrayFunction · 0.85
eighFunction · 0.85
SVDResultClass · 0.85
wrapFunction · 0.85
eigvalshFunction · 0.85
_assert_stacked_2dFunction · 0.85
_commonTypeFunction · 0.85
isComplexTypeFunction · 0.85
_realTypeFunction · 0.85

Tested by

no test coverage detected