MAGMA  2.0.0
Matrix Algebra for GPU and Multicore Architectures
 All Classes Files Functions Friends Groups Pages
double precision

Functions

magma_int_t magma_dgesdd (magma_vec_t jobz, magma_int_t m, magma_int_t n, double *A, magma_int_t lda, double *s, double *U, magma_int_t ldu, double *VT, magma_int_t ldvt, double *work, magma_int_t lwork, magma_int_t *iwork, magma_int_t *info)
 DGESDD computes the singular value decomposition (SVD) of a real M-by-N matrix A, optionally computing the left and right singular vectors, by using divide-and-conquer method. More...
 
magma_int_t magma_dgesvd (magma_vec_t jobu, magma_vec_t jobvt, magma_int_t m, magma_int_t n, double *A, magma_int_t lda, double *s, double *U, magma_int_t ldu, double *VT, magma_int_t ldvt, double *work, magma_int_t lwork, magma_int_t *info)
 DGESVD computes the singular value decomposition (SVD) of a real M-by-N matrix A, optionally computing the left and/or right singular vectors. More...
 

Detailed Description

Function Documentation

magma_int_t magma_dgesdd ( magma_vec_t  jobz,
magma_int_t  m,
magma_int_t  n,
double *  A,
magma_int_t  lda,
double *  s,
double *  U,
magma_int_t  ldu,
double *  VT,
magma_int_t  ldvt,
double *  work,
magma_int_t  lwork,
magma_int_t *  iwork,
magma_int_t *  info 
)

DGESDD computes the singular value decomposition (SVD) of a real M-by-N matrix A, optionally computing the left and right singular vectors, by using divide-and-conquer method.

The SVD is written

A = U * SIGMA * transpose(V)

where SIGMA is an M-by-N matrix which is zero except for its min(m,n) diagonal elements, U is an M-by-M orthogonal matrix, and V is an N-by-N orthogonal 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.

Note that the routine returns VT = V**T, not V.

The divide and conquer algorithm makes very mild assumptions about floating point arithmetic. It will work on machines with a guard digit in add/subtract, or on those binary machines without guard digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2. It could conceivably fail on hexadecimal or decimal machines without guard digits, but we know of none.

Parameters
[in]jobzmagma_vec_t Specifies options for computing all or part of the matrix U:
  • = MagmaAllVec: all M columns of U and all N rows of V**T are returned in the arrays U and VT;
  • = MagmaSomeVec: the first min(M,N) columns of U and the first min(M,N) rows of V**T are returned in the arrays U and VT;
  • = MagmaOverwriteVec: If M >= N, the first N columns of U are overwritten on the array A and all rows of V**T are returned in the array VT; otherwise, all columns of U are returned in the array U and the first M rows of V**T are overwritten on the array A;
  • = MagmaNoVec: no columns of U or rows of V**T are computed.
[in]mINTEGER The number of rows of the input matrix A. M >= 0.
[in]nINTEGER The number of columns of the input matrix A. N >= 0.
[in,out]ADOUBLE PRECISION array, dimension (LDA,N) On entry, the M-by-N matrix A. On exit,
  • if JOBZ = MagmaOverwriteVec, if M >= N, A is overwritten with the first N columns of U (the left singular vectors, stored columnwise); otherwise, A is overwritten with the first M rows of V**T (the right singular vectors, stored owwise).
  • if JOBZ != MagmaOverwriteVec, the contents of A are destroyed.
[in]ldaINTEGER The leading dimension of the array A. LDA >= max(1,M).
[out]sDOUBLE PRECISION array, dimension (min(M,N)) The singular values of A, sorted so that S(i) >= S(i + 1).
[out]UDOUBLE PRECISION array, dimension (LDU,UCOL) UCOL = M if JOBZ = MagmaAllVec or JOBZ = MagmaOverwriteVec and M < N; UCOL = min(M,N) if JOBZ = MagmaSomeVec.
  • If JOBZ = MagmaAllVec or JOBZ = MagmaOverwriteVec and M < N, U contains the M-by-M orthogonal matrix U;
  • if JOBZ = MagmaSomeVec, U contains the first min(M,N) columns of U (the left singular vectors, stored columnwise);
  • if JOBZ = MagmaOverwriteVec and M >= N, or JOBZ = MagmaNoVec, U is not referenced.
