SRC/stgsja.f(3)
π SRC/stgsja.f π
from the Library Functions Manual
okay bestie, sit down, hydrate, because this one is a whole β¨ journey β¨. <pink>stgsja</pink> is the Fortran routine that finishes the job SGGSVP started β it's the GSVD glow-up part two, and it's lowkey iconic. π
β¨ SYNOPSIS β¨
π¦ Functions/Subroutines
subroutine stgsja (jobu, jobv, jobq, m, p, n, k, l, a, lda, b, ldb,
tola, tolb, alpha, beta, u, ldu, v, ldv, q, ldq, work, ncycle, info)
STGSJA
π Function/Subroutine Documentation π
π subroutine stgsja
here's the full signature so you can clock every single argument, no cap:
subroutine stgsja (character jobu, character jobv, character jobq, integer
m, integer p, integer n, integer k, integer l, real, dimension( lda, * )
a, integer lda, real, dimension( ldb, * ) b, integer ldb, real tola,
real tolb, real, dimension( * ) alpha, real, dimension( * ) beta, real,
dimension( ldu, * ) u, integer ldu, real, dimension( ldv, * ) v, integer
ldv, real, dimension( ldq, * ) q, integer ldq, real, dimension( * )
work, integer ncycle, integer info)
STGSJA
πΈ Purpose πΈ
okay so. STGSJA computes the generalized singular value decomposition, aka the GSVD, of two real upper triangular (or trapezoidal) matrices A and B. math serve π
On entry, it's assumed that the matrices A and B already have the following forms β which you get from the preprocessing subroutine SGGSVP working on a general M-by-N matrix A and a P-by-N matrix B:
N-K-L K L
A = K ( 0 A12 A13 ) if M-K-L >= 0;
L ( 0 0 A23 )
M-K-L ( 0 0 0 )
N-K-L K L
A = K ( 0 A12 A13 ) if M-K-L < 0;
M-K ( 0 0 A23 )
N-K-L K L
B = L ( 0 0 B13 )
P-L ( 0 0 0 )
where the K-by-K matrix A12 and the L-by-L matrix B13 are nonsingular upper triangular; A23 is L-by-L upper triangular if M-K-L >= 0, otherwise A23 is (M-K)-by-L upper trapezoidal. bestie that's a mouthful but we're locked in π
On exit, you get:
U**T *A*Q = D1*( 0 R ), V**T *B*Q = D2*( 0 R ),
where U, V and Q are orthogonal matrices. R is a nonsingular upper triangular matrix, and D1 and D2 are "diagonal" matrices (yes, in air quotes β they're structured like this, keep reading) π«Ά
If M-K-L >= 0:
K L
D1 = K ( I 0 )
L ( 0 C )
M-K-L ( 0 0 )
K L
D2 = L ( 0 S )
P-L ( 0 0 )
N-K-L K L
( 0 R ) = K ( 0 R11 R12 ) K
L ( 0 0 R22 ) L
where
C = diag( ALPHA(K+1), ... , ALPHA(K+L) ),
S = diag( BETA(K+1), ... , BETA(K+L) ),
C**2 + S**2 = I.
R is stored in A(1:K+L,N-K-L+1:N) on exit.
and if M-K-L < 0:
K M-K K+L-M
D1 = K ( I 0 0 )
M-K ( 0 C 0 )
K M-K K+L-M
D2 = M-K ( 0 S 0 )
K+L-M ( 0 0 I )
P-L ( 0 0 0 )
N-K-L K M-K K+L-M
( 0 R ) = K ( 0 R11 R12 R13 )
M-K ( 0 0 R22 R23 )
K+L-M ( 0 0 0 R33 )
where
C = diag( ALPHA(K+1), ... , ALPHA(M) ),
S = diag( BETA(K+1), ... , BETA(M) ),
C**2 + S**2 = I.
R = ( R11 R12 R13 ) is stored in A(1:M, N-K-L+1:N) and R33 is stored
( 0 R22 R23 )
in B(M-K+1:L,N+M-K-L+1:N) on exit.
the computation of the orthogonal transformation matrices U, V or Q is optional β genuinely your call, main character choice. these matrices may either be formed explicitly, or they may be postmultiplied into input matrices U1, V1, or Q1. slay, flexible β¨
π Parameters π
JOBUβ isCHARACTER*1= 'U'βUmust contain an orthogonal matrixU1on entry, and the productU1*Uis returned;= 'I'βUis initialized to the unit matrix, and the orthogonal matrixUis returned;= 'N'βUis not computed.
JOBVβ isCHARACTER*1= 'V'βVmust contain an orthogonal matrixV1on entry, and the productV1*Vis returned;= 'I'βVis initialized to the unit matrix, and the orthogonal matrixVis returned;= 'N'βVis not computed.
JOBQβ isCHARACTER*1= 'Q'βQmust contain an orthogonal matrixQ1on entry, and the productQ1*Qis returned;= 'I'βQis initialized to the unit matrix, and the orthogonal matrixQis returned;= 'N'βQis not computed.
Mβ isINTEGER. the number of rows of the matrixA.M >= 0.Pβ isINTEGER. the number of rows of the matrixB.P >= 0.Nβ isINTEGER. the number of columns of the matricesAandB.N >= 0.Kβ isINTEGER.Lβ isINTEGER.
K and L specify the subblocks in the input matrices A and B: A23 = A(K+1:MIN(K+L,M),N-L+1:N) and B13 = B(1:L,N-L+1:N) of A and B, whose GSVD is going to be computed by STGSJA. see Further Details (coming at you in the next part π).
Aβ isREALarray, dimension(LDA,N). on entry, theM-by-NmatrixA. on exit,A(N-K+1:N,1:MIN(K+L,M) )contains the triangular matrixRor part ofR. see Purpose for details.LDAβ isINTEGER. the leading dimension of the arrayA.LDA >= max(1,M).Bβ isREALarray, dimension(LDB,N). on entry, theP-by-NmatrixB. on exit, if necessary,B(M-K+1:L,N+M-K-L+1:N)contains a part ofR. see Purpose for details.LDBβ isINTEGER. the leading dimension of the arrayB.LDB >= max(1,P).TOLAβ isREAL.TOLBβ isREAL.
TOLA and TOLB are the convergence criteria for the Jacobi-Kogbetliantz iteration procedure. generally, they are the same as used in the preprocessing step, say
TOLA = max(M,N)*norm(A)*MACHEPS,
TOLB = max(P,N)*norm(B)*MACHEPS.
ALPHAβ isREALarray, dimension(N).BETAβ isREALarray, dimension(N).
on exit, ALPHA and BETA contain the generalized singular value pairs of A and B:
ALPHA(1:K) = 1,
BETA(1:K) = 0,
and if M-K-L >= 0,
ALPHA(K+1:K+L) = diag(C),
BETA(K+1:K+L) = diag(S),
or if M-K-L < 0,
ALPHA(K+1:M)= C, ALPHA(M+1:K+L)= 0
BETA(K+1:M) = S, BETA(M+1:K+L) = 1.
furthermore, if K+L < N,
ALPHA(K+L+1:N) = 0 and
BETA(K+L+1:N) = 0.
Uβ isREALarray, dimension(LDU,M). on entry, ifJOBU = 'U',Umust contain a matrixU1(usually the orthogonal matrix returned bySGGSVP). on exit:- if
JOBU = 'I',Ucontains the orthogonal matrixU; - if
JOBU = 'U',Ucontains the productU1*U.
- if
if JOBU = 'N', U is not referenced. π
LDUβ isINTEGER. the leading dimension of the arrayU.LDU >= max(1,M)ifJOBU = 'U';LDU >= 1otherwise.Vβ isREALarray, dimension(LDV,P). on entry, ifJOBV = 'V',Vmust contain a matrixV1(usually the orthogonal matrix returned bySGGSVP). on exit:- if
JOBV = 'I',Vcontains the orthogonal matrixV; - if
JOBV = 'V',Vcontains the productV1*V.
- if
if JOBV = 'N', V is not referenced.
LDVβ isINTEGER. the leading dimension of the arrayV.LDV >= max(1,P)ifJOBV = 'V';LDV >= 1otherwise.Qβ isREALarray, dimension(LDQ,N). on entry, ifJOBQ = 'Q',Qmust contain a matrixQ1(usually the orthogonal matrix returned bySGGSVP). on exit:- if
JOBQ = 'I',Qcontains the orthogonal matrixQ; - if
JOBQ = 'Q',Qcontains the productQ1*Q.
- if
if JOBQ = 'N', Q is not referenced.
LDQβ isINTEGER. the leading dimension of the arrayQ.LDQ >= max(1,N)ifJOBQ = 'Q';LDQ >= 1otherwise.WORKβ isREALarray, dimension(2*N).NCYCLEβ isINTEGER. the number of cycles required for convergence. how many laps did it take, bestie πββοΈINFOβ isINTEGER= 0β successful exit π< 0β ifINFO = -i, thei-th argument had an illegal value.= 1β the procedure does not converge afterMAXITcycles.
π§ Internal Parameters π§
MAXITisINTEGERMAXITspecifies the total loops that the iterative procedure may take. if afterMAXITcycles, the routine fails to converge, we returnINFO = 1. so yeah, it gave up β that's the vibe check failing, not you π
π Author π
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
π Further Details
And the tea on STGSJA, bestie: it essentially uses a variant of the Kogbetliantz algorithm to reduce a min(L,M-K)-by-L triangular (or trapezoidal) matrix A23 and an L-by-L matrix B13 into this exact form:
U1**T *A13*Q1 = C1*R1; V1**T *B13*Q1 = S1*R1,
where U1, V1 and Q1 are orthogonal matrix (yes, the source says "matrix" β not me changing it), and Z**T is the transpose of Z. C1 and S1 are diagonal matrices satisfying
C1**2 + S1**2 = I,
and R1 is an L-by-L nonsingular upper triangular matrix. It's giving clean reduction, iconic diagonal energy. π
β¨
Definition at line 375 of file stgsja.f.
Author π
Generated automatically by Doxygen for LAPACK from the source code. Fr fr.
That's the little sign-off, bestie: this page is from LAPACK Version 3.12.0, for SRC/stgsja.f(3). Mwah. π«Άπ
π¦ 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