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 n

  • jobz – Compute all, part, or none of matrices U and VT

  • algo – For Host SVD calls, whether to use more efficient divide-and-conquer based gesdd routine or the QR factorization based gesvd routine. gesdd can run significantly faster, especially for large matrices. However, gesdd requires \( O(\min(M,N) ^ 2) \) memory as compared to \( O(\max(M,N)) \) for gesvd, 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 k for SVDMode::REDUCED and ... x m x m otherwise.

  • S - A tensor of shape ... x k containing 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 n for SVDMode::REDUCED and ... x n x n otherwise.

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,n columns 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’)

enum class matx::SVDHostAlgo#

Controls the LAPACK driver used for SVD on host.

Values:

enumerator QR#

QR-based method (corresponds to gesvd)

enumerator DC#

Divide and Conquer method (corresponds to gesdd)

Examples#

(mtie(Uv, Sv, VTv) = svd(Av)).run(this->exec);