[in]lduINTEGER The leading dimension of the array U. LDU >= 1; if JOBZ = MagmaSomeVec or MagmaAllVec or JOBZ = MagmaOverwriteVec and M < N, LDU >= M.
[out]VTDOUBLE PRECISION array, dimension (LDVT,N)
  • If JOBZ = MagmaAllVec or JOBZ = MagmaOverwriteVec and M >= N, VT contains the N-by-N orthogonal matrix V**T;
  • if JOBZ = MagmaSomeVec, VT contains the first min(M,N) rows of V**T (the right singular vectors, stored rowwise);
  • if JOBZ = MagmaOverwriteVec and M < N, or JOBZ = MagmaNoVec, VT is not referenced.
[in]ldvtINTEGER The leading dimension of the array VT. LDVT >= 1; if JOBZ = MagmaAllVec or JOBZ = MagmaOverwriteVec and M >= N, LDVT >= N; if JOBZ = MagmaSomeVec, LDVT >= min(M,N).
[out]work(workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) On exit, if INFO = 0, WORK[0] returns the optimal LWORK.
[in]lworkINTEGER The dimension of the array WORK. Let x = max(M,N) and y = min(M,N). The optimal block size nb can be obtained through magma_get_dgesvd_nb( M, N ). The threshold for x >> y currently is x >= y*11/6. Required size different than in LAPACK.* In most cases, these sizes should give optimal performance for both MAGMA and LAPACK.
  • If JOBZ = MagmaNoVec, if x >> y, LWORK >= 3*y + max( (2*y)*nb, 7*y ); otherwise, LWORK >= 3*y + max( (x+y)*nb, 7*y ).
  • If JOBZ = MagmaOverwriteVec, if x >> y, LWORK >= y*y + 3*y + max( (2*y)*nb, 4*y*y + 4*y ), prefer LWORK >= y*y + 3*y + max( (2*y)*nb, 4*y*y + 4*y, y*y + y*nb ); otherwise, LWORK >= 3*y + max( (x+y)*nb, 4*y*y + 4*y ).
  • If JOBZ = MagmaSomeVec, if x >> y, LWORK >= y*y + 3*y + max( (2*y)*nb, 3*y*y + 4*y ); otherwise, LWORK >= 3*y + max( (x+y)*nb, 3*y*y + 4*y ).
  • If JOBZ = MagmaAllVec, if x >> y, LWORK >= y*y + max( 3*y + max( (2*y)*nb, 3*y*y + 4*y ), y + x ), prefer LWORK >= y*y + max( 3*y + max( (2*y)*nb, 3*y*y + 4*y ), y + x*nb ); otherwise, LWORK >= 3*y + max( (x+y)*nb, 3*y*y + 4*y ).
    If LWORK = -1 but other input arguments are legal, WORK[0] returns the optimal LWORK.
iwork(workspace) INTEGER array, dimension (8*min(M,N))
[out]infoINTEGER
  • = 0: successful exit.
  • < 0: if INFO = -i, the i-th argument had an illegal value.
  • > 0: DBDSDC did not converge, updating process failed.

Further Details

Based on contributions by Ming Gu and Huan Ren, Computer Science Division, University of California at Berkeley, USA

magma_int_t magma_dgesvd ( magma_vec_t  jobu,
magma_vec_t  jobvt,
magma_int_t  m,
magma_int_t  n,
double *  A,
magma_int_t  lda,
double *  s,
double *  U,
magma_int_t  ldu,
double *  VT,
magma_int_t  ldvt,
double *  work,
magma_int_t  lwork,
magma_int_t *  info 
)

DGESVD computes the singular value decomposition (SVD) of a real M-by-N matrix A, optionally computing the left and/or right singular vectors.

The SVD is written

A = U * SIGMA * conjugate-transpose(V)

where SIGMA is an M-by-N matrix which is zero except for its min(m,n) diagonal elements, U is an M-by-M orthogonal matrix, and V is an N-by-N orthogonal 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.

Note that the routine returns V**T, not V.

Parameters
[in]jobumagma_vec_t Specifies options for computing all or part of the matrix U:
  • = MagmaAllVec: all M columns of U are returned in array U:
  • = MagmaSomeVec: the first min(m,n) columns of U (the left singular vectors) are returned in the array U;
  • = MagmaOverwriteVec: the first min(m,n) columns of U (the left singular vectors) are overwritten on the array A;
  • = MagmaNoVec: no columns of U (no left singular vectors) are computed.
