PZGESVX(l)
π PZGESVX β the LAPACK routine that solves your complex linear system and also tells you how confident it is π
okay bestie, listen. we're doing PZGESVX from LAPACK routine (version 1.5), and this one is a whole journey. it's the parallel, distributed-memory girlie who takes your complex system A * X = B, crunches it, and then hands you back error bounds and a condition estimate like a little overachiever. main character energy fr fr. β¨
πΈ NAME πΈ
PZGESVX β she uses the LU factorization to compute the solution to a complex system of linear equations
A(IA:IA+N-1,JA:JA+N-1) * X = B(IB:IB+N-1,JB:JB+NRHS-1),
periodt. that's the whole job description. π
β¨ SYNOPSIS β¨
SUBROUTINE PZGESVX( FACT, TRANS, N, NRHS, A, IA, JA, DESCA, AF, IAF,
JAF, DESCAF, IPIV, EQUED, R, C, B, IB, JB, DESCB, X,
IX, JX, DESCX, RCOND, FERR, BERR, WORK, LWORK,
RWORK, LRWORK, INFO )
CHARACTER EQUED, FACT, TRANS
INTEGER IA, IAF, IB, INFO, IX, JA, JAF, JB, JX, LRWORK,
LWORK, N, NRHS
DOUBLE PRECISION RCOND
INTEGER DESCA( * ), DESCAF( * ), DESCB( * ), DESCX( * ),
IPIV( * )
DOUBLE PRECISION BERR( * ), C( * ), FERR( * ), R( * ),
RWORK( * )
COMPLEX*16 A( * ), AF( * ), B( * ), WORK( * ), X( * )
look at all those arguments. she's booked and busy. π«Ά
π¦ PURPOSE π¦
PZGESVX uses the LU factorization to compute the solution to a complex system of linear equations
where A(IA:IA+N-1,JA:JA+N-1) is an N-by-N matrix and X and B(IB:IB+N-1,JB:JB+NRHS-1) are N-by-NRHS matrices.
Error bounds on the solution and a condition estimate are also provided. like, she doesn't just solve it β she rates her own work. iconic behavior honestly. ππ
π Notes π
Each global data object is described by an associated description vector. This vector stores the information required to establish the mapping between an object element and its corresponding process and memory location.
Let A be a generic term for any 2D block cyclicly distributed array. Such a global array has an associated description vector DESCA. In the following comments, the character _ should be read as "of the global array".
so here's the little cheat sheet, rewritten with love:
DTYPE_A(global) β stored inDESCA( DTYPE_ )β the descriptor type. In this case,DTYPE_A = 1.CTXT_A(global) β stored inDESCA( CTXT_ )β the BLACS context handle, indicating the BLACS process gridAis distributed over. The context itself is global, but the handle (the integer value) may vary.M_A(global) β stored inDESCA( M_ )β the number of rows in the global arrayA.N_A(global) β stored inDESCA( N_ )β the number of columns in the global arrayA.MB_A(global) β stored inDESCA( MB_ )β the blocking factor used to distribute the rows of the array.NB_A(global) β stored inDESCA( NB_ )β the blocking factor used to distribute the columns of the array.RSRC_A(global) β stored inDESCA( RSRC_ )β the process row over which the first row of the arrayAis distributed.CSRC_A(global) β stored inDESCA( CSRC_ )β the process column over which the first column of the arrayAis distributed.LLD_A(local) β stored inDESCA( LLD_ )β the leading dimension of the local array.LLD_A >= MAX(1,LOCr(M_A)).
Let K be the number of rows or columns of a distributed matrix, and assume that its process grid has dimension p x q.
LOCr( K ) denotes the number of elements of K that a process would receive if K were distributed over the p processes of its process column.
Similarly, LOCc( K ) denotes the number of elements of K that a process would receive if K were distributed over the q processes of its process row.
The values of LOCr() and LOCc() may be determined via a call to the ScaLAPACK tool function, NUMROC:
LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
An upper bound for these quantities may be computed by:
LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
math girlies rise up, this is your moment π§ββοΈ
π DESCRIPTION π
In the following description, A denotes A(IA:IA+N-1,JA:JA+N-1), B denotes B(IB:IB+N-1,JB:JB+NRHS-1) and X denotes X(IX:IX+N-1,JX:JX+NRHS-1).
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.
- The factored form of
Ais used to estimate the condition number of the matrixA. If the reciprocal of the condition number is less than machine precision, steps 4-6 are skipped. - The system of equations is solved for
Xusing the factored form ofA. - Iterative refinement is applied to improve the computed solution matrix and calculate error bounds and backward error estimates for it.
- If
FACT = 'E'and equilibration was used, the matrixXis premultiplied bydiag(C)(ifTRANS = 'N') ordiag(R)(ifTRANS = 'T'or'C') so that it solves the original system before equilibration.
like, she undoes her own glow-up at the end so the answer actually matches your original problem. self-aware queen. π
π ARGUMENTS π
FACTβ (global input)CHARACTER
Specifies whether or not the factored form of the matrix A(IA:IA+N-1,JA:JA+N-1) is supplied on entry, and if not, whether the matrix A(IA:IA+N-1,JA:JA+N-1) should be equilibrated before it is factored.
= 'F': On entry,AF(IAF:IAF+N-1,JAF:JAF+N-1)andIPIVcontain the factored form ofA(IA:IA+N-1,JA:JA+N-1). IfEQUEDis not'N', the matrixA(IA:IA+N-1,JA:JA+N-1)has been equilibrated with scaling factors given byRandC.A(IA:IA+N-1,JA:JA+N-1),AF(IAF:IAF+N-1,JAF:JAF+N-1), andIPIVare not modified.= 'N': The matrixA(IA:IA+N-1,JA:JA+N-1)will be copied toAF(IAF:IAF+N-1,JAF:JAF+N-1)and factored.= 'E': The matrixA(IA:IA+N-1,JA:JA+N-1)will be equilibrated if necessary, then copied toAF(IAF:IAF+N-1,JAF:JAF+N-1)and factored.
TRANSβ (global input)CHARACTER
Specifies the form of the system of equations:
= 'N':A(IA:IA+N-1,JA:JA+N-1) * X(IX:IX+N-1,JX:JX+NRHS-1) = B(IB:IB+N-1,JB:JB+NRHS-1)(No transpose)= 'T':A(IA:IA+N-1,JA:JA+N-1)**T * X(IX:IX+N-1,JX:JX+NRHS-1) = B(IB:IB+N-1,JB:JB+NRHS-1)(Transpose)= 'C':A(IA:IA+N-1,JA:JA+N-1)**H * X(IX:IX+N-1,JX:JX+NRHS-1) = B(IB:IB+N-1,JB:JB+NRHS-1)(Conjugate transpose)
Nβ (global input)INTEGER
The number of rows and columns to be operated on, i.e. the order of the distributed submatrix A(IA:IA+N-1,JA:JA+N-1). N >= 0.
NRHSβ (global input)INTEGER
The number of right-hand sides, i.e., the number of columns of the distributed submatrices B(IB:IB+N-1,JB:JB+NRHS-1) and X(IX:IX+N-1,JX:JX+NRHS-1). NRHS >= 0.
Aβ (local input/local output)COMPLEX*16pointer into the local memory to an array of local dimension(LLD_A,LOCc(JA+N-1)).
On entry, the N-by-N matrix A(IA:IA+N-1,JA:JA+N-1). If FACT = 'F' and EQUED is not 'N', then A(IA:IA+N-1,JA:JA+N-1) must have been equilibrated by the scaling factors in R and/or C. A(IA:IA+N-1,JA:JA+N-1) is not modified if FACT = 'F' or 'N', or if FACT = 'E' and EQUED = 'N' on exit.
On exit, if EQUED .ne. 'N', A(IA:IA+N-1,JA:JA+N-1) is scaled as follows:
EQUED = 'R':A(IA:IA+N-1,JA:JA+N-1) := diag(R) * A(IA:IA+N-1,JA:JA+N-1)EQUED = 'C':A(IA:IA+N-1,JA:JA+N-1) := A(IA:IA+N-1,JA:JA+N-1) * diag(C)EQUED = 'B':A(IA:IA+N-1,JA:JA+N-1) := diag(R) * A(IA:IA+N-1,JA:JA+N-1) * diag(C)
IAβ (global input)INTEGER
The row index in the global array A indicating the first row of sub( A ).
JAβ (global input)INTEGER
The column index in the global array A indicating the first column of sub( A ).
DESCAβ (global and local input)INTEGERarray of dimensionDLEN_.
The array descriptor for the distributed matrix A.
AFβ (local input or local output)COMPLEX*16pointer into the local memory to an array of local dimension(LLD_AF,LOCc(JA+N-1)).
If FACT = 'F', then AF(IAF:IAF+N-1,JAF:JAF+N-1) is an input argument and on entry contains the factors L and U from the factorization A(IA:IA+N-1,JA:JA+N-1) = P*L*U as computed by PZGETRF. If EQUED .ne. 'N', then AF is the factored form of the equilibrated matrix A(IA:IA+N-1,JA:JA+N-1).
If FACT = 'N', then AF(IAF:IAF+N-1,JAF:JAF+N-1) is an output argument and on exit returns the factors L and U from the factorization A(IA:IA+N-1,JA:JA+N-1) = P*L*U of the original matrix A(IA:IA+N-1,JA:JA+N-1).
If FACT = 'E', then AF(IAF:IAF+N-1,JAF:JAF+N-1) is an output argument and on exit returns the factors L and U from the factorization A(IA:IA+N-1,JA:JA+N-1) = P*L*U of the equilibrated matrix A(IA:IA+N-1,JA:JA+N-1) (see the description of A(IA:IA+N-1,JA:JA+N-1) for the form of the equilibrated matrix).
IAFβ (global input)INTEGER
The row index in the global array AF indicating the first row of sub( AF ).
JAFβ (global input)INTEGER
The column index in the global array AF indicating the first column of sub( AF ).
DESCAFβ (global and local input)INTEGERarray of dimensionDLEN_.
The array descriptor for the distributed matrix AF.
IPIVβ (local input or local output)INTEGERarray, dimensionLOCr(M_A)+MB_A.
If FACT = 'F', then IPIV is an input argument and on entry contains the pivot indices from the factorization A(IA:IA+N-1,JA:JA+N-1) = P*L*U as computed by PZGETRF; IPIV(i) -> The global row local row i was swapped with. This array must be aligned with A( IA:IA+N-1, * ).
If FACT = 'N', then IPIV is an output argument and on exit contains the pivot indices from the factorization A(IA:IA+N-1,JA:JA+N-1) = P*L*U of the original matrix A(IA:IA+N-1,JA:JA+N-1).
π«Ά okay that's the tea so far and we're only partway through the arguments β hold on bestie, there's more coming. don't go anywhere. π
If FACT = 'E', then IPIV is an output argument, and on exit it contains the pivot indices from the factorization A(IA:IA+N-1,JA:JA+N-1) = P*L*U of the equilibrated matrix A(IA:IA+N-1,JA:JA+N-1). π«
EQUEDβ global input or global output, typeCHARACTER. Specifies the form of equilibration that was done. Bestie, this is literally the "which flavor of scaling did we do" flag:= 'N': no equilibration at all (always true ifFACT = 'N').= 'R': row equilibration, i.e.A(IA:IA+N-1,JA:JA+N-1)has been premultiplied bydiag(R).= 'C': column equilibration, i.e.A(IA:IA+N-1,JA:JA+N-1)has been postmultiplied bydiag(C).= 'B': both row and column equilibration, i.e.A(IA:IA+N-1,JA:JA+N-1)has been replaced bydiag(R) * A(IA:IA+N-1,JA:JA+N-1) * diag(C).
EQUED is an input variable if FACT = 'F'; otherwise it's an output variable. π
Rβ local input or local output,DOUBLE PRECISIONarray, dimensionLOCr(M_A). The row scale factors forA(IA:IA+N-1,JA:JA+N-1). IfEQUED = 'R'or'B', thenA(IA:IA+N-1,JA:JA+N-1)is multiplied on the left bydiag(R); ifEQUED='N'or'C',Ris not accessed.Ris an input variable ifFACT = 'F'; otherwise,Ris an output variable. IfFACT = 'F'andEQUED = 'R'or'B', each element ofRmust be positive.Ris replicated in every process column, and is aligned with the distributed matrixA. β¨Cβ local input or local output,DOUBLE PRECISIONarray, dimensionLOCc(N_A). The column scale factors forA(IA:IA+N-1,JA:JA+N-1). IfEQUED = 'C'or'B', thenA(IA:IA+N-1,JA:JA+N-1)is multiplied on the right bydiag(C); ifEQUED = 'N'or'R',Cis not accessed.Cis an input variable ifFACT = 'F'; otherwise,Cis an output variable. IfFACT = 'F'andEQUED = 'C'orCis replicated in every process row, and is aligned with the distributed matrixA. πBβ local input/local output,COMPLEX*16pointer into the local memory to an array of local dimension(LLD_B,LOCc(JB+NRHS-1) ). On entry, theN-by-NRHSright-hand side matrixB(IB:IB+N-1,JB:JB+NRHS-1). On exit, ifEQUED = 'N', thenB(IB:IB+N-1,JB:JB+NRHS-1)is not modified; ifTRANS = 'N'andEQUED = 'R'or'B',Bis overwritten bydiag(R)*B(IB:IB+N-1,JB:JB+NRHS-1); ifTRANS = 'T'or'C'andEQUED = 'C'or'B',B(IB:IB+N-1,JB:JB+NRHS-1)is overwritten bydiag(C)*B(IB:IB+N-1,JB:JB+NRHS-1). π«ΆIBβ global input,INTEGER. The row index in the global arrayBindicating the first row ofsub( B ).JBβ global input,INTEGER. The column index in the global arrayBindicating the first column ofsub( B ).DESCBβ global and local input,INTEGERarray of dimensionDLEN_. The array descriptor for the distributed matrixB. πXβ local input/local output,COMPLEX*16pointer into the local memory to an array of local dimension(LLD_X, LOCc(JX+NRHS-1)). IfINFO = 0, this is theN-by-NRHSsolution matrixX(IX:IX+N-1,JX:JX+NRHS-1)to the original system of equations. Heads up though, bestie: note thatA(IA:IA+N-1,JA:JA+N-1)andB(IB:IB+N-1,JB:JB+NRHS-1)are modified on exit ifEQUED .ne. 'N', and the solution to the equilibrated system isinv(diag(C))*X(IX:IX+N-1,JX:JX+NRHS-1)ifTRANS = 'N'andEQUED = 'C'or'B', orinv(diag(R))*X(IX:IX+N-1,JX:JX+NRHS-1)ifTRANS = 'T'or'C'andEQUED = 'R'or'B'. πIXβ global input,INTEGER. The row index in the global arrayXindicating the first row ofsub( X ).JXβ global input,INTEGER. The column index in the global arrayXindicating the first column ofsub( X ).DESCXβ global and local input,INTEGERarray of dimensionDLEN_. The array descriptor for the distributed matrixX. π¦RCONDβ global output,DOUBLE PRECISION. The estimate of the reciprocal condition number of the matrixA(IA:IA+N-1,JA:JA+N-1)after equilibration (if it was done). IfRCONDis less than the machine precision (in particular, ifRCOND = 0), the matrix is singular to working precision. This condition is indicated by a return code ofINFO > 0. π¨FERRβ local output,DOUBLE PRECISIONarray, dimensionLOCc(N_B). The estimated forward error bounds for each solution vectorX(j)(that's thej-th column of the solution matrixX(IX:IX+N-1,JX:JX+NRHS-1)). IfXTRUEis the true solution,FERR(j)bounds the magnitude of the largest entry in(X(j) - XTRUE)divided by the magnitude of the largest entry inX(j). The estimate is as reliable as the estimate forRCOND, and is almost always a slight overestimate of the true error.FERRis replicated in every process row, and is aligned with the matricesBandX. πBERRβ local output,DOUBLE PRECISIONarray, dimensionLOCc(N_B). The componentwise relative backward error of each solution vectorX(j)(i.e., the smallest relative change in any entry ofA(IA:IA+N-1,JA:JA+N-1)orB(IB:IB+N-1,JB:JB+NRHS-1)that makesX(j)an exact solution).BERRis replicated in every process row, and is aligned with the matricesBandX. πΈWORKβ local workspace/local output,COMPLEX*16array, dimension(LWORK). On exit,WORK(1)returns the minimal and optimalLWORK. βLWORKβ local or global input,INTEGER. The dimension of the arrayWORK.LWORKis local input and must be at least:
LWORK = MAX( PZGECON( LWORK ), PZGERFS( LWORK ) ) + LOCr( N_A )
If LWORK = -1, then LWORK is global input and a workspace query is assumed; the routine only calculates the minimum and optimal size for all work arrays. Each of these values is returned in the first entry of the corresponding work array, and no error message is issued by PXERBLA. π
RWORKβ local workspace/local output,DOUBLE PRECISIONarray, dimension(LRWORK). On exit,RWORK(1)returns the minimal and optimalLRWORK. πLRWORKβ local or global input,INTEGER. The dimension of the arrayRWORK.LRWORKis local input and must be at least:
LRWORK = 2*LOCc(N_A)
If LRWORK = -1, then LRWORK is global input and a workspace query is assumed; the routine only calculates the minimum and optimal size for all work arrays. Each of these values is returned in the first entry of the corresponding work array, and no error message is issued by PXERBLA. π
INFOβ global output,INTEGER. The receipts:= 0: successful exit β¨< 0: ifINFO = -i, thei-th argument had an illegal value π> 0: ifINFO = i, andiis<= N:U(IA+I-1,IA+I-1)is exactly zero. The factorization has been completed, but the factorUis exactly singular, so the solution and error bounds could not be computed.= N+1:RCONDis less than machine precision. The factorization has been completed, but the matrix is singular to working precision, and the solution and error bounds have not been computed. π
Bestie, real talk: INFO > 0 is not a vibe. If you see it, the matrix said "no" and the solution + error bounds simply don't exist. Don't come for me, come for your conditioning. π
And that's a wrap, gorgeous β this page is from LAPACK version 1.5, dated 12 May 1997, and it's the man page for PZGESVX(l). The 90s really served us this distributed-matrix realness and honestly? Iconic. Go forth and solve, bestie. ππ
π¦ where this page comes from
- ubuntu jammy: scalapack-doc 1.5-11
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms