gesvxx(3)
π gesvxx(3) β factor and solve, extra precise π
okay so bestie, this is gesvxx(3) from the Library Functions Manual, and it's literally the extra-precise glow-up of solving A * X = B for GE matrices. No cap, it's giving "I did the math and I brought receipts." Let's get into it π«Ά
β¨ NAME β¨
gesvxx β gesvxx: factor and solve, extra precise
πΈ SYNOPSIS πΈ
Functions
subroutine cgesvxx (fact, trans, n, nrhs, a, lda, af, ldaf, ipiv, equed, r, c, b, ldb, x, ldx, rcond, rpvgrw, berr, n_err_bnds, err_bnds_norm, err_bnds_comp, nparams, params, work, rwork, info)
CGESVXX computes the solution to system of linear equations A * X = B for GE matrices
subroutine dgesvxx (fact, trans, n, nrhs, a, lda, af, ldaf, ipiv, equed, r, c, b, ldb, x, ldx, rcond, rpvgrw, berr, n_err_bnds, err_bnds_norm, err_bnds_comp, nparams, params, work, iwork, info)
DGESVXX computes the solution to system of linear equations A * X = B for GE matrices
subroutine sgesvxx (fact, trans, n, nrhs, a, lda, af, ldaf, ipiv, equed, r, c, b, ldb, x, ldx, rcond, rpvgrw, berr, n_err_bnds, err_bnds_norm, err_bnds_comp, nparams, params, work, iwork, info)
SGESVXX computes the solution to system of linear equations A * X = B for GE matrices
subroutine zgesvxx (fact, trans, n, nrhs, a, lda, af, ldaf, ipiv, equed, r, c, b, ldb, x, ldx, rcond, rpvgrw, berr, n_err_bnds, err_bnds_norm, err_bnds_comp, nparams, params, work, rwork, info)
ZGESVXX computes the solution to system of linear equations A * X = B for GE matrices
π« Detailed Description π«
This is the part where the docs get into the actual function lore. Stay with me, it's iconic.
π Function Documentation π
π subroutine cgesvxx (character fact, character trans, integer n, integer nrhs, complex, dimension( lda, * ) a, integer lda, complex, dimension( ldaf, * ) af, integer ldaf, integer, dimension( * ) ipiv, character equed, real, dimension( * ) r, real, dimension( * ) c, complex, dimension( ldb, * ) b, integer ldb, complex, dimension( ldx , * ) x, integer ldx, real rcond, real rpvgrw, real, dimension( * ) berr, integer n_err_bnds, real, dimension( nrhs, * ) err_bnds_norm, real, dimension( nrhs, * ) err_bnds_comp, integer nparams, real, dimension( * ) params, complex, dimension( * ) work, real, dimension( * ) rwork, integer info)
CGESVXX computes the solution to system of linear equations A * X = B for GE matrices
π Purpose π
okay so CGESVXX uses the LU factorization to compute the solution to a complex system of linear equations A * X = B, where A is an N-by-N matrix and X and B are N-by-NRHS matrices.
If requested, both normwise and maximum componentwise error bounds are returned. CGESVXX will return a solution with a tiny guaranteed error (O(eps) where eps is the working machine precision) unless the matrix is very ill-conditioned, in which case a warning is returned. Relevant condition numbers also are calculated and returned.
CGESVXX accepts user-provided factorizations and equilibration factors; see the definitions of the FACT and EQUED options. Solving with refinement and using a factorization from a previous CGESVXX call will also produce a solution with either O(eps) errors or warnings, but we cannot make that claim for general user-provided factorizations and equilibration factors if they differ from what CGESVXX would itself produce.
π¦ Description π¦
The following steps are performed:
- If
FACT = 'E', real scaling factors are computed to equilibrate the system:
TRANS = 'N': diag(R)*A*diag(C) *inv(diag(C))*X = diag(R)*B
TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B
TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B
Whether or not the system will be equilibrated depends on the scaling of the matrix A, but if equilibration is used, A is overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N') or diag(C)*B (if TRANS = 'T' or 'C').
- If
FACT = 'N'or'E', the LU decomposition is used to factor the matrixA(after equilibration ifFACT = 'E') as
A = P * L * U,
where P is a permutation matrix, L is a unit lower triangular matrix, and U is upper triangular.
- If some
U(i,i)=0, so thatUis exactly singular, then the routine returns withINFO = i. Otherwise, the factored form ofAis used to estimate the condition number of the matrixA(see argumentRCOND). If the reciprocal of the condition number is less than machine precision, the routine still goes on to solve forXand compute error bounds as described below. - The system of equations is solved for
Xusing the factored form ofA. - By default (unless
PARAMS(LA_LINRX_ITREF_I)is set to zero), the routine will use iterative refinement to try to get a small error and error bounds. Refinement calculates the residual to at least twice the working precision. - If equilibration was used, the matrix
Xis premultiplied bydiag(C)(ifTRANS = 'N') ordiag(R)(ifTRANS = 'T'or'C') so that it solves the original system before equilibration.
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.
π Parameters π
FACT
FACT is CHARACTER*1. Specifies whether or not the factored form of the matrix A is supplied on entry, and if not, whether the matrix A should be equilibrated before it is factored.
= 'F': On entry,AFandIPIVcontain the factored form ofA. IfEQUEDis not'N', the matrixAhas been equilibrated with scaling factors given byRandC.A,AF, andIPIVare not modified.= 'N': The matrixAwill be copied toAFand factored.= 'E': The matrixAwill be equilibrated if necessary, then copied toAFand factored.
TRANS
TRANS is CHARACTER*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)
N
N is INTEGER. The number of linear equations, i.e., the order of the matrix A. N >= 0.
NRHS
NRHS is INTEGER. The number of right hand sides, i.e., the number of columns of the matrices B and X. NRHS >= 0.
A
A is COMPLEX array, dimension (LDA,N). On entry, the N-by-N matrix A. If FACT = 'F' and EQUED is not 'N', then A must have been equilibrated by the scaling factors in R and/or C. A is not modified if FACT = 'F' or 'N', or if FACT = 'E' and EQUED = 'N' on exit.
On exit, if EQUED .ne. 'N', A is scaled as follows:
EQUED = 'R':A := diag(R) * AEQUED = 'C':A := A * diag(C)EQUED = 'B':A := diag(R) * A * diag(C).
LDA
LDA is INTEGER. The leading dimension of the array A. LDA >= max(1,N).
AF
AF is COMPLEX array, dimension (LDAF,N). If FACT = 'F', then AF is an input argument and on entry contains the factors L and U from the factorization A = P*L*U as computed by CGETRF. If EQUED .ne. 'N', then AF is the factored form of the equilibrated matrix A.
If FACT = 'N', then AF is an output argument and on exit returns the factors L and U from the factorization A = P*L*U of the original matrix A.
If FACT = 'E', then AF is an output argument and on exit returns the factors L and U from the factorization A = P*L*U of the equilibrated matrix A (see the description of A for the form of the equilibrated matrix).
LDAF
LDAF is INTEGER. The leading dimension of the array AF. LDAF >= max(1,N).
IPIV
IPIV is INTEGER array, dimension (N). If FACT = 'F', then IPIV is an input argument and on entry contains the pivot indices from the factorization A = P*L*U as computed by CGETRF; row i of the matrix was interchanged with row IPIV(i).
If FACT = 'N', then IPIV is an output argument and on exit contains the pivot indices from the factorization A = P*L*U of the original matrix A.
If FACT = 'E', then IPIV is an output argument and on exit contains the pivot indices from the factorization A = P*L*U of the equilibrated matrix A.
EQUED
EQUED is CHARACTER*1. Specifies the form of equilibration that was done.
= 'N': No equilibration (always true ifFACT = 'N').= 'R': Row equilibration, i.e.,Ahas been premultiplied bydiag(R).= 'C': Column equilibration, i.e.,Ahas been postmultiplied bydiag(C).= 'B': Both row and column equilibration, i.e.,Ahas been replaced bydiag(R) * A * diag(C).
EQUED is an input argument if FACT = 'F'; otherwise, it is an output argument.
R
(and this is literally where part 1 cuts off β R's whole deal is next, bestie, don't leave me hanging π« )
RβREALarray, dimension(N). The row scale factors forA, bestie. IfEQUED = 'R'or'B',Ais multiplied on the left bydiag(R); ifEQUED = 'N'or'C',Ris not accessed.Ris an input argument ifFACT = 'F'; otherwise,Ris an output argument. IfFACT = 'F'andEQUED = 'R'or'B', each element ofRmust be positive.
If R is output, each element of R is a power of the radix. If R is input, 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. π
CβREALarray, dimension(N). The column scale factors forA. IfEQUED = 'C'or'B',Ais multiplied on the right bydiag(C); ifEQUED = 'N'or'R',Cis not accessed.Cis an input argument ifFACT = 'F'; otherwise,Cis an output argument. IfFACT = 'F'andEQUED = 'C'or'B', each element ofCmust be positive.
If C is output, each element of C is a power of the radix. If C is input, 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. π
BβCOMPLEXarray, dimension(LDB,NRHS). On entry, theN-by-NRHSright hand side matrixB. On exit:- if
EQUED = 'N',Bis not modified; - if
TRANS = 'N'andEQUED = 'R'or'B',Bis overwritten bydiag(R)*B; - if
TRANS = 'T'or'C'andEQUED = 'C'or'B',Bis overwritten bydiag(C)*B.
- if
LDBβINTEGER. The leading dimension of the arrayB.LDB >= max(1,N).XβCOMPLEXarray, dimension(LDX,NRHS). IfINFO = 0, theN-by-NRHSsolution matrixXto the original system of equations. Note thatAandBare modified on exit ifEQUED .ne. 'N', and the solution to the equilibrated system isinv(diag(C))*XifTRANS = 'N'andEQUED = 'C'or'B', orinv(diag(R))*XifTRANS = 'T'or'C'andEQUED = 'R'or'B'. π¦LDXβINTEGER. The leading dimension of the arrayX.LDX >= max(1,N).RCONDβREAL. Reciprocal 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. πRPVGRWβREAL. Reciprocal pivot growth. On exit, this contains the reciprocal pivot growth factornorm(A)/norm(U). Thenormis used. If this is much less than 1, then the stability of the LU factorization of the (equilibrated) matrixAcould be poor. This also means that the solutionX, estimated condition numbers, and error bounds could be unreliable. If factorization fails with0<INFO<=N, then this contains the reciprocal pivot growth factor for the leadingINFOcolumns ofA. InCGESVX, this quantity is returned inWORK(1). πBERRβREALarray, dimension(NRHS). Componentwise relative backward error. This is the componentwise relative backward error of each solution vectorX(j)(i.e., the smallest relative change in any element ofAorBthat makesX(j)an exact solution). β¨N_ERR_BNDSβ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βREALarray, 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β boolean. Trust the answer if the reciprocal condition number is less than the thresholdsqrt(n) * slamch('Epsilon').err = 2β 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 . 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 approximately 1.
See Lapack Working Note 165 for further details and extra cautions. π§
ERR_BNDS_COMPβREALarray, 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β boolean. Trust the answer if the reciprocal condition number is less than the thresholdsqrt(n) * slamch('Epsilon').err = 2β 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 componentwise reciprocal condition number. Compared with the thresholdsqrt(n) * slamch('Epsilon')to determine if the error estimate is . These reciprocal condition numbers are1 / (norm(Z^{-1},inf) * norm(Z,inf))for some appropriately scaled matrixZ. 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 ofZare approximately 1.
See Lapack Working Note 165 for further details and extra cautions. πΈ
NPARAMSβINTEGER. Specifies the number of parameters set inPARAMS. If<= 0, thePARAMSarray is never referenced and default values are used.PARAMSβ
So PARAMS is a REAL array, dimension NPARAMS, and it's literally the settings menu for the whole algorithm. Here's the vibe: if any entry is < 0.0, that entry gets filled in with the default value used for that parameter (so you can be lazy and let it pick π
). Only positions up to NPARAMS are accessed at all β anything higher-numbered just quietly uses defaults. No drama.
PARAMS(LA_LINRX_ITREF_I = 1)β are we doing iterative refinement or not?- Default:
1.0 = 0.0: no refinement is performed, and no error bounds are computed. (zero glamour, zero receipts.)= 1.0: use the double-precision refinement algorithm, possibly with doubled-single computations if the compilation environment does not supportDOUBLE PRECISION. (it improvises, respectfully π«Ά)- (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. BUT β if the factorization uses a technique other than Gaussian elimination, the guarantees inerr_bnds_normanderr_bnds_compmay no longer be trustworthy. Read that again. The receipts stop being receipts. π
- 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 COMPLEX array, dimension (2*N).
π RWORK π
RWORK is REAL array, dimension (2*N).
π INFO π
INFO is INTEGER. The full tea:
= 0: successful exit. The solution to every right-hand side is guaranteed. (slay, all of it π )< 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. Bestie, 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. (iykyk β it's only gonna tell you about the first one that goes sideways π« )
π¦ Author π¦
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Definition at line 538 of file cgesvxx.f.
β¨ dgesvxx β¨
subroutine dgesvxx (character fact, character trans, integer n, integer
nrhs, double precision, dimension( lda, * ) a, integer lda, double
precision, dimension( ldaf, * ) af, integer ldaf, integer, dimension( *
) ipiv, character equed, double precision, dimension( * ) r, double
precision, dimension( * ) c, double precision, dimension( ldb, * ) b,
integer ldb, double precision, dimension( ldx , * ) x, integer ldx,
double precision rcond, double precision rpvgrw, double precision,
dimension( * ) berr, integer n_err_bnds, double precision, dimension(
nrhs, * ) err_bnds_norm, double precision, dimension( nrhs, * )
err_bnds_comp, integer nparams, double precision, dimension( * ) params,
double precision, dimension( * ) work, integer, dimension( * ) iwork,
integer info)
DGESVXX computes the solution to system of linear equations A * X = B for GE matrices π (the double-precision sibling of the page you were just reading, and yes she ate)
πΈ Purpose πΈ
DGESVXX uses the LU factorization to compute the solution to a double precision system of linear equationsA * X = B, where A is anN-by-Nmatrix and X and B areN-by-NRHSmatrices. If requested, both normwise and maximum componentwise error bounds are returned. DGESVXX will return a solution with a tiny guaranteed error (O(eps)whereepsis the working machine precision) unless the matrix is very ill-conditioned, in which case a warning is returned. Relevant condition numbers also are calculated and returned. DGESVXX accepts user-provided factorizations and equilibration factors; see the definitions of theFACTandEQUEDoptions. Solving with refinement and using a factorization from a previous DGESVXX call will also produce a solution with eitherO(eps)errors or warnings, but we cannot make that claim for general user-provided factorizations and equilibration factors if they differ from what DGESVXX would itself produce. (translation: bring your own factorization and you're on your own, bestie π)
β Description β
The following steps are performed:
- If
FACT = 'E', double precision scaling factors are computed to equilibrate the system:
TRANS = 'N': diag(R)*A*diag(C) *inv(diag(C))*X = diag(R)*B
TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B
TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B
Whether or not the system will be equilibrated depends on the scaling of the matrix A, but if equilibration is used, A is overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N') or diag(C)*B (if TRANS = 'T' or 'C').
- If
FACT = 'N'or'E', the LU decomposition is used to factor the matrix A (after equilibration ifFACT = 'E') as
A = P * L * U,
where P is a permutation matrix, L is a unit lower triangular matrix, and U is upper triangular. (the classic glow-up sequence β¨)
- If some
U(i,i)=0, so that U is exactly singular, then the routine returns withINFO = i. Otherwise, the factored form of A is used to estimate the condition number of the matrix A (see argumentRCOND). If the reciprocal of the condition number is less than machine precision, the routine still goes on to solve for X and compute error bounds as described below. (she doesn't give up, she just warns you π ) - The system of equations is solved for X using the factored form of A.
- By default (unless
PARAMS(LA_LINRX_ITREF_I)is set to zero), the routine will use iterative refinement to try to get a small error and error bounds. Refinement calculates the residual to at least twice the working precision. - If equilibration was used, the matrix X is premultiplied by
diag(C)(ifTRANS = 'N') ordiag(R)(ifTRANS = 'T'or'C') so that it solves the original system before equilibration.
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. (zero-effort mode, we love her for that π«Ά)
π Parameters π
π FACT π
FACTisCHARACTER*1Specifies whether or not the factored form of the matrix A is supplied on entry, and if not, whether the matrix A should be equilibrated before it is factored.
= 'F': On entry,AFandIPIVcontain the factored form of A. IfEQUEDis not'N', the matrix A has been equilibrated with scaling factors given byRandC.A,AF, andIPIVare not modified.= 'N': The matrix A will be copied toAFand factored.= 'E': The matrix A will be equilibrated if necessary, then copied toAFand factored.
π TRANS π
TRANSisCHARACTER*1Specifies 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 π
NisINTEGERThe number of linear equations, i.e., the order of the matrix A.N >= 0.
π NRHS π
NRHSisINTEGERThe number of right hand sides, i.e., the number of columns of the matrices B and X.NRHS >= 0.
π A π
AisDOUBLE PRECISIONarray, dimension(LDA,N)On entry, theN-by-Nmatrix A. IfFACT = 'F'andEQUEDis not'N', then A must have been equilibrated by the scaling factors inRand/orC. A is not modified ifFACT = 'F'or'N', or ifFACT = 'E'andEQUED = 'N'on exit. On exit, ifEQUED .ne. 'N', A is scaled as follows:EQUED = 'R':A := diag(R) * AEQUED = 'C':A := A * diag(C)EQUED = 'B':A := diag(R) * A * diag(C).
π LDA π
LDAisINTEGERThe leading dimension of the array A.LDA >= max(1,N).
π AF π
π¦ AF β DOUBLE PRECISION array, dimension (LDAF,N)
Okay so AF is the β¨personalityβ¨ of the factorization, and what it means depends entirely on FACT:
- If
FACT = 'F', thenAFis an input argument and on entry it contains the factorsLandUfrom the factorizationA = P*L*Uas computed byDGETRF. IfEQUED .ne. 'N', thenAFis the factored form of the equilibrated matrixA. (So likeβ¦ it's the pre-chewed version, you're just handing it over π«Ά) - If
FACT = 'N', thenAFis an output argument and on exit it returns the factorsLandUfrom the factorizationA = P*L*Uof the original matrixA. - If
FACT = 'E', thenAFis an output argument and on exit it returns the factorsLandUfrom the factorizationA = P*L*Uof the equilibrated matrixA(see the description ofAfor the form of the equilibrated matrix).
π LDAF β INTEGER
The leading dimension of the array AF. And the vibe check here is strict, bestie:
LDAF >= max(1,N)
π
IPIV β INTEGER array, dimension (N)
The pivot indices, and again FACT runs the show:
- If
FACT = 'F', thenIPIVis an input argument and on entry it contains the pivot indices from the factorizationA = P*L*Uas computed byDGETRF; rowiof the matrix was interchanged with rowIPIV(i). - If
FACT = 'N', thenIPIVis an output argument and on exit it contains the pivot indices from the factorizationA = P*L*Uof the original matrixA. - If
FACT = 'E', thenIPIVis an output argument and on exit it contains the pivot indices from the factorizationA = P*L*Uof the equilibrated matrixA.
πΈ EQUED β CHARACTER*1
Specifies the form of equilibration that was done. Pick your fighter:
= 'N': No equilibration (always true ifFACT = 'N').= 'R': Row equilibration, i.e.,Ahas been premultiplied bydiag(R).= 'C': Column equilibration, i.e.,Ahas been postmultiplied bydiag(C).= 'B': Both row and column equilibration, i.e.,Ahas been replaced bydiag(R) * A * diag(C).
EQUED is an input argument if FACT = 'F'; otherwise, it is an output argument. iykyk π«
π R β DOUBLE PRECISION array, dimension (N)
The row scale factors for A. Here's the tea:
- If
EQUED = 'R'or'B',Ais multiplied on the left bydiag(R); ifEQUED = 'N'or'C',Ris not accessed. Ris an input argument ifFACT = 'F'; otherwise,Ris an output argument.- If
FACT = 'F'andEQUED = 'R'or'B', each element ofRmust be positive. - If
Ris output, each element ofRis a power of the radix. - If
Ris input, each element ofRshould be a power of the radix to ensure a reliable solution and error estimates.
Okay important caveat time π: 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, which produces error estimates that may not be reliable. So likeβ¦ don't be cute with it.
π§ C β DOUBLE PRECISION array, dimension (N)
The column scale factors for A, same energy, other axis:
- If
EQUED = 'C'or'B',Ais multiplied on the right bydiag(C); ifEQUED = 'N'or'R',Cis not accessed. Cis an input argument ifFACT = 'F'; otherwise,Cis an output argument.- If
FACT = 'F'andEQUED = 'C'or'B', each element ofCmust be positive. - If
Cis output, each element ofCis a power of the radix. - If
Cis input, each element ofCshould be a power of the radix to ensure a reliable solution and error estimates.
Same warning as R, no cap π: powers-of-the-radix scaling doesn't cause rounding errors unless the result underflows or overflows, and rounding errors during scaling mean you're refining with a matrix that isn't equivalent to the input matrix β so the error estimates may not be reliable.
π B β DOUBLE PRECISION array, dimension (LDB,NRHS)
On entry, the N-by-NRHS right hand side matrix B. Main character input, literally.
On exit:
- if
EQUED = 'N',Bis not modified; - if
TRANS = 'N'andEQUED = 'R'or'B',Bis overwritten bydiag(R)*B; - if
TRANS = 'T'or'C'andEQUED = 'C'or'B',Bis overwritten bydiag(C)*B.
β LDB β INTEGER
The leading dimension of the array B:
LDB >= max(1,N)
π X β DOUBLE PRECISION array, dimension (LDX,NRHS)
If INFO = 0, this is the N-by-NRHS solution matrix X to the original system of equations. Slay. π
Note thatAandBare modified on exit ifEQUED .ne. 'N', and the solution to the equilibrated system isinv(diag(C))*XifTRANS = 'N'andEQUED = 'C'or'B', orinv(diag(R))*XifTRANS = 'T'or'C'andEQUED = 'R'or'B'.
π LDX β INTEGER
The leading dimension of the array X:
LDX >= max(1,N)
π₯ RCOND β DOUBLE PRECISION
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 like⦠lowkey don't panic, highkey pay attention.
π¦ RPVGRW β DOUBLE PRECISION
Reciprocal pivot growth. On exit, this contains the reciprocal pivot growth factor norm(A)/norm(U). The norm is used. (The doc literally says "The norm is used" and the symbol got eaten, bestie π β that's a faithful transcription, don't @ me.)
- If this is much less than 1, then the stability of the LU factorization of the (equilibrated) matrix
Acould be poor. - This also means that the solution
X, estimated condition numbers, and error bounds could be unreliable. - If factorization fails with
0<INFO<=N, then this contains the reciprocal pivot growth factor for the leadingINFOcolumns ofA. - In
DGESVX, this quantity is returned inWORK(1).
π BERR β DOUBLE PRECISION 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. Iconic little number honestly. π
πΈ N_ERR_BNDS β INTEGER
Number of error bounds to return for each right hand side and each type (normwise or componentwise). See ERR_BNDS_NORM and ERR_BNDS_COMP below. π
π ERR_BNDS_NORM β DOUBLE PRECISION 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β boolean. Trust the answer if the reciprocal condition number is less than the thresholdsqrt(n) * dlamch('Epsilon').err = 2β 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) * dlamch('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) * dlamch('Epsilon')to determine if the error estimate is π (the doc genuinely cuts off mid-sentence right there β nothing invented, bestie, that's just how it's printed).
These reciprocal condition numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some appropriately scaled matrix Z. Let Z = 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. π
and ERR_BNDS_COMP? coming right up, hold on π
ERR_BNDS_COMP β okay so this one is a DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS).
For each right-hand side, this array contains info 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β boolean. Trust the answer if the reciprocal condition number is less than the thresholdsqrt(n) * dlamch('Epsilon').err = 2β 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) * dlamch('Epsilon'). This error bound should only be trusted if the previous boolean is true.
bestie, that last bit is not a suggestion β if the previous boolean isnβt true, do not trust that error bound. periodt. π
err = 3β Reciprocal condition number: Estimated componentwise reciprocal condition number. Compared with the thresholdsqrt(n) * dlamch('Epsilon')to determine if the error estimate is . These reciprocal condition numbers are1 / (norm(Z^{-1},inf) * norm(Z,inf))for some appropriately scaled matrixZ. 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 ofZare approximately1.
and yes, that sentence literally just stops at βis .β in the source β no cap, Iβm not hiding anything from you π
See Lapack Working Note 165 for further details and extra cautions.
NPARAMS is INTEGER.
Specifies the number of parameters set in PARAMS. If <= 0, the PARAMS array is never referenced and default values are used.
PARAMS is DOUBLE PRECISION array, dimension (NPARAMS).
Specifies algorithm parameters. If an entry is < 0.0, then that entry will be filled with default value used for that parameter. Only positions up to NPARAMS are accessed; defaults are used for higher-numbered parameters.
PARAMS(LA_LINRX_ITREF_I = 1)β Whether to perform iterative refinement or not.- Default:
1.0D+0 = 0.0: No refinement is performed, and no error bounds are computed.= 1.0: Use the extra-precise refinement algorithm.- (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.
- 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 is DOUBLE PRECISION array, dimension (4*N).
IWORK is INTEGER array, dimension (N).
INFO is INTEGER.
= 0: Successful exit. The solution to every right-hand side is guaranteed.< 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.
Definition at line 535 of file dgesvxx.f.
subroutine sgesvxx
subroutine sgesvxx (character fact, character trans, integer n, integer
nrhs, real, dimension( lda, * ) a, integer lda, real, dimension( ldaf, *
) af, integer ldaf, integer, dimension( * ) ipiv, character equed, real,
dimension( * ) r, real, dimension( * ) c, real, dimension( ldb, * ) b,
integer ldb, real, dimension( ldx , * ) x, integer ldx, real rcond, real
rpvgrw, 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)
SGESVXX computes the solution to system of linear equations A * X = B for GE matrices.
Purpose π
SGESVXX uses the LU factorization to compute the solution to a real system of linear equations A * X = B, where A is an N-by-N matrix and X and B are N-by-NRHS matrices.
If requested, both normwise and maximum componentwise error bounds are returned. SGESVXX will return a solution with a tiny guaranteed error (O(eps) where eps is the working machine precision) unless the matrix is very ill-conditioned, in which case a warning is returned. Relevant condition numbers also are calculated and returned.
SGESVXX accepts user-provided factorizations and equilibration factors; see the definitions of the FACT and EQUED options. Solving with refinement and using a factorization from a previous SGESVXX call will also produce a solution with either O(eps) errors or warnings, but we cannot make that claim for general user-provided factorizations and equilibration factors if they differ from what SGESVXX would itself produce.
Description π¦
The following steps are performed:
- If
FACT = 'E', real scaling factors are computed to equilibrate the system:
TRANS = 'N': diag(R)*A*diag(C) *inv(diag(C))*X = diag(R)*B
TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B
TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B
Whether or not the system will be equilibrated depends on the scaling of the matrix A, but if equilibration is used, A is overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N') or diag(C)*B (if TRANS = 'T' or 'C').
- If
FACT = 'N'or'E', the LU decomposition is used to factor the matrixA(after equilibration ifFACT = 'E') as
A = P * L * U,
where P is a permutation matrix, L is a unit lower triangular matrix, and U is upper triangular.
- If some
U(i,i)=0, so thatUis exactly singular, then the routine returns withINFO = i. Otherwise, the factored form ofAis used to estimate the condition number of the matrixA(see argumentRCOND). If the reciprocal of the condition number is less than machine precision, the routine still goes on to solve forXand compute error bounds as described below. - The system of equations is solved for
Xusing the factored form ofA. - By default (unless
PARAMS(LA_LINRX_ITREF_I)is set to zero), the routine will use iterative refinement to try to get a small error and error bounds. Refinement calculates the residual to at least twice the working precision. - If equilibration was used, the matrix
Xis premultiplied bydiag(C)(ifTRANS = 'N') ordiag(R)(ifTRANS = 'T'or'C') so that it solves the original system before equilibration.
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.
Parameters π
FACT
FACTβ aCHARACTER*1that tells the routine whether the factored form of the matrix A is already in your bag on entry, and if it isn't, whether A should be equilibrated before it gets factored. Options, bestie:= 'F': on entry,AFandIPIVcontain the factored form of A. IfEQUEDis not'N', then A has been equilibrated with the scaling factors given byRandC. And listen βA,AF, andIPIVare not modified. Iconic, no notes. β¨= 'N': the matrix A will be copied toAFand factored. Fresh start, we love that.= 'E': the matrix A will be equilibrated if necessary, then copied toAFand factored.
TRANSβCHARACTER*1, specifies the form of the system of equations, so pick your fighter:= '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, i.e., the order of the matrix A.N >= 0. That's the whole vibe check right there.NRHSβINTEGER. The number of right hand sides, i.e., the number of columns of the matricesBandX.NRHS >= 0.AβREALarray, dimension(LDA,N). On entry, the N-by-N matrix A. π«Ά IfFACT = 'F'andEQUEDis not'N', then A must have been equilibrated by the scaling factors inRand/orC. A is not modified ifFACT = 'F'or'N', or ifFACT = 'E'andEQUED = 'N'on exit.
On exit, if EQUED .ne. 'N', A gets scaled like this:
EQUED = 'R': A := diag(R) * A
EQUED = 'C': A := A * diag(C)
EQUED = 'B': A := diag(R) * A * diag(C)
LDAβINTEGER. The leading dimension of the arrayA.LDA >= max(1,N). Do not come in under that, fr fr.AFβREALarray, dimension(LDAF,N). This one shape-shifts depending onFACT, so keep up:- If
FACT = 'F', thenAFis an input argument and on entry contains the factorsLandUfrom the factorizationA = P*L*Uas computed bySGETRF. IfEQUED .ne. 'N', thenAFis the factored form of the equilibrated matrix A. - If
FACT = 'N', thenAFis an output argument and on exit returns the factorsLandUfrom the factorizationA = P*L*Uof the original matrix A. - If
FACT = 'E', thenAFis an output argument and on exit returns the factorsLandUfrom the factorizationA = P*L*Uof the equilibrated matrix A (peep the description ofAfor the form of the equilibrated matrix).
- If
LDAFβINTEGER. The leading dimension of the arrayAF.LDAF >= max(1,N). Same energy, different letter. πIPIVβINTEGERarray, dimension(N). Again, depends onFACT, we stay flexible:- If
FACT = 'F', thenIPIVis an input argument and on entry contains the pivot indices from the factorizationA = P*L*Uas computed bySGETRF; rowiof the matrix was interchanged with rowIPIV(i). - If
FACT = 'N', thenIPIVis an output argument and on exit contains the pivot indices from the factorizationA = P*L*Uof the original matrix A. - If
FACT = 'E', thenIPIVis an output argument and on exit contains the pivot indices from the factorizationA = P*L*Uof the equilibrated matrix A.
- If
EQUEDβCHARACTER*1, specifies the form of equilibration that was done. The menu:= 'N': no equilibration (always true ifFACT = 'N').= '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).
EQUED is an input argument if FACT = 'F'; otherwise, it is an output argument. Sneaky little switcheroo, iykyk. π¦
RβREALarray, dimension(N). The row scale factors for A. IfEQUED = 'R'or'B', A is multiplied on the left bydiag(R); ifEQUED = 'N'or'C',Ris not accessed (left on read, honestly).Ris an input argument ifFACT = 'F'; otherwise,Ris an output argument. IfFACT = 'F'andEQUED = 'R'or'B', each element ofRmust be positive.
If R is output, each element of R is a power of the radix. If R is input, 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. π So like, respect the radix, okay?
CβREALarray, dimension(N). The column scale factors for A. IfEQUED = 'C'or'B', A is multiplied on the right bydiag(C); ifEQUED = 'N'or'R',Cis not accessed.Cis an input argument ifFACT = 'F'; otherwise,Cis an output argument. IfFACT = 'F'andEQUED = 'C'or'B', each element ofCmust be positive.
If C is output, each element of C is a power of the radix. If C is input, 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, same drama, now in column flavour. π
BβREALarray, dimension(LDB,NRHS). On entry, the N-by-NRHS right hand side matrixB. On exit, it depends:- if
EQUED = 'N',Bis not modified; - if
TRANS = 'N'andEQUED = 'R'or'B',Bis overwritten bydiag(R)*B; - if
TRANS = 'T'or'C'andEQUED = 'C'or'B',Bis overwritten bydiag(C)*B.
- if
LDBβINTEGER. The leading dimension of the arrayB.LDB >= max(1,N).XβREALarray, dimension(LDX,NRHS). IfINFO = 0, this is the N-by-NRHS solution matrixXto the original system of equations. Bestie, heads up: note thatAandBare modified on exit ifEQUED .ne. 'N', and the solution to the equilibrated system is:
inv(diag(C))*X if TRANS = 'N' and EQUED = 'C' or 'B', or
inv(diag(R))*X if TRANS = 'T' or 'C' and EQUED = 'R' or 'B'
LDXβINTEGER. The leading dimension of the arrayX.LDX >= max(1,N). Yes, all four of them have that same bound, it's giving consistency. πRCONDβ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. β οΈ But 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 looks tiny, okay?RPVGRWβREAL. Reciprocal pivot growth. On exit, this contains the reciprocal pivot growth factornorm(A)/norm(U). The norm is used. If this is much less than 1, then the stability of the LU factorization of the (equilibrated) matrix A could be poor. This also means that the solutionX, estimated condition numbers, and error bounds could be unreliable. π₯ If factorization fails with0<INFO<=N, then this contains the reciprocal pivot growth factor for the leadingINFOcolumns of A. InSGESVX, this quantity is returned inWORK(1). Screenshot that, it matters.BERRβREALarray, dimension(NRHS). Componentwise relative backward error. This is the componentwise relative backward error of each solution vectorX(j)(i.e., the smallest relative change in any element of A or B that makesX(j)an exact solution). Every single one of them gets its own little grade. πN_ERR_BNDSβ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_NORMβ 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 *i*th right-hand side.
The second index in ERR_BNDS_NORM(:,err) contains the following three fields:
err = 1β boolean. Trust the answer if the reciprocal condition number is less than the thresholdsqrt(n) * slamch('Epsilon').err = 2β 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 . 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.
See Lapack Working Note 165 for further details and extra cautions. π¦
π ERR_BNDS_COMP
ERR_BNDS_COMPβ 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 *i*th right-hand side.
The second index in ERR_BNDS_COMP(:,err) contains the following three fields:
err = 1β boolean. Trust the answer if the reciprocal condition number is less than the thresholdsqrt(n) * slamch('Epsilon').err = 2β 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 componentwise reciprocal condition number. Compared with the thresholdsqrt(n) * slamch('Epsilon')to determine if the error estimate is . These reciprocal condition numbers are1 / (norm(Z^{-1},inf) * norm(Z,inf))for some appropriately scaled matrixZ. 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 ofZare approximately1.
See Lapack Working Note 165 for further details and extra cautions. π₯
πΈ NPARAMS
NPARAMSβ INTEGER. Specifies the number of parameters set inPARAMS. If<= 0, thePARAMSarray is never referenced and default values are used. π«Ά
β PARAMS
PARAMSβ REAL array, dimensionNPARAMS. 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 toNPARAMSare accessed; defaults are used for higher-numbered parameters.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. π (like, read that twice, bestie)
- 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β REAL array, dimension(4*N).
π IWORK
IWORKβ INTEGER array, dimension(N).
π INFO
INFOβ INTEGER.= 0: successful exit. The solution to every right-hand side is guaranteed. β¨< 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 sides K withK > 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 *J*th 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 *J*th 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.
Definition at line 538 of file sgesvxx.f. π
π subroutine zgesvxx π
subroutine zgesvxx (character fact, character trans, integer n, integer
nrhs, complex*16, dimension( lda, * ) a, integer lda, complex*16,
dimension( ldaf, * ) af, integer ldaf, integer, dimension( * ) ipiv,
character equed, double precision, dimension( * ) r, double precision,
dimension( * ) c, complex*16, dimension( ldb, * ) b, integer ldb,
complex*16, dimension( ldx , * ) x, integer ldx, double precision rcond,
double precision rpvgrw, double precision, dimension( * ) berr, integer
n_err_bnds, double precision, dimension( nrhs, * ) err_bnds_norm, double
precision, dimension( nrhs, * ) err_bnds_comp, integer nparams, double
precision, dimension( * ) params, complex*16, dimension( * ) work,
double precision, dimension( * ) rwork, integer info)
ZGESVXX computes the solution to system of linear equations A * X = B for GE matrices π
β¨ Purpose:
!>
!> ZGESVXX uses the LU factorization to compute the solution to a
!> complex*16 system of linear equations A * X = B, where A is an
!> N-by-N matrix and X and B are N-by-NRHS matrices.
!>
!> If requested, both normwise and maximum componentwise error bounds
!> are returned. ZGESVXX will return a solution with a tiny
!> guaranteed error (O(eps) where eps is the working machine
!> precision) unless the matrix is very ill-conditioned, in which
!> case a warning is returned. Relevant condition numbers also are
!> calculated and returned.
!>
!> ZGESVXX accepts user-provided factorizations and equilibration
!> factors; see the definitions of the FACT and EQUED options.
!> Solving with refinement and using a factorization from a previous
!> ZGESVXX call will also produce a solution with either O(eps)
!> errors or warnings, but we cannot make that claim for general
!> user-provided factorizations and equilibration factors if they
!> differ from what ZGESVXX would itself produce.
!>
So like, ZGESVXX is out here doing the LU factorization thing to solve A * X = B, where A is N-by-N and X and B are N-by-NRHS. If you ask nicely, it hands back both normwise and maximum componentwise error bounds. It returns a solution with a tiny guaranteed error (O(eps), where eps is the working machine precision) β unless the matrix is very ill-conditioned, in which case you get a warning instead. Relevant condition numbers get calculated and returned too. π
It also accepts user-provided factorizations and equilibration factors (peep the definitions of the FACT and EQUED options). Solving with refinement and reusing a factorization from a previous ZGESVXX call will also produce a solution with either O(eps) errors or warnings β but no cap, we cannot make that claim for general user-provided factorizations and equilibration factors if they differ from what ZGESVXX would itself produce. π
π Description:
okay so the actual algorithm goes like this, bestie, and it's honestly kind of iconic:
The following steps are performed:
- If
FACT = 'E', double precision scaling factors are computed to equilibrate the system:
TRANS = 'N': diag(R)*A*diag(C) *inv(diag(C))*X = diag(R)*B
TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B
TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B
Whether or not the system will be equilibrated depends on the scaling of the matrix A, but if equilibration is used, A is overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N') or diag(C)*B (if TRANS = 'T' or 'C').
- If
FACT = 'N'or'E', the LU decomposition is used to factor the matrixA(after equilibration ifFACT = 'E') as
A = P * L * U,
where P is a permutation matrix, L is a unit lower triangular matrix, and U is upper triangular.
- If some
U(i,i)=0, so thatUis exactly singular, then the routine returns withINFO = i. Otherwise, the factored form ofAis used to estimate the condition number of the matrixA(see argumentRCOND). If the reciprocal of the condition number is less than machine precision, the routine still goes on to solve forXand compute error bounds as described below. - The system of equations is solved for
Xusing the factored form ofA. - By default (unless
PARAMS(LA_LINRX_ITREF_I)is set to zero), the routine will use iterative refinement to try to get a small error and error bounds. Refinement calculates the residual to at least twice the working precision. - If equilibration was used, the matrix
Xis premultiplied bydiag(C)(ifTRANS = 'N') ordiag(R)(ifTRANS = 'T'or'C') so that it solves the original system before equilibration.
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.
Parameters π«Ά
FACTβFACT is CHARACTER*1. Specifies whether or not the factored form of the matrixAis supplied on entry, and if not, whether the matrixAshould be equilibrated before it is factored.= 'F': On entry,AFandIPIVcontain the factored form ofA. IfEQUEDis not'N', the matrixAhas been equilibrated with scaling factors given byRandC.A,AF, andIPIVare not modified.= 'N': The matrixAwill be copied toAFand factored.= 'E': The matrixAwill be equilibrated if necessary, then copied toAFand factored.
TRANSβTRANS is CHARACTER*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)
NβN is INTEGER. The number of linear equations, i.e., the order of the matrixA.N >= 0.NRHSβNRHS is INTEGER. The number of right hand sides, i.e., the number of columns of the matricesBandX.NRHS >= 0.AβA is COMPLEX*16 array, dimension (LDA,N). On entry, the N-by-N matrixA. IfFACT = 'F'andEQUEDis not'N', thenAmust have been equilibrated by the scaling factors inRand/orC.Ais not modified ifFACT = 'F'or'N', or ifFACT = 'E'andEQUED = 'N'on exit.
On exit, if EQUED .ne. 'N', A is scaled as follows:
EQUED = 'R': A := diag(R) * A
EQUED = 'C': A := A * diag(C)
EQUED = 'B': A := diag(R) * A * diag(C).
LDAβLDA is INTEGER. The leading dimension of the arrayA.LDA >= max(1,N).AFβAF is COMPLEX*16 array, dimension (LDAF,N). IfFACT = 'F', thenAFis an input argument and on entry contains the factorsLandUfrom the factorizationA = P*L*Uas computed byZGETRF. IfEQUED .ne. 'N', thenAFis the factored form of the equilibrated matrixA.
If FACT = 'N', then AF is an output argument and on exit returns the factors L and U from the factorization A = P*L*U of the original matrix A.
If FACT = 'E', then AF is an output argument and on exit returns the factors L and U from the factorization A = P*L*U of the equilibrated matrix A (see the description of A for the form of the equilibrated matrix).
LDAFβLDAF is INTEGER. The leading dimension of the arrayAF.LDAF >= max(1,N).IPIVβIPIV is INTEGER array, dimension (N). IfFACT = 'F', thenIPIVis an input argument and on entry contains the pivot indices from the factorizationA = P*L*Uas computed byZGETRF; rowiof the matrix was interchanged with rowIPIV(i).
If FACT = 'N', then IPIV is an output argument and on exit contains the pivot indices from the factorization A = P*L*U of the original matrix A.
If FACT = 'E', then IPIV is an output argument and on exit contains the pivot indices from the factorization A = P*L*U of the equilibrated matrix A.
EQUEDβEQUED is CHARACTER*1. Specifies the form of equilibration that was done.= 'N': No equilibration (always true ifFACT = 'N').= 'R': Row equilibration, i.e.,Ahas been premultiplied bydiag(R).= 'C': Column equilibration, i.e.,Ahas been postmultiplied bydiag(C).= 'B': Both row and column equilibration, i.e.,Ahas been replaced bydiag(R) * A * diag(C).
EQUED is an input argument if FACT = 'F'; otherwise, it is an output argument.
RβR is DOUBLE PRECISION array, dimension (N). The row scale factors forA. IfEQUED = 'R'or'B',Ais multiplied on the left bydiag(R); ifEQUED = 'N'or'C',Ris not accessed.Ris an input argument ifFACT = 'F'; otherwise,Ris an output argument. IfFACT = 'F'andEQUED = 'R'or'B', each element ofRmust be positive. IfRis output, each element ofRis a power of the radix. IfRis input, each element ofRshould 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.CβC is DOUBLE PRECISION array, dimension (N). The column scale factors forA. IfEQUED = 'C'or'B',Ais multiplied on the right bydiag(C); ifEQUED = 'N'or'R',Cis not accessed.Cis an input argument ifFACT = 'F'; otherwise,Cis an output argument. IfFACT = 'F'andEQUED = 'C'or'B', each element ofCmust be positive. IfCis output, each element ofCis a power of the radix. 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.BβB is COMPLEX*16 array, dimension (LDB,NRHS). On entry, the N-by-NRHS right hand side matrixB. On exit:- if
EQUED = 'N',Bis not modified; - if
TRANS = 'N'andEQUED = 'R'or'B',Bis overwritten bydiag(R)*B; - if
TRANS = 'T'or'C'andEQUED = 'C'or'B',Bis overwritten bydiag(C)*B.
- if
LDBβLDB is INTEGER. The leading dimension of the arrayB.LDB >= max(1,N).XβX is COMPLEX*16 array, dimension (LDX,NRHS). IfINFO = 0, the N-by-NRHS solution matrixXto the original system of equations. Note thatAandBare modified on exit ifEQUED .ne. 'N', and the solution to the equilibrated system isinv(diag(C))*XifTRANS = 'N'andEQUED = 'C'or'B', orinv(diag(R))*XifTRANS = 'T'or'C'andEQUED = 'R'or'B'.LDXβLDX is INTEGER. The leading dimension of the arrayX.LDX >= max(1,N).RCONDβRCOND is DOUBLE PRECISION. Reciprocal 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.
RPVGRW
RPVGRW β DOUBLE PRECISION. Reciprocal pivot growth. On exit, this contains the reciprocal pivot growth factor norm(A)/norm(U). The norm is used. If this is much less than 1, then 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. If factorization fails with 0<INFO<=N, then this contains the reciprocal pivot growth factor for the leading INFO columns of A. In ZGESVX, this quantity is returned in WORK(1).
BERR β DOUBLE PRECISION 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 β INTEGER. Number of error bounds to return for each right hand side and each type (normwise or componentwise). See ERR_BNDS_NORM and ERR_BNDS_COMP below.
ERR_BNDS_NORM β DOUBLE PRECISION 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:
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β boolean. Trust the answer if the reciprocal condition number is less than the thresholdsqrt(n) * dlamch('Epsilon').err = 2β 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) * dlamch('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) * dlamch('Epsilon')to determine if the error estimate is β¦ (the source has a blank here, bestie β not me inventing a word). 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 β DOUBLE PRECISION 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:
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β boolean. Trust the answer if the reciprocal condition number is less than the thresholdsqrt(n) * dlamch('Epsilon').err = 2β 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) * dlamch('Epsilon'). This error bound should only be trusted if the previous boolean is true.err = 3β Reciprocal condition number: Estimated componentwise reciprocal condition number. Compared with the thresholdsqrt(n) * dlamch('Epsilon')to determine if the error estimate is β¦ (again, blank in the source β no cap). These reciprocal condition numbers are1 / (norm(Z^{-1},inf) * norm(Z,inf))for some appropriately scaled matrix Z. LetZ = S*(A*diag(x)), where x is the solution for the current right-hand side and S scales each row ofA*diag(x)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.
NPARAMS β INTEGER. Specifies the number of parameters set in PARAMS. If <= 0, the PARAMS array is never referenced and default values are used.
PARAMS β DOUBLE PRECISION array, dimension NPARAMS. Specifies algorithm parameters. If an entry is < 0.0, then that entry will be filled with default value used for that parameter. Only positions up to NPARAMS are accessed; defaults are used for higher-numbered parameters.
PARAMS(LA_LINRX_ITREF_I = 1)β Whether to perform iterative refinement or not.- Default:
1.0D+0 = 0.0: No refinement is performed, and no error bounds are computed.= 1.0: Use the extra-precise refinement algorithm.- (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.
- 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 β COMPLEX*16 array, dimension (2*N).
RWORK β DOUBLE PRECISION array, dimension (2*N).
INFO β INTEGER.
= 0: Successful exit. The solution to every right-hand side is guaranteed.< 0: IfINFO = -i, the i-th argument had an illegal value.> 0 and <= N:U(INFO,INFO)is exactly zero. The factorization has been completed, but the factor U is 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 sides K withK > 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 smallest J such 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 smallest J such 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.
Definition at line 535 of file zgesvxx.f.
π¦ Author (generated) π¦
Generated automatically by Doxygen for LAPACK from the source code.
And that's the page, bestie β signing off from the LAPACK source with Version 3.12.0, page gesvxx(3). The footer didn't hand us a date, so that's the whole deets, no cap. π
β¨
π¦ where this page comes from
- arch rolling: lapack-doc 3.12.1-2 Β· custom
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms