MAGMA  2.7.1
Matrix Algebra for GPU and Multicore Architectures
 All Classes Files Functions Friends Groups Pages
gesvd: SVD using QR iteration

Functions

magma_int_t magma_cgesvd (magma_vec_t jobu, magma_vec_t jobvt, magma_int_t m, magma_int_t n, magmaFloatComplex *A, magma_int_t lda, float *s, magmaFloatComplex *U, magma_int_t ldu, magmaFloatComplex *VT, magma_int_t ldvt, magmaFloatComplex *work, magma_int_t lwork, float *rwork, magma_int_t *info)
 CGESVD computes the singular value decomposition (SVD) of a complex M-by-N matrix A, optionally computing the left and/or right singular vectors. 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...
 
magma_int_t magma_sgesvd (magma_vec_t jobu, magma_vec_t jobvt, magma_int_t m, magma_int_t n, float *A, magma_int_t lda, float *s, float *U, magma_int_t ldu, float *VT, magma_int_t ldvt, float *work, magma_int_t lwork, magma_int_t *info)
 SGESVD computes the singular value decomposition (SVD) of a real M-by-N matrix A, optionally computing the left and/or right singular vectors. More...
 
magma_int_t magma_zgesvd (magma_vec_t jobu, magma_vec_t jobvt, magma_int_t m, magma_int_t n, magmaDoubleComplex *A, magma_int_t lda, double *s, magmaDoubleComplex *U, magma_int_t ldu, magmaDoubleComplex *VT, magma_int_t ldvt, magmaDoubleComplex *work, magma_int_t lwork, double *rwork, magma_int_t *info)
 ZGESVD computes the singular value decomposition (SVD) of a complex M-by-N matrix A, optionally computing the left and/or right singular vectors. More...
 

Detailed Description

Function Documentation

magma_int_t magma_cgesvd ( magma_vec_t  jobu,
magma_vec_t  jobvt,
magma_int_t  m,
magma_int_t  n,
magmaFloatComplex *  A,
magma_int_t  lda,
float *  s,
magmaFloatComplex *  U,
magma_int_t  ldu,
magmaFloatComplex *  VT,
magma_int_t  ldvt,
magmaFloatComplex *  work,
magma_int_t  lwork,
float *  rwork,
magma_int_t *  info 
)

CGESVD computes the singular value decomposition (SVD) of a complex 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 unitary matrix, and V is an N-by-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.

Note that the routine returns VT = V**H, 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**H:
  • = MagmaAllVec: all N rows of V**H are returned in the array VT;
  • = MagmaSomeVec: the first min(m,n) rows of V**H (the right singular vectors) are returned in the array VT;
  • = MagmaOverwriteVec: the first min(m,n) rows of V**H (the right singular vectors) are overwritten on the array A;
  • = MagmaNoVec: no rows of V**H (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]ACOMPLEX 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**H (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]sREAL array, dimension (min(M,N)) The singular values of A, sorted so that S(i) >= S(i+1).
[out]UCOMPLEX 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 unitary 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]VTCOMPLEX array, dimension (LDVT,N)
  • If JOBVT = MagmaAllVec, VT contains the N-by-N unitary matrix V**H;
  • if JOBVT = MagmaSomeVec, VT contains the first min(m,n) rows of V**H (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) COMPLEX array, dimension (MAX(1,LWORK)) On exit, if INFO = 0, WORK[0] returns the required LWORK.
