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
, whereU
is a matrix (or a stack of matrices) with orthonormal columns,S
is a vector of non-negative numbers (or stack of vectors), andVh
is 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-sizedU
andVh
, such thatU
has shape(..., M, M)
andVh
has shape(..., N, N)
. IfFalse
, compute on the leadingK
singular vectors, such thatU
has shape(..., M, K)
andVh
has 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
U
and must be an array whose shape depends on the value offull_matrices
and contain matrices with orthonormal columns (i.e., the columns are left singular vectors). Iffull_matrices
isTrue
, the array must have shape(..., M, M)
. Iffull_matrices
isFalse
, the array must have shape(..., M, K)
, whereK = min(M, N)
. The firstx.ndim-2
dimensions must have the same shape as those of the inputx
.second element must have the field name
S
and 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-2
dimensions must have the same shape as those of the inputx
.third element must have the field name
Vh
and must be an array whose shape depends on the value offull_matrices
and contain orthonormal rows (i.e., the rows are the right singular vectors and the array is the adjoint). Iffull_matrices
isTrue
, the array must have shape(..., N, N)
. Iffull_matrices
isFalse
, the array must have shape(..., K, N)
whereK = min(M, N)
. The firstx.ndim-2
dimensions must have the same shape as those of the inputx
.
Each returned array must have the same floating-point data type as
x
.