Skip to main content

cusolverDnSgesvdjBatched

Function cusolverDnSgesvdjBatched 

Source
pub unsafe extern "C" fn cusolverDnSgesvdjBatched(
    handle: cusolverDnHandle_t,
    jobz: cusolverEigMode_t,
    m: c_int,
    n: c_int,
    A: *mut f32,
    lda: c_int,
    S: *mut f32,
    U: *mut f32,
    ldu: c_int,
    V: *mut f32,
    ldv: c_int,
    work: *mut f32,
    lwork: c_int,
    info: *mut c_int,
    params: gesvdjInfo_t,
    batchSize: c_int,
) -> cusolverStatus_t
Expand description

The helper functions below can calculate the sizes needed for pre-allocated buffer.

The S and D data types are real valued single and double precision, respectively.

The C and Z data types are complex valued single and double precision, respectively.

This function computes singular values and singular vectors of a sequence of general $m \times n$ matrices: $$ A_{j} = U_{j}\*\Sigma_{j}\*V_{j}^{H} $$

where $\Sigma_{j}$ is a real $m \times n$ diagonal matrix which is zero except for its min(m,n) diagonal elements. $U_{j}$ (left singular vectors) is an $m \times m$ unitary matrix and $V_{j}$ (right singular vectors) is a $n \times n$ unitary matrix. The diagonal elements of $\Sigma_{j}$ are the singular values of $A_{j}$ in either descending order or non-sorting order.

gesvdjBatched performs gesvdj on each matrix. It requires that all matrices are of the same size m,n no greater than 32 and are packed in contiguous way, $$ \begin{split}A = \begin{pmatrix} {A0} & {A1} & \cdots \\ \end{pmatrix}\end{split} $$

Each matrix is column-major with leading dimension lda, so the formula for random access is $A_{k}\operatorname{(i,j)} = {A\lbrack\ i\ +\ lda\*j\ +\ lda\*n\*k\rbrack}$.

The parameter S also contains singular values of each matrix in contiguous way, $$ \begin{split}S = \begin{pmatrix} {S0} & {S1} & \cdots \\ \end{pmatrix}\end{split} $$

The formula for random access of S is $S_{k}\operatorname{(j)} = {S\lbrack\ j\ +\ min(m,n)\*k\rbrack}$.

Except for tolerance and maximum sweeps, gesvdjBatched can either sort the singular values in descending order (default) or chose as-is (without sorting) by the function cusolverDnXgesvdjSetSortEig. If the user packs several tiny matrices into diagonal blocks of one matrix, non-sorting option can separate singular values of those tiny matrices.

gesvdjBatched cannot report residual and executed sweeps by function cusolverDnXgesvdjGetResidual and cusolverDnXgesvdjGetSweeps. Any call of the above two returns cusolverStatus_t::CUSOLVER_STATUS_NOT_SUPPORTED. The user needs to compute residual explicitly.

The user has to provide working space pointed by input parameter work. The input parameter lwork is the size of the working space, and it is returned by gesvdjBatched_bufferSize(). Please note that the size in bytes of the working space is equal to sizeof(<type>) * lwork.

The output parameter info is an integer array of size batchSize. If the function returns cusolverStatus_t::CUSOLVER_STATUS_INVALID_VALUE, the first element info\[0\] = -i (less than zero) indicates i-th parameter is wrong (not counting handle). Otherwise, if info\[i\] = min(m,n)+1, gesvdjBatched does not converge on i-th matrix under given tolerance and maximum sweeps.

Please visit cuSOLVER Library Samples - gesvdjBatched for a code example.