/home/abui.../zgesvdq.f(3)
๐ธ NAME ๐ธ
okay so bestie, this is the zgesvdq.f(3) page from the Library Functions Manual, and it's literally the page for this file:
/home/abuild/rpmbuild/BUILD/lapack-static-3.12.0-build/lapack-3.12.0/SRC/zgesvdq.f
โจ SYNOPSIS โจ
๐ Functions/Subroutines ๐
subroutine ZGESVDQ (...)โZGESVDQcomputes the singular value decomposition (SVD) with a QR-Preconditioned QR SVD Method for GE matrices. iconic behavior, honestly.
Here's the exact call shape, bestie:
subroutine ZGESVDQ (joba, jobp, jobr, jobu, jobv, m, n, a, lda, s, u,
ldu, v, ldv, numrank, iwork, liwork, cwork, lcwork, rwork, lrwork,
info)
๐ Function/Subroutine Documentation ๐
๐ฆ subroutine ZGESVDQ ๐ฆ
subroutine ZGESVDQ (character joba, character jobp, character jobr,
character jobu, character jobv, 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(
ldv, * ) v, integer ldv, integer numrank, integer, dimension( * ) iwork,
integer liwork, complex*16, dimension( * ) cwork, integer lcwork, double
precision, dimension( * ) rwork, integer lrwork, integer info)
ZGESVDQ computes the singular value decomposition (SVD) with a QR-Preconditioned QR SVD Method for GE matrices. periodt. ๐
๐ Purpose ๐
ZCGESVDQ computes the singular value decomposition (SVD) of a complex M-by-N matrix A, where M >= N. The SVD of A is written as:
[++] [xx] [x0] [xx]
A = U * SIGMA * V^*, [++] = [xx] * [ox] * [xx]
[++] [xx]
where SIGMA is an N-by-N diagonal matrix, U is an M-by-N orthonormal matrix, and V is an N-by-N unitary matrix. The diagonal elements of SIGMA are the singular values of A. The columns of U and V are the left and the right singular vectors of A, respectively. slay. ๐
๐ง Parameters ๐ง
JOBAโCHARACTER*1. Specifies the level of accuracy in the computed SVD, bestie.'A'โ The requested accuracy corresponds to having the backward error bounded by|| delta A ||_F <= f(m,n) * EPS * || A ||_F, whereEPS = DLAMCH('Epsilon'). This authorisesZGESVDQto truncate the computed triangular factor in a rank revealing QR factorization whenever the truncated part is below the threshold of the order ofEPS * ||A||_F. This is the aggressive truncation level. ๐ฅ'M'โ Similarly as with'A', but the truncation is more gentle: it is allowed only when there is a drop on the diagonal of the triangular factor in the QR factorization. This is the medium truncation level. ๐'H'โ High accuracy requested. No numerical rank determination based on the rank revealing QR factorization is attempted.'E'โ Same as'H', and in addition the condition number of column scaledAis estimated and returned inRWORK(1).N^(-1/4)*RWORK(1) <= ||pinv(A_scaled)||_2 <= N^(1/4)*RWORK(1). big brain accuracy vibes. ๐ง
JOBPโCHARACTER*1.'P'โ The rows ofAare ordered in decreasing order with respect to||A(i,:)||_\infty. This enhances numerical accuracy at the cost of extra data movement. Recommended for numerical robustness, no cap.'N'โ No row pivoting.
JOBRโCHARACTER*1.'T'โ After the initial pivoted QR factorization,ZGESVDis applied to the adjointR**Hof the computed triangular factorR. This involves some extra data movement (matrix transpositions). Useful for experiments, research and development. ๐งช'N'โ The triangular factorRis given as input toCGESVD. This may be preferred as it involves less data movement.
JOBUโCHARACTER*1.'A'โ AllMleft singular vectors are computed and returned in the matrixU. See the description ofU.'S'or'U'โN = min(M,N)left singular vectors are computed and returned in the matrixU. See the description ofU.'R'โ Numerical rankNUMRANKis determined and onlyNUMRANKleft singular vectors are computed and returned in the matrixU.'F'โ TheNleft singular vectors are returned in factored form as the product of theQfactor from the initial QR factorization and theNleft singular vectors of(R**H , 0)**H. If row pivoting is used, then the necessary information on the row pivoting is stored inIWORK(N+1:N+M-1).'N'โ The left singular vectors are not computed.
JOBVโCHARACTER*1.'A','V'โ AllNright singular vectors are computed and returned in the matrixV.'R'โ Numerical rankNUMRANKis determined and onlyNUMRANKright singular vectors are computed and returned in the matrixV. This option is allowed only ifJOBU = 'R'orJOBU = 'N'; otherwise it is illegal. ๐จ'N'โ The right singular vectors are not computed.
MโINTEGER. The number of rows of the input matrixA.M >= 0.NโINTEGER. The number of columns of the input matrixA.M >= N >= 0.AโCOMPLEX*16array of dimensionsLDA x N. On entry, the input matrixA. On exit, ifJOBU .NE. 'N'orJOBV .NE. 'N', the lower triangle ofAcontains the Householder vectors as stored byZGEQP3. IfJOBU = 'F', these Householder vectors together withCWORK(1:N)can be used to restore theQfactors from the initial pivoted QR factorization ofA. See the description ofU.LDAโINTEGER. The leading dimension of the arrayA.LDA >= max(1,M).SโDOUBLE PRECISIONarray of dimensionN. The singular values ofA, ordered so thatS(i) >= S(i+1). descending order, as she should. ๐ซUโCOMPLEX*16array, dimension:LDU x MifJOBU = 'A'; see the description ofLDU. In this case, on exit,Ucontains theMleft singular vectors.LDU x NifJOBU = 'S','U','R'; see the description ofLDU. In this case,Ucontains the leadingNor the leadingNUMRANKleft singular vectors.LDU x NifJOBU = 'F'; see the description ofLDU. In this caseUcontainsN x Nunitary matrix that can be used to form the left singular vectors.- If
JOBU = 'N',Uis not referenced.
LDUโINTEGER. The leading dimension of the arrayU.- If
JOBU = 'A','S','U','R',LDU >= max(1,M). - If
JOBU = 'F',LDU >= max(1,N). - Otherwise,
LDU >= 1.
- If
VโCOMPLEX*16array, dimension:LDV x NifJOBV = 'A','V','R'or ifJOBA = 'E'.- If
JOBV = 'A', or'V',Vcontains theN-by-Nunitary matrixV**H. - If
JOBV = 'R',Vcontains the firstNUMRANKrows ofV**H(the right singular vectors, stored rowwise, of theNUMRANKlargest singular values). - If
JOBV = 'N'andJOBA = 'E',Vis used as a workspace. - If
JOBV = 'N', andJOBA.NE.'E',Vis not referenced.
LDVโINTEGER. The leading dimension of the arrayV.- If
JOBV = 'A','V','R', orJOBA = 'E',LDV >= max(1,N). - Otherwise,
LDV >= 1.
- If
NUMRANKโINTEGER.NUMRANKis the numerical rank first determined after the rank revealing QR factorization, following the strategy specified by the value ofJOBA. IfJOBV = 'R'andJOBU = 'R', onlyNUMRANKleading singular values and vectors are then requested in the call ofCGESVD. The final value ofNUMRANKmight be further reduced if some singular values are computed as zeros. rank reveal tea. โIWORKโINTEGERarray, dimension(max(1, LIWORK)). On exit,IWORK(1:N)contains column pivoting permutation of the rank revealing QR factorization. IfJOBP = 'P',IWORK(N+1:N+M-1)contains the indices of the sequence of row swaps used in row pivoting. These can be used to restore the left singular vectors in the caseJOBU = 'F'.
If LIWORK, LCWORK, or LRWORK = -1, then on exit, if INFO = 0, IWORK(1) returns the minimal LIWORK.
LIWORKโINTEGER. The dimension of the arrayIWORK.LIWORK >= N + M - 1, ifJOBP = 'P';LIWORK >= NifJOBP = 'N'.
If LIWORK = -1, then a workspace query is assumed; the routine only calculates and returns the optimal and minimal sizes for the CWORK, IWORK, and RWORK arrays, and no error message related to LCWORK is issued by XERBLA.
CWORKโCOMPLEX*12array, dimension(max(2, LCWORK)), used as a workspace. On exit, if, on entry,LCWORK.NE.-1,CWORK(1:N)contains parameters needed to recover theQfactor from the QR factorization computed byZGEQP3.
If LIWORK, LCWORK, or LRWORK = -1, then on exit, if INFO = 0, CWORK(1) returns the optimal LCWORK, and CWORK(2) returns the minimal LCWORK.
yes bestie, it says COMPLEX*12 right there โ I'm keeping it exactly as the page has it. ๐
LCWORKโ this is exactly where part 1 cuts off, bestie; part 2 picks it up right here. ๐ซถ
๐พ LCWORK
ok so bestie, LCWORK is an INTEGER and it's literally just how much room you're giving the CWORK array. and the way you figure out the minimum? buckle up ๐ โ it's a whole little recipe:
Let LWQP3 = N+1, LWCON = 2*N, and let
LWUNQ = { MAX( N, 1 ), if JOBU = 'R', 'S', or 'U'
{ MAX( M, 1 ), if JOBU = 'A'
LWSVD = MAX( 3*N, 1 )
LWLQF = MAX( N/2, 1 ), LWSVD2 = MAX( 3*(N/2), 1 ), LWUNLQ = MAX( N, 1 ),
LWQRF = MAX( N/2, 1 ), LWUNQ2 = MAX( N, 1 )
then, with all those little numbers in your pocket, the minimal LCWORK works out to:
= MAX( N + LWQP3, LWSVD ) if only the singular values are needed;
= MAX( N + LWQP3, LWCON, LWSVD ) if only the singular values are needed,
and a scaled condition estimate requested;
= N + MAX( LWQP3, LWSVD, LWUNQ ) if the singular values and the left
singular vectors are requested;
= N + MAX( LWQP3, LWCON, LWSVD, LWUNQ ) if the singular values and the left
singular vectors are requested, and also
a scaled condition estimate requested;
= N + MAX( LWQP3, LWSVD ) if the singular values and the right
singular vectors are requested;
= N + MAX( LWQP3, LWCON, LWSVD ) if the singular values and the right
singular vectors are requested, and also
a scaled condition etimate requested;
= N + MAX( LWQP3, LWSVD, LWUNQ ) if the full SVD is requested with JOBV = 'R';
independent of JOBR;
= N + MAX( LWQP3, LWCON, LWSVD, LWUNQ ) if the full SVD is requested,
JOBV = 'R' and, also a scaled condition
estimate requested; independent of JOBR;
= MAX( N + MAX( LWQP3, LWSVD, LWUNQ ),
N + MAX( LWQP3, N/2+LWLQF, N/2+LWSVD2, N/2+LWUNLQ, LWUNQ) ) if the
full SVD is requested with JOBV = 'A' or 'V', and
JOBR ='N'
= MAX( N + MAX( LWQP3, LWCON, LWSVD, LWUNQ ),
N + MAX( LWQP3, LWCON, N/2+LWLQF, N/2+LWSVD2, N/2+LWUNLQ, LWUNQ ) )
if the full SVD is requested with JOBV = 'A' or 'V', and
JOBR ='N', and also a scaled condition number estimate
requested.
= MAX( N + MAX( LWQP3, LWSVD, LWUNQ ),
N + MAX( LWQP3, N/2+LWQRF, N/2+LWSVD2, N/2+LWUNQ2, LWUNQ ) ) if the
full SVD is requested with JOBV = 'A', 'V', and JOBR ='T'
= MAX( N + MAX( LWQP3, LWCON, LWSVD, LWUNQ ),
N + MAX( LWQP3, LWCON, N/2+LWQRF, N/2+LWSVD2, N/2+LWUNQ2, LWUNQ ) )
if the full SVD is requested with JOBV = 'A', 'V' and
JOBR ='T', and also a scaled condition number estimate
requested.
and then โ the final plot twist ๐ญ โ LCWORK has to be at least two: LCWORK = MAX( 2, LCWORK ).
๐จ but wait, there's a special case: ifLCWORK = -1, then a workspace query is assumed. the routine only calculates and returns the optimal and minimal sizes for theCWORK,IWORK, andRWORKarrays, and no error message related toLCWORKis issued byXERBLA. it's giving โจwindow shopping, not buyingโจ
๐งฎ RWORK
RWORK is a DOUBLE PRECISION array, dimension (max(1, LRWORK)). and on exit? two little gifts ๐
- If
JOBA = 'E',RWORK(1)contains an estimate of the condition number of column scaledA. IfA = C * DwhereDis diagonal andChas unit columns in the Euclidean norm, then, assuming full column rank,
N^(-1/4) * RWORK(1) <= ||pinv(C)||_2 <= N^(1/4) * RWORK(1).
Otherwise, RWORK(1) = -1. (we love a graceful little dash-one, ngl ๐)
RWORK(2)contains the number of singular values computed as exact zeros inZGESVDapplied to the upper triangular or trapezoidalR(from the initial QR factorization). In case of early exit (no call toZGESVD, such as in the case of zero matrix)RWORK(2) = -1. ๐
and, quote, if LIWORK, LCWORK, or LRWORK = -1, then on exit, if INFO = 0, RWORK(1) returns the minimal LRWORK. cute. iconic. ๐ซถ
๐ LRWORK
LRWORK is an INTEGER. it's the dimension of the array RWORK, bestie. so:
- If
JOBP ='P', thenLRWORK >= MAX(2, M, 5*N); ๐ธ - Otherwise,
LRWORK >= MAX(2, 5*N).
๐ same drill as before: ifLRWORK = -1, then a workspace query is assumed โ the routine only calculates and returns the optimal and minimal sizes for theCWORK,IWORK, andRWORKarrays, and no error message related toLCWORKis issued byXERBLA. (yes, it saysLCWORKthere, we're just reading the page as written, don't come for me ๐ญ)
๐ฆ INFO
INFO is an INTEGER. the vibe check at the end:
= 0: successful exit. slay ๐ฅ< 0: ifINFO = -i, the i-th argument had an illegal value. ๐> 0: ifZBDSQRdid not converge,INFOspecifies how many superdiagonals of an intermediate bidiagonal formB(computed inZGESVD) did not converge to zero. ๐ซ
๐ Further Details
- The data movement (matrix transpose) is coded using simple nested DO-loops because BLAS and LAPACK do not provide corresponding subroutines. Those DO-loops are easily identified in this source code โ by the
CONTINUEstatements labeled with11**. In an optimized version of this code, the nested DO loops should be replaced with calls to an optimized subroutine. iykyk ๐ง - This code scales
Aby1/SQRT(M)if the largestABS(A(i,j))could cause column norm overflow. This is the minial precaution (their spelling, not mine, love u Drmaฤ ๐) and it is left to the SVD routine (CGESVD) to do its own preemptive scaling if potential over- or underflows are detected. To avoid repeated scanning of the arrayA, an optimal implementation would do all necessary scaling before callingCGESVDand the scaling inCGESVDcan be switched off. - Other comments related to code optimization are given in comments in the code, enclosed in
[[double brackets]]. ๐
๐ Bugs, examples and comments
Please report all bugs and send interesting examples and/or comments to drmac@math.hr. Thank you. โ literally a sweet little "ty" note, we stan ๐ซถ
๐ References
[1]Zlatko Drmac, Algorithm 977: A QR-Preconditioned QR SVD Method for Computing the SVD with High Accuracy. ACM Trans. Math. Softw. 44(1): 11:1-11:30 (2017)- SIGMA library, xGESVDQ section updated February 2016. Developed and coded by Zlatko Drmac, Department of Mathematics, University of Zagreb, Croatia,
drmac@math.hr
๐ Contributors:
Developed and coded by Zlatko Drmac, Department of Mathematics, University of Zagreb, Croatia, drmac@math.hr ๐
โ๏ธ Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Definition at line 410 of file zgesvdq.f.
๐ฌ Author (again, yes, there are two of them)
Generated automatically by Doxygen for LAPACK from the source code.
and that's the whole page, bestie โ go forth and query your workspaces responsibly ๐ โจ
๐ source: zgesvdq.f ยท LAPACK Version 3.12.0 ยท from the LAPACK source tree ๐ ily, bye ๐ฆ
๐ฆ where this page comes from
- opensuse-leap 16.0: lapack-man 3.12.0-160000.2.2 ยท BSD-3-Clause
- opensuse-leap 16.0: lapack-man 3.12.0-160000.2.2 ยท BSD-3-Clause
- opensuse-leap 16.0: lapack-man 3.12.0-160000.2.2 ยท BSD-3-Clause
- opensuse-leap 16.0: lapack-man 3.12.0-160000.2.2 ยท BSD-3-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms