SRC/dgesvxx.f(3)
SRC/dgesvxx.f(3) β Library Functions Manual π
π NAME π
SRC/dgesvxx.f
β¨ SYNOPSIS β¨
Functions/Subroutines
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)βDGESVXXcomputes the solution to system of linear equationsA * X = Bfor 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)
π Function/Subroutine Documentation π
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
Purpose
Ok bestie, hereβs the tea β: DGESVXX uses the LU factorization to compute the solution to a double precision 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. DGESVXX 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. β¨
DGESVXX 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 DGESVXX 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 DGESVXX would itself produce. π«Ά
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 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.
Ok so some optional parameters are bundled in thePARAMSarray. These settings determine how refinement is performed, but often the defaults are acceptable. If the defaults are acceptable, users can passNPARAMS = 0which prevents the source code from accessing thePARAMSargument. π«Ά
Parameters
FACTβFACTisCHARACTER*1. It 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βTRANSisCHARACTER*1. 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 number of linear equations, i.e., 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βAisDOUBLE PRECISIONarray, dimension(LDA,N). On entry, theN-by-NmatrixA. 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',Ais scaled as follows:EQUED = 'R':A := diag(R) * AEQUED = 'C':A := A * diag(C)EQUED = 'B':A := diag(R) * A * diag(C).
- On exit, if
LDAβLDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,N).AFβAFisDOUBLE PRECISIONarray, dimension(LDAF,N).- If
FACT = 'F', thenAFis an input argument and on entry contains the factorsLandUfrom the factorizationA = P*L*Uas computed byDGETRF. IfEQUED .ne. 'N', thenAFis the factored form of the equilibrated matrixA. - If
FACT = 'N', thenAFis an output argument and on exit returns the factorsLandUfrom the factorizationA = P*L*Uof the original matrixA. - If
FACT = 'E', thenAFis an output argument and on exit returns the factorsLandUfrom the factorizationA = P*L*Uof the equilibrated matrixA(see the description ofAfor the form of the equilibrated matrix).
- If
LDAFβLDAFisINTEGER. The leading dimension of the arrayAF.LDAF >= max(1,N).IPIVβIPIVisINTEGERarray, dimension(N).- If
FACT = 'F', thenIPIVis an input argument and on entry 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 contains the pivot indices from the factorizationA = P*L*Uof the original matrixA. - If
FACT = 'E', thenIPIVis an output argument and on exit contains the pivot indices from the factorizationA = P*L*Uof the equilibrated matrixA.
- If
EQUEDβEQUEDisCHARACTER*1. It 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βRisDOUBLE PRECISIONarray, 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.CCβ the column scale factors forA. DOUBLE PRECISION array, dimension(N). So: ifEQUED = 'C'or'B', thenAgets multiplied on the right bydiag(C); ifEQUED = 'N'or'R', thenCis literally not even looked at, bestie. πCis an input argument ifFACT = 'F'; otherwiseCis an output argument.- If
FACT = 'F'andEQUED = 'C'or'B', each element ofCmust be positive. No cap. - 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. 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 thing, okay?
Bβ DOUBLE PRECISION array, 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). That's the whole vibe check, babes. βXβ DOUBLE PRECISION array, dimension(LDX,NRHS). IfINFO = 0, this is theN-by-NRHSsolution matrixXto the original system of equations. π
Heads up bestie: note thatAandBare modified on exit ifEQUED .ne. 'N', and the solution to the equilibrated system isinv(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'.So don't come crying to me when yourAlooks different, it's giving documented behaviour. π
LDXβ INTEGER. The leading dimension of the arrayX.LDX >= max(1,N). πRCONDβ 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.
Ngl the error may still be small even if this number is very small and the matrix appears ill-conditioned. So likeβ¦ don't panic immediately? π
RPVGRWβ DOUBLE PRECISION. Reciprocal pivot growth. πΈ On exit, this contains the reciprocal pivot growth factornorm(A)/norm(U). The norm is used. (yeah, the manpage literally just says "The norm is used" β the norm name got eaten by the source, iykyk π)
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 DGESVX, 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 vectorX(j)(i.e., the smallest relative change in any element ofAorBthat makesX(j)an exact solution). Iconic little number tbh.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β 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 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 *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) * 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 word got dropped in the source, it's giving mystery π). These reciprocal condition numbers are1 / (norm(Z^{-1},inf) * norm(Z,inf))for some appropriately scaled matrixZ.
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. π
ERR_BNDS_COMPβ 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, defined like this:
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), thenERR_BNDS_COMPis not accessed. And ifN_ERR_BNDS < 3, then at most the first(:,N_ERR_BNDS)entries are returned. Slay, but plan accordingly.
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) * 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 componentwise reciprocal condition number. Compared with the thresholdsqrt(n) * dlamch('Epsilon')to determine if the error estimate is (same dropped word situation, we move π§). 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. β
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. Simple as that, bestie. πPARAMSβ DOUBLE PRECISION array, dimension(NPARAMS). 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.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 in
err_bnds_normanderr_bnds_compmay no longer be trustworthy. That's a real one, not just vibes.
- 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β DOUBLE PRECISION array, dimension(4*N). β¨ That's it. That's the whole description. Respect the brevity honestly.IWORKβ babes it's anINTEGER array, dimension (N)π she's just here to hold workspace ints, that's her whole job.INFOβ anINTEGERand honestly the main character of the whole exit-story π here's the vibe check on every value she can hand you:= 0β slay, successful exit β¨ and the solution to every right-hand side is guaranteed. no notes.< 0β not the vibe π ifINFO = -i, the i-th argument had an illegal value. you passed her something cursed.> 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 for you as a little consolation prize.= N+Jβ okay so this one's lowkey the most important: the solution corresponding to the J-th right-hand side is not guaranteed. And heads up β 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 β that's the smallest J such 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 smallest J such that eitherERR_BNDS_NORM(J,1) = 0.0orERR_BNDS_COMP(J,1) = 0.0. - See the definition of
ERR_BNDS_NORM(:,1)andERR_BNDS_COMP(:,1)for the receipts π§Ύ and if you want info about all of the right-hand sides, go checkERR_BNDS_NORMorERR_BNDS_COMPdirectly. iykyk.
- If a small componentwise error is not requested (
π AUTHOR π
The legendary institutions behind this icon, no cap π
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Also worth noting, fr fr: Definition at line 535 of file dgesvxx.f.
π AUTHOR (again, the doxygen one) π
Generated automatically by Doxygen for LAPACK from the source code. she's self-aware, she documents herself, we love a meta queen π¦
babygirl that's the whole page, you ate that π
go forth and check your INFO values, i'm obsessed with you β
mwah π β this was LAPACK Version 3.12.0, page SRC/dgesvxx.f(3), dated from the source code itself πΈ
π¦ 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