realGEcomputational(3)
πΈ NAME πΈ
realGEcomputational β real π
β¨ SYNOPSIS β¨
okay so here's the whole squad of functions, no cap:
subroutine sgebak (JOB, SIDE, N, ILO, IHI, SCALE, M, V, LDV, INFO)β SGEBAKsubroutine sgebal (JOB, N, A, LDA, ILO, IHI, SCALE, INFO)β SGEBALsubroutine sgebd2 (M, N, A, LDA, D, E, TAUQ, TAUP, WORK, INFO)β SGEBD2 reduces a general matrix to bidiagonal form using an unblocked algorithm.subroutine sgebrd (M, N, A, LDA, D, E, TAUQ, TAUP, WORK, LWORK, INFO)β SGEBRDsubroutine sgecon (NORM, N, A, LDA, ANORM, RCOND, WORK, IWORK, INFO)β SGECONsubroutine sgeequ (M, N, A, LDA, R, C, ROWCND, COLCND, AMAX, INFO)β SGEEQUsubroutine sgeequb (M, N, A, LDA, R, C, ROWCND, COLCND, AMAX, INFO)β SGEEQUBsubroutine sgehd2 (N, ILO, IHI, A, LDA, TAU, WORK, INFO)β SGEHD2 reduces a general square matrix to upper Hessenberg form using an unblocked algorithm.subroutine sgehrd (N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO)β SGEHRDsubroutine sgelq2 (M, N, A, LDA, TAU, WORK, INFO)β SGELQ2 computes the LQ factorization of a general rectangular matrix using an unblocked algorithm.subroutine sgelqf (M, N, A, LDA, TAU, WORK, LWORK, INFO)β SGELQFsubroutine sgemqrt (SIDE, TRANS, M, N, K, NB, V, LDV, T, LDT, C, LDC, WORK, INFO)β SGEMQRTsubroutine sgeql2 (M, N, A, LDA, TAU, WORK, INFO)β SGEQL2 computes the QL factorization of a general rectangular matrix using an unblocked algorithm.subroutine sgeqlf (M, N, A, LDA, TAU, WORK, LWORK, INFO)β SGEQLFsubroutine sgeqp3 (M, N, A, LDA, JPVT, TAU, WORK, LWORK, INFO)β SGEQP3subroutine sgeqr2 (M, N, A, LDA, TAU, WORK, INFO)β SGEQR2 computes the QR factorization of a general rectangular matrix using an unblocked algorithm.subroutine sgeqr2p (M, N, A, LDA, TAU, WORK, INFO)β SGEQR2P computes the QR factorization of a general rectangular matrix with non-negative diagonal elements using an unblocked algorithm.subroutine sgeqrf (M, N, A, LDA, TAU, WORK, LWORK, INFO)β SGEQRFsubroutine sgeqrfp (M, N, A, LDA, TAU, WORK, LWORK, INFO)β SGEQRFPsubroutine sgeqrt (M, N, NB, A, LDA, T, LDT, WORK, INFO)β SGEQRTsubroutine sgeqrt2 (M, N, A, LDA, T, LDT, INFO)β SGEQRT2 computes a QR factorization of a general real or complex matrix using the compact WY representation of Q.recursive subroutine sgeqrt3 (M, N, A, LDA, T, LDT, INFO)β SGEQRT3 recursively computes a QR factorization of a general real or complex matrix using the compact WY representation of Q.subroutine sgerfs (TRANS, N, NRHS, A, LDA, AF, LDAF, IPIV, B, LDB, X, LDX, FERR, BERR, WORK, IWORK, INFO)β SGERFSsubroutine sgerfsx (TRANS, EQUED, N, NRHS, A, LDA, AF, LDAF, IPIV, R, C, B, LDB, X, LDX, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_NORM, ERR_BNDS_COMP, NPARAMS, PARAMS, WORK, IWORK, INFO)β SGERFSXsubroutine sgerq2 (M, N, A, LDA, TAU, WORK, INFO)β SGERQ2 computes the RQ factorization of a general rectangular matrix using an unblocked algorithm.subroutine sgerqf (M, N, A, LDA, TAU, WORK, LWORK, INFO)β SGERQFsubroutine sgesvj (JOBA, JOBU, JOBV, M, N, A, LDA, SVA, MV, V, LDV, WORK, LWORK, INFO)β SGESVJsubroutine sgetf2 (M, N, A, LDA, IPIV, INFO)β SGETF2 computes the LU factorization of a general m-by-n matrix using partial pivoting with row interchanges (unblocked algorithm).subroutine sgetrf (M, N, A, LDA, IPIV, INFO)β SGETRFrecursive subroutine sgetrf2 (M, N, A, LDA, IPIV, INFO)β SGETRF2subroutine sgetri (N, A, LDA, IPIV, WORK, LWORK, INFO)β SGETRIsubroutine sgetrs (TRANS, N, NRHS, A, LDA, IPIV, B, LDB, INFO)β SGETRSsubroutine shgeqz (JOB, COMPQ, COMPZ, N, ILO, IHI, H, LDH, T, LDT, ALPHAR, ALPHAI, BETA, Q, LDQ, Z, LDZ, WORK, LWORK, INFO)β SHGEQZsubroutine sla_geamv (TRANS, M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)β SLA_GEAMV computes a matrix-vector product using a general matrix to calculate error bounds.real function sla_gercond (TRANS, N, A, LDA, AF, LDAF, IPIV, CMODE, C, INFO, WORK, IWORK)β SLA_GERCOND estimates the Skeel condition number for a general matrix.subroutine sla_gerfsx_extended (PREC_TYPE, TRANS_TYPE, N, NRHS, A, LDA, AF, LDAF, IPIV, COLEQU, C, B, LDB, Y, LDY, BERR_OUT, N_NORMS, ERRS_N, ERRS_C, RES, AYB, DY, Y_TAIL, RCOND, ITHRESH, RTHRESH, DZ_UB, IGNORE_CWISE, INFO)β SLA_GERFSX_EXTENDED improves the computed solution to a system of linear equations for general matrices by performing extra-precise iterative refinement and provides error bounds and backward error estimates for the solution.real function sla_gerpvgrw (N, NCOLS, A, LDA, AF, LDAF)β SLA_GERPVGRWsubroutine slaorhr_col_getrfnp (M, N, A, LDA, D, INFO)β SLAORHR_COL_GETRFNPrecursive subroutine slaorhr_col_getrfnp2 (M, N, A, LDA, D, INFO)β SLAORHR_COL_GETRFNP2subroutine stgevc (SIDE, HOWMNY, SELECT, N, S, LDS, P, LDP, VL, LDVL, VR, LDVR, MM, M, WORK, INFO)β STGEVCsubroutine stgexc (WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z, LDZ, IFST, ILST, WORK, LWORK, INFO)β STGEXC
π Detailed Description π
This is the group of real computational functions for GE matrices. periodt. π
π¦ Function Documentation π¦
π subroutine sgebak β SGEBAK π
subroutine sgebak (character JOB, character SIDE, integer N, integer ILO,
integer IHI, real, dimension( * ) SCALE, integer M, real, dimension(
ldv, * ) V, integer LDV, integer INFO)
Purpose: bestie, SGEBAK forms the right or left eigenvectors of a real general matrix by backward transformation on the computed eigenvectors of the balanced matrix output by SGEBAL. That's literally the whole point. β¨
Parameters
JOBβJOBisCHARACTER*1. It specifies the type of backward transformation required:= 'N': do nothing, return immediately;= 'P': do backward transformation for permutation only;= 'S': do backward transformation for scaling only;= 'B': do backward transformations for both permutation and scaling.JOBmust be the same as the argumentJOBsupplied toSGEBAL.
SIDEβSIDEisCHARACTER*1:= 'R':Vcontains right eigenvectors;= 'L':Vcontains left eigenvectors.
NβNisINTEGER. The number of rows of the matrixV.N >= 0.ILOβILOisINTEGER.IHIβIHIisINTEGER. The integersILOandIHIdetermined bySGEBAL.1 <= ILO <= IHI <= N, ifN > 0;ILO=1andIHI=0, ifN=0.SCALEβSCALEisREALarray, dimension (N). Details of the permutation and scaling factors, as returned bySGEBAL.MβMisINTEGER. The number of columns of the matrixV.M >= 0.VβVisREALarray, dimension (LDV,M). On entry, the matrix of right or left eigenvectors to be transformed, as returned bySHSEINorSTREVC. On exit,Vis overwritten by the transformed eigenvectors.LDVβLDVisINTEGER. The leading dimension of the arrayV.LDV >= max(1,N).INFOβINFOisINTEGER:= 0: successful exit< 0: ifINFO = -i, thei-th argument had an illegal value.
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
π subroutine sgebal β SGEBAL π
subroutine sgebal (character JOB, integer N, real, dimension( lda, * ) A,
integer LDA, integer ILO, integer IHI, real, dimension( * ) SCALE,
integer INFO)
Purpose: SGEBAL balances a general real matrix A. This involves, first, permuting A by a similarity transformation to isolate eigenvalues in the first 1 to ILO-1 and last IHI+1 to N elements on the diagonal; and second, applying a diagonal similarity transformation to rows and columns ILO to IHI to make the rows and columns as close in norm as possible. Both steps are optional.
Balancing may reduce the 1-norm of the matrix, and improve the accuracy of the computed eigenvalues and/or eigenvectors.
Parameters
JOBβJOBisCHARACTER*1. Specifies the operations to be performed onA:= 'N': none: simply setILO = 1,IHI = N,SCALE(I) = 1.0fori = 1,...,N;= 'P': permute only;= 'S': scale only;= 'B': both permute and scale.
NβNisINTEGER. The order of the matrixA.N >= 0.AβAisREALarray, dimension (LDA,N). On entry, the input matrixA. On exit,Ais overwritten by the balanced matrix. IfJOB = 'N',Ais not referenced. See Further Details.LDAβLDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,N).ILOβILOisINTEGER.IHIβIHIisINTEGER.ILOandIHIare set to integers such that on exitA(i,j) = 0ifi > jandj = 1,...,ILO-1orI = IHI+1,...,N. IfJOB = 'N'or'S',ILO = 1andIHI = N.SCALEβSCALEisREALarray, dimension (N). Details of the permutations and scaling factors applied toA. IfP(j)is the index of the row and column interchanged with row and columnjandD(j)is the scaling factor applied to row and columnj, then
SCALE(j) = P(j) for j = 1,...,ILO-1
= D(j) for j = ILO,...,IHI
= P(j) for j = IHI+1,...,N.
The order in which the interchanges are made is N to IHI+1, then 1 to ILO-1.
INFOβINFOisINTEGER:= 0: successful exit.< 0: ifINFO = -i, thei-th argument had an illegal value.
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Further Details
The permutations consist of row and column interchanges which put the matrix in the form
( T1 X Y )
P A P = ( 0 B Z )
( 0 0 T2 )
...where T1 and T2 are upper triangular matrices and their eigenvalues are just sitting there, right along the diagonal. π
The column indices ILO and IHI mark the starting and ending columns of the submatrix B, okay? And balancing? Bestie, balancing is literally just applying a diagonal similarity transformation inv(D) * B * D so that the 1-norms of each row of B and its corresponding column are nearly equal. That's the whole assignment. β¨
The output matrix comes out looking like this:
( T1 X*D Y )
( 0 inv(D)*B*D inv(D)*Z ).
( 0 0 T2 )
And all the info about the permutations P and the diagonal matrix D? It gets handed back to you in the vector SCALE. π
This subroutine is based on the EISPACK routine BALANC.
Modified by Tzu-Yi Chen, Computer Science Division, University of California at Berkeley, USA
π¦ sgebd2 π¦
subroutine sgebd2 (integer M, integer N, real, dimension( lda, * ) A,
integer LDA, real, dimension( * ) D, real, dimension( * ) E, real,
dimension( * ) TAUQ, real, dimension( * ) TAUP, real, dimension( * )
WORK, integer INFO)
SGEBD2 reduces a general matrix to bidiagonal form using an unblocked algorithm. (the unblocked one, iykyk β it's giving small-and-simple energy πΈ)
β¨ Purpose β¨
SGEBD2 reduces a real general m by n matrix A to upper or lower bidiagonal form B by an orthogonal transformation: Q**T * A * P = B.
If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal.
π Parameters π
MβMis INTEGER. The number of rows in the matrix A.M >= 0.NβNis INTEGER. The number of columns in the matrix A.N >= 0.AβAis REAL array, dimension(LDA,N).
On entry, the m by n general matrix to be reduced.
On exit:
- if
m >= n, the diagonal and the first superdiagonal are overwritten with the upper bidiagonal matrix B; the elements below the diagonal, with the array TAUQ, represent the orthogonal matrix Q as a product of elementary reflectors, and the elements above the first superdiagonal, with the array TAUP, represent the orthogonal matrix P as a product of elementary reflectors; - if
m < n, the diagonal and the first subdiagonal are overwritten with the lower bidiagonal matrix B; the elements below the first subdiagonal, with the array TAUQ, represent the orthogonal matrix Q as a product of elementary reflectors, and the elements above the diagonal, with the array TAUP, represent the orthogonal matrix P as a product of elementary reflectors.
See Further Details. π
LDAβLDAis INTEGER. The leading dimension of the array A.LDA >= max(1,M).DβDis REAL array, dimension(min(M,N)). The diagonal elements of the bidiagonal matrix B:D(i) = A(i,i).EβEis REAL array, dimension(min(M,N)-1). The off-diagonal elements of the bidiagonal matrix B:- if
m >= n,E(i) = A(i,i+1)fori = 1,2,...,n-1; - if
m < n,E(i) = A(i+1,i)fori = 1,2,...,m-1.
- if
TAUQβTAUQis REAL array, dimension(min(M,N)). The scalar factors of the elementary reflectors which represent the orthogonal matrix Q. See Further Details.TAUPβTAUPis REAL array, dimension(min(M,N)). The scalar factors of the elementary reflectors which represent the orthogonal matrix P. See Further Details.WORKβWORKis REAL array, dimension(max(M,N)).INFOβINFOis INTEGER.= 0: successful exit.< 0: ifINFO = -i, the i-th argument had an illegal value. π¨
π«Ά Author π«Ά
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
π Further Details π
The matrices Q and P are represented as products of elementary reflectors:
If m >= n,
Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1)
Each H(i) and G(i) has the form:
H(i) = I - tauq * v * v**T and G(i) = I - taup * u * u**T
where tauq and taup are real scalars, and v and u are real vectors;
v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in A(i+1:m,i);
u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in A(i,i+2:n);
tauq is stored in TAUQ(i) and taup in TAUP(i).
If m < n,
Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m)
Each H(i) and G(i) has the form:
H(i) = I - tauq * v * v**T and G(i) = I - taup * u * u**T
where tauq and taup are real scalars, and v and u are real vectors;
v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i);
u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n);
tauq is stored in TAUQ(i) and taup in TAUP(i).
The contents of A on exit are illustrated by the following examples β look at the glow-up fr fr:
m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n):
( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 )
( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 )
( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 )
( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 )
( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 )
( v1 v2 v3 v4 v5 )
where d and e denote diagonal and off-diagonal elements of B, vi denotes an element of the vector defining H(i), and ui an element of the vector defining G(i). π¦
π sgebrd π
subroutine sgebrd (integer M, integer N, real, dimension( lda, * ) A,
integer LDA, real, dimension( * ) D, real, dimension( * ) E, real,
dimension( * ) TAUQ, real, dimension( * ) TAUP, real, dimension( * )
WORK, integer LWORK, integer INFO)
SGEBRD β the blocked glow-up of the same job. π
β¨ Purpose β¨
SGEBRD reduces a general real M-by-N matrix A to upper or lower bidiagonal form B by an orthogonal transformation: Q**T * A * P = B.
If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal.
π Parameters π
MβMis INTEGER. The number of rows in the matrix A.M >= 0.NβNis INTEGER. The number of columns in the matrix A.N >= 0.AβAis REAL array, dimension(LDA,N).
On entry, the M-by-N general matrix to be reduced.
On exit:
- if
m >= n, the diagonal and the first superdiagonal are overwritten with the upper bidiagonal matrix B; the elements below the diagonal, with the array TAUQ, represent the orthogonal matrix Q as a product of elementary reflectors, and the elements above the first superdiagonal, with the array TAUP, represent the orthogonal matrix P as a product of elementary reflectors; - if
m < n, the diagonal and the first subdiagonal are overwritten with the lower bidiagonal matrix B; the elements below the first subdiagonal, with the array TAUQ, represent the orthogonal matrix Q as a product of elementary reflectors, and the elements above the diagonal, with the array TAUP, represent the orthogonal matrix P as a product of elementary reflectors.
See Further Details. π
LDAβLDAis INTEGER. The leading dimension of the array A.LDA >= max(1,M).DβDis REAL array, dimension(min(M,N)). The diagonal elements of the bidiagonal matrix B:D(i) = A(i,i).EβEis REAL array, dimension(min(M,N)-1). The off-diagonal elements of the bidiagonal matrix B:- if
m >= n,E(i) = A(i,i+1)fori = 1,2,...,n-1; - if
m < n,E(i) = A(i+1,i)fori = 1,2,...,m-1.
- if
TAUQβTAUQis REAL array, dimension(min(M,N)). The scalar factors of the elementary reflectors which represent the orthogonal matrix Q. See Further Details.TAUPβTAUPis REAL array, dimension(min(M,N)). The scalar factors of the elementary reflectors which represent the orthogonal matrix P. See Further Details.WORKβWORKis REAL array, dimension(MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimal LWORK. πLWORKβLWORKis INTEGER. The length of the array WORK.LWORK >= max(1,M,N). For optimum performanceLWORK >= (M+N)*NB, whereNBis the optimal blocksize.
IfLWORK = -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 byXERBLA. π΅οΈββοΈ
INFOβINFOis INTEGER.= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value. π¨
π«Ά Author π«Ά
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
π Further Details π
The matrices Q and P are represented as products of elementary reflectors:
If m >= n,
Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1)
Each H(i) and G(i) has the form:
H(i) = I - tauq * v * v**T and G(i) = I - taup * u * u**T
where tauq and taup are real scalars, and v and u are real vectors;
v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in A(i+1:m,i);
u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in A(i,i+2:n);
tauq is stored in TAUQ(i) and taup in TAUP(i).
If m < n,
Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m)
Each H(i) and G(i) has the form:
H(i) = I - tauq * v * v**T and G(i) = I - taup * u * u**T
where tauq and taup are real scalars, and v and u are real vectors;
v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i);
u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n);
tauq is stored in TAUQ(i) and taup in TAUP(i).
The contents of A on exit are illustrated by the following examples:
m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n):
( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 )
( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 )
( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 )
( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 )
( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 )
( v1 v2 v3 v4 v5 )
where d and e denote diagonal and off-diagonal elements of B, vi denotes an element of the vector defining H(i), and ui an element of the vector defining G(i). bestie that's the whole shape of it π
πΈ sgecon β SGECON πΈ
subroutine sgecon (character NORM, integer N, real, dimension( lda, * ) A,
integer LDA, real ANORM, real RCOND, real, dimension( * ) WORK, integer,
dimension( * ) IWORK, integer INFO)
π― Purpose
SGECON estimates the reciprocal of the condition number of a general real matrix A, in either the 1-norm or the infinity-norm, using the LU factorization computed by SGETRF.
An estimate is obtained for norm(inv(A)), and the reciprocal of the condition number is computed as
RCOND = 1 / ( norm(A) * norm(inv(A)) ).
π Parameters
NORMβNORMisCHARACTER*1. Specifies whether the 1-norm condition number or the infinity-norm condition number is required:= '1' or 'O': 1-norm;= 'I': Infinity-norm.
NβNisINTEGER. The order of the matrixA.N >= 0.AβAisREALarray, dimension(LDA,N). The factorsLandUfrom the factorizationA = P*L*Uas computed bySGETRF.LDAβLDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,N).ANORMβANORMisREAL. IfNORM = '1'or'O', the 1-norm of the original matrixA. IfNORM = 'I', the infinity-norm of the original matrixA.RCONDβRCONDisREAL. The reciprocal of the condition number of the matrixA, computed asRCOND = 1/(norm(A) * norm(inv(A))).WORKβWORKisREALarray, dimension(4*N).IWORKβIWORKisINTEGERarray, dimension(N).INFOβINFOisINTEGER:= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value
π Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
π¦ sgeequ β SGEEQU π¦
subroutine sgeequ (integer M, integer N, real, dimension( lda, * ) A,
integer LDA, real, dimension( * ) R, real, dimension( * ) C, real
ROWCND, real COLCND, real AMAX, integer INFO)
π― Purpose
SGEEQU computes row and column scalings intended to equilibrate an M-by-N matrix A and reduce its condition number. R returns the row scale factors and C the column scale factors, chosen to try to make the largest element in each row and column of the matrix B with elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1.
R(i) and C(j) are restricted to be between SMLNUM = smallest safe number and BIGNUM = largest safe number. Use of these scaling factors is not guaranteed to reduce the condition number of A but works well in practice. fr fr, it's giving "best effort" energy π
π Parameters
MβMisINTEGER. The number of rows of the matrixA.M >= 0.NβNisINTEGER. The number of columns of the matrixA.N >= 0.AβAisREALarray, dimension(LDA,N). The M-by-N matrix whose equilibration factors are to be computed.LDAβLDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,M).RβRisREALarray, dimension(M). IfINFO = 0orINFO > M,Rcontains the row scale factors forA.CβCisREALarray, dimension(N). IfINFO = 0,Ccontains the column scale factors forA.ROWCNDβROWCNDisREAL. IfINFO = 0orINFO > M,ROWCNDcontains the ratio of the smallestR(i)to the largestR(i). IfROWCND >= 0.1andAMAXis neither too large nor too small, it is not worth scaling byR.COLCNDβCOLCNDisREAL. IfINFO = 0,COLCNDcontains the ratio of the smallestC(i)to the largestC(i). IfCOLCND >= 0.1, it is not worth scaling byC.AMAXβAMAXisREAL. Absolute value of largest matrix element. IfAMAXis very close to overflow or very close to underflow, the matrix should be scaled.INFOβINFOisINTEGER:= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value> 0: ifINFO = i, andiis<= M: the i-th row ofAis exactly zero> M: the (i-M)-th column ofAis exactly zero
π Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
β¨ sgeequb β SGEEQUB β¨
subroutine sgeequb (integer M, integer N, real, dimension( lda, * ) A,
integer LDA, real, dimension( * ) R, real, dimension( * ) C, real
ROWCND, real COLCND, real AMAX, integer INFO)
π― Purpose
SGEEQUB computes row and column scalings intended to equilibrate an M-by-N matrix A and reduce its condition number. R returns the row scale factors and C the column scale factors, chosen to try to make the largest element in each row and column of the matrix B with elements B(i,j)=R(i)*A(i,j)*C(j) have an absolute value of at most the radix.
R(i) and C(j) are restricted to be a power of the radix between SMLNUM = smallest safe number and BIGNUM = largest safe number. Use of these scaling factors is not guaranteed to reduce the condition number of A but works well in practice.
This routine differs from SGEEQU by restricting the scaling factors to a power of the radix. Barring over- and underflow, scaling by these factors introduces no additional rounding errors. However, the scaled entries' magnitudes are no longer approximately 1 but lie between sqrt(radix) and 1/sqrt(radix). the way it trades tidy magnitudes for zero extra rounding?? obsessed π
π Parameters
MβMisINTEGER. The number of rows of the matrixA.M >= 0.NβNisINTEGER. The number of columns of the matrixA.N >= 0.AβAisREALarray, dimension(LDA,N). The M-by-N matrix whose equilibration factors are to be computed.LDAβLDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,M).RβRisREALarray, dimension(M). IfINFO = 0orINFO > M,Rcontains the row scale factors forA.CβCisREALarray, dimension(N). IfINFO = 0,Ccontains the column scale factors forA.ROWCNDβROWCNDisREAL. IfINFO = 0orINFO > M,ROWCNDcontains the ratio of the smallestR(i)to the largestR(i). IfROWCND >= 0.1andAMAXis neither too large nor too small, it is not worth scaling byR.COLCNDβCOLCNDisREAL. IfINFO = 0,COLCNDcontains the ratio of the smallestC(i)to the largestC(i). IfCOLCND >= 0.1, it is not worth scaling byC.AMAXβAMAXisREAL. Absolute value of largest matrix element. IfAMAXis very close to overflow or very close to underflow, the matrix should be scaled.INFOβINFOisINTEGER:= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value> 0: ifINFO = i, andiis<= M: the i-th row ofAis exactly zero> M: the (i-M)-th column ofAis exactly zero
π Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
π sgehd2 β SGEHD2 π
SGEHD2 reduces a general square matrix to upper Hessenberg form using an unblocked algorithm.
subroutine sgehd2 (integer N, integer ILO, integer IHI, real, dimension(
lda, * ) A, integer LDA, real, dimension( * ) TAU, real, dimension( * )
WORK, integer INFO)
π― Purpose
SGEHD2 reduces a real general matrix A to upper Hessenberg form H by an orthogonal similarity transformation:
Q**T * A * Q = H .
π Parameters
NβNisINTEGER. The order of the matrixA.N >= 0.ILOβILOisINTEGER.IHIβIHIisINTEGER. It is assumed thatAis already upper triangular in rows and columns1:ILO-1andIHI+1:N.ILOandIHIare normally set by a previous call toSGEBAL; otherwise they should be set to 1 andNrespectively. See Further Details.1 <= ILO <= IHI <= max(1,N).AβAisREALarray, dimension(LDA,N). On entry, the n by n general matrix to be reduced. On exit, the upper triangle and the first subdiagonal ofAare overwritten with the upper Hessenberg matrixH, and the elements below the first subdiagonal, with the arrayTAU, represent the orthogonal matrixQas a product of elementary reflectors. See Further Details.LDAβLDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,N).TAUβTAUisREALarray, dimension(N-1). The scalar factors of the elementary reflectors (see Further Details).WORKβWORKisREALarray, dimension(N).INFOβINFOisINTEGER:= 0: successful exit.< 0: ifINFO = -i, the i-th argument had an illegal value.
π Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
π Further Details
The matrix Q is represented as a product of (ihi-ilo) elementary reflectors
Q = H(ilo) H(ilo+1) . . . H(ihi-1).
okay so each H(i) has the form
H(i) = I - tau * v * v**T
where tau is a real scalar, and v is a real vector with v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on exit in A(i+2:ihi,i), and tau in TAU(i). π
The contents of A are illustrated by the following example, with n = 7, ilo = 2 and ihi = 6:
on entry, on exit,
( a a a a a a a ) ( a a h h h h a )
( a a a a a a ) ( a h h h h a )
( a a a a a a ) ( h h h h h h )
( a a a a a a ) ( v2 h h h h h )
( a a a a a a ) ( v2 v3 h h h h )
( a a a a a a ) ( v2 v3 v4 h h h )
( a ) ( a )
where a denotes an element of the original matrix A, h denotes a modified element of the upper Hessenberg matrix H, and vi denotes an element of the vector defining H(i). β¨
πΈ subroutine sgehrd πΈ
subroutine sgehrd (integer N, integer ILO, integer IHI, real, dimension(
lda, * ) A, integer LDA, real, dimension( * ) TAU, real, dimension( * )
WORK, integer LWORK, integer INFO)
SGEHRD π
Purpose:
SGEHRD reduces a real general matrix A to upper Hessenberg form H by an orthogonal similarity transformation: Q**T * A * Q = H. no cap, that's literally the whole job π
Parameters
NβNis INTEGER. The order of the matrixA.N >= 0.ILOβILOis INTEGER.IHIβIHIis INTEGER. It is assumed thatAis already upper triangular in rows and columns1:ILO-1andIHI+1:N.ILOandIHIare normally set by a previous call toSGEBAL; otherwise they should be set to1andNrespectively. See Further Details.1 <= ILO <= IHI <= N, ifN > 0;ILO=1andIHI=0, ifN=0.AβAis REAL array, dimension(LDA,N). On entry, theN-by-Ngeneral matrix to be reduced. On exit, the upper triangle and the first subdiagonal ofAare overwritten with the upper Hessenberg matrixH, and the elements below the first subdiagonal, with the arrayTAU, represent the orthogonal matrixQas a product of elementary reflectors. See Further Details.LDAβLDAis INTEGER. The leading dimension of the arrayA.LDA >= max(1,N).TAUβTAUis REAL array, dimension(N-1). The scalar factors of the elementary reflectors (see Further Details). Elements1:ILO-1andIHI:N-1ofTAUare set to zero.WORKβWORKis REAL array, dimension(LWORK). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK.LWORKβLWORKis INTEGER. The length of the arrayWORK.LWORK >= max(1,N). For good performance,LWORKshould generally be larger. 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. π«ΆINFOβINFOis INTEGER.= 0: successful exit.< 0: ifINFO = -i, the i-th argument had an illegal value.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
The matrix Q is represented as a product of (ihi-ilo) elementary reflectors
Q = H(ilo) H(ilo+1) . . . H(ihi-1).
Each H(i) has the form
H(i) = I - tau * v * v**T
where tau is a real scalar, and v is a real vector with v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on exit in A(i+2:ihi,i), and tau in TAU(i). π¦
The contents of A are illustrated by the following example, with n = 7, ilo = 2 and ihi = 6:
on entry, on exit,
( a a a a a a a ) ( a a h h h h a )
( a a a a a a ) ( a h h h h a )
( a a a a a a ) ( h h h h h h )
( a a a a a a ) ( v2 h h h h h )
( a a a a a a ) ( v2 v3 h h h h )
( a a a a a a ) ( v2 v3 v4 h h h )
( a ) ( a )
where a denotes an element of the original matrix A, h denotes a modified element of the upper Hessenberg matrix H, and vi denotes an element of the vector defining H(i). π
This file is a slight modification of LAPACK-3.0's SGEHRD subroutine incorporating improvements proposed by Quintana-Orti and Van de Geijn (2006). (See SLAHR2.) π
π subroutine sgelq2 π
subroutine sgelq2 (integer M, integer N, real, dimension( lda, * ) A,
integer LDA, real, dimension( * ) TAU, real, dimension( * ) WORK,
integer INFO)
SGELQ2 computes the LQ factorization of a general rectangular matrix using an unblocked algorithm. bestie this one is the unblocked version, okay, we're doing it the simple way today π
Purpose:
SGELQ2 computes an LQ factorization of a real m-by-n matrix A:
A = ( L 0 ) * Q
where:
Qis a n-by-n orthogonal matrix;Lis a lower-triangular m-by-m matrix;0is a m-by-(n-m) zero matrix, ifm < n.
Parameters
MβMis INTEGER. The number of rows of the matrixA.M >= 0.NβNis INTEGER. The number of columns of the matrixA.N >= 0.AβAis REAL array, dimension(LDA,N). On entry, the m by n matrixA. On exit, the elements on and below the diagonal of the array contain the m bymin(m,n)lower trapezoidal matrixL(Lis lower triangular ifm <= n); the elements above the diagonal, with the arrayTAU, represent the orthogonal matrixQas a product of elementary reflectors (see Further Details).LDAβLDAis INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).TAUβTAUis REAL array, dimension(min(M,N)). The scalar factors of the elementary reflectors (see Further Details).WORKβWORKis REAL array, dimension(M).INFOβINFOis INTEGER.= 0: successful exit.< 0: ifINFO = -i, the i-th argument had an illegal value.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
The matrix Q is represented as a product of elementary reflectors
Q = H(k) . . . H(2) H(1), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**T
where tau is a real scalar, and v is a real vector with v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i,i+1:n), and tau in TAU(i). β¨
π subroutine sgelqf π
subroutine sgelqf (integer M, integer N, real, dimension( lda, * ) A,
integer LDA, real, dimension( * ) TAU, real, dimension( * ) WORK,
integer LWORK, integer INFO)
SGELQF π§
Purpose:
SGELQF computes an LQ factorization of a real M-by-N matrix A:
A = ( L 0 ) * Q
where:
Qis a N-by-N orthogonal matrix;Lis a lower-triangular M-by-M matrix;0is a M-by-(N-M) zero matrix, ifM < N.
Parameters
MβMis INTEGER. The number of rows of the matrixA.M >= 0.NβNis INTEGER. The number of columns of the matrixA.N >= 0.AβAis REAL array, dimension(LDA,N). On entry, the M-by-N matrixA. On exit, the elements on and below the diagonal of the array contain the m-by-min(m,n)lower trapezoidal matrixL(Lis lower triangular ifm <= n); the elements above the diagonal, with the arrayTAU, represent the orthogonal matrixQas a product of elementary reflectors (see Further Details).LDAβLDAis INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).TAUβTAUis REAL array, dimension(min(M,N)). The scalar factors of the elementary reflectors (see Further Details).WORKβWORKis REAL array, dimension(MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK.LWORKβLWORKis INTEGER. The dimension of the arrayWORK.LWORK >= max(1,M). For optimum performanceLWORK >= M*NB, whereNBis the optimal blocksize. 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. π₯INFOβINFOis INTEGER.= 0: successful exit.< 0: ifINFO = -i, the i-th argument had an illegal value.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
The matrix Q is represented as a product of elementary reflectors
Q = H(k) . . . H(2) H(1), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**T
where tau is a real scalar, and v is a real vector with v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i,i+1:n), and tau in TAU(i). πΈ
π« subroutine sgemqrt π«
subroutine sgemqrt (character SIDE, character TRANS, integer M, integer N,
integer K, integer NB, real, dimension( ldv, * ) V, integer LDV, real,
dimension( ldt, * ) T, integer LDT, real, dimension( ldc, * ) C, integer
LDC, real, dimension( * ) WORK, integer INFO)
SGEMQRT π
Purpose:
SGEMQRT overwrites the general real M-by-N matrix C with
SIDE = 'L' SIDE = 'R'
TRANS = 'N': Q C C Q
TRANS = 'T': Q**T C C Q**T
where Q is a real orthogonal matrix defined as the product of K elementary reflectors:
Q = H(1) H(2) . . . H(K) = I - V T V**T
generated using the compact WY representation as returned by <code>SGEQRT</code>.
And <code>Q</code> is of order <code>M</code> if <code>SIDE = 'L'</code>, and of order <code>N</code> if <code>SIDE = 'R'</code>. okay bestie that's the shape lore π
Parameters β¨
SIDEβSIDEisCHARACTER*1= 'L': applyQorQ**Tfrom the Left;= 'R': applyQorQ**Tfrom the Right.
TRANSβTRANSisCHARACTER*1= 'N': No transpose, applyQ;= 'T': Transpose, applyQ**T.
MβMisINTEGERβ the number of rows of the matrixC.M >= 0.NβNisINTEGERβ the number of columns of the matrixC.N >= 0.KβKisINTEGERβ the number of elementary reflectors whose product defines the matrixQ. IfSIDE = 'L',M >= K >= 0; ifSIDE = 'R',N >= K >= 0.NBβNBisINTEGERβ the block size used for the storage ofT.K >= NB >= 1. This must be the same value ofNBused to generateTinSGEQRT. fr fr, don't switch it up, they have to match πVβVisREALarray, dimension(LDV,K)β thei-th column must contain the vector which defines the elementary reflectorH(i), fori = 1,2,...,k, as returned bySGEQRTin the firstKcolumns of its array argumentA.LDVβLDVisINTEGERβ the leading dimension of the arrayV. IfSIDE = 'L',LDA >= max(1,M); ifSIDE = 'R',LDA >= max(1,N).TβTisREALarray, dimension(LDT,K)β the upper triangular factors of the block reflectors as returned bySGEQRT, stored as aNB-by-Nmatrix.LDTβLDTisINTEGERβ the leading dimension of the arrayT.LDT >= NB.CβCisREALarray, dimension(LDC,N)β on entry, theM-by-NmatrixC. On exit,Cis overwritten byQ C,Q**T C,C Q**TorC Q.LDCβLDCisINTEGERβ the leading dimension of the arrayC.LDC >= max(1,M).WORKβWORKisREALarray. The dimension ofWORKisN*NBifSIDE = 'L', orM*NBifSIDE = 'R'.INFOβINFOisINTEGER= 0: successful exit< 0: ifINFO = -i, thei-th argument had an illegal value
Author πΈ
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
subroutine sgeql2 π
subroutine sgeql2 (integer M, integer N, real, dimension( lda, * ) A,
integer LDA, real, dimension( * ) TAU, real, dimension( * ) WORK,
integer INFO)
<code>SGEQL2</code> computes the QL factorization of a general rectangular matrix using an unblocked algorithm.
Purpose: π¦
SGEQL2 computes a QL factorization of a real m by n matrix A: A = Q * L.
Parameters
MβMisINTEGERβ the number of rows of the matrixA.M >= 0.NβNisINTEGERβ the number of columns of the matrixA.N >= 0.AβAisREALarray, dimension(LDA,N)β on entry, the m by n matrixA. On exit, ifm >= n, the lower triangle of the subarrayA(m-n+1:m,1:n)contains the n by n lower triangular matrixL; ifm <= n, the elements on and below the (n-m)-th superdiagonal contain the m by n lower trapezoidal matrixL; the remaining elements, with the arrayTAU, represent the orthogonal matrixQas a product of elementary reflectors (see Further Details).LDAβLDAisINTEGERβ the leading dimension of the arrayA.LDA >= max(1,M).TAUβTAUisREALarray, dimension(min(M,N))β the scalar factors of the elementary reflectors (see Further Details).WORKβWORKisREALarray, dimension(N)INFOβINFOisINTEGER= 0: successful exit< 0: ifINFO = -i, thei-th argument had an illegal value
Author πΈ
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details: π
The matrix Q is represented as a product of elementary reflectors
Q = H(k) . . . H(2) H(1), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**T
where tau is a real scalar, and v is a real vector with v(m-k+i+1:m) = 0 and v(m-k+i) = 1; v(1:m-k+i-1) is stored on exit in A(1:m-k+i-1,n-k+i), and tau in TAU(i).
subroutine sgeqlf β¨
subroutine sgeqlf (integer M, integer N, real, dimension( lda, * ) A,
integer LDA, real, dimension( * ) TAU, real, dimension( * ) WORK,
integer LWORK, integer INFO)
<code>SGEQLF</code>
Purpose: π¦
SGEQLF computes a QL factorization of a real M-by-N matrix A: A = Q * L.
Parameters
MβMisINTEGERβ the number of rows of the matrixA.M >= 0.NβNisINTEGERβ the number of columns of the matrixA.N >= 0.AβAisREALarray, dimension(LDA,N)β on entry, the M-by-N matrixA. On exit, ifm >= n, the lower triangle of the subarrayA(m-n+1:m,1:n)contains the N-by-N lower triangular matrixL; ifm <= n, the elements on and below the (n-m)-th superdiagonal contain the M-by-N lower trapezoidal matrixL; the remaining elements, with the arrayTAU, represent the orthogonal matrixQas a product of elementary reflectors (see Further Details).LDAβLDAisINTEGERβ the leading dimension of the arrayA.LDA >= max(1,M).TAUβTAUisREALarray, dimension(min(M,N))β the scalar factors of the elementary reflectors (see Further Details).WORKβWORKisREALarray, dimension(MAX(1,LWORK))β on exit, ifINFO = 0,WORK(1)returns the optimalLWORK.LWORKβLWORKisINTEGERβ the dimension of the arrayWORK.LWORK >= max(1,N). For optimum performanceLWORK >= N*NB, whereNBis the optimal blocksize.
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. it's giving "just asking, no commitment" energy π
INFOβINFOisINTEGER= 0: successful exit< 0: ifINFO = -i, thei-th argument had an illegal value
Author πΈ
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details: π
The matrix Q is represented as a product of elementary reflectors
Q = H(k) . . . H(2) H(1), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**T
where tau is a real scalar, and v is a real vector with v(m-k+i+1:m) = 0 and v(m-k+i) = 1; v(1:m-k+i-1) is stored on exit in A(1:m-k+i-1,n-k+i), and tau in TAU(i).
subroutine sgeqp3 π₯
subroutine sgeqp3 (integer M, integer N, real, dimension( lda, * ) A,
integer LDA, integer, dimension( * ) JPVT, real, dimension( * ) TAU,
real, dimension( * ) WORK, integer LWORK, integer INFO)
<code>SGEQP3</code>
Purpose: π¦
SGEQP3 computes a QR factorization with column pivoting of a matrix A: A*P = Q*R using Level 3 BLAS.
Parameters
MβMisINTEGERβ the number of rows of the matrixA.M >= 0.NβNisINTEGERβ the number of columns of the matrixA.N >= 0.AβAisREALarray, dimension(LDA,N)β on entry, the M-by-N matrixA. On exit, the upper triangle of the array contains themin(M,N)-by-N upper trapezoidal matrixR; the elements below the diagonal, together with the arrayTAU, represent the orthogonal matrixQas a product ofmin(M,N)elementary reflectors.LDAβLDAisINTEGERβ the leading dimension of the arrayA.LDA >= max(1,M).JPVTβJPVTisINTEGERarray, dimension(N)β on entry, ifJPVT(J).ne.0, theJ-th column ofAis permuted to the front ofA*P(a leading column); ifJPVT(J)=0, theJ-th column ofAis a free column. On exit, ifJPVT(J)=K, then theJ-th column ofA*Pwas the theK-th column ofA. (yes bestie, "the the" β we keep the lore exactly as it was written, no edits π)TAUβTAUisREALarray, dimension(min(M,N))β the scalar factors of the elementary reflectors.WORKβWORKisREALarray, dimension(MAX(1,LWORK))β on exit, ifINFO=0,WORK(1)returns the optimalLWORK.LWORKβLWORKisINTEGERβ the dimension of the arrayWORK.LWORK >= 3*N+1. For optimal performanceLWORK >= 2*N+( N+1 )*NB, whereNBis the optimal blocksize.
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. same "no strings attached" vibe check π
INFOβINFOisINTEGER= 0: successful exit.< 0: ifINFO = -i, thei-th argument had an illegal value.
Author πΈ
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details: π
The matrix Q is represented as a product of elementary reflectors
Q = H(1) H(2) . . . H(k), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**T
where tau is a real scalar, and v is a real/complex vector with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), and tau in TAU(i).
Contributors: π
G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
X. Sun, Computer Science Dept., Duke University, USA
subroutine sgeqr2 π«
subroutine sgeqr2 (integer M, integer N, real, dimension( lda, * ) A,
integer LDA, real, dimension( * ) TAU, real, dimension( * ) WORK,
integer INFO)
okay bestie so SGEQR2 computes the QR factorization of a general rectangular matrix using an unblocked algorithm. no cap, it's the little one that does the work one reflector at a time. π«Ά
Purpose
SGEQR2 computes a QR factorization of a real m-by-n matrix A:
A = Q * ( R ),
( 0 )
where:
Qis a m-by-m orthogonal matrix;Ris an upper-triangular n-by-n matrix;0is a (m-n)-by-n zero matrix, if m > n.
Parameters
MβMis INTEGER. The number of rows of the matrixA.M >= 0.NβNis INTEGER. The number of columns of the matrixA.N >= 0.AβAis REAL array, dimension (LDA,N). On entry, the m by n matrixA. On exit, the elements on and above the diagonal of the array contain the min(m,n) by n upper trapezoidal matrixR(Ris upper triangular if m >= n); the elements below the diagonal, with the arrayTAU, represent the orthogonal matrixQas a product of elementary reflectors (see Further Details).LDAβLDAis INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).TAUβTAUis REAL array, dimension (min(M,N)). The scalar factors of the elementary reflectors (see Further Details).WORKβWORKis REAL array, dimension (N).INFOβINFOis INTEGER.= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Further Details
The matrix Q is represented as a product of elementary reflectors
Q = H(1) H(2) . . . H(k), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**T
where tau is a real scalar, and v is a real vector with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), and tau in TAU(i). π
subroutine sgeqr2p πΈ
subroutine sgeqr2p (integer M, integer N, real, dimension( lda, * ) A,
integer LDA, real, dimension( * ) TAU, real, dimension( * ) WORK,
integer INFO)
and now for her sister SGEQR2P π β she computes the QR factorization of a general rectangular matrix with non-negative diagonal elements, using an unblocked algorithm. same energy, but the diagonal is giving β¨all positiveβ¨ vibes only.
Purpose
SGEQR2P computes a QR factorization of a real m-by-n matrix A:
A = Q * ( R ),
( 0 )
where:
Qis a m-by-m orthogonal matrix;Ris an upper-triangular n-by-n matrix with nonnegative diagonal entries;0is a (m-n)-by-n zero matrix, if m > n.
Parameters
MβMis INTEGER. The number of rows of the matrixA.M >= 0.NβNis INTEGER. The number of columns of the matrixA.N >= 0.AβAis REAL array, dimension (LDA,N). On entry, the m by n matrixA. On exit, the elements on and above the diagonal of the array contain the min(m,n) by n upper trapezoidal matrixR(Ris upper triangular if m >= n). The diagonal entries ofRare nonnegative; the elements below the diagonal, with the arrayTAU, represent the orthogonal matrixQas a product of elementary reflectors (see Further Details).LDAβLDAis INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).TAUβTAUis REAL array, dimension (min(M,N)). The scalar factors of the elementary reflectors (see Further Details).WORKβWORKis REAL array, dimension (N).INFOβINFOis INTEGER.= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Further Details
The matrix Q is represented as a product of elementary reflectors
Q = H(1) H(2) . . . H(k), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**T
where tau is a real scalar, and v is a real vector with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), and tau in TAU(i).
See Lapack Working Note 203 for details. π (iykyk)
subroutine sgeqrf π₯
subroutine sgeqrf (integer M, integer N, real, dimension( lda, * ) A,
integer LDA, real, dimension( * ) TAU, real, dimension( * ) WORK,
integer LWORK, integer INFO)
SGEQRF π β this is the blocked glow-up, the one that actually gets called in real life. it's giving main character energy.
Purpose
SGEQRF computes a QR factorization of a real M-by-N matrix A:
A = Q * ( R ),
( 0 )
where:
Qis a M-by-M orthogonal matrix;Ris an upper-triangular N-by-N matrix;0is a (M-N)-by-N zero matrix, if M > N.
Parameters
MβMis INTEGER. The number of rows of the matrixA.M >= 0.NβNis INTEGER. The number of columns of the matrixA.N >= 0.AβAis REAL array, dimension (LDA,N). On entry, the M-by-N matrixA. On exit, the elements on and above the diagonal of the array contain the min(M,N)-by-N upper trapezoidal matrixR(Ris upper triangular if m >= n); the elements below the diagonal, with the arrayTAU, represent the orthogonal matrixQas a product of min(m,n) elementary reflectors (see Further Details).LDAβLDAis INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).TAUβTAUis REAL array, dimension (min(M,N)). The scalar factors of the elementary reflectors (see Further Details).WORKβWORKis REAL array, dimension (MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK.LWORKβLWORKis INTEGER. The dimension of the arrayWORK.LWORK >= 1, ifMIN(M,N) = 0, andLWORK >= N, otherwise. For optimum performanceLWORK >= N*NB, whereNBis the optimal blocksize.
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. π΅οΈββοΈ (sneaky little peek, she won't yell at you)
INFOβINFOis INTEGER.= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Further Details
The matrix Q is represented as a product of elementary reflectors
Q = H(1) H(2) . . . H(k), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**T
where tau is a real scalar, and v is a real vector with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), and tau in TAU(i). π
subroutine sgeqrfp π¦
subroutine sgeqrfp (integer M, integer N, real, dimension( lda, * ) A,
integer LDA, real, dimension( * ) TAU, real, dimension( * ) WORK,
integer LWORK, integer INFO)
SGEQRFP π β blocked and non-negative diagonal. the full package, honestly.
Purpose
SGEQR2P computes a QR factorization of a real M-by-N matrix A:
A = Q * ( R ),
( 0 )
where:
Qis a M-by-M orthogonal matrix;Ris an upper-triangular N-by-N matrix with nonnegative diagonal entries;0is a (M-N)-by-N zero matrix, if M > N.
Parameters
MβMis INTEGER. The number of rows of the matrixA.M >= 0.NβNis INTEGER. The number of columns of the matrixA.N >= 0.AβAis REAL array, dimension (LDA,N). On entry, the M-by-N matrixA. On exit, the elements on and above the diagonal of the array contain the min(M,N)-by-N upper trapezoidal matrixR(Ris upper triangular if m >= n). The diagonal entries ofRare nonnegative; the elements below the diagonal, with the arrayTAU, represent the orthogonal matrixQas a product of min(m,n) elementary reflectors (see Further Details).LDAβLDAis INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).TAUβTAUis REAL array, dimension (min(M,N)). The scalar factors of the elementary reflectors (see Further Details).WORKβWORKis REAL array, dimension (MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK.LWORKβLWORKis INTEGER. The dimension of the arrayWORK.LWORK >= max(1,N). For optimum performanceLWORK >= N*NB, whereNBis the optimal blocksize.
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. β¨
INFOβINFOis INTEGER.= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Further Details
The matrix Q is represented as a product of elementary reflectors
Q = H(1) H(2) . . . H(k), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**T
where tau is a real scalar, and v is a real vector with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), and tau in TAU(i).
See Lapack Working Note 203 for details. π
subroutine sgeqrt π
subroutine sgeqrt (integer M, integer N, integer NB, real, dimension( lda, *
) A, integer LDA, real, dimension( ldt, * ) T, integer LDT, real,
dimension( * ) WORK, integer INFO)
SGEQRT β β she's the block-reflector one, and we're just getting started with her...
Purpose
β¨ Parameters β¨
MβMisINTEGER, bestie. It's the number of rows in the matrixA, and it better beM >= 0. πNβNisINTEGER. Number of columns ofA.N >= 0, obviously. πΈNBβNBisINTEGER, and it's the block size used in the blocked QR. The vibe check here isMIN(M,N) >= NB >= 1. π₯AβAis aREALarray, dimension(LDA,N).- On entry: the
M-by-NmatrixA. - On exit: the elements on and above the diagonal of the array hold the
min(M,N)-by-Nupper trapezoidal matrixR(andRis straight-up upper triangular ifM >= N); the elements below the diagonal are the columns ofV. She's doing double duty, iconic. π
- On entry: the
LDAβLDAisINTEGER, the leading dimension of the arrayA. Requirement:LDA >= max(1,M). Don't play with this one. πTβTis aREALarray, dimension(LDT,MIN(M,N)). It's the upper triangular block reflectors, stored in compact form as a sequence of upper triangular blocks. Peep below for the deets. πLDTβLDTisINTEGER, the leading dimension of the arrayT.LDT >= NB. Periodt.WORKβWORKis aREALarray, dimension(NB*N). Just workspace, she's doing her best. π«ΆINFOβINFOisINTEGER.= 0: successful exit, we ate. β¨< 0: ifINFO = -i, the i-th argument had an illegal value. π¨
π Author π
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
π Further Details:
The matrix V stores the elementary reflectors H(i) in the i-th column below the diagonal. For example, if M=5 and N=3, the matrix V is
V = ( 1 )
( v1 1 )
( v1 v2 1 )
( v1 v2 v3 )
( v1 v2 v3 )
where the vi's represent the vectors which define H(i), which are returned in the matrix A. The 1's along the diagonal of V are not stored in A. Not me pointing that out twice, but it matters. π
Let K=MIN(M,N). The number of blocks is B = ceiling(K/NB), where each block is of order NB except for the last block, which is of order IB = K - (B-1)*NB. For each of the B blocks, an upper triangular block reflector factor is computed: T1, T2, ..., TB. The NB-by-NB (and IB-by-IB for the last block) T's are stored in the NB-by-K matrix T as
T = (T1 T2 ... TB).
π¦ subroutine sgeqrt2
subroutine sgeqrt2 (integer M, integer N, real, dimension( lda, * ) A,
integer LDA, real, dimension( ldt, * ) T, integer LDT, integer INFO)
SGEQRT2 computes a QR factorization of a general real or complex matrix using the compact WY representation of Q. She's giving classic, no recursion needed. π
π Purpose:
SGEQRT2 computes a QR factorization of a real M-by-N matrix A, using the compact WY representation of Q.
β¨ Parameters β¨
MβMisINTEGER, the number of rows of the matrixA. Requirement:M >= N. (Note that this is a stricter vibe than plainSGEQRThad, bestie. π)NβNisINTEGER, the number of columns of the matrixA.N >= 0.AβAis aREALarray, dimension(LDA,N).- On entry: the real
M-by-NmatrixA. - On exit: the elements on and above the diagonal contain the
N-by-Nupper triangular matrixR; the elements below the diagonal are the columns ofV. See below for further details.
- On entry: the real
LDAβLDAisINTEGER, the leading dimension of the arrayA.LDA >= max(1,M).TβTis aREALarray, dimension(LDT,N). It's theN-by-Nupper triangular factor of the block reflector. The elements on and above the diagonal contain the block reflectorT; the elements below the diagonal are not used (they're just sitting there, unemployed π). See below for further details.LDTβLDTisINTEGER, the leading dimension of the arrayT.LDT >= max(1,N).INFOβINFOisINTEGER.= 0: successful exit β¨< 0: ifINFO = -i, the i-th argument had an illegal value π¨
π Author π
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
π Further Details:
The matrix V stores the elementary reflectors H(i) in the i-th column below the diagonal. For example, if M=5 and N=3, the matrix V is
V = ( 1 )
( v1 1 )
( v1 v2 1 )
( v1 v2 v3 )
( v1 v2 v3 )
where the vi's represent the vectors which define H(i), which are returned in the matrix A. The 1's along the diagonal of V are not stored in A. The block reflector H is then given by
H = I - V * T * V**T
where V**T is the transpose of V. Simple as that, and honestly? Slay. β¨
π§ recursive subroutine sgeqrt3
recursive subroutine sgeqrt3 (integer M, integer N, real, dimension( lda, *
) A, integer LDA, real, dimension( ldt, * ) T, integer LDT, integer
INFO)
SGEQRT3</purpose> β okay not a real tag, but: SGEQRT3 recursively computes a QR factorization of a general real or complex matrix using the compact WY representation of Q. She recurses. She's main character energy. π
π Purpose:
SGEQRT3 recursively computes a QR factorization of a real M-by-N matrix A, using the compact WY representation of Q.
Based on the algorithm of Elmroth and Gustavson, IBM J. Res. Develop. Vol 44 No. 4 July 2000. Cite your sources, bestie. π
β¨ Parameters β¨
MβMisINTEGER, the number of rows of the matrixA.M >= N.NβNisINTEGER, the number of columns of the matrixA.N >= 0.AβAis aREALarray, dimension(LDA,N).- On entry: the real
M-by-NmatrixA. - On exit: the elements on and above the diagonal contain the
N-by-Nupper triangular matrixR; the elements below the diagonal are the columns ofV. See below for further details.
- On entry: the real
LDAβLDAisINTEGER, the leading dimension of the arrayA.LDA >= max(1,M).TβTis aREALarray, dimension(LDT,N). TheN-by-Nupper triangular factor of the block reflector. Elements on and above the diagonal contain the block reflectorT; elements below the diagonal are not used. See below for further details.LDTβLDTisINTEGER, the leading dimension of the arrayT.LDT >= max(1,N).INFOβINFOisINTEGER.= 0: successful exit β¨< 0: ifINFO = -i, the i-th argument had an illegal value π¨
π Author π
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
π Further Details:
The matrix V stores the elementary reflectors H(i) in the i-th column below the diagonal. For example, if M=5 and N=3, the matrix V is
V = ( 1 )
( v1 1 )
( v1 v2 1 )
( v1 v2 v3 )
( v1 v2 v3 )
where the vi's represent the vectors which define H(i), which are returned in the matrix A. The 1's along the diagonal of V are not stored in A. The block reflector H is then given by
H = I - V * T * V**T
where V**T is the transpose of V.
For details of the algorithm, see Elmroth and Gustavson (cited above). Go read it, it's giving academia. π
π subroutine sgerfs
subroutine sgerfs (character TRANS, integer N, integer NRHS, real,
dimension( lda, * ) A, integer LDA, real, dimension( ldaf, * ) AF,
integer LDAF, integer, dimension( * ) IPIV, real, dimension( ldb, * ) B,
integer LDB, real, dimension( ldx, * ) X, integer LDX, real, dimension(
* ) FERR, real, dimension( * ) BERR, real, dimension( * ) WORK, integer,
dimension( * ) IWORK, integer INFO)
SGERFS β the glow-up arc for your solution. β¨
π Purpose:
SGERFS improves the computed solution to a system of linear equations and provides error bounds and backward error estimates for the solution. She's not just fixing your answer, she's telling you how wrong you were, lovingly. π«Ά
β¨ Parameters β¨
TRANSβTRANSisCHARACTER*1, and it specifies the form of the system of equations:= 'N':A * X = B(No transpose)= 'T':A**T * X = B(Transpose)= 'C':A**H * X = B(Conjugate transpose = Transpose)
NβNisINTEGER, the order of the matrixA.N >= 0.NRHSβNRHSisINTEGER, the number of right hand sides, i.e., the number of columns of the matricesBandX.NRHS >= 0.AβAis aREALarray, dimension(LDA,N). The originalN-by-NmatrixA.LDAβLDAisINTEGER, the leading dimension of the arrayA.LDA >= max(1,N).AFβAFis aREALarray, dimension(LDAF,N). The factorsLandUfrom the factorizationA = P*L*Uas computed bySGETRF.LDAFβLDAFisINTEGER, the leading dimension of the arrayAF.LDAF >= max(1,N).IPIVβIPIVis anINTEGERarray, dimension(N). The pivot indices fromSGETRF; for1<=i<=N, row i of the matrix was interchanged with rowIPIV(i). Swapped. Shuffled. Gorgeous. πBβBis aREALarray, dimension(LDB,NRHS). The right hand side matrixB.LDBβLDBisINTEGER, the leading dimension of the arrayB.LDB >= max(1,N).XβXis aREALarray, dimension(LDX,NRHS).- On entry: the solution matrix
X, as computed bySGETRS. - On exit: the improved solution matrix
X. Glow-up complete. π
- On entry: the solution matrix
LDXβLDXisINTEGER, the leading dimension of the arrayX.LDX >= max(1,N).FERRβFERRis aREALarray, dimension(NRHS). The estimated forward error bound for each solution vectorX(j)(the j-th column of the solution matrixX). IfXTRUEis the true solution corresponding toX(j),FERR(j)is an estimated upper bound for the magnitude of the largest element in(X(j) - XTRUE)divided by the magnitude of the largest element inX(j). The estimate is as reliable as the estimate forRCOND, and is almost always a slight overestimate of the true error. So like, she's a little dramatic, but she's not wrong. πBERRβBERRβ REAL array, dimension(NRHS). This is the componentwise relative backward error of every solution vector X(j). Translation bestie: it's the smallest relative change you could make to any element of A or B that would make X(j) an actual exact solution. tiny number = good vibes β¨WORKβ REAL array, dimension(3*N). Scratch space, don't touch it, it's busy πIWORKβ INTEGER array, dimension(N). Same deal, but integers.INFOβ INTEGER. The receipts:= 0: successful exit, we ate, no crumbs π< 0: ifINFO = -i, then the i-th argument had an illegal value. so like. it's on you bestie π
Internal Parameters
ITMAX is the maximum number of steps of iterative refinement. (i.e. how many glow-up passes the algorithm is allowed to do on your solution before it gives up and hands it over as-is.)
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
subroutine sgerfsx
subroutine sgerfsx (character TRANS, character EQUED, integer N, integer
NRHS, real, dimension( lda, * ) A, integer LDA, real, dimension( ldaf, *
) AF, integer LDAF, integer, dimension( * ) IPIV, real, dimension( * )
R, real, dimension( * ) C, real, dimension( ldb, * ) B, integer LDB,
real, dimension( ldx , * ) X, integer LDX, real RCOND, real, dimension(
* ) BERR, integer N_ERR_BNDS, real, dimension( nrhs, * ) ERR_BNDS_NORM,
real, dimension( nrhs, * ) ERR_BNDS_COMP, integer NPARAMS, real,
dimension( * ) PARAMS, real, dimension( * ) WORK, integer, dimension( *
) IWORK, integer INFO)
SGERFSX β yes the name is giving extra and it earned it. π
Purpose
SGERFSX improves the computed solution to a system of linear equations and provides error bounds and backward error estimates for the solution. So it takes your solution, does a lil refinement arc, and also hands you receipts on how wrong it might be. Iconic behaviour, honestly. π
On top of the normwise error bound, the code provides a maximum componentwise error bound if possible. Peep the comments on ERR_BNDS_NORM and ERR_BNDS_COMP for the deets on those bounds.
The original system of linear equations may have been equilibrated before calling this routine, as described by arguments EQUED, R and C below. If that happened, the solution and error bounds returned are for the original unequilibrated system β like, it undoes the glow-up so you get your actual answer back. π¦
Some optional parameters are bundled in the PARAMS array. These settings determine how refinement is performed, but often the defaults are acceptable. If the defaults are acceptable, users can pass NPARAMS = 0, which prevents the source code from accessing the PARAMS argument entirely. Lazy? No. Efficient. periodt. π
Parameters
TRANSβTRANSisCHARACTER*1. Specifies the form of the system of equations:= 'N':A * X = B(No transpose)= 'T':A**T * X = B(Transpose)= 'C':A**H * X = B(Conjugate transpose = Transpose)
EQUEDβEQUEDisCHARACTER*1. Specifies the form of equilibration that was done to A before calling this routine. This is needed to compute the solution and error bounds correctly β no skimping, it matters fr fr.= 'N': No equilibration= 'R': Row equilibration, i.e., A has been premultiplied bydiag(R).= 'C': Column equilibration, i.e., A has been postmultiplied bydiag(C).= 'B': Both row and column equilibration, i.e., A has been replaced bydiag(R) * A * diag(C). The right hand side B has been changed accordingly.
NβNis INTEGER. The order of the matrix A.N >= 0.NRHSβNRHSis INTEGER. The number of right hand sides, i.e., the number of columns of the matrices B and X.NRHS >= 0.AβAis REAL array, dimension(LDA,N). The original N-by-N matrix A. the moment. the main character. πLDAβLDAis INTEGER. The leading dimension of the array A.LDA >= max(1,N).AFβAFis REAL array, dimension(LDAF,N). The factors L and U from the factorizationA = P*L*Uas computed bySGETRF.LDAFβLDAFis INTEGER. The leading dimension of the array AF.LDAF >= max(1,N).IPIVβIPIVis INTEGER array, dimension(N). The pivot indices fromSGETRF; for1<=i<=N, row i of the matrix was interchanged with rowIPIV(i).RβRis REAL array, dimension(N). The row scale factors for A. IfEQUED = 'R'or'B', A is multiplied on the left bydiag(R); ifEQUED = 'N'or'C', R is not accessed.
If R is accessed, each element of R should be a power of the radix to ensure a reliable solution and error estimates. Scaling by powers of the radix does not cause rounding errors unless the result underflows or overflows. Rounding errors during scaling lead to refining with a matrix that is not equivalent to the input matrix, producing error estimates that may not be reliable. π¨ bestie this one's a real caveat, don't skip it
CβCis REAL array, dimension(N). The column scale factors for A. IfEQUED = 'C'or'B', A is multiplied on the right bydiag(C); ifEQUED = 'N'or'R', C is not accessed.
If C is accessed, each element of C should be a power of the radix to ensure a reliable solution and error estimates. Scaling by powers of the radix does not cause rounding errors unless the result underflows or overflows. Rounding errors during scaling lead to refining with a matrix that is not equivalent to the input matrix, producing error estimates that may not be reliable. (same warning, different array, still very much a thing π)
BβBis REAL array, dimension(LDB,NRHS). The right hand side matrix B.LDBβLDBis INTEGER. The leading dimension of the array B.LDB >= max(1,N).XβXis REAL array, dimension(LDX,NRHS). On entry, the solution matrix X, as computed bySGETRS. On exit, the improved solution matrix X. she's been to the gym. ποΈββοΈLDXβLDXis INTEGER. The leading dimension of the array X.LDX >= max(1,N).RCONDβRCONDis REAL. Reciprocal scaled condition number. This is an estimate of the reciprocal Skeel condition number of the matrix A after equilibration (if done). If this is less than the machine precision (in particular, if it is zero), the matrix is singular to working precision.
Note that the error may still be small even if this number is very small and the matrix appears ill-conditioned. so don't panic-spiral just because the number is smol π
BERRβBERRis REAL array, dimension(NRHS). Componentwise relative backward error. This is the componentwise relative backward error of each solution vector X(j) (i.e., the smallest relative change in any element of A or B that makes X(j) an exact solution).N_ERR_BNDSβN_ERR_BNDSis INTEGER. Number of error bounds to return for each right hand side and each type (normwise or componentwise). SeeERR_BNDS_NORMandERR_BNDS_COMPbelow. πERR_BNDS_NORMβERR_BNDS_NORMis REAL array, dimension(NRHS, N_ERR_BNDS). For each right-hand side, this array contains information about various error bounds and condition numbers corresponding to the normwise relative error, which is defined as follows:
Normwise relative error in the ith solution vector:
max_j (abs(XTRUE(j,i) - X(j,i)))
------------------------------
max_j abs(X(j,i))
The array is indexed by the type of error information as described below. There currently are up to three pieces of information returned.
The first index in ERR_BNDS_NORM(i,:) corresponds to the ith right-hand side.
The second index in ERR_BNDS_NORM(:,err) contains the following three fields:
err = 1β'Trust/don't trust'boolean. Trust the answer if the reciprocal condition number is less than the thresholdsqrt(n) * slamch('Epsilon').err = 2β'Guaranteed'error bound: The estimated forward error, almost certainly within a factor of 10 of the true error so long as the next entry is greater than the thresholdsqrt(n) * slamch('Epsilon'). This error bound should only be trusted if the previous boolean is true.err = 3β Reciprocal condition number: Estimated normwise reciprocal condition number. Compared with the thresholdsqrt(n) * slamch('Epsilon')to determine if the error estimate is'guaranteed'. These reciprocal condition numbers are1 / (norm(Z^{-1},inf) * norm(Z,inf))for some appropriately scaled matrix Z. LetZ = S*A, where S scales each row by a power of the radix so all absolute row sums of Z are approximately 1.
See Lapack Working Note 165 for further details and extra cautions. π
ERR_BNDS_COMPβERR_BNDS_COMPis REAL array, dimension(NRHS, N_ERR_BNDS). For each right-hand side, this array contains information about various error bounds and condition numbers corresponding to the componentwise relative error, which is defined as follows:
Componentwise relative error in the ith solution vector:
abs(XTRUE(j,i) - X(j,i))
max_j ----------------------
abs(X(j,i))
The array is indexed by the right-hand side i (on which the componentwise relative error depends), and the type of error information as described below. There currently are up to three pieces of information returned for each right-hand side. If componentwise accuracy is not requested (PARAMS(3) = 0.0), then ERR_BNDS_COMP is not accessed. If N_ERR_BNDS < 3, then at most the first (:,N_ERR_BNDS) entries are returned.
The first index in ERR_BNDS_COMP(i,:) corresponds to the ith right-hand side.
The second index in ERR_BNDS_COMP(:,err) contains the following three fields:
err = 1β'Trust/don't trust'boolean. Trust the answer if the reciprocal condition number is less than the thresholdsqrt(n) * slamch('Epsilon').
err = 2β the "Guaranteed" error bound. This is the estimated forward error, and it's almost certainly within a factor of 10 of the true error, as long as the next entry is greater than the thresholdsqrt(n) * slamch('Epsilon'). Bestie, only trust this one if the previous boolean is true. Like, that's the vibe check. πerr = 3β Reciprocal condition number: the estimated componentwise reciprocal condition number. It gets compared against the thresholdsqrt(n) * slamch('Epsilon')to figure out whether the error estimate is "guaranteed". These reciprocal condition numbers are1 / (norm(Z^{-1},inf) * norm(Z,inf))for some appropriately scaled matrix Z. LetZ = S*(A*diag(x)), wherexis the solution for the current right-hand side andSscales each row ofA*diag(x)by a power of the radix so all absolute row sums of Z are approximately 1. Iconic scaling behaviour, honestly. β¨
See Lapack Working Note 165 for further details and extra cautions. (Read it. It's giving "required reading." π)
NPARAMS
NPARAMS is INTEGER.
It specifies the number of parameters set in PARAMS. If it's <= 0, the PARAMS array is never referenced and default values are used. Like, don't even look at it. π
PARAMS
PARAMS is REAL array, dimension NPARAMS.
It specifies algorithm parameters. If an entry is < 0.0, then that entry will be filled with the default value used for that parameter. Only positions up to NPARAMS are accessed; defaults are used for higher-numbered parameters. No cap. π§
PARAMS(LA_LINRX_ITREF_I = 1)β whether to perform iterative refinement or not.- Default:
1.0 = 0.0: no refinement is performed, and no error bounds are computed.= 1.0: use the double-precision refinement algorithm, possibly with doubled-single computations if the compilation environment does not supportDOUBLE PRECISION.- (other values are reserved for future use)
- Default:
PARAMS(LA_LINRX_ITHRESH_I = 2)β maximum number of residual computations allowed for refinement.- Default:
10 - Aggressive: set to
100to permit convergence using approximate factorizations or factorizations other than LU. If the factorization uses a technique other than Gaussian elimination, the guarantees inerr_bnds_normanderr_bnds_compmay no longer be trustworthy. β οΈ so like, proceed with caution, fr.
- Default:
PARAMS(LA_LINRX_CWISE_I = 3)β flag determining if the code will attempt to find a solution with small componentwise relative error in the double-precision algorithm. Positive is true,0.0is false.- Default:
1.0(attempt componentwise convergence)
- Default:
WORK
WORK is REAL array, dimension (4*N)
IWORK
IWORK is INTEGER array, dimension (N)
INFO
INFO is INTEGER
= 0: successful exit. The solution to every right-hand side is guaranteed. slay. π< 0: ifINFO = -i, the i-th argument had an illegal value.> 0and<= N:U(INFO,INFO)is exactly zero. The factorization has been completed, but the factorUis exactly singular, so the solution and error bounds could not be computed.RCOND = 0is returned. π= N+J: the solution corresponding to the Jth right-hand side is not guaranteed. The solutions corresponding to other right-hand sidesKwithK > Jmay not be guaranteed as well, but only the first such right-hand side is reported. If a small componentwise error is not requested (PARAMS(3) = 0.0) then the Jth right-hand side is the first with a normwise error bound that is not guaranteed (the smallestJsuch thatERR_BNDS_NORM(J,1) = 0.0). By default (PARAMS(3) = 1.0) the Jth right-hand side is the first with either a normwise or componentwise error bound that is not guaranteed (the smallestJsuch that eitherERR_BNDS_NORM(J,1) = 0.0orERR_BNDS_COMP(J,1) = 0.0). See the definition ofERR_BNDS_NORM(:,1)andERR_BNDS_COMP(:,1). To get information about all of the right-hand sides, checkERR_BNDS_NORMorERR_BNDS_COMP. π
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
π§ subroutine sgerq2 π§
subroutine sgerq2 (integer M, integer N, real, dimension( lda, * ) A,
integer LDA, real, dimension( * ) TAU, real, dimension( * ) WORK,
integer INFO)
SGERQ2 computes the RQ factorization of a general rectangular matrix using an unblocked algorithm. π
Purpose
SGERQ2 computes an RQ factorization of a real m by n matrix A:
A = R * Q.
Parameters
MβM is INTEGER. The number of rows of the matrixA.M >= 0.NβN is INTEGER. The number of columns of the matrixA.N >= 0.AβA is REAL array, dimension (LDA,N). On entry, the m by n matrixA. On exit, ifm <= n, the upper triangle of the subarrayA(1:m,n-m+1:n)contains the m by m upper triangular matrixR; ifm >= n, the elements on and above the(m-n)-th subdiagonal contain the m by n upper trapezoidal matrixR; the remaining elements, with the arrayTAU, represent the orthogonal matrixQas a product of elementary reflectors (see Further Details).LDAβLDA is INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).TAUβTAU is REAL array, dimension (min(M,N)). The scalar factors of the elementary reflectors (see Further Details).WORKβWORK is REAL array, dimension (M)INFOβINFO is INTEGER= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Further Details
The matrix Q is represented as a product of elementary reflectors
Q = H(1) H(2) . . . H(k), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**T
where tau is a real scalar, and v is a real vector with v(n-k+i+1:n) = 0 and v(n-k+i) = 1; v(1:n-k+i-1) is stored on exit in A(m-k+i,1:n-k+i-1), and tau in TAU(i). periodt. β¨
π¦ subroutine sgerqf π¦
subroutine sgerqf (integer M, integer N, real, dimension( lda, * ) A,
integer LDA, real, dimension( * ) TAU, real, dimension( * ) WORK,
integer LWORK, integer INFO)
SGERQF
Purpose
SGERQF computes an RQ factorization of a real M-by-N matrix A:
A = R * Q.
Parameters
MβM is INTEGER. The number of rows of the matrixA.M >= 0.NβN is INTEGER. The number of columns of the matrixA.N >= 0.AβA is REAL array, dimension (LDA,N). On entry, the M-by-N matrixA. On exit, ifm <= n, the upper triangle of the subarrayA(1:m,n-m+1:n)contains the M-by-M upper triangular matrixR; ifm >= n, the elements on and above the(m-n)-th subdiagonal contain the M-by-N upper trapezoidal matrixR; the remaining elements, with the arrayTAU, represent the orthogonal matrixQas a product ofmin(m,n)elementary reflectors (see Further Details).LDAβLDA is INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).TAUβTAU is REAL array, dimension (min(M,N)). The scalar factors of the elementary reflectors (see Further Details).WORKβWORK is REAL array, dimension (MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK. πLWORKβLWORK is INTEGER. The dimension of the arrayWORK.LWORK >= 1, ifMIN(M,N) = 0, andLWORK >= M, otherwise. For optimum performanceLWORK >= M*NB, whereNBis the optimal blocksize.
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. (the sneak peek manoeuvre π
)
INFOβINFO is INTEGER= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Further Details
The matrix Q is represented as a product of elementary reflectors
Q = H(1) H(2) . . . H(k), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**T
where tau is a real scalar, and v is a real vector with v(n-k+i+1:n) = 0 and v(n-k+i) = 1; v(1:n-k+i-1) is stored on exit in A(m-k+i,1:n-k+i-1), and tau in TAU(i). πΈ
π subroutine sgesvj π
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 bestie, 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 like this:
[++] [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. And here's the iconic part: SGESVJ can sometimes compute tiny singular values and their singular vectors much more accurately than other SVD routines β see below under Further Details. β¨
β¨ Parameters β¨
π JOBA
JOBA is CHARACTER*1.
It specifies the structure of A, bestie:
= 'L': the input matrix A is lower triangular;= 'U': the input matrix A is upper triangular;= 'G': the input matrix A is a general M-by-N matrix,M >= N.
π JOBU
JOBU is CHARACTER*1.
It says whether we're computing the left singular vectors (aka the columns of U):
= 'U': the left singular vectors corresponding to the nonzero singular values get computed and returned in the leading columns of A. More deets in the description of A. The default numerical orthogonality threshold is set to approximatelyTOL=CTOL*EPS,CTOL=SQRT(M),EPS=SLAMCH('E').= 'C': same vibe asJOBU='U', except you get to control the level of numerical orthogonality of the computed left singular vectors. TOL can be set toTOL = CTOL*EPS, where CTOL is given on input in the array WORK. No CTOL smaller thanONEis allowed, periodt. CTOL greater than1 / EPSis meaningless. The'C'option can be used ifM*EPSis satisfactory orthogonality of the computed left singular vectors, soCTOL=Mcould save a few sweeps of Jacobi rotations. See the descriptions of A andWORK(1).= 'N': the matrix U is not computed. However β see the description of A. π
π JOBV
JOBV is CHARACTER*1.
It says whether we're computing the right singular vectors, that is, the matrix V:
= 'V': the matrix V is computed and returned in the array V= 'A': the Jacobi rotations are applied to the MV-by-N array V. In other words, the right singular vector matrix V is not computed explicitly; instead it is applied to an MV-by-N matrix initially stored in the first MV rows of V.= 'N': the matrix V is not computed and the array V is 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 REAL array, dimension (LDA,N).
On entry, the M-by-N matrix A.
On exit:
- If
JOBU = 'U'.OR.JOBU = 'C':- If
INFO = 0:RANKAorthonormal columns of U are returned in the leadingRANKAcolumns of the array A. HereRANKA <= Nis the number of computed singular values of A that 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 array WORK asRANKA=NINT(WORK(2)). Also see the descriptions of SVA and WORK. The computed columns of U are mutually numerically orthogonal up to approximatelyTOL=SQRT(M)*EPS(default); orTOL=CTOL*EPS(JOBU = 'C'), see the description of JOBU. - If
INFO > 0: the procedure SGESVJ did not converge in the given number of iterations (sweeps). In that case, the computed columns of U may not be orthogonal up to TOL. The output U (stored in A), SIGMA (given by the computed singular values inSVA(1:N)) and V is still a decomposition of the input matrix A in 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 of U is not an issue and iterations are stopped when the columns of the iterated matrix are numerically orthogonal up to approximatelyM*EPS. Thus, on exit, A contains the columns of U scaled with the corresponding singular values. - If
INFO > 0: the procedure SGESVJ did 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 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 of A. During the computation SVA contains the Euclidean column norms of the iterated matrices in the array A. - If
SCALE .NE. ONE: the singular values of A areSCALE*SVA(1:N), and this factored representation is due to the fact that some of the singular values of A might underflow or overflow.
- If
- If
INFO > 0: the procedure SGESVJ did 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 REAL array, dimension (LDV,N).
- If
JOBV = 'V', then V contains on exit the N-by-N matrix of the right singular vectors; - If
JOBV = 'A', then V contains the product of the computed right singular vector matrix and the initial matrix in the array V. - If
JOBV = 'N', then V is 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 REAL array, dimension (LWORK).
On entry:
- If
JOBU = 'C':WORK(1) = CTOL, where CTOL defines the threshold for convergence. The process stops if all columns of A are 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 below EPSILON.
On exit:
WORK(1) = SCALEis the scaling factor such thatSCALE*SVA(1:N)are the computed singular values of A. (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 when SGESVJ did 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, WORK >= MAX(6,M+N).
π INFO
INFO is INTEGER.
= 0: successful exit. π< 0: ifINFO = -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.
β¨ Author β¨
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
πΈ Further Details πΈ
okay so the tea on the orthogonal N-by-N matrix V: it gets built as a product of Jacobi plane rotations, and those rotations are implemented as the fast scaled rotations of Anda and Park [1]. And if the Jacobi angle underflows? π no worries, a modified Jacobi transformation of Drmac [4] slides in. The pivot strategy uses column interchanges of de Rijk [2]. The relative accuracy of the computed singular values, plus the accuracy of the computed singular vectors (in angle metric), is exactly as guaranteed by the theory of Demmel and Veselic [3]. The condition number that decides the accuracy in the full rank case is essentially min_{D=diag} kappa(A*D), where kappa(.) is the spectral condition number. Best performance of this Jacobi SVD procedure hits different when it's used in an accelerated version of Drmac and Veselic [5,6] β it's literally 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. π
π«Ά 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.
π Bugs, Examples and Comments π
Please report all bugs and send interesting test examples and comments to drmac@math.hr. Thank you. π«Ά
π subroutine sgetf2 (integer M, integer N, real, dimension( lda, * ) A, integer LDA, integer, dimension( * ) IPIV, integer INFO) π
SGETF2 computes the LU factorization of a general m-by-n matrix using partial pivoting with row interchanges (unblocked algorithm).
π― Purpose
SGETF2 computes an LU factorization of a general m-by-n matrix A using partial pivoting with row interchanges.
The factorization has the form
A = P * L * U
where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n), and U is upper triangular (upper trapezoidal if m < n).
This is the right-looking Level 2 BLAS version of the algorithm.
π§© Parameters
M
M is INTEGER
The number of rows of the matrix A. M >= 0.
N
N is INTEGER
The number of columns of the matrix A. N >= 0.
A
A is REAL array, dimension (LDA,N)
On entry, the m by n matrix to be factored.
On exit, the factors L and U from the factorization A = P*L*U; the unit diagonal elements of L are not stored.
LDA
LDA is INTEGER
The leading dimension of the array A. LDA >= max(1,M).
IPIV
IPIV is INTEGER array, dimension (min(M,N))
The pivot indices; for 1 <= i <= min(M,N), row i of the matrix was interchanged with row IPIV(i).
INFO
INFO is INTEGER
= 0: successful exit< 0: ifINFO = -k, the k-th argument had an illegal value> 0: ifINFO = k,U(k,k)is exactly zero. The factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations. π¨
ποΈ Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
π subroutine sgetrf (integer M, integer N, real, dimension( lda, * ) A, integer LDA, integer, dimension( * ) IPIV, integer INFO) π
SGETRF SGETRF VARIANT: iterative version of Sivan Toledo's recursive LU algorithm
SGETRF VARIANT: left-looking Level 3 BLAS version of the algorithm.
π― Purpose
SGETRF computes an LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges.
The factorization has the form
A = P * L * U
where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n), and U is upper triangular (upper trapezoidal if m < n).
This is the right-looking Level 3 BLAS version of the algorithm.
π§© Parameters
M
M is INTEGER
The number of rows of the matrix A. M >= 0.
N
N is INTEGER
The number of columns of the matrix A. N >= 0.
A
A is REAL array, dimension (LDA,N)
On entry, the M-by-N matrix to be factored.
On exit, the factors L and U from the factorization A = P*L*U; the unit diagonal elements of L are not stored.
LDA
LDA is INTEGER
The leading dimension of the array A. LDA >= max(1,M).
IPIV
IPIV is INTEGER array, dimension (min(M,N))
The pivot indices; for 1 <= i <= min(M,N), row i of the matrix was interchanged with row IPIV(i).
INFO
INFO is INTEGER
= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value> 0: ifINFO = i,U(i,i)is exactly zero. The factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations. π¨
ποΈ Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
π― Purpose (round two, bestie)
SGETRF computes an LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges.
The factorization has the form
A = P * L * U
where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n), and U is upper triangular (upper trapezoidal if m < n).
This is the left-looking Level 3 BLAS version of the algorithm.
π§© Parameters
M
M is INTEGER
The number of rows of the matrix A. M >= 0.
N
N is INTEGER
The number of columns of the matrix A. N >= 0.
A
A is REAL array, dimension (LDA,N)
On entry, the M-by-N matrix to be factored.
On exit, the factors L and U from the factorization A = P*L*U; the unit diagonal elements of L are not stored.
LDA
LDA is INTEGER
The leading dimension of the array A. LDA >= max(1,M).
IPIV
IPIV is INTEGER array, dimension (min(M,N))
The pivot indices; for 1 <= i <= min(M,N), row i of the matrix was interchanged with row IPIV(i).
INFO
INFO is INTEGER
= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value> 0: ifINFO = i,U(i,i)is exactly zero. The factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations. π¨
ποΈ Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
π Date
December 2016
π― Purpose (round three, the iterative one)
SGETRF computes an LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges.
The factorization has the form
A = P * L * U
where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n), and U is upper triangular (upper trapezoidal if m < n).
This code implements an iterative version of Sivan Toledo's recursive LU algorithm[1]. For square matrices, this iterative versions should be within a factor of two of the optimum number of memory transfers.
The pattern is as follows, with the large blocks of U being updated in one call to STRSM, and the dotted lines denoting sections that have had all pending permutations applied:
1 2 3 4 5 6 7 8
+-+---+---+-------+------
| |1| | |
|.+-+ 2 | |
| | | | |
|.|.+-+-+ 4 |
| | | |1| |
| | |.+-+ |
| | | | | |
|.|.|.|.+-+-+---+ 8
| | | | | |1| |
| | | | |.+-+ 2 |
| | | | | | | |
| | | | |.|.+-+-+
| | | | | | | |1|
| | | | | | |.+-+
| | | | | | | | |
|.|.|.|.|.|.|.|.+-----
| | | | | | | | |
The 1-2-1-4-1-2-1-8-... pattern is the position of the last 1 bit in the binary expansion of the current column. Each Schur update is applied as soon as the necessary portion of U is available. π
[1] Toledo, S. 1997. Locality of Reference in LU Decomposition with Partial Pivoting. SIAM J. Matrix Anal. Appl. 18, 4 (Oct. 1997), 1065-1081. http://dx.doi.org/10.1137/S0895479896297744
π§© Parameters
M
M is INTEGER
The number of rows of the matrix A. M >= 0.
N
N is INTEGER
The number of columns of the matrix A. N >= 0.
A
A is REAL array, dimension (LDA,N)
On entry, the M-by-N matrix to be factored.
On exit, the factors L and U from the factorization A = P*L*U; the unit diagonal elements of L are not stored.
LDALDAβ INTEGER, bestie. The leading dimension of the arrayA. Rule of the land:LDA >= max(1,M). Do not test it. π«ΆIPIVβ INTEGER array, dimension(min(M,N)). These are the pivot indices, and here's the tea: for1 <= i <= min(M,N), rowiof the matrix was interchanged with rowIPIV(i). Every row swap, receipted. πINFOβ INTEGER, the final vibe check:= 0: successful exit β¨< 0: ifINFO = -i, the i-th argument had an illegal value π> 0: ifINFO = i,U(i,i)is exactly zero. The factorization has been completed, but the factorUis exactly singular, and division by zero will occur if it is used to solve a system of equations. π
Author π«Ά
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date π
December 2016
recursive subroutine sgetrf2
recursive subroutine sgetrf2 (integer M, integer N, real, dimension( lda, * )
A, integer LDA, integer, dimension( * ) IPIV, integer INFO)
SGETRF2
Purpose π«
SGETRF2 computes an LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges.
The factorization has the form
A = P * L * U
where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n), and U is upper triangular (upper trapezoidal if m < n).
This is the recursive version of the algorithm. It divides the matrix into four submatrices:
[ A11 | A12 ] where A11 is n1 by n1 and A22 is n2 by n2
A = [ -----|----- ] with n1 = min(m,n)/2
[ A21 | A22 ] n2 = n-n1
The subroutine calls itself to factor:
[ A11 ]
The subroutine calls itself to factor [ --- ],
[ A12 ]
and then it does the swaps on:
[ A12 ]
do the swaps on [ --- ], solve A12, update A22,
[ A22 ]
then calls itself to factor A22 and do the swaps on A21. Recursion, but make it math. π
Parameters
Mβ INTEGER. The number of rows of the matrixA.M >= 0.Nβ INTEGER. The number of columns of the matrixA.N >= 0.Aβ REAL array, dimension(LDA,N). On entry, the M-by-N matrix to be factored. On exit, the factorsLandUfrom the factorizationA = P*L*U; the unit diagonal elements ofLare not stored.LDAβ INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).IPIVβ INTEGER array, dimension(min(M,N)). The pivot indices; for1 <= i <= min(M,N), rowiof the matrix was interchanged with rowIPIV(i).INFOβ INTEGER:= 0: successful exit β¨< 0: ifINFO = -i, the i-th argument had an illegal value π> 0: ifINFO = i,U(i,i)is exactly zero. The factorization has been completed, but the factorUis exactly singular, and division by zero will occur if it is used to solve a system of equations. π
Author π«Ά
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
subroutine sgetri
subroutine sgetri (integer N, real, dimension( lda, * ) A, integer LDA,
integer, dimension( * ) IPIV, real, dimension( * ) WORK, integer LWORK,
integer INFO)
SGETRI
Purpose π«
SGETRI computes the inverse of a matrix using the LU factorization computed by SGETRF.
This method inverts U and then computes inv(A) by solving the system inv(A)*L = inv(U) for inv(A). It's giving "undo the factoring, get the original back." πͺ
Parameters
Nβ INTEGER. The order of the matrixA.N >= 0.Aβ REAL array, dimension(LDA,N). On entry, the factorsLandUfrom the factorizationA = P*L*Uas computed bySGETRF. On exit, ifINFO = 0, the inverse of the original matrixA.LDAβ INTEGER. The leading dimension of the arrayA.LDA >= max(1,N).IPIVβ INTEGER array, dimension(N). The pivot indices fromSGETRF; for1<=i<=N, rowiof the matrix was interchanged with rowIPIV(i).WORKβ REAL array, dimension(MAX(1,LWORK)). On exit, ifINFO=0, thenWORK(1)returns the optimalLWORK.LWORKβ INTEGER. The dimension of the arrayWORK.LWORK >= max(1,N). For optimal performanceLWORK >= N*NB, whereNBis the optimal blocksize returned byILAENV.
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 query mode, iconic. π
INFOβ INTEGER:= 0: successful exit β¨< 0: ifINFO = -i, the i-th argument had an illegal value π> 0: ifINFO = i,U(i,i)is exactly zero; the matrix is singular and its inverse could not be computed. No inverse for you, bestie. π
Author π«Ά
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
subroutine sgetrs
subroutine sgetrs (character TRANS, integer N, integer NRHS, real,
dimension( lda, * ) A, integer LDA, integer, dimension( * ) IPIV, real,
dimension( ldb, * ) B, integer LDB, integer INFO)
SGETRS
Purpose π«
SGETRS solves a system of linear equations
A * X = B or A**T * X = B
with a general N-by-N matrix A using the LU factorization computed by SGETRF. Feed it the factorization, get the solution. That's the whole gig. πΈ
Parameters
TRANSβ CHARACTER*1. Specifies the form of the system of equations:= 'N':A * X = B(No transpose)= 'T':A**T* X = B(Transpose)= 'C':A**T* X = B(Conjugate transpose = Transpose)
Nβ INTEGER. The order of the matrixA.N >= 0.NRHSβ INTEGER. The number of right hand sides, i.e., the number of columns of the matrixB.NRHS >= 0.Aβ REAL array, dimension(LDA,N). The factorsLandUfrom the factorizationA = P*L*Uas computed bySGETRF.LDAβ INTEGER. The leading dimension of the arrayA.LDA >= max(1,N).IPIVβ INTEGER array, dimension(N). The pivot indices fromSGETRF; for1<=i<=N, rowiof the matrix was interchanged with rowIPIV(i).Bβ REAL array, dimension(LDB,NRHS). On entry, the right hand side matrixB. On exit, the solution matrixX.LDBβ INTEGER. The leading dimension of the arrayB.LDB >= max(1,N).INFOβ INTEGER:= 0: successful exit β¨< 0: ifINFO = -i, the i-th argument had an illegal value π
Author π«Ά
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
subroutine shgeqz
subroutine shgeqz (character JOB, character COMPQ, character COMPZ, integer
N, integer ILO, integer IHI, real, dimension( ldh, * ) H, integer LDH,
real, dimension( ldt, * ) T, integer LDT, real, dimension( * ) ALPHAR,
real, dimension( * ) ALPHAI, real, dimension( * ) BETA, real, dimension(
ldq, * ) Q, integer LDQ, real, dimension( ldz, * ) Z, integer LDZ, real,
dimension( * ) WORK, integer LWORK, integer INFO)
SHGEQZ
Purpose π«
SHGEQZ computes the eigenvalues of a real matrix pair (H,T), where H is an upper Hessenberg matrix and T is upper triangular, using the double-shift QZ method. Matrix pairs of this type are produced by the reduction to generalized upper Hessenberg form of a real matrix pair (A,B):
A = Q1*H*Z1**T, B = Q1*T*Z1**T,
as computed by SGGHRD.
If JOB='S', then the Hessenberg-triangular pair (H,T) is also reduced to generalized Schur form,
H = Q*S*Z**T, T = Q*P*Z**T,
where Q and Z are orthogonal matrices, P is an upper triangular matrix, and S is a quasi-triangular matrix with 1-by-1 and 2-by-2 diagonal blocks.
The 1-by-1 blocks correspond to real eigenvalues of the matrix pair (H,T) and the 2-by-2 blocks correspond to complex conjugate pairs of eigenvalues. Two flavors of eigenvalue, one matrix pair. π
Additionally, the 2-by-2 upper triangular diagonal blocks of P corresponding to 2-by-2 blocks of S are reduced to positive diagonal form, i.e., if S(j+1,j) is non-zero, then P(j+1,j) = P(j,j+1) = 0, P(j,j) > 0, and P(j+1,j+1) > 0.
Optionally, the orthogonal matrix Q from the generalized Schur factorization may be postmultiplied into an input matrix Q1, and the orthogonal matrix Z may be postmultiplied into an input matrix Z1. If Q1 and Z1 are the orthogonal matrices from SGGHRD that reduced the matrix pair (A,B) to generalized upper Hessenberg form, then the output matrices Q1*Q and Z1*Z are the orthogonal factors from the generalized Schur factorization of (A,B):
A = (Q1*Q)*S*(Z1*Z)**T, B = (Q1*Q)*P*(Z1*Z)**T.
To avoid overflow, eigenvalues of the matrix pair (H,T) (equivalently, of (A,B)) are computed as a pair of values (alpha,beta), where alpha is complex and beta real. If beta is nonzero, lambda = alpha / beta is an eigenvalue of the generalized nonsymmetric eigenvalue problem (GNEP)
A*x = lambda*B*x
and if alpha is nonzero, mu = beta / alpha is an eigenvalue of the alternate form of the GNEP
mu*A*y = B*y.
Real eigenvalues can be read directly from the generalized Schur form: alpha = S(i,i), beta = P(i,i). Just read it off the diagonal, bestie. π
Ref: C.B. Moler & G.W. Stewart, 'An Algorithm for Generalized Matrix Eigenvalue Problems', SIAM J. Numer. Anal., 10(1973), pp. 241--256.
Parameters
JOBβ CHARACTER*1:= 'E': Compute eigenvalues only;= 'S': Compute eigenvalues and the Schur form.
COMPQ
COMPQ
COMPQ is CHARACTER*1, bestie, and here's the tea:
= 'N': Left Schur vectors (Q) are not computed. Not today, not ever.= 'I': Q gets initialized to the unit matrix, and the matrix Q of left Schur vectors of (H,T) is handed back to you π= 'V': Q must contain an orthogonal matrix Q1 on entry, and then you get the product Q1*Q returned. So like, you gotta bring your own Q1, okay?
COMPZ
COMPZ is also CHARACTER*1, and she's the mirror sister:
= 'N': Right Schur vectors (Z) are not computed.= 'I': Z is initialized to the unit matrix and the matrix Z of right Schur vectors of (H,T) is returned β¨= 'V': Z must contain an orthogonal matrix Z1 on entry, and the product Z1*Z is returned.
N
N is INTEGER β the order of the matrices H, T, Q, and Z. And N >= 0, periodt.
ILO
ILO is INTEGER. That's it, that's the entry. (She gets explained in IHI's paragraph, iykyk.)
IHI
IHI is INTEGER.
So like, ILO and IHI mark the rows and columns of H which are in Hessenberg form. It's assumed that A is already upper triangular in rows and columns 1:ILO-1 and IHI+1:N. And: if N > 0, then 1 <= ILO <= IHI <= N; but if N = 0, then ILO=1 and IHI=0. Yes queen, the empty case is real and it's handled π«Ά
H
H is REAL array, dimension (LDH, N).
On entry, it's the N-by-N upper Hessenberg matrix H. On exit, if JOB = 'S', H contains the upper quasi-triangular matrix S from the generalized Schur factorization. But if JOB = 'E', the diagonal blocks of H match those of S, and the rest of H is justβ¦ unspecified π (do not look at her)
LDH
LDH is INTEGER β the leading dimension of the array H. And LDH >= max( 1, N ), no cap.
T
T is REAL array, dimension (LDT, N).
On entry, the N-by-N upper triangular matrix T. On exit, if JOB = 'S', T contains the upper triangular matrix P from the generalized Schur factorization. And here's the fine print, so listen up: the 2-by-2 diagonal blocks of P corresponding to 2-by-2 blocks of S are reduced to positive diagonal form, i.e., if H(j+1,j) is non-zero, then T(j+1,j) = T(j,j+1) = 0, T(j,j) > 0, and T(j+1,j+1) > 0. Slay.
If JOB = 'E', the diagonal blocks of T match those of P, but the rest of T is unspecified. Again β eyes off the leftovers π
LDT
LDT is INTEGER β the leading dimension of the array T. LDT >= max( 1, N ).
ALPHAR
ALPHAR is REAL array, dimension (N) β the real parts of each scalar alpha defining an eigenvalue of GNEP β¨
ALPHAI
ALPHAI is REAL array, dimension (N) β the imaginary parts of each scalar alpha defining an eigenvalue of GNEP.
And the drama of it: if ALPHAI(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, with ALPHAI(j+1) = -ALPHAI(j). They come as a matching set, bestie, never separate them π¦
BETA
BETA is REAL array, dimension (N) β the scalars beta that define the eigenvalues of GNEP.
Together, the quantities alpha = (ALPHAR(j),ALPHAI(j)) and beta = BETA(j) represent the j-th eigenvalue of the matrix pair (A,B), in one of the forms lambda = alpha/beta or mu = beta/alpha. And the warning, okay, highlight it: since either lambda or mu may overflow, they should not, in general, be computed. Do not do the division. I am begging π
Q
Q is REAL array, dimension (LDQ, N).
On entry, if COMPQ = 'V', it's the orthogonal matrix Q1 used in the reduction of (A,B) to generalized Hessenberg form. On exit, if COMPQ = 'I', it's the orthogonal matrix of left Schur vectors of (H,T), and if COMPQ = 'V', it's the orthogonal matrix of left Schur vectors of (A,B).
Not referenced if COMPQ = 'N'. She's off duty, leave her alone π
LDQ
LDQ is INTEGER β the leading dimension of the array Q. LDQ >= 1. But if COMPQ='V' or 'I', then LDQ >= N. Conditional requirements, love that for us.
Z
Z is REAL array, dimension (LDZ, N).
On entry, if COMPZ = 'V', it's the orthogonal matrix Z1 used in the reduction of (A,B) to generalized Hessenberg form. On exit, if COMPZ = 'I', it's the orthogonal matrix of right Schur vectors of (H,T), and if COMPZ = 'V', it's the orthogonal matrix of right Schur vectors of (A,B).
Not referenced if COMPZ = 'N'. β¨
LDZ
LDZ is INTEGER β the leading dimension of the array Z. LDZ >= 1. If COMPZ='V' or 'I', then LDZ >= N. Same energy as LDQ, they're a duo π
WORK
WORK is REAL array, dimension (MAX(1,LWORK)).
On exit, if INFO >= 0, WORK(1) returns the optimal LWORK. She's telling you what she wants, respect it π
LWORK
LWORK is INTEGER β the dimension of the array WORK. And LWORK >= max(1,N).
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 shortcut, iykyk π
INFO
INFO is INTEGER:
= 0: successful exit. We love a clean win π< 0: ifINFO = -i, the i-th argument had an illegal value. Rude of you.= 1,...,N: the QZ iteration did not converge. (H,T) is not in Schur form, butALPHAR(i),ALPHAI(i), andBETA(i),i=INFO+1,...,Nshould be correct. So like, partial credit π= N+1,...,2*N: the shift calculation failed. (H,T) is not in Schur form, butALPHAR(i),ALPHAI(i), andBETA(i),i=INFO-N+1,...,Nshould be correct.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
Iteration counters, bestie, keep up:
JITERβ counts iterations.IITERβ counts iterations run sinceILASTwas last changed. This is therefore reset only when a 1-by-1 or 2-by-2 block deflates off the bottom. Only then. Not before. π¦
subroutine sla_geamv
subroutine sla_geamv (integer TRANS, integer M, integer N, real ALPHA, real,
dimension( lda, * ) A, integer LDA, real, dimension( * ) X, integer
INCX, real BETA, real, dimension( * ) Y, integer INCY)
SLA_GEAMV computes a matrix-vector product using a general matrix to calculate error bounds. Like, she's not here for the math math, she's here for the error bounds β¨
Purpose:
SLA_GEAMV performs one of the matrix-vector operations
y := alpha*abs(A)*abs(x) + beta*abs(y),
or y := alpha*abs(A)**T*abs(x) + beta*abs(y),
where alpha and beta are scalars, x and y are vectors and A is an m by n matrix.
This function is primarily used in calculating error bounds. And now the protection detail: to protect against underflow during evaluation, components in the resulting vector are perturbed away from zero by (N+1) times the underflow threshold. To prevent unnecessarily large errors for block-structure embedded in general matrices, 'symbolically' zero components are not perturbed. A zero entry is considered 'symbolic' if all multiplications involved in computing that entry have at least one zero multiplicand. She knows the difference between a real zero and a fake zero, no cap π
Parameters
TRANS
TRANS is INTEGER.
On entry, TRANS specifies the operation to be performed as follows:
BLAS_NO_TRANSβy := alpha*abs(A)*abs(x) + beta*abs(y)BLAS_TRANSβy := alpha*abs(A**T)*abs(x) + beta*abs(y)BLAS_CONJ_TRANSβy := alpha*abs(A**T)*abs(x) + beta*abs(y)
Unchanged on exit. She stays exactly how you left her π«Ά
M
M is INTEGER.
On entry, M specifies the number of rows of the matrix A. M must be at least zero. Unchanged on exit.
N
N is INTEGER.
On entry, N specifies the number of columns of the matrix A. N must be at least zero. Unchanged on exit.
ALPHA
ALPHA is REAL.
On entry, ALPHA specifies the scalar alpha. Unchanged on exit.
A
A is REAL array, dimension ( LDA, n ).
Before entry, the leading m by n part of the array A must contain the matrix of coefficients. Unchanged on exit.
LDA
LDA is INTEGER.
On entry, LDA specifies the first dimension of A as declared in the calling (sub) program. LDA must be at least max( 1, m ). Unchanged on exit.
X
X is REAL array, dimension
( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
and at least
( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
Before entry, the incremented array X must contain the vector x. Unchanged on exit.
INCX
INCX is INTEGER.
On entry, INCX specifies the increment for the elements of X. INCX must not be zero. Unchanged on exit.
BETA
BETA is REAL.
On entry, BETA specifies the scalar beta. When BETA is supplied as zero then Y need not be set on input. Unchanged on exit. (Free pass when it's zero, we love an efficient queen π)
Y
Y is REAL array, dimension at least
( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
and at least
( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
Before entry with BETA non-zero, the incremented array Y must contain the vector y. On exit, Y is overwritten by the updated vector y. She's changed, she's grown, she's the updated y now π
INCY
INCY is INTEGER.
On entry, INCY specifies the increment for the elements of Y. INCY must not be zero. Unchanged on exit.
Level 2 Blas routine. (say it with me: level twooooo)
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
real function sla_gercond
real function sla_gercond (character TRANS, integer N, real, dimension( lda,
* ) A, integer LDA, real, dimension( ldaf, * ) AF, integer LDAF,
integer, dimension( * ) IPIV, integer CMODE, real, dimension( * ) C,
integer INFO, real, dimension( * ) WORK, integer, dimension( * ) IWORK)
SLA_GERCOND estimates the Skeel condition number for a general matrix. Yes bestie, the Skeel one, she's fancy π
Purpose:
okay so, continuing from where we were π β SLA_GERCOND estimates the Skeel condition number of op(A) * op2(C), and op2 is whatever CMODE says it is, bestie:
CMODE = 1βop2(C) = CCMODE = 0βop2(C) = ICMODE = -1βop2(C) = inv(C)
The Skeel condition number cond(A) = norminf( |inv(A)||A| ) gets computed by finding scaling factors R such that diag(R)*A*op2(C) is row equilibrated, and then just computing the standard infinity-norm condition number. no cap, that's the whole move β¨
π Parameters π
TRANSβCHARACTER*1. Tells us the form of the system of equations:= 'N':A * X = B(No transpose)= 'T':A**T * X = B(Transpose)= 'C':A**H * X = B(Conjugate Transpose = Transpose)
NβINTEGER. The number of linear equations, aka the order of the matrixA. Gotta haveN >= 0.AβREAL array, dimension (LDA,N). On entry, theN-by-NmatrixA. the moment β¨LDAβINTEGER. The leading dimension of the arrayA.LDA >= max(1,N).AFβREAL array, dimension (LDAF,N). The factorsLandUfrom the factorizationA = P*L*Uas computed bySGETRF.LDAFβINTEGER. The leading dimension of the arrayAF.LDAF >= max(1,N).IPIVβINTEGER array, dimension (N). The pivot indices from the factorizationA = P*L*Uas computed bySGETRF; rowiof the matrix was interchanged with rowIPIV(i). iconic behavior πCMODEβINTEGER. Determinesop2(C)in the formulaop(A) * op2(C)as follows:CMODE = 1op2(C) = CCMODE = 0op2(C) = ICMODE = -1op2(C) = inv(C)
CβREAL array, dimension (N). The vectorCin the formulaop(A) * op2(C).INFOβINTEGER.= 0: Successful exit. slay π«Άi > 0: Theith argument is invalid.
WORKβREAL array, dimension (3*N). Workspace. (gotta have somewhere to put the thoughts π)IWORKβINTEGER array, dimension (N). Workspace. same vibe, but integers.
π Author π
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
π¦ sla_gerfsx_extended π¦
subroutine sla_gerfsx_extended (integer PREC_TYPE, integer TRANS_TYPE,
integer N, integer NRHS, real, dimension( lda, * ) A, integer LDA, real,
dimension( ldaf, * ) AF, integer LDAF, integer, dimension( * ) IPIV,
logical COLEQU, real, dimension( * ) C, real, dimension( ldb, * ) B,
integer LDB, real, dimension( ldy, * ) Y, integer LDY, real, dimension(
* ) BERR_OUT, integer N_NORMS, real, dimension( nrhs, * ) ERRS_N, real,
dimension( nrhs, * ) ERRS_C, real, dimension( * ) RES, real, dimension(
* ) AYB, real, dimension( * ) DY, real, dimension( * ) Y_TAIL, real
RCOND, integer ITHRESH, real RTHRESH, real DZ_UB, logical IGNORE_CWISE,
integer INFO)
SLA_GERFSX_EXTENDED improves the computed solution to a system of linear equations for general matrices by performing extra-precise iterative refinement and provides error bounds and backward error estimates for the solution. it's giving overachiever and we love that π
π Purpose π
SLA_GERFSX_EXTENDED improves the computed solution to a system of linear equations by performing extra-precise iterative refinement and provides error bounds and backward error estimates for the solution. This subroutine is called by SGERFSX to perform iterative refinement.
In addition to a normwise error bound, the code provides a maximum componentwise error bound if possible. See the comments for ERRS_N and ERRS_C for the deets on the error bounds. Note that this subroutine is only responsible for setting the second fields of ERRS_N and ERRS_C. (division of labor, bestie, we respect it π«‘)
β¨ Parameters β¨
PREC_TYPEβINTEGER. Specifies the intermediate precision to be used in refinement. The value is defined byILAPREC(P)wherePis aCHARACTERand:P = 'S': SingleP = 'D': DoubleP = 'I': IndigenousP = 'X'or'E': Extra
TRANS_TYPEβINTEGER. Specifies the transposition operation onA. The value is defined byILATRANS(T)whereTis aCHARACTERand:T = 'N': No transposeT = 'T': TransposeT = 'C': Conjugate transpose
NβINTEGER. The number of linear equations, i.e., the order of the matrixA.N >= 0.NRHSβINTEGER. The number of right-hand-sides, i.e., the number of columns of the matrixB.AβREAL array, dimension (LDA,N). On entry, theN-by-NmatrixA.LDAβINTEGER. The leading dimension of the arrayA.LDA >= max(1,N).AFβREAL array, dimension (LDAF,N). The factorsLandUfrom the factorizationA = P*L*Uas computed bySGETRF.LDAFβINTEGER. The leading dimension of the arrayAF.LDAF >= max(1,N).IPIVβINTEGER array, dimension (N). The pivot indices from the factorizationA = P*L*Uas computed bySGETRF; rowiof the matrix was interchanged with rowIPIV(i).COLEQUβLOGICAL. If.TRUE.then column equilibration was done toAbefore calling this routine. This is needed to compute the solution and error bounds correctly. (skip this and the math gets feral, fr fr)CβREAL array, dimension (N). The column scale factors forA. IfCOLEQU = .FALSE.,Cis not accessed. IfCis input, each element ofCshould be a power of the radix to ensure a reliable solution and error estimates. Scaling by powers of the radix does not cause rounding errors unless the result underflows or overflows. Rounding errors during scaling lead to refining with a matrix that is not equivalent to the input matrix, producing error estimates that may not be reliable.
β οΈ okay so that last bit is the important part: powers of the radix = safe, anything else = rounding errors, and then you're refining against a matrix that isn't even your matrix anymore and your error estimates are lowkey untrustworthy. don't do it π
BβREAL array, dimension (LDB,NRHS). The right-hand-side matrixB.LDBβINTEGER. The leading dimension of the arrayB.LDB >= max(1,N).YβREAL array, dimension (LDY,NRHS). On entry, the solution matrixX, as computed bySGETRS. On exit, the improved solution matrixY. glow-up arc β¨LDYβINTEGER. The leading dimension of the arrayY.LDY >= max(1,N).BERR_OUTβREAL array, dimension (NRHS). On exit,BERR_OUT(j)contains the componentwise relative backward error for right-hand-sidejfrom the formula
max(i) ( abs(RES(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) )
where abs(Z) is the componentwise absolute value of the matrix or vector Z. This is computed by SLA_LIN_BERR.
N_NORMSβINTEGER. Determines which error bounds to return (seeERRS_NandERRS_C).- If
N_NORMS >= 1return normwise error bounds. - If
N_NORMS >= 2return componentwise error bounds.
- If
ERRS_NβREAL array, dimension (NRHS, N_ERR_BNDS). For each right-hand side, this array contains information about various error bounds and condition numbers corresponding to the normwise relative error, which is defined as follows:
Normwise relative error in the ith solution vector:
max_j (abs(XTRUE(j,i) - X(j,i)))
------------------------------
max_j abs(X(j,i))
The array is indexed by the type of error information as described below. There currently are up to three pieces of information returned.
The first index in ERRS_N(i,:) corresponds to the ith right-hand side.
The second index in ERRS_N(:,err) contains the following three fields:
err = 1β'Trust/don't trust'boolean. Trust the answer if the reciprocal condition number is less than the thresholdsqrt(n) * slamch('Epsilon').err = 2β'Guaranteed'error bound: The estimated forward error, almost certainly within a factor of10of the true error so long as the next entry is greater than the thresholdsqrt(n) * slamch('Epsilon'). This error bound should only be trusted if the previous boolean is true.err = 3β Reciprocal condition number: Estimated normwise reciprocal condition number. Compared with the thresholdsqrt(n) * slamch('Epsilon')to determine if the error estimate is'guaranteed'. These reciprocal condition numbers are1 / (norm(Z^{-1},inf) * norm(Z,inf))for some appropriately scaled matrixZ. LetZ = S*A, whereSscales each row by a power of the radix so all absolute row sums ofZare approximately1.
This subroutine is only responsible for setting the second field above. See Lapack Working Note 165 for further details and extra cautions. iykyk π
ERRS_CβREAL array, dimension (NRHS, N_ERR_BNDS). For each right-hand side, this array contains information about various error bounds and condition numbers corresponding to the componentwise relative error, which is defined as follows:
Componentwise relative error in the ith solution vector:
abs(XTRUE(j,i) - X(j,i))
max_j ----------------------
abs(X(j,i))
The array is indexed by the right-hand side i (on which the componentwise relative error depends), and the type of error information as described below. There currently are up to three pieces of information returned for each right-hand side. If componentwise accuracy is not requested (PARAMS(3) = 0.0), then ERRS_C is not accessed. If N_ERR_BNDS < 3, then at most the first (:,N_ERR_BNDS) entries are returned.
The first index in ERRS_C(i,:) corresponds to the ith right-hand side.
err = 1β the 'Trust/don't trust' boolean π. Trust the answer if the reciprocal condition number is less than the thresholdsqrt(n) * slamch('Epsilon').err = 2β the 'Guaranteed' error bound π‘οΈ. This is the estimated forward error, and it's almost certainly within a factor of10of the true error so long as the next entry is greater than the thresholdsqrt(n) * slamch('Epsilon'). Bestie listen: this error bound should only be trusted if the previous boolean is true. No cap.err = 3β the Reciprocal condition number π. Estimated componentwise reciprocal condition number. It gets compared against the thresholdsqrt(n) * slamch('Epsilon')to figure out whether the error estimate is'guaranteed'. These reciprocal condition numbers are1 / (norm(Z^{-1},inf) * norm(Z,inf))for some appropriately scaled matrixZ.
Let Z = S*(A*diag(x)), where x is the solution for the current right-hand side and S scales each row of A*diag(x) by a power of the radix so all absolute row sums of Z are approximately 1.
This subroutine is only responsible for setting the second field above, fr fr. That's its whole job.
See Lapack Working Note 165 for further details and extra cautions π.
π RES
RESisREALarray, dimension(N)Workspace to hold the intermediate residual.
πΈ AYB
AYBisREALarray, dimension(N)Workspace. This can be the same workspace passed forY_TAIL. Reuse is slay.
π¦ DY
DYisREALarray, dimension(N)Workspace to hold the intermediate solution.
β Y_TAIL
Y_TAILisREALarray, dimension(N)Workspace to hold the trailing bits of the intermediate solution.
π RCOND
RCONDisREALReciprocal scaled condition number. This is an estimate of the reciprocal Skeel condition number of the matrixAafter equilibration (if done). If this is less than the machine precision (in particular, if it is zero), the matrix is singular to working precision π. Note that the error may still be small even if this number is very small and the matrix appears ill-conditioned. Not me warning you twice but here we are.
π₯ ITHRESH
ITHRESHisINTEGERThe maximum number of residual computations allowed for refinement. The default is10. For'aggressive'set to100to permit convergence using approximate factorizations or factorizations other than LU. If the factorization uses a technique other than Gaussian elimination, the guarantees inERRS_NandERRS_Cmay no longer be trustworthy π.
π RTHRESH
RTHRESHisREALDetermines when to stop refinement if the error estimate stops decreasing. Refinement will stop when the next solution no longer satisfiesnorm(dx_{i+1}) < RTHRESH * norm(dx_i)wherenorm(Z)is the infinity norm ofZ.RTHRESHsatisfies0 < RTHRESH <= 1. The default value is0.5. For'aggressive'set to0.9to permit convergence on extremely ill-conditioned matrices. See LAWN 165 for more details.
π DZ_UB
DZ_UBisREALDetermines when to start considering componentwise convergence. Componentwise convergence is only considered after each component of the solutionYis stable, which we define as the relative change in each component being less thanDZ_UB. The default value is0.25, requiring the first bit to be stable. See LAWN 165 for more details.
π§ IGNORE_CWISE
IGNORE_CWISEisLOGICALIf.TRUE.then ignore componentwise convergence. Default value is.FALSE..
π INFO
INFOisINTEGER= 0: Successful exit. π< 0: ifINFO = -i, theith argument toSGETRShad an illegal value.
π Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
β¨ real function sla_gerpvgrw β¨
real function sla_gerpvgrw (integer N, integer NCOLS, real, dimension( lda,
* ) A, integer LDA, real, dimension( ldaf, * ) AF, integer LDAF)
SLA_GERPVGRW π«Ά
π Purpose:
SLA_GERPVGRW computes the reciprocal pivot growth factor norm(A)/norm(U). The 'max absolute element' norm is used. If this is much less than 1, the stability of the LU factorization of the (equilibrated) matrix A could be poor π¬. This also means that the solution X, estimated condition numbers, and error bounds could be unreliable. Big yikes, watch out for that one.
π Parameters
Nβ INTEGER The number of linear equations, i.e., the order of the matrixA.N >= 0.NCOLSβ INTEGER The number of columns of the matrixA.NCOLS >= 0.Aβ REAL array, dimension(LDA,N)On entry, theN-by-NmatrixA.LDAβ INTEGER The leading dimension of the arrayA.LDA >= max(1,N).AFβ REAL array, dimension(LDAF,N)The factorsLandUfrom the factorizationA = P*L*Uas computed bySGETRF.LDAFβ INTEGER The leading dimension of the arrayAF.LDAF >= max(1,N).
π Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
β¨ subroutine slaorhr_col_getrfnp β¨
subroutine slaorhr_col_getrfnp (integer M, integer N, real, dimension( lda,
* ) A, integer LDA, real, dimension( * ) D, integer INFO)
SLAORHR_COL_GETRFNP π
π Purpose:
SLAORHR_COL_GETRFNP computes the modified LU factorization without pivoting of a real general M-by-N matrix A. The factorization has the form:
A - S = L * U,
where:
Sis a m-by-n diagonal sign matrix with the diagonalD, so thatD(i) = S(i,i),1 <= i <= min(M,N). The diagonalDis constructed asD(i)=-SIGN(A(i,i)), whereA(i,i)is the value after performingi-1steps of Gaussian elimination. This means that the diagonal element at each step of'modified'Gaussian elimination is at least one in absolute value (so that division-by-zero not not possible during the division by the diagonal element);Lis aM-by-Nlower triangular matrix with unit diagonal elements (lower trapezoidal ifM > N);- and
Uis aM-by-Nupper triangular matrix (upper trapezoidal ifM < N).
This routine is an auxiliary routine used in the Householder reconstruction routine SORHR_COL. In SORHR_COL, this routine is applied to an M-by-N matrix A with orthonormal columns, where each element is bounded by one in absolute value. With the choice of the matrix S above, one can show that the diagonal element at each step of Gaussian elimination is the largest (in absolute value) in the column on or below the diagonal, so that no pivoting is required for numerical stability [1]. Iconic behaviour honestly.
For more details on the Householder reconstruction algorithm, including the modified LU factorization, see [1].
This is the blocked right-looking version of the algorithm, calling Level 3 BLAS to update the submatrix. To factorize a block, this routine calls the recursive routine SLAORHR_COL_GETRFNP2. Recursion go brrr π
[1] 'Reconstructing Householder vectors from tall-skinny QR', G. Ballard, J. Demmel, L. Grigori, M. Jacquelin, H.D. Nguyen, E. Solomonik, J. Parallel Distrib. Comput., vol. 85, pp. 3-31, 2015.
π Parameters
Mβ INTEGER The number of rows of the matrixA.M >= 0.Nβ INTEGER The number of columns of the matrixA.N >= 0.Aβ REAL array, dimension(LDA,N)On entry, theM-by-Nmatrix to be factored. On exit, the factorsLandUfrom the factorizationA-S=L*U; the unit diagonal elements ofLare not stored.LDAβ INTEGER The leading dimension of the arrayA.LDA >= max(1,M).Dβ REAL array, dimensionmin(M,N)The diagonal elements of the diagonalM-by-Nsign matrixS,D(i) = S(i,i), where1 <= i <= min(M,N). The elements can be only plus or minus one.INFOβ INTEGER= 0: successful exit π< 0: ifINFO = -i, thei-th argument had an illegal value
π Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
πΈ Contributors:
November 2019, Igor Kozachenko, Computer Science Division, University of California, Berkeley
β¨ recursive subroutine slaorhr_col_getrfnp2 β¨
recursive subroutine slaorhr_col_getrfnp2 (integer M, integer N, real,
dimension( lda, * ) A, integer LDA, real, dimension( * ) D, integer
INFO)
SLAORHR_COL_GETRFNP2 π¦
π Purpose:
SLAORHR_COL_GETRFNP2 computes the modified LU factorization without pivoting of a real general M-by-N matrix A. The factorization has the form:
A - S = L * U,
where:
Sis a m-by-n diagonal sign matrix with the diagonalD, so thatD(i) = S(i,i),1 <= i <= min(M,N). The diagonalDis constructed asD(i)=-SIGN(A(i,i)), whereA(i,i)is the value after performingi-1steps of Gaussian elimination. This means that the diagonal element at each step of'modified'Gaussian elimination is at least one in absolute value (so that division-by-zero not possible during the division by the diagonal element);Lis aM-by-Nlower triangular matrix with unit diagonal elements (lower trapezoidal ifM > N);- and
Uis aM-by-Nupper triangular matrix (upper trapezoidal ifM < N).
okay so this routine? it's literally the auxiliary bestie for the Householder reconstruction routine SORHR_COL π In SORHR_COL, this routine gets applied to an M-by-N matrix A with orthonormal columns, where every element is bounded by one in absolute value. And with the choice of the matrix S above, you can show that the diagonal element at each step of Gaussian elimination is the largest (in absolute value) in the column on or below the diagonal, so no pivoting is required for numerical stability [1]. no cap.
For more details on the Householder reconstruction algorithm, including the modified LU factorization, see [1].
This is the recursive version of the LU factorization algorithm. Denote A - S by B. The algorithm divides the matrix B into four submatrices:
[ B11 | B12 ] where B11 is n1 by n1,
B = [ -----|----- ] B21 is (m-n1) by n1,
[ B21 | B22 ] B12 is n1 by n2,
B22 is (m-n1) by n2,
with n1 = min(m,n)/2, n2 = n-n1.
The subroutine calls itself to factor B11, solves for B21, solves for B12, updates B22, then calls itself to factor B22.
For more details on the recursive LU algorithm, see [2].
SLAORHR_COL_GETRFNP2 is called to factorize a block by the blocked routine SLAORHR_COL_GETRFNP, which uses blocked code calling Level 3 BLAS to update the submatrix. However, SLAORHR_COL_GETRFNP2 is self-sufficient and can be used without SLAORHR_COL_GETRFNP. π
[1] 'Reconstructing Householder vectors from tall-skinny QR',
G. Ballard, J. Demmel, L. Grigori, M. Jacquelin, H.D. Nguyen,
E. Solomonik, J. Parallel Distrib. Comput.,
vol. 85, pp. 3-31, 2015.
[2] 'Recursion leads to automatic variable blocking for dense linear
algebra algorithms', F. Gustavson, IBM J. of Res. and Dev.,
vol. 41, no. 6, pp. 737-755, 1997.
Parameters β¨
MβMisINTEGER. The number of rows of the matrixA.M >= 0. row count bestie πNβNisINTEGER. The number of columns of the matrixA.N >= 0. column count slay β¨AβAisREALarray, dimension(LDA,N). On entry, theM-by-Nmatrix to be factored. On exit, the factorsLandUfrom the factorizationA-S=L*U; the unit diagonal elements ofLare not stored. the glow up is real π¦LDAβLDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,M). leading dimension vibes πDβDisREALarray, dimensionmin(M,N). The diagonal elements of the diagonalM-by-Nsign matrixS,D(i) = S(i,i), where1 <= i <= min(M,N). The elements can be only plus or minus one. only Β±1, no in-between πINFOβINFOisINTEGER.= 0: successful exit;< 0: ifINFO = -i, thei-th argument had an illegal value. bestie if it's negative, something's wrong π
Author πΈ
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Contributors π
- November 2019, Igor Kozachenko, Computer Science Division, University of California, Berkeley
STGEVC β¨
subroutine stgevc (character SIDE, character HOWMNY, logical, dimension( * ) SELECT, integer N, real, dimension( lds, * ) S, integer LDS, real, dimension( ldp, * ) P, integer LDP, real, dimension( ldvl, * ) VL, integer LDVL, real, dimension( ldvr, * ) VR, integer LDVR, integer MM, integer M, real, dimension( * ) WORK, integer INFO)
Purpose: π
STGEVC computes some or all of the right and/or left eigenvectors of a pair of real matrices (S,P), where S is a quasi-triangular matrix and P is upper triangular. Matrix pairs of this type are produced by the generalized Schur factorization of a matrix pair (A,B):
A = Q*S*Z**T, B = Q*P*Z**T
as computed by SGGHRD + SHGEQZ.
The right eigenvector x and the left eigenvector y of (S,P) corresponding to an eigenvalue w are defined by:
S*x = w*P*x, (y**H)*S = w*(y**H)*P,
where y**H denotes the conjugate tranpose of y. The eigenvalues are not input to this routine, but are computed directly from the diagonal blocks of S and P. eigen everything π
This routine returns the matrices X and/or Y of right and left eigenvectors of (S,P), or the products Z*X and/or Q*Y, where Z and Q are input matrices. If Q and Z are the orthogonal factors from the generalized Schur factorization of a matrix pair (A,B), then Z*X and Q*Y are the matrices of right and left eigenvectors of (A,B). iconic behavior π
Parameters π
SIDEβSIDEisCHARACTER*1.= 'R': compute right eigenvectors only;= 'L': compute left eigenvectors only;= 'B': compute both right and left eigenvectors. pick your side bestie πHOWMNYβHOWMNYisCHARACTER*1.= 'A': compute all right and/or left eigenvectors;= 'B': compute all right and/or left eigenvectors, backtransformed by the matrices inVRand/orVL;= 'S': compute selected right and/or left eigenvectors, specified by the logical arraySELECT. how many? yes β¨SELECTβSELECTisLOGICALarray, dimension(N). IfHOWMNY='S',SELECTspecifies the eigenvectors to be computed. Ifw(j)is a real eigenvalue, the corresponding real eigenvector is computed ifSELECT(j)is.TRUE.. Ifw(j)andw(j+1)are the real and imaginary parts of a complex eigenvalue, the corresponding complex eigenvector is computed if eitherSELECT(j)orSELECT(j+1)is.TRUE., and on exitSELECT(j)is set to.TRUE.andSELECT(j+1)is set to.FALSE.. Not referenced ifHOWMNY = 'A'or'B'. the chosen ones π¦NβNisINTEGER. The order of the matricesSandP.N >= 0. order up πSβSisREALarray, dimension(LDS,N). The upper quasi-triangular matrixSfrom a generalized Schur factorization, as computed bySHGEQZ. quasi-triangular realness πLDSβLDSisINTEGER. The leading dimension of arrayS.LDS >= max(1,N). leading dim, no skimping βPβPisREALarray, dimension(LDP,N). The upper triangular matrixPfrom a generalized Schur factorization, as computed bySHGEQZ. 2-by-2 diagonal blocks ofPcorresponding to 2-by-2 blocks ofSmust be in positive diagonal form. positive diagonal form only, periodt πLDPβLDPisINTEGER. The leading dimension of arrayP.LDP >= max(1,N). another leading dim, another slay β¨VLβVLisREALarray, dimension(LDVL,MM). On entry, ifSIDE = 'L'or'B'andHOWMNY = 'B',VLmust contain anN-by-NmatrixQ(usually the orthogonal matrixQof left Schur vectors returned bySHGEQZ). On exit, ifSIDE = 'L'or'B',VLcontains: ifHOWMNY = 'A', the matrixYof left eigenvectors of(S,P); ifHOWMNY = 'B', the matrixQ*Y; ifHOWMNY = 'S', the left eigenvectors of(S,P)specified bySELECT, stored consecutively in the columns ofVL, in the same order as their eigenvalues. A complex eigenvector corresponding to a complex eigenvalue is stored in two consecutive columns, the first holding the real part, and the second the imaginary part. Not referenced ifSIDE = 'R'. left side story πLDVLβLDVLisINTEGER. The leading dimension of arrayVL.LDVL >= 1, and ifSIDE = 'L'or'B',LDVL >= N. dimension check πVRβVRisREALarray, dimension(LDVR,MM). On entry, ifSIDE = 'R'or'B'andHOWMNY = 'B',VRmust contain anN-by-NmatrixZ(usually the orthogonal matrixZof right Schur vectors returned bySHGEQZ). On exit, ifSIDE = 'R'or'B',VRcontains: ifHOWMNY = 'A', the matrixXof right eigenvectors of(S,P); ifHOWMNY = 'B'or'b', the matrixZ*X; ifHOWMNY = 'S'or's', the right eigenvectors of(S,P)specified bySELECT, stored consecutively in the columns ofVR, in the same order as their eigenvalues. A complex eigenvector corresponding to a complex eigenvalue is stored in two consecutive columns, the first holding the real part and the second the imaginary part. Not referenced ifSIDE = 'L'. right side story πLDVRβLDVRisINTEGER. The leading dimension of the arrayVR.LDVR >= 1, and ifSIDE = 'R'or'B',LDVR >= N. leading dim again, we love consistency πMMβMMisINTEGER. The number of columns in the arraysVLand/orVR.MM >= M. max columns, got it β¨MβMisINTEGER. The number of columns in the arraysVLand/orVRactually used to store the eigenvectors. IfHOWMNY = 'A'or'B',Mis set toN. Each selected real eigenvector occupies one column and each selected complex eigenvector occupies two columns. columns used, no cap πWORKβWORKisREALarray, dimension(6*N). workspace bestie π¦INFOβINFOisINTEGER.= 0: successful exit.< 0: ifINFO = -i, thei-th argument had an illegal value.> 0: the 2-by-2 block(INFO:INFO+1)does not have a complex eigenvalue. if positive, that block is not giving complex eigenvalue energy π
Author πΈ
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Further Details π₯
Allocation of workspace:
---------- -- ---------
WORK( j ) = 1-norm of j-th column of A, above the diagonal
WORK( N+j ) = 1-norm of j-th column of B, above the diagonal
WORK( 2*N+1:3*N ) = real part of eigenvector
WORK( 3*N+1:4*N ) = imaginary part of eigenvector
WORK( 4*N+1:5*N ) = real part of back-transformed eigenvector
WORK( 5*N+1:6*N ) = imaginary part of back-transformed eigenvector
Rowwise vs. columnwise solution methods:
------- -- ---------- -------- -------
Finding a generalized eigenvector consists basically of solving the
singular triangular system
(A - w B) x = 0 (for right) or: (A - w B)**H y = 0 (for left)
and that's the math, bestie πβ¨
okay so bestie, imagine we're finding the i-th right eigenvector (assume all eigenvalues are real). The equation to be solved is literally this:
n i
0 = sum C(j,k) v(k) = sum C(j,k) v(k) for j = i,. . .,1
k=j k=j
where C = (A - w B) and the components v(i+1:n) are 0.
The 'rowwise' method is:
(1) v(i) := 1
for j = i-1,. . .,1:
i
(2) compute s = - sum C(j,k) v(k) and
k=j+1
(3) v(j) := s / C(j,j)
Step 2 is sometimes called the 'dot product' step, since it is an inner product between the j-th row and the portion of the eigenvector that has been computed so far.
The 'columnwise' method consists basically in doing the sums for all the rows in parallel. As each v(j) is computed, the contribution of v(j) times the j-th column of C is added to the partial sums. Since FORTRAN arrays are stored columnwise, this has the advantage that at each step, the elements of C that are accessed are adjacent to one another, whereas with the rowwise method, the elements accessed at a step are spaced LDS (and LDP) words apart.
When finding left eigenvectors, the matrix in question is the transpose of the one in storage, so the rowwise method then actually accesses columns of A and B at each step, and so is the preferred method.
subroutine stgexc
subroutine stgexc (logical WANTQ, logical WANTZ, integer N, real, dimension(
lda, * ) A, integer LDA, real, dimension( ldb, * ) B, integer LDB, real,
dimension( ldq, * ) Q, integer LDQ, real, dimension( ldz, * ) Z, integer
LDZ, integer IFST, integer ILST, real, dimension( * ) WORK, integer
LWORK, integer INFO)
STGEXC
Purpose:
STGEXC reorders the generalized real Schur decomposition of a real matrix pair (A,B) using an orthogonal equivalence transformation
(A, B) = Q * (A, B) * Z**T,
so that the diagonal block of (A, B) with row index IFST is moved to row ILST.
(A, B) must be in generalized real Schur canonical form (as returned by SGGES), i.e. A is block upper triangular with 1-by-1 and 2-by-2 diagonal blocks. B is upper triangular.
Optionally, the matrices Q and Z of generalized Schur vectors are updated.
Q(in) * A(in) * Z(in)**T = Q(out) * A(out) * Z(out)**T
Q(in) * B(in) * Z(in)**T = Q(out) * B(out) * Z(out)**T
Parameters
WANTQβ WANTQ is LOGICAL, bestie..TRUE.: update the left transformation matrix Q;.FALSE.: do not update Q.WANTZβ WANTZ is LOGICAL..TRUE.: update the right transformation matrix Z;.FALSE.: do not update Z.Nβ N is INTEGER. It's the order of the matrices A and B.N >= 0, no cap.Aβ A is REAL array, dimension(LDA,N). On entry, the matrix A in generalized real Schur canonical form. On exit, the updated matrix A, again in generalized real Schur canonical form. iconic.LDAβ LDA is INTEGER. The leading dimension of the array A.LDA >= max(1,N).Bβ B is REAL array, dimension(LDB,N). On entry, the matrix B in generalized real Schur canonical form (A,B). On exit, the updated matrix B, again in generalized real Schur canonical form (A,B).LDBβ LDB is INTEGER. The leading dimension of the array B.LDB >= max(1,N).Qβ Q is REAL array, dimension(LDQ,N). On entry, ifWANTQ = .TRUE., the orthogonal matrix Q. On exit, the updated matrix Q. IfWANTQ = .FALSE., Q is not referenced.LDQβ LDQ is INTEGER. The leading dimension of the array Q.LDQ >= 1. IfWANTQ = .TRUE.,LDQ >= N.Zβ Z is REAL array, dimension(LDZ,N). On entry, ifWANTZ = .TRUE., the orthogonal matrix Z. On exit, the updated matrix Z. IfWANTZ = .FALSE., Z is not referenced.LDZβ LDZ is INTEGER. The leading dimension of the array Z.LDZ >= 1. IfWANTZ = .TRUE.,LDZ >= N.IFSTβ IFST is INTEGERILSTβ ILST is INTEGER. It specifies the reordering of the diagonal blocks of (A, B). The block with row index IFST is moved to row ILST, by a sequence of swapping between adjacent blocks. On exit, if IFST pointed on entry to the second row of a 2-by-2 block, it is changed to point to the first row; ILST always points to the first row of the block in its final position (which may differ from its input value by+1or-1).1 <= IFST, ILST <= N.WORKβ WORK is REAL array, dimension(MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimal LWORK.LWORKβ LWORK is INTEGER. The dimension of the array WORK.LWORK >= 1whenN <= 1, otherwiseLWORK >= 4*N + 16. IfLWORK = -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.INFOβ INFO is INTEGER.=0: successful exit.<0: ifINFO = -i, the i-th argument had an illegal value.=1: The transformed matrix pair (A, B) would be too far from generalized Schur form; the problem is ill-conditioned. (A, B) may have been partially reordered, and ILST points to the first row of the current position of the block being moved.
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Contributors:
- Bo Kagstrom and Peter Poromaa, Department of Computing Science, Umea University, S-901 87 Umea, Sweden.
References:
- [1] B. Kagstrom; A Direct Method for Reordering Eigenvalues in the Generalized Real Schur Form of a Regular Matrix Pair (A, B), in M.S. Moonen et al (eds), Linear Algebra for Large Scale and Real-Time Applications, Kluwer Academic Publ. 1993, pp 195-218.
Author Generated automatically by Doxygen for LAPACK from the source code.
and that's the whole vibe, bestie! this page is from LAPACK version 3.11.0, dated Sun Nov 27 2022, for realGEcomputational(3). periodt π
β¨
π¦ where this page comes from
- debian bookworm: liblapack-doc 3.11.0-2 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms