ggevx(3)
π ggevx(3) β Library Functions Manual π
okay bestie, this is the ggevx(3) page from the Library Functions Manual, and it is very expert-eig-coded. no cap. letβs get into it π
πΈ NAME πΈ
ggevx β ggevx: eig, expert
β¨ SYNOPSIS β¨
okay so this page is giving βa whole little family of subroutines,β and they all compute eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices. iconic behavior, honestly π«Ά
π§ Functions π§
subroutine cggevx (...)
subroutine cggevx (balanc, jobvl, jobvr, sense, n, a, lda, b, ldb,
alpha, beta, vl, ldvl, vr, ldvr, ilo, ihi, lscale, rscale, abnrm,
bbnrm, rconde, rcondv, work, lwork, rwork, iwork, bwork, info)
CGGEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices
subroutine dggevx (...)
subroutine dggevx (balanc, jobvl, jobvr, sense, n, a, lda, b, ldb,
alphar, alphai, beta, vl, ldvl, vr, ldvr, ilo, ihi, lscale, rscale,
abnrm, bbnrm, rconde, rcondv, work, lwork, iwork, bwork, info)
DGGEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices
subroutine sggevx (...)
subroutine sggevx (balanc, jobvl, jobvr, sense, n, a, lda, b, ldb,
alphar, alphai, beta, vl, ldvl, vr, ldvr, ilo, ihi, lscale, rscale,
abnrm, bbnrm, rconde, rcondv, work, lwork, iwork, bwork, info)
SGGEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices
subroutine zggevx (...)
subroutine zggevx (balanc, jobvl, jobvr, sense, n, a, lda, b, ldb,
alpha, beta, vl, ldvl, vr, ldvr, ilo, ihi, lscale, rscale, abnrm,
bbnrm, rconde, rcondv, work, lwork, rwork, iwork, bwork, info)
ZGGEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices
π«Ά Detailed Description π«Ά
this is the part where the page says βokay, function docs time,β and honestly that is the vibe. we are heading straight into the cggevx breakdown, bestie. β¨
π Function Documentation π
π subroutine cggevx π
subroutine cggevx (character balanc, character jobvl, character jobvr,
character sense, integer n, complex, dimension( lda, * ) a, integer lda,
complex, dimension( ldb, * ) b, integer ldb, complex, dimension( * )
alpha, complex, dimension( * ) beta, complex, dimension( ldvl, * ) vl,
integer ldvl, complex, dimension( ldvr, * ) vr, integer ldvr, integer
ilo, integer ihi, real, dimension( * ) lscale, real, dimension( * )
rscale, real abnrm, real bbnrm, real, dimension( * ) rconde, real,
dimension( * ) rcondv, complex, dimension( * ) work, integer lwork,
real, dimension( * ) rwork, integer, dimension( * ) iwork, logical,
dimension( * ) bwork, integer info)
CGGEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices
π― Purpose π―
CGGEVX computes, for a pair of N-by-N complex nonsymmetric matrices (A,B), the generalized eigenvalues, and optionally, the left and/or right generalized eigenvectors. π
Optionally, it also computes a balancing transformation to improve the conditioning of the eigenvalues and eigenvectors (ILO, IHI, LSCALE, RSCALE, ABNRM, and BBNRM), reciprocal condition numbers for the eigenvalues (RCONDE), and reciprocal condition numbers for the right eigenvectors (RCONDV). π
A generalized eigenvalue for a pair of matrices (A,B) is a scalar lambda or a ratio alpha/beta = lambda, such that A - lambda*B is singular. It is usually represented as the pair (alpha,beta), as there is a reasonable interpretation for beta=0, and even for both being zero. bestie, that zero-beta situation is not a typo, itβs just giving generalized eigenvalue realness. π¦
The right eigenvector v(j) corresponding to the eigenvalue lambda(j) of (A,B) satisfies
A * v(j) = lambda(j) * B * v(j) .
The left eigenvector u(j) corresponding to the eigenvalue lambda(j) of (A,B) satisfies
u(j)**H * A = lambda(j) * u(j)**H * B.
where u(j)**H is the conjugate-transpose of u(j).
π Parameters π
BALANCβBALANC is CHARACTER*1. Specifies the balance option to be performed:= 'N': do not diagonally scale or permute;= 'P': permute only;= 'S': scale only;= 'B': both permute and scale.
Computed reciprocal condition numbers will be for the matrices after permuting and/or balancing. Permuting does not change condition numbers (in exact arithmetic), but balancing does.
JOBVLβJOBVL is CHARACTER*1= 'N': do not compute the left generalized eigenvectors;= 'V': compute the left generalized eigenvectors.
JOBVRβJOBVR is CHARACTER*1= 'N': do not compute the right generalized eigenvectors;= 'V': compute the right generalized eigenvectors.
SENSEβSENSE is CHARACTER*1. Determines which reciprocal condition numbers are computed.= 'N': none are computed;= 'E': computed for eigenvalues only;= 'V': computed for eigenvectors only;= 'B': computed for eigenvalues and eigenvectors.
NβN is INTEGER. The order of the matricesA,B,VL, andVR.N >= 0.AβA is COMPLEX array, dimension (LDA, N)- On entry, the matrix
Ain the pair(A,B). - On exit,
Ahas been overwritten. IfJOBVL='V'orJOBVR='V'or both, thenAcontains the first part of the complex Schur form of the versions of the inputAandB.
- On entry, the matrix
LDAβLDA is INTEGER. The leading dimension ofA.LDA >= max(1,N).BβB is COMPLEX array, dimension (LDB, N)- On entry, the matrix
Bin the pair(A,B). - On exit,
Bhas been overwritten. IfJOBVL='V'orJOBVR='V'or both, thenBcontains the second part of the complex Schur form of the versions of the inputAandB.
- On entry, the matrix
LDBβLDB is INTEGER. The leading dimension ofB.LDB >= max(1,N).ALPHAβALPHA is COMPLEX array, dimension (N)BETAβBETA is COMPLEX array, dimension (N). On exit,ALPHA(j)/BETA(j), j=1,...,N,will be the generalized eigenvalues.
Note: the quotient ALPHA(j)/BETA(j) ) may easily over- or underflow, and BETA(j) may even be zero. Thus, the user should avoid naively computing the ratio ALPHA/BETA. However, ALPHA will be always less than and usually comparable with norm(A) in magnitude, and BETA always less than and usually comparable with norm(B).
VLβVL is COMPLEX array, dimension (LDVL,N). IfJOBVL = 'V', the left generalized eigenvectorsu(j)are stored one after another in the columns ofVL, in the same order as their eigenvalues. Each eigenvector will be scaled so the largest component will haveabs(real part) + abs(imag. part) = 1.Not referenced ifJOBVL = 'N'.LDVLβLDVL is INTEGER. The leading dimension of the matrixVL.LDVL >= 1, and ifJOBVL = 'V',LDVL >= N.VRβVR is COMPLEX array, dimension (LDVR,N). IfJOBVR = 'V', the right generalized eigenvectorsv(j)are stored one after another in the columns ofVR, in the same order as their eigenvalues. Each eigenvector will be scaled so the largest component will haveabs(real part) + abs(imag. part) = 1.Not referenced ifJOBVR = 'N'.LDVRβLDVR is INTEGER. The leading dimension of the matrixVR.LDVR >= 1, and ifJOBVR = 'V',LDVR >= N.ILOβILO is INTEGERIHIβIHI is INTEGER.ILOandIHIare integer values such that on exitA(i,j) = 0andB(i,j) = 0ifi > jandj = 1,...,ILO-1ori = IHI+1,...,N. IfBALANC = 'N'or'S',ILO = 1andIHI = N.LSCALEβLSCALE is REAL array, dimension (N). Details of the permutations and scaling factors applied to the left side ofAandB. IfPL(j)is the index of the row interchanged with rowj, andDL(j)is the scaling factor applied to rowj, then
LSCALE(j) = PL(j) for j = 1,...,ILO-1
= DL(j) for j = ILO,...,IHI
= PL(j) for j = IHI+1,...,N.
The order in which the interchanges are made is N to IHI+1, then 1 to ILO-1.
RSCALEβRSCALE is REAL array, dimension (N). Details of the permutations and scaling factors applied to the right side ofAandB. IfPR(j)is the index of the column interchanged with columnj, andDR(j)is the scaling factor applied to columnj, then
RSCALE(j) = PR(j) for j = 1,...,ILO-1
= DR(j) for j = ILO,...,IHI
= PR(j) for j = IHI+1,...,N
The order in which the interchanges are made is N to IHI+1, then 1 to ILO-1.
ABNRMβABNRM is REAL. The one-norm of the balanced matrixA.BBNRMβBBNRM is REAL. The one-norm of the balanced matrixB.RCONDEβRCONDE is REAL array, dimension (N). IfSENSE = 'E'or'B', the reciprocal condition numbers of the eigenvalues, stored in consecutive elements of the array. IfSENSE = 'N'or'V',RCONDEis not referenced.RCONDVβRCONDV is REAL array, dimension (N). IfSENSE = 'V'or'B', the estimated reciprocal condition numbers of the eigenvectors, stored in consecutive elements of the array. If the eigenvalues cannot be reordered to computeRCONDV(j),RCONDV(j)is set to0; this can only occur when the true value would be very small anyway. IfSENSE = 'N'or'E',RCONDVis not referenced.WORKβWORK is COMPLEX array, dimension (MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK.LWORKβLWORKβ INTEGER, the dimension of theWORKarray. How much room you're giving it to vibe in. Minimums, no cap:LWORK >= max(1,2*N)in general,LWORK >= max(1,4*N)ifSENSE = 'E', andLWORK >= max(1,2*N*N+2*N)ifSENSE = 'V'or'B'.
And the iconic part: if LWORK = -1, a workspace query is assumed β the routine literally only calculates the optimal size of the WORK array, returns that value as the first entry of the WORK array, and XERBLA does not issue any error message related to LWORK. It's giving "ask me what I need and I'll tell you" π
RWORKβRWORKis REAL array, dimension (lrwork). Andlrworkmust be at leastmax(1,6*N)ifBALANC = 'S'or'B', and at leastmax(1,2*N)otherwise. Real workspace, real ones know.IWORKβIWORKis INTEGER array, dimension (N+2). But bestie β ifSENSE = 'E',IWORKis not referenced. She's off duty that day π«ΆBWORKβBWORKis LOGICAL array, dimension (N). Same deal: ifSENSE = 'N',BWORKis not referenced. Unbothered, moisturized, not called.INFOβINFOis INTEGER, the receipts:= 0: successful exit π< 0: ifINFO = -i, the i-th argument had an illegal value. Rude of you, honestly.= 1,...,N: The QZ iteration failed. No eigenvectors have been calculated, butALPHA(j)andBETA(j)should be correct forj=INFO+1,...,N. So like β partial credit, the eigenvalues made it, the eigenvectors ghosted π> N:=N+1: other than QZ iteration failed inCHGEQZ.=N+2: error return fromCTGEVC.
π Author π
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Like, four whole institutions collaborated on this. Main character energy across state lines π
β¨ Further Details β¨
Okay so here's the tea about balancing a matrix pair (A,B). It happens in two steps: first, permuting rows and columns to isolate eigenvalues; second, applying a diagonal similarity transformation to the rows and columns so they end up as close in norm as possible. Slay. The computed reciprocal condition numbers correspond to the balanced matrix. Permuting rows and columns won't change the condition numbers (in exact arithmetic) β but diagonal scaling will. So keep that in mind. For further explanation of balancing, see section 4.11.1.2 of LAPACK Users' Guide.
Now, an approximate error bound on the chordal distance between the i-th computed generalized eigenvalue w and the corresponding exact eigenvalue lambda is:
chord(w, lambda) <= EPS * norm(ABNRM, BBNRM) / RCONDE(I)
And an approximate error bound for the angle between the i-th computed eigenvector VL(i) or VR(i) is given by:
EPS * norm(ABNRM, BBNRM) / DIF(i).
For further explanation of the reciprocal condition numbers RCONDE and RCONDV, see section 4.11 of LAPACK User's Guide. Go read it, it's a whole thing π
Definition at line 370 of file cggevx.f.
π¦ subroutine dggevx π¦
subroutine dggevx (character balanc, character jobvl, character jobvr,
character sense, integer n, double precision, dimension( lda, * ) a,
integer lda, double precision, dimension( ldb, * ) b, integer ldb,
double precision, dimension( * ) alphar, double precision, dimension( *
) alphai, double precision, dimension( * ) beta, double precision,
dimension( ldvl, * ) vl, integer ldvl, double precision, dimension(
ldvr, * ) vr, integer ldvr, integer ilo, integer ihi, double precision,
dimension( * ) lscale, double precision, dimension( * ) rscale, double
precision abnrm, double precision bbnrm, double precision, dimension( *
) rconde, double precision, dimension( * ) rcondv, double precision,
dimension( * ) work, integer lwork, integer, dimension( * ) iwork,
logical, dimension( * ) bwork, integer info)
DGGEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices
πΈ Purpose πΈ
DGGEVX computes for a pair of N-by-N real nonsymmetric matrices (A,B) the generalized eigenvalues, and optionally, the left and/or right generalized eigenvectors.
Optionally also, it computes a balancing transformation to improve the conditioning of the eigenvalues and eigenvectors (ILO, IHI, LSCALE, RSCALE, ABNRM, and BBNRM), reciprocal condition numbers for the eigenvalues (RCONDE), and reciprocal condition numbers for the right eigenvectors (RCONDV). It's a whole glow-up for your conditioning π₯
A generalized eigenvalue for a pair of matrices (A,B) is a scalar lambda or a ratio alpha/beta = lambda, such that A - lambda*B is singular. It is usually represented as the pair (alpha,beta), as there is a reasonable interpretation for beta=0, and even for both being zero. Zero and zero? Valid. We don't judge here π
The right eigenvector v(j) corresponding to the eigenvalue lambda(j) of (A,B) satisfies
A * v(j) = lambda(j) * B * v(j) .
The left eigenvector u(j) corresponding to the eigenvalue lambda(j) of (A,B) satisfies
u(j)**H * A = lambda(j) * u(j)**H * B.
where u(j)**H is the conjugate-transpose of u(j). Conjugate-transpose is that girl, ngl.
π Parameters π
BALANCβBALANCis CHARACTER*1. Specifies the balance option to be performed:= 'N': do not diagonally scale or permute;= 'P': permute only;= 'S': scale only;= 'B': both permute and scale.
Computed reciprocal condition numbers will be for the matrices after permuting and/or balancing. Permuting does not change condition numbers (in exact arithmetic), but balancing does. So pick your fighter wisely.
JOBVLβJOBVLis CHARACTER*1:= 'N': do not compute the left generalized eigenvectors;= 'V': compute the left generalized eigenvectors.
JOBVRβJOBVRis CHARACTER*1:= 'N': do not compute the right generalized eigenvectors;= 'V': compute the right generalized eigenvectors.
SENSEβSENSEis CHARACTER*1. Determines which reciprocal condition numbers are computed:= 'N': none are computed;= 'E': computed for eigenvalues only;= 'V': computed for eigenvectors only;= 'B': computed for eigenvalues and eigenvectors.
Pick your SENSE, bestie, literally.
NβNis INTEGER. The order of the matricesA,B,VL, andVR. Constraint:N >= 0.AβAis DOUBLE PRECISION array, dimension (LDA, N). On entry, the matrixAin the pair(A,B). On exit,Ahas been overwritten. IfJOBVL='V'orJOBVR='V'or both, thenAcontains the first part of the real Schur form of the versions of the inputAandB. She's been through something, but she came out the other side πLDAβLDAis INTEGER. The leading dimension ofA.LDA >= max(1,N).BβBis DOUBLE PRECISION array, dimension (LDB, N). On entry, the matrixBin the pair(A,B). On exit,Bhas been overwritten. IfJOBVL='V'orJOBVR='V'or both, thenBcontains the second part of the real Schur form of the versions of the inputAandB. Matching set withA, iconic.LDBβLDBis INTEGER. The leading dimension ofB.LDB >= max(1,N).ALPHARβALPHARis DOUBLE PRECISION array, dimension (N). Real part of the alpha, keeping it together while ALPHAI handles the drama.ALPHAIβALPHAIis DOUBLE PRECISION array, dimension (N). The imaginary part, doing the most.BETAβBETAis DOUBLE PRECISION array, dimension (N). On exit,(ALPHAR(j) + ALPHAI(j)*i)/BETA(j),j=1,...,N, will be the generalized eigenvalues. IfALPHAI(j)is zero, then the j-th eigenvalue is real; if positive, then the j-th and (j+1)-st eigenvalues are a complex conjugate pair, withALPHAI(j+1)negative.
Note (read this, fr fr): the quotientsALPHAR(j)/BETA(j)andALPHAI(j)/BETA(j)may easily over- or underflow, andBETA(j)may even be zero. So please don't naively compute the ratioALPHA/BETAβ that's how you end up withInfin your output at 3am π. However,ALPHARandALPHAIwill be always less than and usually comparable withnorm(A)in magnitude, andBETAalways less than and usually comparable withnorm(B). So the pieces themselves are well-behaved.
VLβVLis DOUBLE PRECISION array, dimension (LDVL,N). IfJOBVL = 'V', the left eigenvectorsu(j)are stored one after another in the columns ofVL, in the same order as their eigenvalues. If the j-th eigenvalue is real, thenu(j) = VL(:,j), the j-th column ofVL. If the j-th and (j+1)-th eigenvalues form a complex conjugate pair, thenu(j) = VL(:,j)+i*VL(:,j+1)andu(j+1) = VL(:,j)-i*VL(:,j+1). Each eigenvector will be scaled so the largest component haveabs(real part) + abs(imag. part) = 1. Not referenced ifJOBVL = 'N'.LDVLβLDVLis INTEGER. The leading dimension of the matrixVL.LDVL >= 1, and ifJOBVL = 'V',LDVL >= N.VRβVRis DOUBLE PRECISION array, dimension (LDVR,N). IfJOBVR = 'V', the right eigenvectorsv(j)are stored one after another in the columns ofVR, in the same order as their eigenvalues. If the j-th eigenvalue is real, thenv(j) = VR(:,j), the j-th column ofVR. If the j-th and (j+1)-th eigenvalues form a complex conjugate pair, thenv(j) = VR(:,j)+i*VR(:,j+1)andv(j+1) = VR(:,j)-i*VR(:,j+1). Each eigenvector will be scaled so the largest component haveabs(real part) + abs(imag. part) = 1. Not referenced ifJOBVR = 'N'. Symmetry withVL, we love a coordinated duo π«ΆLDVRβLDVRis INTEGER. The leading dimension of the matrixVR.LDVR >= 1, and ifJOBVR = 'V',LDVR >= N.ILOβILOis INTEGER. (That's literally all the page says about her β mysterious, lowkey.)IHIβIHIβINTEGER. So here's the tea:ILOandIHIare the ranges where stuff actually still lives. On exit,A(i,j) = 0andB(i,j) = 0ifi > jandj = 1,...,ILO-1, or ifi = IHI+1,...,N. Basically everything outside the interesting block got zeroed out, slay. And ifBALANC = 'N'or'S', thenILO = 1andIHI = Nβ no permuting happened, so the whole matrix is the main character. πLSCALEβDOUBLE PRECISIONarray, dimension(N). This is the receipts for all the permutations and scaling factors that got applied to the left side ofAandB. So ifPL(j)is the index of the row interchanged with rowj, andDL(j)is the scaling factor applied to rowj, then:
LSCALE(j) = PL(j) for j = 1,...,ILO-1
= DL(j) for j = ILO,...,IHI
= PL(j) for j = IHI+1,...,N.
And the order in which the interchanges are made is N to IHI+1, then 1 to ILO-1. That's the sequence, don't come for me. π
RSCALEβDOUBLE PRECISIONarray, dimension(N). Literally the same situation but for the right side ofAandB. IfPR(j)is the index of the column interchanged with columnj, andDR(j)is the scaling factor applied to columnj, then:
RSCALE(j) = PR(j) for j = 1,...,ILO-1
= DR(j) for j = ILO,...,IHI
= PR(j) for j = IHI+1,...,N
Same interchange order, bestie: N to IHI+1, then 1 to ILO-1. No cap. β¨
ABNRMβDOUBLE PRECISION. The one-norm of the balanced matrixA. That's it, that's the whole vibe. πBBNRMβDOUBLE PRECISION. The one-norm of the balanced matrixB. Matching set, we love a coordinated moment. π¦RCONDEβDOUBLE PRECISIONarray, dimension(N). IfSENSE = 'E'or'B', this holds the reciprocal condition numbers of the eigenvalues, stored in consecutive elements of the array. For a complex conjugate pair of eigenvalues, two consecutive elements ofRCONDEare set to the same value β twins! SoRCONDE(j),RCONDV(j), and thej-th columns ofVLandVRall correspond to thej-th eigenpair. Everything lines up, it's giving organized. πΈ IfSENSE = 'Nor'V',RCONDEis not referenced. (Yes, the original really does have that stray quote in'Nβ leaving it exactly as found, don't @ me π)RCONDVβDOUBLE PRECISIONarray, dimension(N). IfSENSE = 'V'or'B', these are the estimated reciprocal condition numbers of the eigenvectors, stored in consecutive elements of the array. For a complex eigenvector, two consecutive elements ofRCONDVare set to the same value. And heads up: if the eigenvalues cannot be reordered to computeRCONDV(j), thenRCONDV(j)is set to0β and per the page, this can only occur when the true value would be very small anyway. So like, not a crisis. π IfSENSE = 'N'or'E',RCONDVis not referenced.WORKβDOUBLE PRECISIONarray, dimension(MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK. Free real estate info, we stan. π₯LWORKβINTEGER. The dimension of the arrayWORK. Buckle up:
LWORK >= max(1,2*N).
If BALANC = 'S' or 'B', or JOBVL = 'V', or JOBVR = 'V',
LWORK >= max(1,6*N).
If SENSE = 'E' or 'B', LWORK >= max(1,10*N).
If SENSE = 'V' or 'B', LWORK >= 2*N*N+8*N+16.
And the cute part: 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. Sneaky little size-checker, I love her. π
IWORKβINTEGERarray, dimension(N+6). IfSENSE = 'E',IWORKis not referenced. That's the whole paragraph, she's short and to the point. π«ΆBWORKβLOGICALarray, dimension(N). IfSENSE = 'N',BWORKis not referenced. Same energy. βINFOβINTEGER. The report card, let's read it together:= 0: successful exit. We love a clean finish. π< 0: ifINFO = -i, thei-th argument had an illegal value.= 1,...,N: The QZ iteration failed. No eigenvectors have been calculated, butALPHAR(j),ALPHAI(j), andBETA(j)should be correct forj=INFO+1,...,N.> N:=N+1: other than QZ iteration failed inDHGEQZ.=N+2: error return fromDTGEVC.
Okay so lowkey the INFO = 1,...,N case is the dramatic one β the iteration failed, no eigenvectors for you, but the eigenvalue pieces are still valid. Don't panic-delete anything. π
π«Ά Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
The whole squad showed up. Respect. π
π Further Details
Balancing a matrix pair (A,B) includes, first, permuting rows and columns to isolate eigenvalues, and second, applying a diagonal similarity transformation to the rows and columns to make the rows and columns as close in norm as possible. The computed reciprocal condition numbers correspond to the balanced matrix. Permuting rows and columns will not change the condition numbers (in exact arithmetic) but diagonal scaling will. For further explanation of balancing, see section 4.11.1.2 of LAPACK Users' Guide. It's giving "read the textbook, bestie." π
So here's the error-bound situation. An approximate error bound on the chordal distance between the i-th computed generalized eigenvalue w and the corresponding exact eigenvalue lambda is:
chord(w, lambda) <= EPS * norm(ABNRM, BBNRM) / RCONDE(I)
And an approximate error bound for the angle between the i-th computed eigenvector VL(i) or VR(i) is given by:
EPS * norm(ABNRM, BBNRM) / DIF(i).
For further explanation of the reciprocal condition numbers RCONDE and RCONDV, see section 4.11 of LAPACK User's Guide. Yes, another section. Go read it, it's worth it. β¨
Definition at line 387 of file dggevx.f. π
π sggevx β the single-precision twin, obvs
Like, same energy, REAL instead of DOUBLE PRECISION. The glow-up:
subroutine sggevx (character balanc, character jobvl, character jobvr,
character sense, integer n, real, dimension( lda, * ) a, integer lda,
real, dimension( ldb, * ) b, integer ldb, real, dimension( * ) alphar,
real, dimension( * ) alphai, real, dimension( * ) beta, real, dimension(
ldvl, * ) vl, integer ldvl, real, dimension( ldvr, * ) vr, integer ldvr,
integer ilo, integer ihi, real, dimension( * ) lscale, real, dimension(
* ) rscale, real abnrm, real bbnrm, real, dimension( * ) rconde, real,
dimension( * ) rcondv, real, dimension( * ) work, integer lwork,
integer, dimension( * ) iwork, logical, dimension( * ) bwork, integer
info)
SGGEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices. π¦
β¨ Purpose β¨
So SGGEVX computes, for a pair of N-by-N real nonsymmetric matrices (A,B), the generalized eigenvalues, and optionally, the left and/or right generalized eigenvectors. Main character behaviour. π
Optionally also, it computes a balancing transformation to improve the conditioning of the eigenvalues and eigenvectors (ILO, IHI, LSCALE, RSCALE, ABNRM, and BBNRM), reciprocal condition numbers for the eigenvalues (RCONDE), and reciprocal condition numbers for the right eigenvectors (RCONDV). Look at all those outputs, thriving. π
A generalized eigenvalue for a pair of matrices (A,B) is a scalar lambda or a ratio alpha/beta = lambda, such that A - lambda*B is singular. It is usually represented as the pair (alpha,beta), as there is a reasonable interpretation for beta=0, and even for both being zero. Equality, but make it linear algebra. π
The right eigenvector v(j) corresponding to the eigenvalue lambda(j) of (A,B) satisfies:
A * v(j) = lambda(j) * B * v(j) .
The left eigenvector u(j) corresponding to the eigenvalue lambda(j) of (A,B) satisfies:
u(j)**H * A = lambda(j) * u(j)**H * B.
where u(j)**H is the conjugate-transpose of u(j). Get you a routine that does both directions. π₯
π Parameters
BALANCβCHARACTER*1. Specifies the balance option to be performed. The menu:= 'N': do not diagonally scale or permute;= 'P': permute only;= 'S': scale only;= 'B': both permute and scale.
Computed reciprocal condition numbers will be for the matrices after permuting and/or balancing. Permuting does not change condition numbers (in exact arithmetic), but balancing does. Choose wisely, bestie. π§
JOBVLβCHARACTER*1.= 'N': do not compute the left generalized eigenvectors;= 'V': compute the left generalized eigenvectors.
JOBVRβCHARACTER*1.= 'N': do not compute the right generalized eigenvectors;= 'V': compute the right generalized eigenvectors.
SENSEβCHARACTER*1. Determines which reciprocal condition numbers are computed.= 'N': none are computed;= 'E': computed for eigenvalues only;= 'V': computed for eigenvectors only;= 'B': computed for eigenvalues and eigenvectors.
Pick your fighter. π
NβINTEGER. The order of the matricesA,B,VL, andVR. Constraint:N >= 0. Not negotiable, it's a dimension. πAβREALarray, dimension(LDA, N). On entry, the matrixAin the pair(A,B). On exit,Ahas been overwritten. IfJOBVL='V'orJOBVR='V'or both, thenAcontains the first part of the real Schur form of the versions of the inputAandB. She's been through something, but she's fine. πLDAβINTEGER. The leading dimension ofA. Constraint:LDA >= max(1,N).BβREALarray, dimension(LDB, N). On entry, the matrixBin the pair(A,B). On exit,Bhas been overwritten. IfJOBVL='V'orJOBVR='V'or both, thenBcontains the second part of the real Schur form of the versions of the inputAandB. Matching set withA, as it should be. πLDBβINTEGER. The leading dimension ofB. Constraint:LDB >= max(1,N).ALPHARβREALarray, dimension(N). (That's literally all this page says here β the real parts are just vibing in their own array. π)ALPHAIβ okay so the imaginary parts are next, and that's exactly where we're picking this back up β don't go anywhere, bestie, the description of this one is literally right there on the next page π β¨ALPHAIβ REAL array, dimension(N)πBETAβ REAL array, dimension(N). On exit,(ALPHAR(j) + ALPHAI(j)*i)/BETA(j), forj=1,...,N, gives you the generalized eigenvalues π IfALPHAI(j)is zero then the j-th eigenvalue is real, if it's positive then the j-th and (j+1)-st eigenvalues are a complex conjugate pair, withALPHAI(j+1)negative. No cap.
Ok so massive heads-up here bestie, this is the "don't do the obvious thing" warning π The quotientsALPHAR(j)/BETA(j)andALPHAI(j)/BETA(j)can easily over- or underflow, andBETA(j)might legitimately be zero. So pls pls pls do not naively compute the ratioALPHA/BETA. The good news:ALPHARandALPHAIare always less than, and usually comparable with,norm(A)in magnitude, andBETAis always less than, and usually comparable with,norm(B). Slay.
VLβ REAL array, dimension(LDVL,N). IfJOBVL = 'V', the left eigenvectorsu(j)are stored one after another in the columns ofVL, in the same order as their eigenvalues β If the j-th eigenvalue is real, thenu(j) = VL(:,j), the j-th column ofVL. If the j-th and (j+1)-th eigenvalues form a complex conjugate pair, thenu(j) = VL(:,j)+i*VL(:,j+1)andu(j+1) = VL(:,j)-i*VL(:,j+1). Each eigenvector gets scaled so the largest component hasabs(real part) + abs(imag. part) = 1. Not referenced ifJOBVL = 'N'πLDVLβ INTEGER. The leading dimension of the matrixVL.LDVL >= 1, and ifJOBVL = 'V',LDVL >= Nπ¦VRβ REAL array, dimension(LDVR,N). IfJOBVR = 'V', the right eigenvectorsv(j)are stored one after another in the columns ofVR, in the same order as their eigenvalues β¨ Same energy asVL: if the j-th eigenvalue is real, thenv(j) = VR(:,j), the j-th column ofVR. If the j-th and (j+1)-th eigenvalues form a complex conjugate pair, thenv(j) = VR(:,j)+i*VR(:,j+1)andv(j+1) = VR(:,j)-i*VR(:,j+1). Each eigenvector is scaled so the largest component hasabs(real part) + abs(imag. part) = 1. Not referenced ifJOBVR = 'N'πLDVRβ INTEGER. The leading dimension of the matrixVR.LDVR >= 1, and ifJOBVR = 'V',LDVR >= NπΈILOβ INTEGER π«ΆIHIβ INTEGER.ILOandIHIare integer values such that on exitA(i,j) = 0andB(i,j) = 0ifi > jandj = 1,...,ILO-1ori = IHI+1,...,N. IfBALANC = 'N'or'S', thenILO = 1andIHI = NπLSCALEβ REAL array, dimension(N). All the deets of the permutations and scaling factors applied to the left side ofAandBπ IfPL(j)is the index of the row interchanged with rowj, andDL(j)is the scaling factor applied to rowj, then:
LSCALE(j) = PL(j) for j = 1,...,ILO-1
= DL(j) for j = ILO,...,IHI
= PL(j) for j = IHI+1,...,N.
The order in which the interchanges are made is N to IHI+1, then 1 to ILO-1 β
RSCALEβ REAL array, dimension(N). Same vibe but for the right side ofAandBπ IfPR(j)is the index of the column interchanged with columnj, andDR(j)is the scaling factor applied to columnj, then:
RSCALE(j) = PR(j) for j = 1,...,ILO-1
= DR(j) for j = ILO,...,IHI
= PR(j) for j = IHI+1,...,N
The order in which the interchanges are made is N to IHI+1, then 1 to ILO-1 π«
ABNRMβ REAL. The one-norm of the balanced matrixAπBBNRMβ REAL. The one-norm of the balanced matrixBπRCONDEβ REAL array, dimension(N). IfSENSE = 'E'or'B', this holds the reciprocal condition numbers of the eigenvalues, stored in consecutive elements of the array. For a complex conjugate pair of eigenvalues, two consecutive elements ofRCONDEget set to the same value. SoRCONDE(j),RCONDV(j), and the j-th columns ofVLandVRall correspond to the j-th eigenpair β matching set, iconic π IfSENSE = 'N'or'V',RCONDEis not referenced πRCONDVβ REAL array, dimension(N). IfSENSE = 'V'or'B', these are the estimated reciprocal condition numbers of the eigenvectors, stored in consecutive elements of the array. For a complex eigenvector, two consecutive elements ofRCONDVare set to the same value. If the eigenvalues cannot be reordered to computeRCONDV(j), thenRCONDV(j)is set to0β and ngl that can only happen when the true value would be very small anyway, so it's not the tragedy it sounds like π IfSENSE = 'N'or'E',RCONDVis not referenced.WORKβ REAL array, dimension(MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORKβ¨LWORKβ INTEGER. The dimension of the arrayWORK.LWORK >= max(1,2*N). And then it escalates, bestie:- If
BALANC = 'S'or'B', orJOBVL = 'V', orJOBVR = 'V', thenLWORK >= max(1,6*N). - If
SENSE = 'E', thenLWORK >= max(1,10*N). - If
SENSE = 'V'or'B', thenLWORK >= 2*N*N+8*N+16.
- If
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. Literally just asking "how much room do u need", no drama π
IWORKβ INTEGER array, dimension(N+6). IfSENSE = 'E',IWORKis not referenced π¦BWORKβ LOGICAL array, dimension(N). IfSENSE = 'N',BWORKis not referenced π¦INFOβ INTEGER, the vibe check at the end of the run:= 0: successful exit π slay< 0: ifINFO = -i, the i-th argument had an illegal value π= 1,...,N: the QZ iteration failed π No eigenvectors have been calculated, butALPHAR(j),ALPHAI(j), andBETA(j)should be correct forj=INFO+1,...,Nβ so you still get partial credit.> N:=N+1: something other than QZ iteration failed inSHGEQZ.=N+2: error return fromSTGEVCπ«
π Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
πΈ Further Details:
Balancing a matrix pair (A,B) is a whole little two-step, ok: first, permuting rows and columns to isolate eigenvalues, second, applying diagonal similarity transformation to the rows and columns to make the rows and columns as close in norm as possible. The computed reciprocal condition numbers correspond to the balanced matrix. Permuting rows and columns will not change the condition numbers (in exact arithmetic) but diagonal scaling will. For further explanation of balancing, see section 4.11.1.2 of LAPACK Users' Guide π
An approximate error bound on the chordal distance between the i-th computed generalized eigenvalue w and the corresponding exact eigenvalue lambda is:
chord(w, lambda) <= EPS * norm(ABNRM, BBNRM) / RCONDE(I)
An approximate error bound for the angle between the i-th computed eigenvector VL(i) or VR(i) is given by:
EPS * norm(ABNRM, BBNRM) / DIF(i).
For further explanation of the reciprocal condition numbersRCONDEandRCONDV, see section 4.11 of LAPACK User's Guide π
Definition at line 387 of file sggevx.f.
π¦ subroutine zggevx π¦
Fr fr, here's the complex sibling β same energy, different precision:
subroutine zggevx (character balanc, character jobvl, character jobvr,
character sense, integer n, complex*16, dimension( lda, * ) a, integer
lda, complex*16, dimension( ldb, * ) b, integer ldb, complex*16,
dimension( * ) alpha, complex*16, dimension( * ) beta, complex*16,
dimension( ldvl, * ) vl, integer ldvl, complex*16, dimension( ldvr, * )
vr, integer ldvr, integer ilo, integer ihi, double precision, dimension(
* ) lscale, double precision, dimension( * ) rscale, double precision
abnrm, double precision bbnrm, double precision, dimension( * ) rconde,
double precision, dimension( * ) rcondv, complex*16, dimension( * )
work, integer lwork, double precision, dimension( * ) rwork, integer,
dimension( * ) iwork, logical, dimension( * ) bwork, integer info)
ZGGEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices π
β¨
Purpose:
ZGGEVX is out here computing, for a pair of N-by-N complex nonsymmetric matrices (A,B), the generalized eigenvalues β and optionally the left and/or right generalized eigenvectors. π
Optionally it also computes a balancing transformation to improve the conditioning of the eigenvalues and eigenvectors (ILO, IHI, LSCALE, RSCALE, ABNRM, and BBNRM), reciprocal condition numbers for the eigenvalues (RCONDE), and reciprocal condition numbers for the right eigenvectors (RCONDV). β¨
A generalized eigenvalue for a pair of matrices (A,B) is a scalar lambda or a ratio alpha/beta = lambda, such that A - lambda*B is singular. It's usually represented as the pair (alpha,beta), because there's a reasonable interpretation for beta=0, and even for both being zero. π
The right eigenvector v(j) corresponding to the eigenvalue lambda(j) of (A,B) satisfies
A * v(j) = lambda(j) * B * v(j) .
The left eigenvector u(j) corresponding to the eigenvalue lambda(j) of (A,B) satisfies
u(j)**H * A = lambda(j) * u(j)**H * B.
where u(j)**H is the conjugate-transpose of u(j). π¦
β¨ Parameters β¨
πΈ BALANC
CHARACTER*1 β tells us which balance option to perform, bestie:
'N': do not diagonally scale or permute;'P': permute only;'S': scale only;'B': both permute and scale.
Heads up fr: computed reciprocal condition numbers will be for the matrices after permuting and/or balancing. Permuting does not change condition numbers (in exact arithmetic), but balancing does. π«Ά
πΈ JOBVL
CHARACTER*1:
'N': do not compute the left generalized eigenvectors;'V': compute the left generalized eigenvectors.
πΈ JOBVR
CHARACTER*1:
'N': do not compute the right generalized eigenvectors;'V': compute the right generalized eigenvectors.
πΈ SENSE
CHARACTER*1 β determines which reciprocal condition numbers are computed:
'N': none are computed;'E': computed for eigenvalues only;'V': computed for eigenvectors only;'B': computed for eigenvalues and eigenvectors.
πΈ N
INTEGER β the order of the matrices A, B, VL, and VR. N >= 0. π
πΈ A
COMPLEX*16 array, dimension (LDA, N)
On entry, the matrix A in the pair (A,B). On exit, A has been overwritten. If JOBVL='V' or JOBVR='V' or both, then A contains the first part of the complex Schur form of the versions of the input A and B. π«
πΈ LDA
INTEGER β the leading dimension of A. LDA >= max(1,N).
πΈ B
COMPLEX*16 array, dimension (LDB, N)
On entry, the matrix B in the pair (A,B). On exit, B has been overwritten. If JOBVL='V' or JOBVR='V' or both, then B contains the second part of the complex Schur form of the versions of the input A and B. π«
πΈ LDB
INTEGER β the leading dimension of B. LDB >= max(1,N).
πΈ ALPHA
COMPLEX*16 array, dimension (N) β that's it, that's the whole description. iconic, honestly. π
πΈ BETA
COMPLEX*16 array, dimension (N)
On exit, ALPHA(j)/BETA(j), j=1,...,N, will be the generalized eigenvalues. π
β οΈ okay so real talk: the quotientALPHA(j)/BETA(j)may easily over- or underflow, andBETA(j)may even be zero. Thus, the user should avoid naively computing the ratioALPHA/BETA. However,ALPHAwill be always less than and usually comparable withnorm(A)in magnitude, andBETAalways less than and usually comparable withnorm(B). π
πΈ VL
COMPLEX*16 array, dimension (LDVL,N)
If JOBVL = 'V', the left generalized eigenvectors u(j) are stored one after another in the columns of VL, in the same order as their eigenvalues.
Each eigenvector will be scaled so the largest component will have abs(real part) + abs(imag. part) = 1. β¨
Not referenced if JOBVL = 'N'.
πΈ LDVL
INTEGER β the leading dimension of the matrix VL. LDVL >= 1, and if JOBVL = 'V', LDVL >= N.
πΈ VR
COMPLEX*16 array, dimension (LDVR,N)
If JOBVR = 'V', the right generalized eigenvectors v(j) are stored one after another in the columns of VR, in the same order as their eigenvalues.
Each eigenvector will be scaled so the largest component will have abs(real part) + abs(imag. part) = 1. β¨
Not referenced if JOBVR = 'N'.
πΈ LDVR
INTEGER β the leading dimension of the matrix VR. LDVR >= 1, and if JOBVR = 'V', LDVR >= N.
πΈ ILO
INTEGER β bestie, it's just an INTEGER. π«Ά
πΈ IHI
INTEGER
ILO and IHI are integer values such that on exit A(i,j) = 0 and B(i,j) = 0 if i > j and j = 1,...,ILO-1 or i = IHI+1,...,N.
If BALANC = 'N' or 'S', ILO = 1 and IHI = N. π¦
πΈ LSCALE
DOUBLE PRECISION array, dimension (N)
Details of the permutations and scaling factors applied to the left side of A and B. If PL(j) is the index of the row interchanged with row j, and DL(j) is the scaling factor applied to row j, then
LSCALE(j) = PL(j) for j = 1,...,ILO-1
= DL(j) for j = ILO,...,IHI
= PL(j) for j = IHI+1,...,N.
The order in which the interchanges are made is N to IHI+1, then 1 to ILO-1. π
πΈ RSCALE
DOUBLE PRECISION array, dimension (N)
Details of the permutations and scaling factors applied to the right side of A and B. If PR(j) is the index of the column interchanged with column j, and DR(j) is the scaling factor applied to column j, then
RSCALE(j) = PR(j) for j = 1,...,ILO-1
= DR(j) for j = ILO,...,IHI
= PR(j) for j = IHI+1,...,N
The order in which the interchanges are made is N to IHI+1, then 1 to ILO-1. π
πΈ ABNRM
DOUBLE PRECISION β the one-norm of the balanced matrix A. periodt. π
πΈ BBNRM
DOUBLE PRECISION β the one-norm of the balanced matrix B. π
πΈ RCONDE
DOUBLE PRECISION array, dimension (N)
If SENSE = 'E' or 'B', the reciprocal condition numbers of the eigenvalues, stored in consecutive elements of the array.
If SENSE = 'N' or 'V', RCONDE is not referenced. π
πΈ RCONDV
DOUBLE PRECISION array, dimension (N)
If JOB = 'V' or 'B', the estimated reciprocal condition numbers of the eigenvectors, stored in consecutive elements of the array. If the eigenvalues cannot be reordered to compute RCONDV(j), RCONDV(j) is set to 0; this can only occur when the true value would be very small anyway. π
If SENSE = 'N' or 'E', RCONDV is not referenced.
πΈ WORK
COMPLEX*16 array, dimension (MAX(1,LWORK))
On exit, if INFO = 0, WORK(1) returns the optimal LWORK. β
πΈ LWORK
INTEGER β the dimension of the array WORK.
LWORK >= max(1,2*N).
If SENSE = 'E', LWORK >= max(1,4*N).
If SENSE = 'V' or 'B', LWORK >= max(1,2*N*N+2*N).
π₯ IfLWORK = -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. big main character energy.
πΈ RWORK
DOUBLE PRECISION array, dimension (lrwork)
lrwork must be at least max(1,6*N) if BALANC = 'S' or 'B', and at least max(1,2*N) otherwise.
Real workspace. π
πΈ IWORK
INTEGER array, dimension (N+2)
If SENSE = 'E', IWORK is not referenced. π¦
πΈ BWORK
LOGICAL array, dimension (N)
If SENSE = 'N', BWORK is not referenced. π¦
πΈ INFO
INTEGER β the vibe check at the end:
= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value.= 1,...,N: The QZ iteration failed. No eigenvectors have been calculated, butALPHA(j)andBETA(j)should be correct forj=INFO+1,...,N. π> N:=N+1: other than QZ iteration failed inZHGEQZ.=N+2: error return fromZTGEVC. π
π Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Further Details: π (yes bestie, there's more, hold onβ)
okay so let's talk balancing real quick because it's lowkey doing the most π
Balancing a matrix pair (A,B) is a two-step lil routine, in order: first, permuting rows and columns to isolate eigenvalues, and second, applying a diagonal similarity transformation to the rows and columns to make the rows and columns as close in norm as possible. Two separate moves, bestie, don't mix them up β¨
Now here's the tea that actually matters: the computed reciprocal condition numbers correspond to the balanced matrix. And ngl the two steps behave differently β permuting rows and columns will not change the condition numbers (in exact arithmetic), but diagonal scaling will. So like, one of them is a freebie and one of them actually moves the numbers π. For further explanation of balancing, see section 4.11.1.2 of LAPACK Users' Guide.
πΈ error bounds, aka how wrong are you actually
An approximate error bound on the chordal distance between the i-th computed generalized eigenvalue w and the corresponding exact eigenvalue lambda is:
chord(w, lambda) <= EPS * norm(ABNRM, BBNRM) / RCONDE(I)
And an approximate error bound for the angle between the i-th computed eigenvector VL(i) or VR(i) is given by:
EPS * norm(ABNRM, BBNRM) / DIF(i).
Like, those are bounds, not promises β approximate, bestie, keep that in mind π. For further explanation of the reciprocal condition numbers RCONDE and RCONDV, see section 4.11 of LAPACK Users' Guide. go read it, it's giving study session π
π where this even lives
Definition at line370of filezggevx.f.
π Author
Generated automatically by Doxygen for LAPACK from the source code. not a human, just a robot doing its little documentation duties π«Ά
aaaand that's the whole page, bestie, you made it to the end ππ This was LAPACK Version 3.12.0, the ggevx(3) page β that's the source and version, and the date is whatever your manpage build decided it was when it rendered this (the footer doesn't pin one down, so don't @ me π). mwah, go balance something π
β¨
π¦ 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