pub unsafe extern "C" fn cusolverDnXgesvd(
handle: cusolverDnHandle_t,
params: cusolverDnParams_t,
jobu: c_schar,
jobvt: c_schar,
m: i64,
n: i64,
dataTypeA: cudaDataType,
A: *mut c_void,
lda: i64,
dataTypeS: cudaDataType,
S: *mut c_void,
dataTypeU: cudaDataType,
U: *mut c_void,
ldu: i64,
dataTypeVT: cudaDataType,
VT: *mut c_void,
ldvt: i64,
computeType: cudaDataType,
bufferOnDevice: *mut c_void,
workspaceInBytesOnDevice: size_t,
bufferOnHost: *mut c_void,
workspaceInBytesOnHost: size_t,
info: *mut c_int,
) -> cusolverStatus_tExpand description
The helper functions below can calculate the sizes needed for pre-allocated buffer.
The following routine:
This function computes the singular value decomposition (SVD) of an $m \times n$ matrix A and corresponding the left and/or right singular vectors. The SVD is written:
$$
A = U\*\Sigma\*V^{H}
$$
where $\Sigma$ is an $m \times n$ matrix which is zero except for its min(m,n) diagonal elements, U is an $m \times m$ unitary matrix, and V is an $n \times n$ unitary matrix. The diagonal elements of $\Sigma$ are the singular values of A; they are real and non-negative, and are returned in descending order. The first min(m,n) columns of U and V are the left and right singular vectors of A.
The user has to provide device and host working spaces which are pointed by input parameters bufferOnDevice and bufferOnHost. The input parameters workspaceInBytesOnDevice (and workspaceInBytesOnHost) is size in bytes of the device (and host) working space, and it is returned by cusolverDnXgesvd_bufferSize.
If output parameter info = -i (less than zero), the i-th parameter is wrong (not counting handle). if bdsqr did not converge, info specifies how many superdiagonals of an intermediate bidiagonal form did not converge to zero.
Currently, cusolverDnXgesvd supports only the default algorithm.
Algorithms supported by cusolverDnXgesvd
cusolverAlgMode_t::CUSOLVER_ALG_0 or NULL | Default algorithm. |
Please visit cuSOLVER Library Samples - Xgesvd for a code example.
Remark 1: gesvd only supports m>=n.
Remark 2: the routine returns $V^H$, not V.
List of input arguments for cusolverDnXgesvd_bufferSize and cusolverDnXgesvd:
The generic API has three different types, dataTypeA is data type of the matrix A, dataTypeS is data type of the vector S and dataTypeU is data type of the matrix U, dataTypeVT is data type of the matrix VT, computeType is compute type of the operation. cusolverDnXgesvd only supports the following four combinations.
Valid combination of data type and compute type
| DataTypeA | DataTypeS | DataTypeU | DataTypeVT | ComputeType | Meaning |
|---|---|---|---|---|---|
CUDA_R_32F | CUDA_R_32F | CUDA_R_32F | CUDA_R_32F | CUDA_R_32F | SGESVD |
CUDA_R_64F | CUDA_R_64F | CUDA_R_64F | CUDA_R_64F | CUDA_R_64F | DGESVD |
CUDA_C_32F | CUDA_R_32F | CUDA_C_32F | CUDA_C_32F | CUDA_C_32F | CGESVD |
CUDA_C_64F | CUDA_R_64F | CUDA_C_64F | CUDA_C_64F | CUDA_C_64F | ZGESVD |
§Parameters
handle: Handle to the cuSolverDN library context.params: Structure with information collected bycusolverDnSetAdvOptions.jobu: Specifies options for computing all or part of the matrixU: = ‘A’: all m columns of U are returned in array U: = ‘S’: the first min(m,n) columns of U (the left singular vectors) are returned in the array U; = ‘O’: the first min(m,n) columns of U (the left singular vectors) are overwritten on the array A; = ‘N’: no columns of U (no left singular vectors) are computed.jobvt: Specifies options for computing all or part of the matrix V**T: = ‘A’: all N rows of V**T are returned in the array VT; = ‘S’: the first min(m,n) rows of V**T (the right singular vectors) are returned in the array VT; = ‘O’: the first min(m,n) rows of V**T (the right singular vectors) are overwritten on the array A; = ‘N’: no rows of V**T (no right singular vectors) are computed.m: Number of rows of matrixA.n: Number of columns of matrixA.dataTypeA: Data type of arrayA.A: Array of dimensionlda * nwithldais not less thanmax(1,m). On exit, ifjobu= ‘O’,Ais overwritten withU; ifjobvt= ‘O’,Ais overwritten withVT; otherwise, the contents ofAare destroyed.lda: Leading dimension of two-dimensional array used to store matrixA.dataTypeS: Data type of arrayS.S: Real array of dimensionmin(m,n). The singular values of A, sorted so thatS(i) >= S(i+1).dataTypeU: Data type of arrayU.U: Array of dimensionldu * mwithlduis not less thanmax(1,m). Ifjobu= ‘A’,Ucontains the $m \times m$ unitary matrixU. Ifjobu= ‘S’,Ucontains the first min(m,n) columns of U. Ifjobu= ‘N’ or ‘O’,Uis not referenced.ldu: Leading dimension of two-dimensional array used to store matrixU. Ifjobu= ‘A’ or ‘S’,ldu >= max(1,m). Otherwise,ldu >= 1.dataTypeVT: Data type of arrayVT.VT: Array of dimensionldvt * nwithldvtis not less thanmax(1,n). Ifjobvt= ‘A’,VTcontains the $n \times n$ unitary matrix V**T. Ifjobvt= ‘S’,VTcontains the first min(m,n) rows of V**T. Ifjobvt= ‘N’ or ‘O’,VTis not referenced.ldvt: Leading dimension of two-dimensional array used to store matrixVT. Ifjobvt= ‘A’,ldvt >= max(1,n). Ifjobvt= ‘S’,ldvt >= max(1,min(m,n)). Otherwise,ldvt >= 1.computeType: Data type of computation.bufferOnDevice: Device workspace. Array of typevoidof sizeworkspaceInBytesOnDevicebytes.workspaceInBytesOnDevice: Size in bytes ofbufferOnDevice, returned bycusolverDnXgesvd_bufferSize.bufferOnHost: Host workspace. Array of typevoidof sizeworkspaceInBytesOnHostbytes.workspaceInBytesOnHost: Size in bytes ofbufferOnHost, returned bycusolverDnXgesvd_bufferSize.info: Ifinfo = 0, the operation is successful. Ifinfo = -i, thei-thparameter is wrong (not counting handle). Ifinfo > 0,infoindicates how many superdiagonals of an intermediate bidiagonal form did not converge to zero.
§Return value
cusolverStatus_t::CUSOLVER_STATUS_INTERNAL_ERROR: An internal operation failed.cusolverStatus_t::CUSOLVER_STATUS_INVALID_VALUE: Invalid parameters were passed (m,n<0, orlda<max(1,m), orldu<1, or ifjobu= ‘S’ or ‘A’,ldu< m, orldvt<1, or ifjobvt= ‘A’ldvt<n, or ifjobvt= ‘S’ldvt<min(m,n), orjobu,jobvtare none of ‘N’, ‘O’, ‘S’, ‘A’, orjobu=jobvt= ‘O’ ).cusolverStatus_t::CUSOLVER_STATUS_NOT_INITIALIZED: The library was not initialized.cusolverStatus_t::CUSOLVER_STATUS_SUCCESS: The operation completed successfully.