pub unsafe extern "C" fn cusolverDnXgesvdp(
handle: cusolverDnHandle_t,
params: cusolverDnParams_t,
jobz: cusolverEigMode_t,
econ: c_int,
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,
dataTypeV: cudaDataType,
V: *mut c_void,
ldv: i64,
computeType: cudaDataType,
bufferOnDevice: *mut c_void,
workspaceInBytesOnDevice: size_t,
bufferOnHost: *mut c_void,
workspaceInBytesOnHost: size_t,
d_info: *mut c_int,
h_err_sigma: *mut f64,
) -> cusolverStatus_tExpand description
The helper functions below can calculate the sizes needed for pre-allocated buffer.
The routine below:
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.
cusolverDnXgesvdp combines polar decomposition in [14] and cusolverDnXsyevd to compute SVD. It is much faster than cusolverDnXgesvd which is based on QR algorithm. However polar decomposition in [14] may not deliver a full unitary matrix when the matrix A has a singular value close to zero. To workaround the issue when the singular value is close to zero, we add a small perturbation so polar decomposition can deliver the correct result. The consequence is inaccurate singular values shifted by this perturbation. The output parameter h_err_sigma is the magnitude of this perturbation. In other words, h_err_sigma shows the accuracy of SVD.
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 cusolverDnXgesvdp_bufferSize.
If output parameter info = -i (less than zero), the i-th parameter is wrong (not counting handle).
Currently, cusolverDnXgesvdp supports only the default algorithm.
Algorithms supported by cusolverDnXgesvdp
cusolverAlgMode_t::CUSOLVER_ALG_0 or NULL | Default algorithm. |
Please visit cuSOLVER Library Samples - Xgesvdp for a code example.
Remark 1: gesvdp supports n>=m as well.
Remark 2: the routine returns V, not $V^{H}$
List of input arguments for cusolverDnXgesvdp_bufferSize and cusolverDnXgesvdp:
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, dataTypeV is data type of the matrix V, computeType is compute type of the operation. cusolverDnXgesvdp 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 | SGESVDP |
CUDA_R_64F | CUDA_R_64F | CUDA_R_64F | CUDA_R_64F | CUDA_R_64F | DGESVDP |
CUDA_C_32F | CUDA_R_32F | CUDA_C_32F | CUDA_C_32F | CUDA_C_32F | CGESVDP |
CUDA_C_64F | CUDA_R_64F | CUDA_C_64F | CUDA_C_64F | CUDA_C_64F | ZGESVDP |
§Parameters
handle: Handle to the cuSolverDN library context.params: Structure with information collected bycusolverDnSetAdvOptions.jobz: Specifies options to either compute singular values only or compute singular vectors as well:jobz=cusolverEigMode_t::CUSOLVER_EIG_MODE_NOVECTOR: Compute singular values only.jobz=cusolverEigMode_t::CUSOLVER_EIG_MODE_VECTOR: Compute singular values and singular vectors.econ:econ = 1for economy size forUandV.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, 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).Ucontains the $m \times m$ unitary matrixU. Ifecon=1, only reports firstmin(m,n)columns ofU.ldu: Leading dimension of two-dimensional array used to store matrixU.dataTypeV: Data type of arrayV.V: Array of dimensionldv * nwithldvis not less thanmax(1,n).Vcontains the $n \times n$ unitary matrix V. ifecon=1, only reports firstmin(m,n)columns ofV.ldv: Leading dimension of two-dimensional array used to store matrixV.computeType: Data type of computation.bufferOnDevice: Device workspace. Array of typevoidof sizeworkspaceInBytesOnDevicebytes.workspaceInBytesOnDevice: Size in bytes ofbufferOnDevice, returned bycusolverDnXgesvdp_bufferSize.bufferOnHost: Host workspace. Array of typevoidof sizeworkspaceInBytesOnHostbytes.workspaceInBytesOnHost: Size in bytes ofbufferOnHost, returned bycusolverDnXgesvdp_bufferSize.h_err_sigma: Magnitude of the perturbation, showing the accuracy of SVD.
§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.