[in]lworkINTEGER The dimension of the array WORK. If lwork = -1, a workspace query is assumed. The optimal size for the WORK array is calculated and stored in WORK[0], and no other work except argument checking is performed.
Let mx = max(M,N) and mn = min(M,N). The threshold for mx >> mn is currently mx >= 1.6*mn. For job: N=None, O=Overwrite, S=Some, A=All. Paths below assume M >= N; for N > M swap jobu and jobvt.
Because of varying nb for different subroutines, formulas below are an upper bound. Querying gives an exact number. The optimal block size nb can be obtained through magma_get_dgesvd_nb(M,N). For many cases, there is a fast algorithm, and a slow algorithm that uses less workspace. Here are sizes for both cases.
Optimal lwork (fast algorithm) for mx >> mn: Path 1: jobu=N, jobvt=any 2*mn + 2*mn*nb Path 2: jobu=O, jobvt=N mn*mn + 2*mn + 2*mn*nb or mn*mn + max(2*mn + 2*mn*nb, mx*mn) Path 3: jobu=O, jobvt=A,S mn*mn + 2*mn + 2*mn*nb or mn*mn + max(2*mn + 2*mn*nb, mx*mn) Path 4: jobu=S, jobvt=N mn*mn + 2*mn + 2*mn*nb Path 5: jobu=S, jobvt=O 2*mn*mn + 2*mn + 2*mn*nb Path 6: jobu=S, jobvt=A,S mn*mn + 2*mn + 2*mn*nb Path 7: jobu=A, jobvt=N mn*mn + max(2*mn + 2*mn*nb, mn + mx*nb) Path 8: jobu=A, jobvt=O 2*mn*mn + max(2*mn + 2*mn*nb, mn + mx*nb) Path 9: jobu=A, jobvt=A,S mn*mn + max(2*mn + 2*mn*nb, mn + mx*nb) for mx >= mn, but not mx >> mn: Path 10: jobu=any, jobvt=any 2*mn + (mx + mn)*nb
Optimal lwork (slow algorithm) for mx >> mn: Path 1: jobu=N, jobvt=any n/a Path 2: jobu=O, jobvt=N 2*mn + (mx + mn)*nb Path 3-9: 2*mn + max(2*mn*nb, mx*nb) for mx >= mn, but not mx >> mn: Path 10: jobu=any, jobvt=any n/a
MAGMA requires the optimal sizes above, while LAPACK has the same optimal sizes but the minimum sizes below.
LAPACK minimum lwork (fast algorithm) for mx >> mn: Path 1: jobu=N, jobvt=any 3*mn Path 2: jobu=O, jobvt=N mn*mn + 3*mn Path 3: jobu=O, jobvt=A,S mn*mn + 3*mn Path 4: jobu=S, jobvt=N mn*mn + 3*mn Path 5: jobu=S, jobvt=O 2*mn*mn + 3*mn Path 6: jobu=S, jobvt=A,S mn*mn + 3*mn Path 7: jobu=A, jobvt=N mn*mn + max(3*mn, mn + mx) Path 8: jobu=A, jobvt=O 2*mn*mn + max(3*mn, mn + mx) Path 9: jobu=A, jobvt=A,S mn*mn + max(3*mn, mn + mx) for mx >= mn, but not mx >> mn: Path 10: jobu=any, jobvt=any 2*mn + mx
LAPACK minimum lwork (slow algorithm) for mx >> mn: Path 1: jobu=N, jobvt=any n/a Path 2-9: 2*mn + mx for mx >= mn, but not mx >> mn: Path 10: jobu=any, jobvt=any n/a
rwork(workspace) REAL array, dimension (5*min(M,N)) On exit, if INFO > 0, RWORK(1:MIN(M,N)-1) 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.
[out]infoINTEGER
  • = 0: successful exit.
  • < 0: if INFO = -i, the i-th argument had an illegal value.
  • > 0: if CBDSQR 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.
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 * 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.

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. If lwork = -1, a workspace query is assumed. The optimal size for the WORK array is calculated and stored in WORK[0], and no other work except argument checking is performed.
Let mx = max(M,N) and mn = min(M,N). The threshold for mx >> mn is currently mx >= 1.6*mn. For job: N=None, O=Overwrite, S=Some, A=All. Paths below assume M >= N; for N > M swap jobu and jobvt.
Because of varying nb for different subroutines, formulas below are an upper bound. Querying gives an exact number. The optimal block size nb can be obtained through magma_get_dgesvd_nb(M,N). For many cases, there is a fast algorithm, and a slow algorithm that uses less workspace. Here are sizes for both cases.
Optimal lwork (fast algorithm) for mx >> mn: Path 1: jobu=N, jobvt=any 3*mn + 2*mn*nb Path 2: jobu=O, jobvt=N mn*mn + 3*mn + 2*mn*nb or mn*mn + max(3*mn + 2*mn*nb, mn + mx*mn) Path 3: jobu=O, jobvt=A,S mn*mn + 3*mn + 2*mn*nb or mn*mn + max(3*mn + 2*mn*nb, mn + mx*mn) Path 4: jobu=S, jobvt=N mn*mn + 3*mn + 2*mn*nb Path 5: jobu=S, jobvt=O 2*mn*mn + 3*mn + 2*mn*nb Path 6: jobu=S, jobvt=A,S mn*mn + 3*mn + 2*mn*nb Path 7: jobu=A, jobvt=N mn*mn + max(3*mn + 2*mn*nb, mn + mx*nb) Path 8: jobu=A, jobvt=O 2*mn*mn + max(3*mn + 2*mn*nb, mn + mx*nb) Path 9: jobu=A, jobvt=A,S mn*mn + max(3*mn + 2*mn*nb, mn + mx*nb) for mx >= mn, but not mx >> mn: Path 10: jobu=any, jobvt=any 3*mn + (mx + mn)*nb
Optimal lwork (slow algorithm) for mx >> mn: Path 1: jobu=N, jobvt=any n/a Path 2: jobu=O, jobvt=N 3*mn + (mx + mn)*nb Path 3-9: 3*mn + max(2*mn*nb, mx*nb) for mx >= mn, but not mx >> mn: Path 10: jobu=any, jobvt=any n/a
MAGMA requires the optimal sizes above, while LAPACK has the same optimal sizes but the minimum sizes below.
LAPACK minimum lwork (fast algorithm) for mx >> mn: Path 1: jobu=N, jobvt=any 5*mn Path 2: jobu=O, jobvt=N mn*mn + 5*mn Path 3: jobu=O, jobvt=A,S mn*mn + 5*mn Path 4: jobu=S, jobvt=N mn*mn + 5*mn Path 5: jobu=S, jobvt=O 2*mn*mn + 5*mn Path 6: jobu=S, jobvt=A,S mn*mn + 5*mn Path 7: jobu=A, jobvt=N mn*mn + max(5*mn, mn + mx) Path 8: jobu=A, jobvt=O 2*mn*mn + max(5*mn, mn + mx) Path 9: jobu=A, jobvt=A,S mn*mn + max(5*mn, mn + mx) for mx >= mn, but not mx >> mn: Path 10: jobu=any, jobvt=any max(3*mn + mx, 5*mn)
LAPACK minimum lwork (slow algorithm) for mx >> mn: Path 1: jobu=N, jobvt=any n/a Path 2-9: max(3*mn + mx, 5*mn) for mx >= mn, but not mx >> mn: Path 10: jobu=any, jobvt=any n/a
[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 WORK above for details.
magma_int_t magma_sgesvd ( magma_vec_t  jobu,
magma_vec_t  jobvt,
magma_int_t  m,
magma_int_t  n,
float *  A,
magma_int_t  lda,
float *  s,
float *  U,
magma_int_t  ldu,
float *  VT,
magma_int_t  ldvt,
float *  work,
magma_int_t  lwork,
magma_int_t *  info 
)

SGESVD 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 * 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.

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]AREAL 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]sREAL array, dimension (min(M,N)) The singular values of A, sorted so that S(i) >= S(i+1).
[out]UREAL 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]VTREAL 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) REAL 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. If lwork = -1, a workspace query is assumed. The optimal size for the WORK array is calculated and stored in WORK[0], and no other work except argument checking is performed.
Let mx = max(M,N) and mn = min(M,N). The threshold for mx >> mn is currently mx >= 1.6*mn. For job: N=None, O=Overwrite, S=Some, A=All. Paths below assume M >= N; for N > M swap jobu and jobvt.
Because of varying nb for different subroutines, formulas below are an upper bound. Querying gives an exact number. The optimal block size nb can be obtained through magma_get_sgesvd_nb(M,N). For many cases, there is a fast algorithm, and a slow algorithm that uses less workspace. Here are sizes for both cases.
Optimal lwork (fast algorithm) for mx >> mn: Path 1: jobu=N, jobvt=any 3*mn + 2*mn*nb Path 2: jobu=O, jobvt=N mn*mn + 3*mn + 2*mn*nb or mn*mn + max(3*mn + 2*mn*nb, mn + mx*mn) Path 3: jobu=O, jobvt=A,S mn*mn + 3*mn + 2*mn*nb or mn*mn + max(3*mn + 2*mn*nb, mn + mx*mn) Path 4: jobu=S, jobvt=N mn*mn + 3*mn + 2*mn*nb Path 5: jobu=S, jobvt=O 2*mn*mn + 3*mn + 2*mn*nb Path 6: jobu=S, jobvt=A,S mn*mn + 3*mn + 2*mn*nb Path 7: jobu=A, jobvt=N mn*mn + max(3*mn + 2*mn*nb, mn + mx*nb) Path 8: jobu=A, jobvt=O 2*mn*mn + max(3*mn + 2*mn*nb, mn + mx*nb) Path 9: jobu=A, jobvt=A,S mn*mn + max(3*mn + 2*mn*nb, mn + mx*nb) for mx >= mn, but not mx >> mn: Path 10: jobu=any, jobvt=any 3*mn + (mx + mn)*nb
Optimal lwork (slow algorithm) for mx >> mn: Path 1: jobu=N, jobvt=any n/a Path 2: jobu=O, jobvt=N 3*mn + (mx + mn)*nb Path 3-9: 3*mn + max(2*mn*nb, mx*nb) for mx >= mn, but not mx >> mn: Path 10: jobu=any, jobvt=any n/a
MAGMA requires the optimal sizes above, while LAPACK has the same optimal sizes but the minimum sizes below.
LAPACK minimum lwork (fast algorithm) for mx >> mn: Path 1: jobu=N, jobvt=any 5*mn Path 2: jobu=O, jobvt=N mn*mn + 5*mn Path 3: jobu=O, jobvt=A,S mn*mn + 5*mn Path 4: jobu=S, jobvt=N mn*mn + 5*mn Path 5: jobu=S, jobvt=O 2*mn*mn + 5*mn Path 6: jobu=S, jobvt=A,S mn*mn + 5*mn Path 7: jobu=A, jobvt=N mn*mn + max(5*mn, mn + mx) Path 8: jobu=A, jobvt=O 2*mn*mn + max(5*mn, mn + mx) Path 9: jobu=A, jobvt=A,S mn*mn + max(5*mn, mn + mx) for mx >= mn, but not mx >> mn: Path 10: jobu=any, jobvt=any max(3*mn + mx, 5*mn)
LAPACK minimum lwork (slow algorithm) for mx >> mn: Path 1: jobu=N, jobvt=any n/a Path 2-9: max(3*mn + mx, 5*mn) for mx >= mn, but not mx >> mn: Path 10: jobu=any, jobvt=any n/a
[out]infoINTEGER
  • = 0: successful exit.
  • < 0: if INFO = -i, the i-th argument had an illegal value.
  • > 0: if SBDSQR did not converge, INFO specifies how many superdiagonals of an intermediate bidiagonal form B did not converge to zero. See the description of WORK above for details.
