gesvd(3)
π¦ gesvd(3) β Library Functions Manual π
okay so bestie, welcome to gesvd from the Library Functions Manual β this is the SVD + QR iteration page and it's a long one, so buckle up π
β¨ NAME β¨
gesvd β gesvd: SVD, QR iteration. that's it, that's the whole vibe. it does singular value decompositions and it does them correctly.
πΈ SYNOPSIS πΈ
π Functions
subroutine cgesvd (jobu, jobvt, m, n, a, lda, s, u, ldu, vt, ldvt, work, lwork, rwork, info)β CGESVD computes the singular value decomposition (SVD) for GE matricessubroutine dgesvd (jobu, jobvt, m, n, a, lda, s, u, ldu, vt, ldvt, work, lwork, info)β DGESVD computes the singular value decomposition (SVD) for GE matricessubroutine sgesvd (jobu, jobvt, m, n, a, lda, s, u, ldu, vt, ldvt, work, lwork, info)β SGESVD computes the singular value decomposition (SVD) for GE matricessubroutine zgesvd (jobu, jobvt, m, n, a, lda, s, u, ldu, vt, ldvt, work, lwork, rwork, info)β ZGESVD computes the singular value decomposition (SVD) for GE matrices
π Detailed Description π
no extra prose here bestie, it goes straight into the good stuff π
π Function Documentation π
π subroutine cgesvd
subroutine cgesvd (character jobu, character jobvt, integer m, integer n,
complex, dimension( lda, * ) a, integer lda, real, dimension( * ) s,
complex, dimension( ldu, * ) u, integer ldu, complex, dimension( ldvt, *
) vt, integer ldvt, complex, dimension( * ) work, integer lwork, real,
dimension( * ) rwork, integer info)
CGESVD computes the singular value decomposition (SVD) for GE matrices β periodt.
π§ Purpose:
okay so this is the moment. 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 like this, iconic math incoming:
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 returnsV**H, notV. not me warning you about this, it's literally the whole personality of this function π
πΈ Parameters
JOBUβJOBUisCHARACTER*1. Specifies options for computing all or part of the matrixU:= 'A': allMcolumns ofUare returned in arrayU:= 'S': the firstmin(m,n)columns ofU(the left singular vectors) are returned in the arrayU;= 'O': the firstmin(m,n)columns ofU(the left singular vectors) are overwritten on the arrayA;= 'N': no columns ofU(no left singular vectors) are computed.
JOBVTβJOBVTisCHARACTER*1. Specifies options for computing all or part of the matrixV**H:= 'A': allNrows ofV**Hare returned in the arrayVT;= 'S': the firstmin(m,n)rows ofV**H(the right singular vectors) are returned in the arrayVT;= 'O': the firstmin(m,n)rows ofV**H(the right singular vectors) are overwritten on the arrayA;= 'N': no rows ofV**H(no right singular vectors) are computed.
β οΈJOBVTandJOBUcannot both be'O'. like, literally cannot, don't even try it π
MβMisINTEGER. The number of rows of the input matrixA.M >= 0.NβNisINTEGER. The number of columns of the input matrixA.N >= 0.AβAisCOMPLEXarray, dimension(LDA,N). On entry, theM-by-NmatrixA. On exit:- if
JOBU = 'O',Ais overwritten with the firstmin(m,n)columns ofU(the left singular vectors, stored columnwise); - if
JOBVT = 'O',Ais overwritten with the firstmin(m,n)rows ofV**H(the right singular vectors, stored rowwise); - if
JOBU .ne. 'O'andJOBVT .ne. 'O', the contents ofAare destroyed.
- if
π hi yes, "destroyed" is the technical term. your beautiful matrix is gone. she served her purpose.
LDAβLDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,M).SβSisREALarray, dimension(min(M,N)). The singular values ofA, sorted so thatS(i) >= S(i+1). descending order, the way nature intended β¨UβUisCOMPLEXarray, dimension(LDU,UCOL)β that's(LDU,M)ifJOBU = 'A'or(LDU,min(M,N))ifJOBU = 'S'. IfJOBU = 'A',Ucontains theM-by-Munitary matrixU; ifJOBU = 'S',Ucontains the firstmin(m,n)columns ofU(the left singular vectors, stored columnwise); ifJOBU = 'N'or'O',Uis not referenced. she's simply not part of the conversation πLDUβLDUisINTEGER. The leading dimension of the arrayU.LDU >= 1; ifJOBU = 'S'or'A',LDU >= M.VTβVTisCOMPLEXarray, dimension(LDVT,N). IfJOBVT = 'A',VTcontains theN-by-Nunitary matrixV**H; ifJOBVT = 'S',VTcontains the firstmin(m,n)rows ofV**H(the right singular vectors, stored rowwise); ifJOBVT = 'N'or'O',VTis not referenced.LDVTβLDVTisINTEGER. The leading dimension of the arrayVT.LDVT >= 1; ifJOBVT = 'A',LDVT >= N; ifJOBVT = 'S',LDVT >= min(M,N).WORKβWORKisCOMPLEXarray, dimension(MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK. free real estate π«ΆLWORKβLWORKisINTEGER. The dimension of the arrayWORK.LWORK >= MAX(1,2*MIN(M,N)+MAX(M,N)).- For good performance,
LWORKshould generally be larger. (bestie. give her room to breathe. she deserves it.) - If
LWORK = -1, then a workspace query is assumed; the routine only calculates the optimal size of theWORKarray, returns this value as the first entry of theWORKarray, and no error message related toLWORKis issued byXERBLA.
RWORKβRWORKisREALarray, dimension(5*min(M,N)). On exit, ifINFO > 0,RWORK(1:MIN(M,N)-1)contains the unconverged superdiagonal elements of an upper bidiagonal matrixBwhose diagonal is inS(not necessarily sorted).BsatisfiesA = U * B * VT, so it has the same singular values asA, and singular vectors related byUandVT. iykyk π₯INFOβINFOisINTEGER.= 0: successful exit.< 0: ifINFO = -i, thei-th argument had an illegal value.> 0: ifCBDSQRdid not converge,INFOspecifies how many superdiagonals of an intermediate bidiagonal formBdid not converge to zero. See the description ofRWORKabove for details.
π Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Definition at line 212 of file cgesvd.f.
π« subroutine dgesvd
subroutine dgesvd (character jobu, character jobvt, integer m, integer n,
double precision, dimension( lda, * ) a, integer lda, double precision,
dimension( * ) s, double precision, dimension( ldu, * ) u, integer ldu,
double precision, dimension( ldvt, * ) vt, integer ldvt, double
precision, dimension( * ) work, integer lwork, integer info)
DGESVD computes the singular value decomposition (SVD) for GE matrices β same energy, but make it real (literally, it's the double precision one) π
π§ Purpose:
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 returnsV**T, notV. (the complex sibling returnsV**Hβ same reason, different conjugation situation. the way that these two are cousins π)
πΈ Parameters
JOBUβJOBUisCHARACTER*1. Specifies options for computing all or part of the matrixU:= 'A': allMcolumns ofUare returned in arrayU:= 'S': the firstmin(m,n)columns ofU(the left singular vectors) are returned in the arrayU;= 'O': the firstmin(m,n)columns ofU(the left singular vectors) are overwritten on the arrayA;= 'N': no columns ofU(no left singular vectors) are computed.
JOBVTβJOBVTisCHARACTER*1. Specifies options for computing all or part of the matrixV**T:= 'A': allNrows ofV**Tare returned in the arrayVT;= 'S': the firstmin(m,n)rows ofV**T(the right singular vectors) are returned in the arrayVT;= 'O': the firstmin(m,n)rows ofV**T(the right singular vectors) are overwritten on the arrayA;= 'N': no rows ofV**T(no right singular vectors) are computed.
β οΈJOBVTandJOBUcannot both be'O'. same rule, still not negotiable π«
MβMisINTEGER. The number of rows of the input matrixA.M >= 0.NβNisINTEGER. The number of columns of the input matrixA.N >= 0.AβAβ okay soAis aDOUBLE PRECISIONarray with dimension(LDA,N). On entry, itβs theM-by-NmatrixA. On exit? It depends, bestie:- if
JOBU = 'O',Ais overwritten with the firstmin(m,n)columns ofU(the left singular vectors, stored columnwise); - if
JOBVT = 'O',Ais overwritten with the firstmin(m,n)rows ofV**T(the right singular vectors, stored rowwise); - if
JOBU .ne. 'O'andJOBVT .ne. 'O', the contents ofAare destroyed. Yep, gone. π
- if
LDAβLDAisINTEGER, the leading dimension of the arrayA. Constraint:LDA >= max(1,M). Periodt.SβSisDOUBLE PRECISIONarray, dimension(min(M,N)). It holds the singular values ofA, sorted so thatS(i) >= S(i+1). Slay, descending order. β¨UβUisDOUBLE PRECISIONarray, dimension(LDU,UCOL)β thatβs(LDU,M)ifJOBU = 'A', or(LDU,min(M,N))ifJOBU = 'S'. Specifically:- if
JOBU = 'A',Ucontains theM-by-Morthogonal matrixU; - if
JOBU = 'S',Ucontains the firstmin(m,n)columns ofU(the left singular vectors, stored columnwise); - if
JOBU = 'N'or'O',Uis not referenced. Not even looked at. π
- if
LDUβLDUisINTEGER, the leading dimension of the arrayU.LDU >= 1; ifJOBU = 'S'or'A', thenLDU >= M.VTβVTisDOUBLE PRECISIONarray, dimension(LDVT,N).- If
JOBVT = 'A',VTcontains theN-by-Northogonal matrixV**T; - if
JOBVT = 'S',VTcontains the firstmin(m,n)rows ofV**T(the right singular vectors, stored rowwise); - if
JOBVT = 'N'or'O',VTis not referenced.
- If
LDVTβLDVTisINTEGER, the leading dimension of the arrayVT.LDVT >= 1; ifJOBVT = 'A',LDVT >= N; ifJOBVT = 'S',LDVT >= min(M,N).WORKβWORKisDOUBLE PRECISIONarray, dimension(MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK; ifINFO > 0,WORK(2:MIN(M,N))contains the unconverged superdiagonal elements of an upper bidiagonal matrixBwhose diagonal is inS(not necessarily sorted). AndBsatisfiesA = U * B * VT, so it has the same singular values asA, and singular vectors related byUandVT. Iconic math behavior. π§LWORKβLWORKisINTEGER, the dimension of the arrayWORK. Here are the requirements: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,
LWORKshould generally be larger. Like, bigger is better, no cap. - If
LWORK = -1, then a workspace query is assumed; the routine only calculates the optimal size of theWORKarray, returns this value as the first entry of theWORKarray, and no error message related toLWORKis issued byXERBLA. So itβs just reporting the vibe, not doing the whole job. π«Ά
INFOβINFOisINTEGER:= 0: successful exit. π< 0: ifINFO = -i, thei-th argument had an illegal value. Rude.> 0: ifDBDSQRdid not converge,INFOspecifies how many superdiagonals of an intermediate bidiagonal formBdid not converge to zero. See the description ofWORKabove for details.
π Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Definition at line 209 of file dgesvd.f.
π« subroutine sgesvd π«
subroutine sgesvd (character jobu, character jobvt, integer m, integer n,
real, dimension( lda, * ) a, integer lda, real, dimension( * ) s, real,
dimension( ldu, * ) u, integer ldu, real, dimension( ldvt, * ) vt,
integer ldvt, real, dimension( * ) work, integer lwork, integer info)
SGESVD computes the singular value decomposition (SVD) for GE matrices. Main character energy. π
π― Purpose
Okay so 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 returnsV**T, notV. Do not come forV; itβs giving transpose. π
πΈ Parameters
JOBUβJOBUisCHARACTER*1. It specifies options for computing all or part of the matrixU:= 'A': allMcolumns ofUare returned in arrayU;= 'S': the firstmin(m,n)columns ofU(the left singular vectors) are returned in the arrayU;= 'O': the firstmin(m,n)columns ofU(the left singular vectors) are overwritten on the arrayA;= 'N': no columns ofU(no left singular vectors) are computed.
JOBVTβJOBVTisCHARACTER*1. It specifies options for computing all or part of the matrixV**T:= 'A': allNrows ofV**Tare returned in the arrayVT;= 'S': the firstmin(m,n)rows ofV**T(the right singular vectors) are returned in the arrayVT;= 'O': the firstmin(m,n)rows ofV**T(the right singular vectors) are overwritten on the arrayA;= 'N': no rows ofV**T(no right singular vectors) are computed.
JOBVTandJOBUcannot both be'O'. Like, pick a lane, bestie. π«
MβMisINTEGER, the number of rows of the input matrixA.M >= 0.NβNisINTEGER, the number of columns of the input matrixA.N >= 0.AβAisREALarray, dimension(LDA,N). On entry, theM-by-NmatrixA. On exit:- if
JOBU = 'O',Ais overwritten with the firstmin(m,n)columns ofU(the left singular vectors, stored columnwise); - if
JOBVT = 'O',Ais overwritten with the firstmin(m,n)rows ofV**T(the right singular vectors, stored rowwise); - if
JOBU .ne. 'O'andJOBVT .ne. 'O', the contents ofAare destroyed.
- if
LDAβLDAisINTEGER, the leading dimension of the arrayA.LDA >= max(1,M).SβSisREALarray, dimension(min(M,N)). These are the singular values ofA, sorted so thatS(i) >= S(i+1).UβUisREALarray, dimension(LDU,UCOL)β(LDU,M)ifJOBU = 'A', or(LDU,min(M,N))ifJOBU = 'S'.- If
JOBU = 'A',Ucontains theM-by-Morthogonal matrixU; - if
JOBU = 'S',Ucontains the firstmin(m,n)columns ofU(the left singular vectors, stored columnwise); - if
JOBU = 'N'or'O',Uis not referenced.
- If
LDUβLDUisINTEGER, the leading dimension of the arrayU.LDU >= 1; ifJOBU = 'S'or'A',LDU >= M.VTβVTisREALarray, dimension(LDVT,N).- If
JOBVT = 'A',VTcontains theN-by-Northogonal matrixV**T; - if
JOBVT = 'S',VTcontains the firstmin(m,n)rows ofV**T(the right singular vectors, stored rowwise); - if
JOBVT = 'N'or'O',VTis not referenced.
- If
LDVTβLDVTisINTEGER, the leading dimension of the arrayVT.LDVT >= 1; ifJOBVT = 'A',LDVT >= N; ifJOBVT = 'S',LDVT >= min(M,N).WORKβWORKisREALarray, dimension(MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK; ifINFO > 0,WORK(2:MIN(M,N))contains the unconverged superdiagonal elements of an upper bidiagonal matrixBwhose diagonal is inS(not necessarily sorted).BsatisfiesA = U * B * VT, so it has the same singular values asA, and singular vectors related byUandVT. Yep,REALthis time. πLWORKβLWORKisINTEGER, the dimension of the arrayWORK. Requirements: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,
LWORKshould generally be larger. - If
LWORK = -1, then a workspace query is assumed; the routine only calculates the optimal size of theWORKarray, returns this value as the first entry of theWORKarray, and no error message related toLWORKis issued byXERBLA.
INFOβINFOisINTEGER:= 0: successful exit.< 0: ifINFO = -i, thei-th argument had an illegal value.> 0: ifSBDSQRdid not converge,INFOspecifies how many superdiagonals of an intermediate bidiagonal formBdid not converge to zero. See the description ofWORKabove for details.
π Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Definition at line 209 of file sgesvd.f.
subroutine zgesvd (character jobu, character jobvt, integer m, integer n,
complex*16, dimension( lda, * ) a, integer lda, double precision,
dimension( * ) s, complex*16, dimension( ldu, * ) u, integer ldu,
complex*16, dimension( ldvt, * ) vt, integer ldvt, complex*16,
dimension( * ) work, integer lwork, double precision, dimension( * )
rwork, integer info)
ZGESVD computes the singular value decomposition (SVD) for GE matrices. Bestie, this is the one that decomposes your complex matrix and can hand you back the singular vectors if you ask nicely π
Purpose
okay so ZGESVD computes the singular value decomposition (SVD) of a complex M-by-N matrix A, and optionally computes 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 returnsV**H, notV. that's the plot twist, bestie.
Parameters
JOBUβCHARACTER*1. This tells the routine what to do about all or part of the matrixU:'A': allMcolumns ofUare returned in arrayU:'S': the firstmin(m,n)columns ofU(the left singular vectors) are returned in the arrayU;'O': the firstmin(m,n)columns ofU(the left singular vectors) are overwritten on the arrayA;'N': no columns ofU(no left singular vectors) are computed.
JOBVTβCHARACTER*1. This tells the routine what to do about all or part of the matrixV**H:'A': allNrows ofV**Hare returned in the arrayVT;'S': the firstmin(m,n)rows ofV**H(the right singular vectors) are returned in the arrayVT;'O': the firstmin(m,n)rows ofV**H(the right singular vectors) are overwritten on the arrayA;'N': no rows ofV**H(no right singular vectors) are computed.
π¨ bestie,JOBVTandJOBUcannot both be'O'. that combo is not it.
MβINTEGER. The number of rows of the input matrixA.M >= 0.NβINTEGER. The number of columns of the input matrixA.N >= 0.AβCOMPLEX*16array, dimension(LDA,N). On entry, theM-by-NmatrixA. On exit:- if
JOBU = 'O',Ais overwritten with the firstmin(m,n)columns ofU(the left singular vectors, stored columnwise); - if
JOBVT = 'O',Ais overwritten with the firstmin(m,n)rows ofV**H(the right singular vectors, stored rowwise); - if
JOBU .ne. 'O'andJOBVT .ne. 'O', the contents ofAare destroyed.
- if
LDAβINTEGER. The leading dimension of the arrayA.LDA >= max(1,M).SβDOUBLE PRECISIONarray, dimension(min(M,N)). The singular values ofA, sorted so thatS(i) >= S(i+1).UβCOMPLEX*16array, dimension(LDU,UCOL)β(LDU,M)ifJOBU = 'A'or(LDU,min(M,N))ifJOBU = 'S'.- If
JOBU = 'A',Ucontains theM-by-Munitary matrixU; - if
JOBU = 'S',Ucontains the firstmin(m,n)columns ofU(the left singular vectors, stored columnwise); - if
JOBU = 'N'or'O',Uis not referenced.
- If
LDUβINTEGER. The leading dimension of the arrayU.LDU >= 1; ifJOBU = 'S'or'A',LDU >= M.VTβCOMPLEX*16array, dimension(LDVT,N).- If
JOBVT = 'A',VTcontains theN-by-Nunitary matrixV**H; - if
JOBVT = 'S',VTcontains the firstmin(m,n)rows ofV**H(the right singular vectors, stored rowwise); - if
JOBVT = 'N'or'O',VTis not referenced.
- If
LDVTβINTEGER. The leading dimension of the arrayVT.LDVT >= 1; ifJOBVT = 'A',LDVT >= N; ifJOBVT = 'S',LDVT >= min(M,N).WORKβCOMPLEX*16array, dimension(MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK.LWORKβINTEGER. The dimension of the arrayWORK.LWORK >= MAX(1,2*MIN(M,N)+MAX(M,N)).- For good performance,
LWORKshould generally be larger.
If LWORK = -1, then 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, and no error message related to LWORK is issued by XERBLA.
RWORKβDOUBLE PRECISIONarray, dimension(5*min(M,N)). On exit, ifINFO > 0,RWORK(1:MIN(M,N)-1)contains the unconverged superdiagonal elements of an upper bidiagonal matrixBwhose diagonal is inS(not necessarily sorted).BsatisfiesA = U * B * VT, so it has the same singular values asA, and singular vectors related byUandVT.INFOβINTEGER.= 0: successful exit.< 0: ifINFO = -i, thei-th argument had an illegal value.> 0: ifZBDSQRdid not converge,INFOspecifies how many superdiagonals of an intermediate bidiagonal formBdid not converge to zero. See the description ofRWORKabove for details.
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Definition at line 212 of file zgesvd.f.
Author
Generated automatically by Doxygen for LAPACK from the source code.
okay that's the whole thing, bestie π«Ά signing off from LAPACK Version 3.12.0, page gesvd(3) β no cap, the footer said so πβ¨
π¦ where this page comes from
- arch rolling: lapack-doc 3.12.1-2 Β· custom
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms