gesvd#

Functions

void sgesvd(
    const char*          jobu,
    const char*          jobvt,
    const INT            m,
    const INT            n,
          f32*  restrict A,
    const INT            lda,
          f32*  restrict S,
          f32*  restrict U,
    const INT            ldu,
          f32*  restrict VT,
    const INT            ldvt,
          f32*  restrict work,
    const INT            lwork,
          INT*           info
);
void sgesvd(const char *jobu, const char *jobvt, const INT m, const INT n, f32 *restrict A, const INT lda, f32 *restrict S, f32 *restrict U, const INT ldu, f32 *restrict VT, const INT ldvt, f32 *restrict work, const INT lwork, INT *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 V**T, not V.

Parameters

in
jobu

Specifies options for computing all or part of U: 'A': all m columns of U are returned in array U; 'S': the first min(m,n) columns of U are returned in U; 'O': the first min(m,n) columns of U are overwritten on A; 'N': no columns of U are computed.

in
jobvt

Specifies options for computing all or part of V**T: 'A': all n rows of V**T are returned in array VT; 'S': the first min(m,n) rows of V**T are returned in VT; 'O': the first min(m,n) rows of V**T are overwritten on A; 'N': no rows of V**T are computed. jobvt and jobu cannot both be 'O'.

in
m

The number of rows of the input matrix A. m>=0.

in
n

The number of columns of the input matrix A. n>=0.

inout
A

Single precision array, dimension (lda, n). On entry, the m-by-n matrix A. On exit, contents depend on jobu and jobvt.

in
lda

The leading dimension of the array A. lda>=max(1,m).

out
S

Single precision array, dimension (min(m,n)). The singular values of A, sorted so that S[i]>=S[i+1].

out
U

Single precision array, dimension (ldu, ucol). If jobu='A', U contains the m-by-m orthogonal matrix U; if jobu='S', U contains the first min(m,n) columns of U; if jobu='N' or 'O', U is not referenced.

in
ldu

The leading dimension of the array U. ldu>=1; if jobu='S' or 'A', ldu>=m.

out
VT

Single precision array, dimension (ldvt, n). If jobvt='A', VT contains the n-by-n orthogonal 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.

in
ldvt

The leading dimension of the array VT. ldvt>=1; if jobvt='A', ldvt>=n; if jobvt='S', ldvt>=min(m,n).

out
work

Single precision array, dimension (max(1,lwork)). On exit, if info=0, work[0] returns the optimal lwork; if info>0, work[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.

in
lwork

The dimension of the array work.

lwork >= max(1, 5*min(m,n)) for the paths (see comments inside code):

  • PATH 1 (m much larger than n, jobu='N')

  • PATH 1t (n much larger than m, jobvt='N')

lwork >= max(1, 3*min(m,n) + max(m,n), 5*min(m,n)) for the other paths.

For good performance, lwork should generally be larger. If lwork=-1, a workspace query is assumed; the routine only calculates the optimal size of the work array, returns this value as the first entry of the work array.

out
info

info=0: successful exit. info<0: if info=-i, the i-th argument had an illegal value. info>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.

Functions

void dgesvd(
    const char*          jobu,
    const char*          jobvt,
    const INT            m,
    const INT            n,
          f64*  restrict A,
    const INT            lda,
          f64*  restrict S,
          f64*  restrict U,
    const INT            ldu,
          f64*  restrict VT,
    const INT            ldvt,
          f64*  restrict work,
    const INT            lwork,
          INT*           info
);
void dgesvd(const char *jobu, const char *jobvt, const INT m, const INT n, f64 *restrict A, const INT lda, f64 *restrict S, f64 *restrict U, const INT ldu, f64 *restrict VT, const INT ldvt, f64 *restrict work, const INT lwork, INT *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 V**T, not V.

Parameters

in
jobu

Specifies options for computing all or part of U: 'A': all m columns of U are returned in array U; 'S': the first min(m,n) columns of U are returned in U; 'O': the first min(m,n) columns of U are overwritten on A; 'N': no columns of U are computed.

in
jobvt

Specifies options for computing all or part of V**T: 'A': all n rows of V**T are returned in array VT; 'S': the first min(m,n) rows of V**T are returned in VT; 'O': the first min(m,n) rows of V**T are overwritten on A; 'N': no rows of V**T are computed. jobvt and jobu cannot both be 'O'.

in
m

The number of rows of the input matrix A. m>=0.

in
n

The number of columns of the input matrix A. n>=0.

inout
A

Double precision array, dimension (lda, n). On entry, the m-by-n matrix A. On exit, contents depend on jobu and jobvt.

in
lda

The leading dimension of the array A. lda>=max(1,m).

out
S

Double precision array, dimension (min(m,n)). The singular values of A, sorted so that S[i]>=S[i+1].

out
U

Double precision array, dimension (ldu, ucol). If jobu='A', U contains the m-by-m orthogonal matrix U; if jobu='S', U contains the first min(m,n) columns of U; if jobu='N' or 'O', U is not referenced.

in
ldu

The leading dimension of the array U. ldu>=1; if jobu='S' or 'A', ldu>=m.

out
VT

Double precision array, dimension (ldvt, n). If jobvt='A', VT contains the n-by-n orthogonal 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.

in
ldvt

The leading dimension of the array VT. ldvt>=1; if jobvt='A', ldvt>=n; if jobvt='S', ldvt>=min(m,n).

out
work

Double precision array, dimension (max(1,lwork)). On exit, if info=0, work[0] returns the optimal lwork; if info>0, work[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.

in
lwork

The dimension of the array work.

lwork >= max(1, 5*min(m,n)) for the paths (see comments inside code):

  • PATH 1 (m much larger than n, jobu='N')

  • PATH 1t (n much larger than m, jobvt='N')

lwork >= max(1, 3*min(m,n) + max(m,n), 5*min(m,n)) for the other paths.

For good performance, lwork should generally be larger. If lwork=-1, a workspace query is assumed; the routine only calculates the optimal size of the work array, returns this value as the first entry of the work array.

out
info

info=0: successful exit. info<0: if info=-i, the i-th argument had an illegal value. info>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.

Functions

void cgesvd(
    const char*          jobu,
    const char*          jobvt,
    const INT            m,
    const INT            n,
          c64*  restrict A,
    const INT            lda,
          f32*  restrict S,
          c64*  restrict U,
    const INT            ldu,
          c64*  restrict VT,
    const INT            ldvt,
          c64*  restrict work,
    const INT            lwork,
          f32*  restrict rwork,
          INT*           info
);
void cgesvd(const char *jobu, const char *jobvt, const INT m, const INT n, c64 *restrict A, const INT lda, f32 *restrict S, c64 *restrict U, const INT ldu, c64 *restrict VT, const INT ldvt, c64 *restrict work, const INT lwork, f32 *restrict rwork, INT *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 V**H, not V.

Parameters

in
jobu

Specifies options for computing all or part of U: 'A': all m columns of U are returned in array U; 'S': the first min(m,n) columns of U are returned in U; 'O': the first min(m,n) columns of U are overwritten on A; 'N': no columns of U are computed.

in
jobvt

Specifies options for computing all or part of V**H: 'A': all n rows of V**H are returned in array VT; 'S': the first min(m,n) rows of V**H are returned in VT; 'O': the first min(m,n) rows of V**H are overwritten on A; 'N': no rows of V**H are computed. jobvt and jobu cannot both be 'O'.

in
m

The number of rows of the input matrix A. m>=0.

in
n

The number of columns of the input matrix A. n>=0.

inout
A

Complex*8 array, dimension (lda, n). On entry, the m-by-n matrix A. On exit, contents depend on jobu and jobvt.

in
lda

The leading dimension of the array A. lda>=max(1,m).

out
S

Single precision array, dimension (min(m,n)). The singular values of A, sorted so that S[i]>=S[i+1].

out
U

Complex*8 array, dimension (ldu, ucol). If jobu='A', U contains the m-by-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.

in
ldu

The leading dimension of the array U. ldu>=1; if jobu='S' or 'A', ldu>=m.

out
VT

Complex*8 array, dimension (ldvt, n). If jobvt='A', VT contains the n-by-n unitary matrix V**H; if jobvt='S', VT contains the first min(m,n) rows of V**H; if jobvt='N' or 'O', VT is not referenced.

in
ldvt

The leading dimension of the array VT. ldvt>=1; if jobvt='A', ldvt>=n; if jobvt='S', ldvt>=min(m,n).

out
work

Complex*8 array, dimension (max(1,lwork)). On exit, if info=0, work[0] returns the optimal lwork.

in
lwork

The dimension of the array work. lwork>=max(1,2*min(m,n)+max(m,n)). For good performance, lwork should generally be larger. If lwork=-1, a workspace query is assumed; the routine only calculates the optimal size of the work array, returns this value as the first entry of the work array.

out
rwork

Single precision array, dimension (5*min(m,n)). On exit, if info>0, rwork[0:min(m,n)-2] 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
info

info=0: successful exit. info<0: if info=-i, the i-th argument had an illegal value. info>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.

Functions

void zgesvd(
    const char*          jobu,
    const char*          jobvt,
    const INT            m,
    const INT            n,
          c128* restrict A,
    const INT            lda,
          f64*  restrict S,
          c128* restrict U,
    const INT            ldu,
          c128* restrict VT,
    const INT            ldvt,
          c128* restrict work,
    const INT            lwork,
          f64*  restrict rwork,
          INT*           info
);
void zgesvd(const char *jobu, const char *jobvt, const INT m, const INT n, c128 *restrict A, const INT lda, f64 *restrict S, c128 *restrict U, const INT ldu, c128 *restrict VT, const INT ldvt, c128 *restrict work, const INT lwork, f64 *restrict rwork, INT *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 V**H, not V.

Parameters

in
jobu

Specifies options for computing all or part of U: 'A': all m columns of U are returned in array U; 'S': the first min(m,n) columns of U are returned in U; 'O': the first min(m,n) columns of U are overwritten on A; 'N': no columns of U are computed.

in
jobvt

Specifies options for computing all or part of V**H: 'A': all n rows of V**H are returned in array VT; 'S': the first min(m,n) rows of V**H are returned in VT; 'O': the first min(m,n) rows of V**H are overwritten on A; 'N': no rows of V**H are computed. jobvt and jobu cannot both be 'O'.

in
m

The number of rows of the input matrix A. m>=0.

in
n

The number of columns of the input matrix A. n>=0.

inout
A

Complex*16 array, dimension (lda, n). On entry, the m-by-n matrix A. On exit, contents depend on jobu and jobvt.

in
lda

The leading dimension of the array A. lda>=max(1,m).

out
S

Double precision array, dimension (min(m,n)). The singular values of A, sorted so that S[i]>=S[i+1].

out
U

Complex*16 array, dimension (ldu, ucol). If jobu='A', U contains the m-by-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.

in
ldu

The leading dimension of the array U. ldu>=1; if jobu='S' or 'A', ldu>=m.

out
VT

Complex*16 array, dimension (ldvt, n). If jobvt='A', VT contains the n-by-n unitary matrix V**H; if jobvt='S', VT contains the first min(m,n) rows of V**H; if jobvt='N' or 'O', VT is not referenced.

in
ldvt

The leading dimension of the array VT. ldvt>=1; if jobvt='A', ldvt>=n; if jobvt='S', ldvt>=min(m,n).

out
work

Complex*16 array, dimension (max(1,lwork)). On exit, if info=0, work[0] returns the optimal lwork.

in
lwork

The dimension of the array work. lwork>=max(1,2*min(m,n)+max(m,n)). For good performance, lwork should generally be larger. If lwork=-1, a workspace query is assumed; the routine only calculates the optimal size of the work array, returns this value as the first entry of the work array.

out
rwork

Double precision array, dimension (5*min(m,n)). On exit, if info>0, rwork[0:min(m,n)-2] 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
info

info=0: successful exit. info<0: if info=-i, the i-th argument had an illegal value. info>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.