magma_int_t magma_zgesvd ( magma_vec_t  jobu,
magma_vec_t  jobvt,
magma_int_t  m,
magma_int_t  n,
magmaDoubleComplex *  A,
magma_int_t  lda,
double *  s,
magmaDoubleComplex *  U,
magma_int_t  ldu,
magmaDoubleComplex *  VT,
magma_int_t  ldvt,
magmaDoubleComplex *  work,
magma_int_t  lwork,
double *  rwork,
magma_int_t *  info 
)

ZGESVD computes the singular value decomposition (SVD) of a complex 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 unitary matrix, and V is an N-by-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.

Note that the routine returns VT = V**H, 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**H:
  • = MagmaAllVec: all N rows of V**H are returned in the array VT;
  • = MagmaSomeVec: the first min(m,n) rows of V**H (the right singular vectors) are returned in the array VT;
  • = MagmaOverwriteVec: the first min(m,n) rows of V**H (the right singular vectors) are overwritten on the array A;
  • = MagmaNoVec: no rows of V**H (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]ACOMPLEX_16 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**H (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]UCOMPLEX_16 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 unitary 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]VTCOMPLEX_16 array, dimension (LDVT,N)
  • If JOBVT = MagmaAllVec, VT contains the N-by-N unitary matrix V**H;
  • if JOBVT = MagmaSomeVec, VT contains the first min(m,n) rows of V**H (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) COMPLEX_16 array, dimension (MAX(1,LWORK)) On exit, if INFO = 0, WORK[0] returns the required LWORK.
