Singular Value Decomposition for General Matrices#
Background#
GESVD (GEneral Singular Value Decomposition) computes the singular values and, optionally, the left and/or right singular vectors of batched general matrices using the QR algorithm.
where:
\(A\) is an \(M \times N\) general matrix,
\(\Sigma\) is an \(M \times N\) matrix that is zero except for its \(\min(M, N)\) diagonal elements, which contain the singular values of \(A\) in descending order (singular values are always real and non-negative),
\(U\) is an \(M \times M\) unitary matrix containing the left singular vectors of \(A\), and
\(V^H\) is an \(N \times N\) unitary matrix representing the conjugate transpose of \(V\), containing the right singular vectors of \(A\).
Device API#
The cuSolverDx gesvd device functions are as follows (see Execution Methods):
// Compute singular values only
__device__ void execute(data_type* A, precision_type* S, data_type* workspace, status_type* info);
// Compute singular values only with runtime leading dimension
__device__ void execute(data_type* A, const unsigned int lda, precision_type* S,
data_type* workspace, status_type* info);
// Compute singular values and the left/right singular vectors
__device__ void execute(data_type* A, precision_type* S, data_type* U, data_type* VH,
data_type* workspace, status_type* info);
// Compute singular values and the left/right singular vectors with runtime leading dimensions
__device__ void execute(data_type* A, const unsigned int lda, precision_type* S,
data_type* U, const unsigned int ldu,
data_type* VH, const unsigned int ldvh,
data_type* workspace, status_type* info);
Parameters:
A: Batched \(M \times N\) input matrix. Leading dimension is \(\mathrm{lda} \geq M\) for column-major layout, or \(\mathrm{lda} \geq N\) for row-major layout.S: Array of size \(\min(M, N)\) per batch. On exit, contains the singular values of \(A\) in descending order. Since singular values are always real and non-negative,Sis of typeprecision_type(the underlying real type) rather thandata_type.U: Batched left singular vectors matrix. Storage size depends on thejobuconfiguration (see Storage requirements for U and VH).VH: Batched right singular vectors matrix (\(V^H\)). Storage size depends on thejobvtconfiguration (see Storage requirements for U and VH).workspace: Temporary buffer preallocated by the user. The required size can be obtained via workspace_size.info: Status code for each batch (see Return Status).
Note
The gesvd function returns \(V^H\) (the conjugate transpose of \(V\)) rather than \(V\) itself, consistent with standard LAPACK conventions.
Important
cuSolverDx gesvd supports both tall-skinny (\(M \geq N\)) and short-wide (\(M < N\)) matrices.
Job Options#
The Job operator controls whether singular vectors are computed and how they are stored.
Left singular vectors (jobu):
job::no_vectors:Uis ignored; no left singular vectors are computed.job::all_vectors: AllMcolumns of left singular vectors are returned inU.job::some_vectors: The first \(\min(M, N)\) columns of left singular vectors are returned inU.job::overwrite_vectors: The first \(\min(M, N)\) columns of left singular vectors overwriteA.
Right singular vectors (jobvt):
job::no_vectors:VHis ignored; no right singular vectors are computed.job::all_vectors: AllNrows of right singular vectors (as \(V^H\)) are returned inVH.job::some_vectors: The first \(\min(M, N)\) rows of right singular vectors (as \(V^H\)) are returned inVH.job::overwrite_vectors: The first \(\min(M, N)\) rows of right singular vectors (as \(V^H\)) overwriteA.
Job Configuration |
Size of |
Size of |
|---|---|---|
|
Not required |
Not required |
|
\(M \times M\) (leading dimension \(\mathrm{ldu} \geq M\)) |
\(N \times N\) (leading dimension \(\mathrm{ldvh} \geq N\)) |
|
\(M \times \min(M, N)\) (leading dimension \(\mathrm{ldu} \geq M\) if column-major, \(\mathrm{ldu} \geq \min(M, N)\) if row-major) |
\(\min(M, N) \times N\) (leading dimension \(\mathrm{ldvh} \geq \min(M, N)\) if column-major, \(\mathrm{ldvh} \geq N\) if row-major) |
|
Not required (output |
Not required (output |
Return Status#
The function returns a status code info for each batch:
info = 0: The function completed successfully.info > 0: The algorithm did not converge; specifically,infooff-diagonal elements failed to converge to zero.
Supported Configurations#
Arrangement:
A,U, andVHcan independently use column-major or row-major layouts. Use theArrangement<Arr, Urr, VHrr>operator, whereArr,Urr, andVHrrspecify the layouts forA,U, andVHrespectively (see Arrangement operator).Leading Dimensions: Leading dimensions for
A,U, andVHcan be set independently using theLeadingDimension<LDA, LDU, LDVH>operator (see LeadingDimension operator).Job Options: The
Joboperator acceptsjob::no_vectors,job::all_vectors,job::some_vectors, orjob::overwrite_vectorsfor left and right singular vectors (see Job operator):job::multiply_vectorsis not supported forgesvd; using it results in a compile-time error.Both
jobuandjobvtcannot be set tojob::overwrite_vectorssimultaneously; this results in a compile-time error.If
job::no_vectorsis selected andU/VHpointers are provided, they are ignored.