Skip to main content

cusolverDnXgesvdp

Function cusolverDnXgesvdp 

Source
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_t
Expand 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 NULLDefault 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

DataTypeADataTypeSDataTypeUDataTypeVComputeTypeMeaning
CUDA_R_32FCUDA_R_32FCUDA_R_32FCUDA_R_32FCUDA_R_32FSGESVDP
CUDA_R_64FCUDA_R_64FCUDA_R_64FCUDA_R_64FCUDA_R_64FDGESVDP
CUDA_C_32FCUDA_R_32FCUDA_C_32FCUDA_C_32FCUDA_C_32FCGESVDP
CUDA_C_64FCUDA_R_64FCUDA_C_64FCUDA_C_64FCUDA_C_64FZGESVDP

§Parameters

  • handle: Handle to the cuSolverDN library context.
  • params: Structure with information collected by cusolverDnSetAdvOptions.
  • 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 = 1 for economy size for U and V.
  • m: Number of rows of matrix A.
  • n: Number of columns of matrix A.
  • dataTypeA: Data type of array A.
  • A: Array of dimension lda * n with lda is not less than max(1,m). On exit, the contents of A are destroyed.
  • lda: Leading dimension of two-dimensional array used to store matrix A.
  • dataTypeS: Data type of array S.
  • S: Real array of dimension min(m,n). The singular values of A, sorted so that S(i) >= S(i+1).
  • dataTypeU: Data type of array U.
  • U: Array of dimension ldu * m with ldu is not less than max(1,m). U contains the $m \times m$ unitary matrix U. If econ=1, only reports first min(m,n) columns of U.
  • ldu: Leading dimension of two-dimensional array used to store matrix U.
  • dataTypeV: Data type of array V.
  • V: Array of dimension ldv * n with ldv is not less than max(1,n). V contains the $n \times n$ unitary matrix V. if econ=1, only reports first min(m,n) columns of V.
  • ldv: Leading dimension of two-dimensional array used to store matrix V.
  • computeType: Data type of computation.
  • bufferOnDevice: Device workspace. Array of type void of size workspaceInBytesOnDevice bytes.
  • workspaceInBytesOnDevice: Size in bytes of bufferOnDevice, returned by cusolverDnXgesvdp_bufferSize.
  • bufferOnHost: Host workspace. Array of type void of size workspaceInBytesOnHost bytes.
  • workspaceInBytesOnHost: Size in bytes of bufferOnHost, returned by cusolverDnXgesvdp_bufferSize.
  • h_err_sigma: Magnitude of the perturbation, showing the accuracy of SVD.

§Return value