[in]lworkINTEGER The dimension of the array WORK. If lwork = -1, a workspace query is assumed. The optimal size for the WORK array is calculated and stored in WORK[0], and no other work except argument checking is performed.
Let mx = max(M,N) and mn = min(M,N). The threshold for mx >> mn is currently mx >= 1.6*mn. For job: N=None, O=Overwrite, S=Some, A=All. Paths below assume M >= N; for N > M swap jobu and jobvt.
Because of varying nb for different subroutines, formulas below are an upper bound. Querying gives an exact number. The optimal block size nb can be obtained through magma_get_dgesvd_nb(M,N). For many cases, there is a fast algorithm, and a slow algorithm that uses less workspace. Here are sizes for both cases.
Optimal lwork (fast algorithm) for mx >> mn: Path 1: jobu=N, jobvt=any 2*mn + 2*mn*nb Path 2: jobu=O, jobvt=N mn*mn + 2*mn + 2*mn*nb or mn*mn + max(2*mn + 2*mn*nb, mx*mn) Path 3: jobu=O, jobvt=A,S mn*mn + 2*mn + 2*mn*nb or mn*mn + max(2*mn + 2*mn*nb, mx*mn) Path 4: jobu=S, jobvt=N mn*mn + 2*mn + 2*mn*nb Path 5: jobu=S, jobvt=O 2*mn*mn + 2*mn + 2*mn*nb Path 6: jobu=S, jobvt=A,S mn*mn + 2*mn + 2*mn*nb Path 7: jobu=A, jobvt=N mn*mn + max(2*mn + 2*mn*nb, mn + mx*nb) Path 8: jobu=A, jobvt=O 2*mn*mn + max(2*mn + 2*mn*nb, mn + mx*nb) Path 9: jobu=A, jobvt=A,S mn*mn + max(2*mn + 2*mn*nb, mn + mx*nb) for mx >= mn, but not mx >> mn: Path 10: jobu=any, jobvt=any 2*mn + (mx + mn)*nb
Optimal lwork (slow algorithm) for mx >> mn: Path 1: jobu=N, jobvt=any n/a Path 2: jobu=O, jobvt=N 2*mn + (mx + mn)*nb Path 3-9: 2*mn + max(2*mn*nb, mx*nb) for mx >= mn, but not mx >> mn: Path 10: jobu=any, jobvt=any n/a
MAGMA requires the optimal sizes above, while LAPACK has the same optimal sizes but the minimum sizes below.
LAPACK minimum lwork (fast algorithm) for mx >> mn: Path 1: jobu=N, jobvt=any 3*mn Path 2: jobu=O, jobvt=N mn*mn + 3*mn Path 3: jobu=O, jobvt=A,S mn*mn + 3*mn Path 4: jobu=S, jobvt=N mn*mn + 3*mn Path 5: jobu=S, jobvt=O 2*mn*mn + 3*mn Path 6: jobu=S, jobvt=A,S mn*mn + 3*mn Path 7: jobu=A, jobvt=N mn*mn + max(3*mn, mn + mx) Path 8: jobu=A, jobvt=O 2*mn*mn + max(3*mn, mn + mx) Path 9: jobu=A, jobvt=A,S mn*mn + max(3*mn, mn + mx) for mx >= mn, but not mx >> mn: Path 10: jobu=any, jobvt=any 2*mn + mx
LAPACK minimum lwork (slow algorithm) for mx >> mn: Path 1: jobu=N, jobvt=any n/a Path 2-9: 2*mn + mx for mx >= mn, but not mx >> mn: Path 10: jobu=any, jobvt=any n/a
rwork(workspace) DOUBLE PRECISION array, dimension (5*min(M,N)) On exit, if INFO > 0, RWORK(1:MIN(M,N)-1) 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.
[out]infoINTEGER
  • = 0: successful exit.
  • < 0: if INFO = -i, the i-th argument had an illegal value.
  • > 0: if ZBDSQR 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.