Uses extra precise iterative refinement to compute the solution to the system of linear equations with a square coefficient matrix A and multiple right-hand sides
The routine uses the LU factorization to compute the solution to a real or complex system of linear equations
nmatrix, the columns of the matrix
Bare individual right-hand sides, and the columns of
Xare the corresponding solutions.
Both normwise and maximum componentwise error bounds are also provided on request. The routine returns a solution with a small guaranteed error (
epsis the working machine precision) unless the matrix is very ill-conditioned, in which case a warning is returned. Relevant condition numbers are also calculated and returned.
The routine accepts user-provided factorizations and equilibration factors; see definitions of the
equedoptions. Solving with refinement and using a factorization from a previous call of the routine also produces a solution with
O(eps)errors or warnings but that may not be true for general user-provided factorizations and equilibration factors if they differ from what the routine would itself produce.
?gesvxxperforms the following steps:
- If, scaling factorsfact='E'randcare 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))*inv(Tdiag(r))*X=diag(c)*B:trans='C'(diag(r)*A*diag(c))*inv(Hdiag(r))*X=diag(c)*BWhether or not the system will be equilibrated depends on the scaling of the matrixA, but if equilibration is used,Ais overwritten byanddiag(r)*A*diag(c)Bby(ifdiag(r)*Bortrans='N')(ifdiag(c)*Bortrans='T').'C'
- Iforfact='N', the'E'LUdecomposition is used to factor the matrixA(after equilibration if) asfact='E', whereA=P*L*UPis a permutation matrix,Lis a unit lower triangular matrix, andUis upper triangular.
- If some= 0, so thatUi,iUis exactly singular, then the routine returns with. Otherwise, the factored form ofinfo=iAis used to estimate the condition number of the matrixA(see thercondparameter). If the reciprocal of the condition number is less than machine precision, the routine still goes on to solve forXand compute error bounds.
- The system of equations is solved forXusing the factored form ofA.
- By default, unless is set to zero, the routine applies iterative refinement to improve the computed solution matrix and calculate error bounds. Refinement calculates the residual to at least twice the working precision.
- If equilibration was used, the matrixXis premultiplied by(ifdiag(c)) ortrans='N'(ifdiag(r)ortrans='T') so that it solves the original system before equilibration.'C'
- Specifies whether matrix storage layout is row major (LAPACK_ROW_MAJOR) or column major (LAPACK_COL_MAJOR).
- Must be'F','N', or'E'.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.If, on entry,fact='F'afandipivcontain the factored form ofA. Ifequedis not'N', the matrixAhas been equilibrated with scaling factors given byrandc. Parametersa,af, andipivare not modified.If, the matrixfact='N'Awill be copied toafand factored.If, the matrixfact='E'Awill be equilibrated, if necessary, copied toafand factored.
- Must be'N','T', or'C'.Specifies the form of the system of equations:If, the system has the formtrans='N'(No transpose).A*X=BIf, the system has the formtrans='T'AT*X=B(Transpose).If, the system has the formtrans='C'AH*X=B(Conjugate Transpose = Transpose for real flavors, Conjugate Transpose for complex flavors).
- The number of linear equations; the order of the matrixA;n≥0.
- The number of right hand sides; the number of columns of the matricesBandX;nrhs≥0.
- Arrays:a(size max(,lda*n))af(size max(,ldaf*n))b(size max(1,.ldb*nrhs) for column major layout and max(1,ldb*n) for row major layout)The arrayacontains the matrixA. Ifandfact='F'equedis not'N', thenAmust have been equilibrated by the scaling factors inrand/orc. .The arrayafis an input argument if. It contains the factored form of the matrixfact='F'A, that is, the factorsLandUfrom the factorizationas computed byA=P*L*U?getrf. Ifequedis not'N', thenafis the factored form of the equilibrated matrixA.The arraybcontains the matrixBwhose columns are the right-hand sides for the systems of equations.
- The leading dimension ofa;.lda≥max(1,n)
- The leading dimension ofaf;.ldaf≥max(1,n)
- Array, size at leastmax(1,. The arrayn)ipivis an input argument if. It contains the pivot indices from the factorizationfact='F'as computed byA=P*L*U?getrf; rowiof the matrix was interchanged with row.ipiv[i-1]
- Must be'N','R','C', or'B'.equedis an input argument if. It specifies the form of equilibration that was done:fact='F'If, no equilibration was done (always true ifequed='N').fact='N'If, row equilibration was done, that is,equed='R'Ahas been premultiplied bydiag(r).If, column equilibration was done, that is,equed='C'Ahas been postmultiplied bydiag(c).If, both row and column equilibration was done, that is,equed='B'Ahas been replaced by.diag(r)*A*diag(c)
- Arrays:r(sizen),. The arrayc(sizen)rcontains the row scale factors forA, and the arrayccontains the column scale factors forA. These arrays are input arguments ifonly; otherwise they are output arguments.fact='F'Iforequed='R''B',Ais multiplied on the left bydiag(r); iforequed='N''C',ris not accessed.Ifandfact='F'orequed='R''B', each element ofrmust be positive.Iforequed='C''B',Ais multiplied on the right bydiag(c); iforequed='N''R',cis not accessed.Ifandfact='F'orequed='C''B', each element ofcmust be positive.Each element ofrorcshould 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.
- The leading dimension of the arrayb;.ldb≥max(1,n) for column major layout andldb≥nrhsfor row major layout
- The leading dimension of the output arrayx;.ldx≥max(1,n) for column major layout andldx≥nrhsfor row major layout
- Number of error bounds to return for each right hand side and each type (normwise or componentwise). Seeerr_bnds_normanderr_bnds_compdescriptions inOutput Argumentssection below.
- Specifies the number of parameters set inparams. If≤0, theparamsarray is never referenced and default values are used.
- Array, size max(1,nparams). Specifies algorithm parameters. If an entry is less than 0.0, that entry is filled with the default value used for that parameter. Only positions up tonparamsare accessed; defaults are used for higher-numbered parameters. If defaults are acceptable, you can passnparams= 0, which prevents the source code from accessing theparamsargument.: Whether to perform iterative refinement or not. Default: 1.0params
(Other values are reserved for future use.): Maximum number of residual computations allowed for refinement.params
- No refinement is performed and no error bounds are computed.
- Use the double-precision refinement algorithm, possibly with doubled-single computations if the compilation environment does not support double precision.
: Flag determining if the code will attempt to find a solution with a small componentwise relative error in the double-precision algorithm. Positive is true, 0.0 is false. Default: 1.0 (attempt componentwise convergence).params
- Set to 100.0 to permit convergence using approximate factorizations or factorizations other thanLU. If the factorization uses a technique other than Gaussian elimination, the guarantees inerr_bnds_normanderr_bnds_compmay no longer be trustworthy.
- Array, sizemax(1,.ldx*nrhs) for column major layout and max(1,ldx*n) for row major layoutIf, the arrayinfo= 0xcontains the solutionn-by-nrhsmatrixXto theoriginalsystem of equations. Note thatAandBare modified on exit if, and the solution to the equilibrated system is:equed≠'N'inv(, ifdiag(c))*Xandtrans='N'orequed='C''B'; orinv(, ifdiag(r))*Xortrans='T''C'andorequed='R''B'.
- Arrayais not modified on exit iforfact='F''N', or ifandfact='E'equed='N'.If,equed≠'N'Ais scaled on exit as follows:equed='R':A=diag(r)*Aequed='C':A=A*diag(c)equed='B':.A=diag(r)*A*diag(c)
- Iforfact='N''E', thenafis an output argument and on exit returns the factorsLandUfrom the factorizationof the original matrixA=PLUA(if) or of the equilibrated matrixfact='N'A(if). See the description offact='E'afor the form of the equilibrated matrix.
- Overwritten byifdiag(r)*Bandtrans='N'orequed='R';'B'overwritten byortrans='T'and'C'orequed='C';'B'not changed ifequed='N'.
- These arrays are output arguments if. Each element of these arrays is a power of the radix. See the description offact≠'F'r,cinInput Argumentssection.
- Reciprocal scaled condition number. An estimate of the reciprocal Skeel condition number of the matrixAafter equilibration (if done). Ifrcondis less than the machine precision, in particular, ifrcond= 0, 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.
- Contains the reciprocal pivot growth factor:If this is much less than 1, the stability of theLUfactorization of the (equlibrated) matrixAcould be poor. This also means that the solutionX, estimated condition numbers, and error bounds could be unreliable. If factorization fails with0 <, this parameter contains the reciprocal pivot growth factor for the leadinginfo≤ninfocolumns ofA. In?gesvx, this quantity is returned in.rpivot
- Array, size at leastmax(1,. Contains the componentwise relative backward error for each solution vectornrhs), that is, the smallest relative change in any element ofxjAorBthat makesan exact solution.xj
- Array of size. For each right-hand side, contains information about various error bounds and condition numbers corresponding to the normwise relative errornrhs*n_err_bnds, which is defined as follows:Normwise relative error in thei-th solution vectorThe array is indexed by the type of error information as described below. There are currently up to three pieces of information returned.
- "Trust/don't trust" boolean. Trust the answer if the reciprocal condition number is less than the thresholdsqrt