pub unsafe extern "C" fn cusolverDnXgesvdr(
handle: cusolverDnHandle_t,
params: cusolverDnParams_t,
jobu: c_schar,
jobv: c_schar,
m: i64,
n: i64,
k: i64,
p: i64,
niters: i64,
dataTypeA: cudaDataType,
A: *mut c_void,
lda: i64,
dataTypeSrand: cudaDataType,
Srand: *mut c_void,
dataTypeUrand: cudaDataType,
Urand: *mut c_void,
ldUrand: i64,
dataTypeVrand: cudaDataType,
Vrand: *mut c_void,
ldVrand: i64,
computeType: cudaDataType,
bufferOnDevice: *mut c_void,
workspaceInBytesOnDevice: size_t,
bufferOnHost: *mut c_void,
workspaceInBytesOnHost: size_t,
d_info: *mut c_int,
) -> cusolverStatus_tExpand description
The helper functions below can calculate the sizes needed for pre-allocated buffer.
The routine below
This function computes the approximated rank-k singular value decomposition (k-SVD) of an $m \times n$ matrix A and the corresponding left and/or right singular vectors. The k-SVD is written as:
$$
A_{k}\approx U\*\Sigma\*V^{H}
$$
where $\Sigma$ is a $k \times k$ matrix which is zero except for its diagonal elements, U is an $m \times k$ orthonormal matrix, and V is an $k \times n$ orthonormal matrix. The diagonal elements of $\Sigma$ are the approximated singular values of A; they are real and non-negative, and are returned in descending order. The columns of U and V are the top-k left and right singular vectors of A.
cusolverDnXgesvdr implements randomized methods described in [15] to compute k-SVD that is accurate with high probability if the conditions described in [15] hold. cusolverDnXgesvdr is intended to compute a very small portion of the spectrum (meaning that k is very small compared to min(m,n)). of A fast and with good quality, specially when the dimensions of the matrix are large.
The accuracy of the method depends on the spectrum of A, the number of power iterations niters, the oversampling parameter p and the ratio between p and the dimensions of the matrix A. Larger values of oversampling p or larger number of iterations niters might produce more accurate approximations, but it will also increase the run time of cusolverDnXgesvdr.
Our recommendation is to use two iterations and set the oversampling to at least 2k. Once the solver provides enough accuracy, adjust the values of k and niters for better performance.
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 cusolverDnXgesvdr_bufferSize.
If output parameter info = -i (less than zero), the i-th parameter is wrong (not counting handle).
Currently, cusolverDnXgesvdr supports only the default algorithm.
Algorithms supported by cusolverDnXgesvdr
cusolverAlgMode_t::CUSOLVER_ALG_0 or NULL | Default algorithm. |
Please visit cuSOLVER Library Samples - Xgesvdr for a code example.
Remark 1: gesvdr supports n>=m as well.
Remark 2: the routine returns V, not $V^{H}$
List of input arguments for cusolverDnXgesvdr_bufferSize and cusolverDnXgesvdr:
The generic API has five 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, dataTypeV is data type of the matrix V, computeType is compute type of the operation. cusolverDnXgesvdr only supports the following four combinations.
Valid combination of data type and compute type
| DataTypeA | DataTypeS | DataTypeU | DataTypeV | ComputeType | Meaning |
|---|---|---|---|---|---|
CUDA_R_32F | CUDA_R_32F | CUDA_R_32F | CUDA_R_32F | CUDA_R_32F | SGESVDR |
CUDA_R_64F | CUDA_R_64F | CUDA_R_64F | CUDA_R_64F | CUDA_R_64F | DGESVDR |
CUDA_C_32F | CUDA_R_32F | CUDA_C_32F | CUDA_C_32F | CUDA_C_32F | CGESVDR |
CUDA_C_64F | CUDA_R_64F | CUDA_C_64F | CUDA_C_64F | CUDA_C_64F | ZGESVDR |
§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: = ‘S’: the first k columns of U (the left singular vectors) are returned in the array U; = ‘N’: no columns of U (no left singular vectors) are computed.jobv: Specifies options for computing all or part of the matrix V: = ‘S’: the first k rows of V (the right singular vectors) are returned in the array V; = ‘N’: no rows of V (no right singular vectors) are computed.m: Number of rows of matrixA.n: Number of columns of matrixA.k: Rank of the k-SVD decomposition of matrixA.rankis less thanmin(m,n).p: Oversampling. The size of the subspace will be(k + p).(k+p)is less thanmin(m,n).niters: Number of iteration of power method.dataTypeA: Data type of arrayA.A: Array of dimensionlda * nwithldais not less thanmax(1,m). On exit, the contents ofAare destroyed.lda: Leading dimension of two-dimensional array used to store matrixA.computeType: Data type of computation.bufferOnDevice: Device workspace. Array of typevoidof sizeworkspaceInBytesOnDevicebytes.workspaceInBytesOnDevice: Size in bytes ofbufferOnDevice, returned bycusolverDnXgesvdr_bufferSize.bufferOnHost: Host workspace. Array of typevoidof sizeworkspaceInBytesOnHostbytes.workspaceInBytesOnHost: Size in bytes ofbufferOnHost, returned bycusolverDnXgesvdr_bufferSize.d_info: Ifinfo = 0, the operation is successful. Ifinfo = -i, thei-thparameter is wrong (not counting handle).
§Return value
cusolverStatus_t::CUSOLVER_STATUS_INTERNAL_ERROR: An internal operation failed.cusolverStatus_t::CUSOLVER_STATUS_INVALID_VALUE: Invalid parameters were passed (m,n<0orlda<max(1,m)orldu<max(1,m)orldv<max(1,n)).cusolverStatus_t::CUSOLVER_STATUS_NOT_INITIALIZED: The library was not initialized.cusolverStatus_t::CUSOLVER_STATUS_SUCCESS: The operation completed successfully.