Skip to main content

cusolverDnXgesvd

Function cusolverDnXgesvd 

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

DataTypeADataTypeSDataTypeUDataTypeVTComputeTypeMeaning
CUDA_R_32FCUDA_R_32FCUDA_R_32FCUDA_R_32FCUDA_R_32FSGESVD
CUDA_R_64FCUDA_R_64FCUDA_R_64FCUDA_R_64FCUDA_R_64FDGESVD
CUDA_C_32FCUDA_R_32FCUDA_C_32FCUDA_C_32FCUDA_C_32FCGESVD
CUDA_C_64FCUDA_R_64FCUDA_C_64FCUDA_C_64FCUDA_C_64FZGESVD

§Parameters

  • handle: Handle to the cuSolverDN library context.
  • params: Structure with information collected by cusolverDnSetAdvOptions.
  • jobu: Specifies options for computing all or part of the matrix U: = ‘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 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, if jobu = ‘O’, A is overwritten with U; if jobvt = ‘O’, A is overwritten with VT; otherwise, 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). If jobu = ‘A’, U contains the $m \times m$ unitary matrix U. If jobu = ‘S’, U contains the first min(m,n) columns of U. If jobu = ‘N’ or ‘O’, U is not referenced.
  • ldu: Leading dimension of two-dimensional array used to store matrix U. If jobu = ‘A’ or ‘S’, ldu >= max(1,m). Otherwise, ldu >= 1.
  • dataTypeVT: Data type of array VT.
  • VT: Array of dimension ldvt * n with ldvt is not less than max(1,n). If jobvt = ‘A’, VT contains the $n \times n$ unitary matrix V**T. If jobvt = ‘S’, VT contains the first min(m,n) rows of V**T. If jobvt = ‘N’ or ‘O’, VT is not referenced.
  • ldvt: Leading dimension of two-dimensional array used to store matrix VT. If jobvt = ‘A’, ldvt >= max(1,n). If jobvt = ‘S’, ldvt >= max(1,min(m,n)). Otherwise, ldvt >= 1.
  • computeType: Data type of computation.
  • bufferOnDevice: Device workspace. Array of type void of size workspaceInBytesOnDevice bytes.
  • workspaceInBytesOnDevice: Size in bytes of bufferOnDevice, returned by cusolverDnXgesvd_bufferSize.
  • bufferOnHost: Host workspace. Array of type void of size workspaceInBytesOnHost bytes.
  • workspaceInBytesOnHost: Size in bytes of bufferOnHost, returned by cusolverDnXgesvd_bufferSize.
  • info: If info = 0, the operation is successful. If info = -i, the i-th parameter is wrong (not counting handle). If info > 0, info indicates how many superdiagonals of an intermediate bidiagonal form did not converge to zero.

§Return value