svd¶
- svd(x: array, /, *, full_matrices: bool = True) Tuple[array, array, array]¶
Returns a singular value decomposition A = USVh of a matrix (or a stack of matrices)
x, whereUis a matrix (or a stack of matrices) with orthonormal columns,Sis a vector of non-negative numbers (or stack of vectors), andVhis a matrix (or a stack of matrices) with orthonormal rows.- Parameters:
x (array) – input array having shape
(..., M, N)and whose innermost two dimensions form matrices on which to perform singular value decomposition. Should have a floating-point data type.full_matrices (bool) – If
True, compute full-sizedUandVh, such thatUhas shape(..., M, M)andVhhas shape(..., N, N). IfFalse, compute on the leadingKsingular vectors, such thatUhas shape(..., M, K)andVhhas shape(..., K, N)and whereK = min(M, N). Default:True.
- Returns:
.. – NOTE: once complex numbers are supported, each square matrix must be Hermitian.
out (Tuple[array, array, array]) – a namedtuple
(U, S, Vh)whosefirst element must have the field name
Uand must be an array whose shape depends on the value offull_matricesand contain matrices with orthonormal columns (i.e., the columns are left singular vectors). Iffull_matricesisTrue, the array must have shape(..., M, M). Iffull_matricesisFalse, the array must have shape(..., M, K), whereK = min(M, N). The firstx.ndim-2dimensions must have the same shape as those of the inputx.second element must have the field name
Sand must be an array with shape(..., K)that contains the vector(s) of singular values of lengthK, whereK = min(M, N). For each vector, the singular values must be sorted in descending order by magnitude, such thats[..., 0]is the largest value,s[..., 1]is the second largest value, et cetera. The firstx.ndim-2dimensions must have the same shape as those of the inputx.third element must have the field name
Vhand must be an array whose shape depends on the value offull_matricesand contain orthonormal rows (i.e., the rows are the right singular vectors and the array is the adjoint). Iffull_matricesisTrue, the array must have shape(..., N, N). Iffull_matricesisFalse, the array must have shape(..., K, N)whereK = min(M, N). The firstx.ndim-2dimensions must have the same shape as those of the inputx.
Each returned array must have the same floating-point data type as
x.