MCPcopy
hub / github.com/dask/dask / svd

Function svd

dask/array/linalg.py:874–971  ·  view source on GitHub ↗

Compute the singular value decomposition of a matrix. Parameters ---------- a : (M, N) Array coerce_signs : bool Whether or not to apply sign coercion to singular vectors in order to maintain deterministic results, by default True. full_matrices : bool, opti

(a, coerce_signs=True, full_matrices=False)

Source from the content-addressed store, hash-verified

872
873
874def svd(a, coerce_signs=True, full_matrices=False):
875 """
876 Compute the singular value decomposition of a matrix.
877
878 Parameters
879 ----------
880 a : (M, N) Array
881 coerce_signs : bool
882 Whether or not to apply sign coercion to singular vectors in
883 order to maintain deterministic results, by default True.
884 full_matrices : bool, optional
885 If True, raises ``NotImplementedError``. Only ``full_matrices=False``
886 (reduced SVD) is currently supported. Default is ``False``.
887
888 .. versionadded:: 2026.3.0
889
890 Examples
891 --------
892
893 >>> u, s, v = da.linalg.svd(x) # doctest: +SKIP
894
895 Returns
896 -------
897
898 u : (M, K) Array, unitary / orthogonal
899 Left-singular vectors of `a` (in columns) with shape (M, K)
900 where K = min(M, N).
901 s : (K,) Array, singular values in decreasing order (largest first)
902 Singular values of `a`.
903 v : (K, N) Array, unitary / orthogonal
904 Right-singular vectors of `a` (in rows) with shape (K, N)
905 where K = min(M, N).
906
907 Warnings
908 --------
909
910 SVD is only supported for arrays with chunking in one dimension.
911 This requires that all inputs either contain a single column
912 of chunks (tall-and-skinny) or a single row of chunks (short-and-fat).
913 For arrays with chunking in both dimensions, see da.linalg.svd_compressed.
914
915 See Also
916 --------
917
918 np.linalg.svd : Equivalent NumPy Operation
919 da.linalg.svd_compressed : Randomized SVD for fully chunked arrays
920 dask.array.linalg.tsqr : QR factorization for tall-and-skinny arrays
921 dask.array.utils.svd_flip : Sign normalization for singular vectors
922 """
923 if full_matrices:
924 raise NotImplementedError(
925 "full_matrices=True is not implemented for dask arrays. Use full_matrices=False to compute the reduced SVD."
926 )
927 nb = a.numblocks
928 if a.ndim != 2:
929 raise ValueError(
930 f"Array must be 2D.\nInput shape: {a.shape}\nInput ndim: {a.ndim}\n"
931 )

Callers 3

normFunction · 0.85

Calls 5

delayedFunction · 0.90
from_delayedFunction · 0.90
svd_flipFunction · 0.90
minFunction · 0.85
tsqrFunction · 0.85

Tested by 2