MCPcopy
hub / github.com/numpy/numpy / svdvals

Function svdvals

numpy/linalg/_linalg.py:1860–1906  ·  view source on GitHub ↗

Returns the singular values of a matrix (or a stack of matrices) ``x``. When x is a stack of matrices, the function will compute the singular values for each matrix in the stack. This function is Array API compatible. Calling ``np.svdvals(x)`` to get singular values is the sam

(x, /)

Source from the content-addressed store, hash-verified

1858
1859@array_function_dispatch(_svdvals_dispatcher)
1860def svdvals(x, /):
1861 """
1862 Returns the singular values of a matrix (or a stack of matrices) ``x``.
1863 When x is a stack of matrices, the function will compute the singular
1864 values for each matrix in the stack.
1865
1866 This function is Array API compatible.
1867
1868 Calling ``np.svdvals(x)`` to get singular values is the same as
1869 ``np.svd(x, compute_uv=False, hermitian=False)``.
1870
1871 Parameters
1872 ----------
1873 x : (..., M, N) array_like
1874 Input array having shape (..., M, N) and whose last two
1875 dimensions form matrices on which to perform singular value
1876 decomposition. Should have a floating-point data type.
1877
1878 Returns
1879 -------
1880 out : ndarray
1881 An array with shape (..., K) that contains the vector(s)
1882 of singular values of length K, where K = min(M, N).
1883
1884 See Also
1885 --------
1886 scipy.linalg.svdvals : Compute singular values of a matrix.
1887
1888 Examples
1889 --------
1890
1891 >>> np.linalg.svdvals([[1, 2, 3, 4, 5],
1892 ... [1, 4, 9, 16, 25],
1893 ... [1, 8, 27, 64, 125]])
1894 array([146.68862757, 5.57510612, 0.60393245])
1895
1896 Determine the rank of a matrix using singular values:
1897
1898 >>> s = np.linalg.svdvals([[1, 2, 3],
1899 ... [2, 4, 6],
1900 ... [-1, 1, -1]]); s
1901 array([8.38434191e+00, 1.64402274e+00, 2.31534378e-16])
1902 >>> np.count_nonzero(s > 1e-10) # Matrix of rank 2
1903 2
1904
1905 """
1906 return svd(x, compute_uv=False, hermitian=False)
1907
1908
1909def _cond_dispatcher(x, p=None):

Callers

nothing calls this directly

Calls 1

svdFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…