svd#
Perform a singular value decomposition (SVD).
-
template<typename OpA>
__MATX_INLINE__ auto matx::svd(const OpA &a, const SVDMode jobz = SVDMode::ALL, const SVDHostAlgo algo = SVDHostAlgo::DC)# Perform a singular value decomposition (SVD) using cuSolver or a LAPACK host library.
The singular values within each vector are sorted in descending order.
If rank > 2, operations are batched.
- Template Parameters:
OpA – Operator input type
- Parameters:
a – Input operator of shape
... x m x njobz – Compute all, part, or none of matrices U and VT
algo – For Host SVD calls, whether to use more efficient divide-and-conquer based
gesddroutine or the QR factorization basedgesvdroutine.gesddcan run significantly faster, especially for large matrices. However,gesddrequires \( O(\min(M,N) ^ 2) \) memory as compared to \( O(\max(M,N)) \) forgesvd, and it can have poorer accuracy in some cases. Ignored for CUDA SVD calls.
- Returns:
Operator that produces U, S, and VT tensors. Regardless of jobz, all 3 tensors must be correctly setup for the operation and used with
mtie().k = min(m, n)U - The unitary matrix containing the left singular vectors. A tensor of shape
... x m x kforSVDMode::REDUCEDand... x m x motherwise.S - A tensor of shape
... x kcontaining the singular values in descending order. It must be of real type and match the inner type of the other tensors.VT - The unitary matrix containing the right singular vectors. A tensor of shape
... x k x nforSVDMode::REDUCEDand... x n x notherwise.
Enums#
The following enums are used for configuring the behavior of SVD operations.
-
enum class matx::SVDMode#
Modes for computing columns of U and rows of VT in Singular Value Decomposition (SVD). Corresponds to the LAPACK/cuSolver parameters jobu and jobvt. The same option is used for both jobu and jobvt in MatX.
Values:
-
enumerator ALL#
Compute all columns of U and all rows of VT (Equivalent to jobu = jobvt = ‘A’)
-
enumerator REDUCED#
Compute only the first
min(m,ncolumns of U and rows of VT (Equivalent to jobu = jobvt = ‘S’)
-
enumerator NONE#
Compute no columns of U or rows of VT (Equivalent to jobu = jobvt = ‘N’)
-
enumerator ALL#
Examples#
(mtie(Uv, Sv, VTv) = svd(Av)).run(this->exec);