[in]jobvtmagma_vec_t Specifies options for computing all or part of the matrix V**T:
  • = MagmaAllVec: all N rows of V**T are returned in the array VT;
  • = MagmaSomeVec: the first min(m,n) rows of V**T (the right singular vectors) are returned in the array VT;
  • = MagmaOverwriteVec: the first min(m,n) rows of V**T (the right singular vectors) are overwritten on the array A;
  • = MagmaNoVec: no rows of V**T (no right singular vectors) are computed.
    JOBVT and JOBU cannot both be MagmaOverwriteVec.
[in]mINTEGER The number of rows of the input matrix A. M >= 0.
[in]nINTEGER The number of columns of the input matrix A. N >= 0.
[in,out]ADOUBLE_PRECISION array, dimension (LDA,N) On entry, the M-by-N matrix A. On exit,
  • if JOBU = MagmaOverwriteVec, A is overwritten with the first min(m,n) columns of U (the left singular vectors, stored columnwise);
  • if JOBVT = MagmaOverwriteVec, A is overwritten with the first min(m,n) rows of V**T (the right singular vectors, stored rowwise);
  • if JOBU != MagmaOverwriteVec and JOBVT != MagmaOverwriteVec, the contents of A are destroyed.
[in]ldaINTEGER The leading dimension of the array A. LDA >= max(1,M).
[out]sDOUBLE_PRECISION array, dimension (min(M,N)) The singular values of A, sorted so that S(i) >= S(i+1).
[out]UDOUBLE_PRECISION array, dimension (LDU,UCOL) (LDU,M) if JOBU = MagmaAllVec or (LDU,min(M,N)) if JOBU = MagmaSomeVec.
  • If JOBU = MagmaAllVec, U contains the M-by-M orthogonal matrix U;
  • if JOBU = MagmaSomeVec, U contains the first min(m,n) columns of U (the left singular vectors, stored columnwise);
  • if JOBU = MagmaNoVec or MagmaOverwriteVec, U is not referenced.
[in]lduINTEGER The leading dimension of the array U. LDU >= 1; if JOBU = MagmaSomeVec or MagmaAllVec, LDU >= M.
[out]VTDOUBLE_PRECISION array, dimension (LDVT,N)
  • If JOBVT = MagmaAllVec, VT contains the N-by-N orthogonal matrix V**T;
  • if JOBVT = MagmaSomeVec, VT contains the first min(m,n) rows of V**T (the right singular vectors, stored rowwise);
  • if JOBVT = MagmaNoVec or MagmaOverwriteVec, VT is not referenced.
[in]ldvtINTEGER The leading dimension of the array VT. LDVT >= 1;
  • if JOBVT = MagmaAllVec, LDVT >= N;
  • if JOBVT = MagmaSomeVec, LDVT >= min(M,N).
[out]work(workspace) DOUBLE_PRECISION array, dimension (MAX(1,LWORK)) On exit, if INFO = 0, WORK[0] returns the required LWORK. if INFO > 0, WORK(2:MIN(M,N)) contains the unconverged superdiagonal elements of an upper bidiagonal matrix B whose diagonal is in S (not necessarily sorted). B satisfies A = U * B * VT, so it has the same singular values as A, and singular vectors related by U and VT.
[in]lworkINTEGER The dimension of the array WORK. LWORK >= (M+N)*nb + 3*min(M,N). For optimum performance with some paths (m >> n and jobu=A,S,O; or n >> m and jobvt=A,S,O), LWORK >= (M+N)*nb + 3*min(M,N) + 2*min(M,N)**2 (see comments inside code).
If LWORK = -1, then a workspace query is assumed; the routine only calculates the required size of the WORK array, returns this value as the first entry of the WORK array, and no error message related to LWORK is issued by XERBLA.
[out]infoINTEGER
  • = 0: successful exit.
  • < 0: if INFO = -i, the i-th argument had an illegal value.
  • > 0: if DBDSQR did not converge, INFO specifies how many superdiagonals of an intermediate bidiagonal form B did not converge to zero. See the description of RWORK above for details.