SRC/sgesvj.f(3)
π NAME π
SRC/sgesvj.f β bestie, this is the page from the Library Functions Manual, aka SRC/sgesvj.f(3). Weβre in full Unix-manual group-chat mode now, periodt π¦
β¨ SYNOPSIS β¨
π§ Functions/Subroutines π§
subroutine sgesvj (joba, jobu, jobv, m, n, a, lda, sva, mv, v, ldv,
work, lwork, info)
SGESVJ
π« Function/Subroutine Documentation π«
subroutine sgesvj (character*1 joba, character*1 jobu, character*1 jobv,
integer m, integer n, real, dimension( lda, * ) a, integer lda, real,
dimension( n ) sva, integer mv, real, dimension( ldv, * ) v, integer
ldv, real, dimension( lwork ) work, integer lwork, integer info)
SGESVJ
πΈ Purpose πΈ
Okay so SGESVJ computes the singular value decomposition (SVD) of a real M-by-N matrix A, where M >= N. The SVD of A is written as:
!> [++] [xx] [x0] [xx]
!> A = U * SIGMA * V^t, [++] = [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 orthogonal 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. SGESVJ can sometimes compute tiny singular values and their singular vectors much more accurately than other SVD routines, see below under Further Details. Thatβs the lore, bestie π
π Parameters π
π JOBA π
JOBA is CHARACTER*1 β it specifies the structure of A.
'L': the input matrixAis lower triangular;'U': the input matrixAis upper triangular;'G': the input matrixAis a generalM-by-Nmatrix,M >= N.
π¦ JOBU π¦
JOBU is CHARACTER*1 β it specifies whether to compute the left singular vectors (the columns of U):
'U': the left singular vectors corresponding to the nonzero singular values are computed and returned in the leading columns ofA. See more details in the description ofA. The default numerical orthogonality threshold is set to approximatelyTOL=CTOL*EPS,CTOL=SQRT(M),EPS=SLAMCH('E').'C': analogous toJOBU='U', except that the user can control the level of numerical orthogonality of the computed left singular vectors.TOLcan be set toTOL = CTOL*EPS, whereCTOLis given on input in the arrayWORK. NoCTOLsmaller thanONEis allowed.CTOLgreater than1 / EPSis meaningless. The option'C'can be used ifM*EPSis satisfactory orthogonality of the computed left singular vectors, soCTOL=Mcould save few sweeps of Jacobi rotations. See the descriptions ofAandWORK(1).'N': the matrixUis not computed. However, see the description ofA.
π¨ no cap: with'C', noCTOLsmaller thanONEis allowed β you cannot force the routine to obtain orthogonality belowEPSILON.
π JOBV π
JOBV is CHARACTER*1 β it specifies whether to compute the right singular vectors, that is, the matrix V:
'V': the matrixVis computed and returned in the arrayV.'A': the Jacobi rotations are applied to theMV-by-NarrayV. In other words, the right singular vector matrixVis not computed explicitly; instead it is applied to anMV-by-Nmatrix initially stored in the firstMVrows ofV.'N': the matrixVis not computed and the arrayVis not referenced.
π M π
M is INTEGER β the number of rows of the input matrix A. 1/SLAMCH('E') > M >= 0.
πΈ N πΈ
N is INTEGER β the number of columns of the input matrix A. M >= N >= 0.
π A π
A is a REAL array, dimension (LDA,N).
On entry, itβs the M-by-N matrix A.
On exit:
- If
JOBU = 'U' .OR. JOBU = 'C':- If
INFO = 0:RANKAorthonormal columns ofUare returned in the leadingRANKAcolumns of the arrayA. HereRANKA <= Nis the number of computed singular values ofAthat are above the underflow thresholdSLAMCH('S'). The singular vectors corresponding to underflowed or zero singular values are not computed. The value ofRANKAis returned in the arrayWORKasRANKA=NINT(WORK(2)). Also see the descriptions ofSVAandWORK. The computed columns ofUare mutually numerically orthogonal up to approximatelyTOL=SQRT(M)*EPS(default); orTOL=CTOL*EPS(JOBU = 'C'), see the description ofJOBU. - If
INFO > 0, the procedureSGESVJdid not converge in the given number of iterations (sweeps). In that case, the computed columns ofUmay not be orthogonal up toTOL. The outputU(stored inA),SIGMA(given by the computed singular values inSVA(1:N)) andVis still a decomposition of the input matrixAin the sense that the residual||A-SCALE*U*SIGMA*V^T||_2 / ||A||_2is small.
- If
- If
JOBU = 'N':- If
INFO = 0: note that the left singular vectors are'for free'in the one-sided Jacobi SVD algorithm. However, if only the singular values are needed, the level of numerical orthogonality ofUis not an issue and iterations are stopped when the columns of the iterated matrix are numerically orthogonal up to approximatelyM*EPS. Thus, on exit,Acontains the columns ofUscaled with the corresponding singular values. - If
INFO > 0: the procedureSGESVJdid not converge in the given number of iterations (sweeps).
- If
π«Ά LDA π«Ά
LDA is INTEGER β the leading dimension of the array A. LDA >= max(1,M).
β SVA β
SVA is a REAL array, dimension (N).
On exit:
- If
INFO = 0: depending on the valueSCALE = WORK(1), we have:- If
SCALE = ONE:SVA(1:N)contains the computed singular values ofA. During the computationSVAcontains the Euclidean column norms of the iterated matrices in the arrayA. - If
SCALE .NE. ONE: the singular values ofAareSCALE*SVA(1:N), and this factored representation is due to the fact that some of the singular values ofAmight underflow or overflow.
- If
- If
INFO > 0: the procedureSGESVJdid not converge in the given number of iterations (sweeps) andSCALE*SVA(1:N)may not be accurate.
π§ MV π§
MV is INTEGER β if JOBV = 'A', then the product of Jacobi rotations in SGESVJ is applied to the first MV rows of V. See the description of JOBV.
π V π
V is a REAL array, dimension (LDV,N).
- If
JOBV = 'V', thenVcontains on exit theN-by-Nmatrix of the right singular vectors; - If
JOBV = 'A', thenVcontains the product of the computed right singular vector matrix and the initial matrix in the arrayV. - If
JOBV = 'N', thenVis not referenced.
π LDV π
LDV is INTEGER β the leading dimension of the array V, LDV >= 1.
- If
JOBV = 'V', thenLDV >= max(1,N). - If
JOBV = 'A', thenLDV >= max(1,MV).
π₯ WORK π₯
WORK is a REAL array, dimension (MAX(1,LWORK)).
On entry:
- If
JOBU = 'C':WORK(1) = CTOL, whereCTOLdefines the threshold for convergence. The process stops if all columns ofAare mutually orthogonal up toCTOL*EPS,EPS=SLAMCH('E'). It is required thatCTOL >= ONE, i.e. it is not allowed to force the routine to obtain orthogonality belowEPSILON.
On exit:
WORK(1) = SCALEis the scaling factor such thatSCALE*SVA(1:N)are the computed singular vcalues ofAβ yes,vcalues, the typo is iconic and weβre keeping it π (See description ofSVA().)WORK(2) = NINT(WORK(2))is the number of the computed nonzero singular values.WORK(3) = NINT(WORK(3))is the number of the computed singular values that are larger than the underflow threshold.WORK(4) = NINT(WORK(4))is the number of sweeps of Jacobi rotations needed for numerical convergence.WORK(5) = max_{i.NE.j} |COS(A(:,i),A(:,j))|in the last sweep. This is useful information in cases whenSGESVJdid not converge, as it can be used to estimate whether the output is still useful and for post festum analysis.WORK(6)= the largest absolute value over all sines of the Jacobi rotation angles in the last sweep. It can be useful for a post festum analysis.
π LWORK π
LWORK is INTEGER β length of WORK. LWORK >= 1, if MIN(M,N) = 0, and LWORK >= MAX(6,M+N), otherwise.
If on entry LWORK = -1, then a workspace query is assumed and no computation is done; WORK(1) is set to the minial (and optimal) length of WORK β yes, minial, another iconic typo, we move π
π INFO π
INFOisINTEGERβ the little status report bestie, and here's the whole tea:
= 0: successful exit.
< 0: if INFO = -i, then the i-th argument had an illegal value
> 0: SGESVJ did not converge in the maximal allowed number (30)
of sweeps. The output may still be useful. See the
description of WORK.
So like: 0 = we ate π
, negative = you passed me something cursed at slot -i, and positive = she did not converge in the max sweeps allowed, which is 30. And honestly? The output may still be useful β go read the description of WORK before you panic π₯
π«Ά Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
π¬ Further Details:
The orthogonal N-by-N matrix V is obtained as a product of Jacobi plane rotations. The rotations are implemented as fast scaled rotations of Anda and Park [1]. In the case of underflow of the Jacobi angle, a modified Jacobi transformation of Drmac [4] is used. Pivot strategy uses column interchanges of de Rijk [2]. The relative accuracy of the computed singular values and the accuracy of the computed singular vectors (in angle metric) is as guaranteed by the theory of Demmel and Veselic [3]. The condition number that determines the accuracy in the full rank case is essentially min_{D=diag} kappa(A*D), where kappa(.) is the spectral condition number. The best performance of this Jacobi SVD procedure is achieved if used in an accelerated version of Drmac and Veselic [5,6], and it is the kernel routine in the SIGMA library [7]. Some tuning parameters (marked with [TP]) are available for the implementer.
The computational range for the nonzero singular values is the machine number interval ( UNDERFLOW , OVERFLOW ). In extreme cases, even denormalized singular values can be computed with the corresponding gradual loss of accurate digits.
ok so that last bit is lowkey iconic β denormalized singular values, with a gradual loss of accurate digits. She'll still try for you, she just gets a lil fuzzy at the edges πβ¨
π Contributors:
Zlatko Drmac (Zagreb, Croatia) and Kresimir Veselic (Hagen, Germany)
π References:
[1] A. A. Anda and H. Park: Fast plane rotations with dynamic
scaling.
SIAM J. matrix Anal. Appl., Vol. 15 (1994), pp. 162-174.
[2] P. P. M. De Rijk: A one-sided Jacobi algorithm for computing the
singular value decomposition on a vector computer.
SIAM J. Sci. Stat. Comp., Vol. 10 (1998), pp. 359-371.
[3] J. Demmel and K. Veselic: Jacobi method is more accurate than
QR.
[4] Z. Drmac: Implementation of Jacobi rotations for accurate
singular value computation in floating point arithmetic.
SIAM J. Sci. Comp., Vol. 18 (1997), pp. 1200-1222.
[5] Z. Drmac and K. Veselic: New fast and accurate Jacobi SVD
algorithm I.
SIAM J. Matrix Anal. Appl. Vol. 35, No. 2 (2008), pp. 1322-1342.
LAPACK Working note 169.
[6] Z. Drmac and K. Veselic: New fast and accurate Jacobi SVD
algorithm II.
SIAM J. Matrix Anal. Appl. Vol. 35, No. 2 (2008), pp. 1343-1362.
LAPACK Working note 170.
[7] Z. Drmac: SIGMA - mathematical software library for accurate
SVD, PSV, QSVD, (H,K)-SVD computations.
Department of Mathematics, University of Zagreb, 2008.
The way these papers are just stacked β the whole bibliography ate, no cap π
π Bugs, Examples and Comments:
Please report all bugs and send interesting test examples and comments to drmac@math.hr. Thank you.
bestie if you find a bug, email the man. He said thank you in advance, that's so sweet ππ
Definition at line 326 of file sgesvj.f.
πΈ Author
Generated automatically by Doxygen for LAPACK from the source code.
k bye bestie, go forth and decompose those matrices π This lil gem is from LAPACK, Version 3.12.0, page SRC/sgesvj.f(3) β screenshot it, save it, tattoo it idk π¦β¨
π¦ 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