PCGESVX(l)
โจ PCGESVX โจ โ LAPACK routine (version 1.5)
okay bestie, sit down, hydrate, because this one is a whole moment ๐
this is the manual page for PCGESVX(l), and it's lowkey one of the most useful routines in the whole ScaLAPACK lineup. no cap.
๐ธ NAME ๐ธ
PCGESVX โ use 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)
๐ SYNOPSIS ๐
SUBROUTINE PCGESVX( 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
REAL RCOND
INTEGER DESCA( * ), DESCAF( * ), DESCB( * ), DESCX( * ),
IPIV( * )
REAL BERR( * ), C( * ), FERR( * ), R( * ), RWORK( * )
COMPLEX A( * ), AF( * ), B( * ), WORK( * ), X( * )
๐ PURPOSE ๐
PCGESVX 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. โจ it doesn't just solve, it grades the solve, she's giving main character energy.
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".
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 grid A is 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 array A.N_A(global) โ stored inDESCA( N_ )โ the number of columns in the global array A.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 array A is distributed.CSRC_A(global) โ stored inDESCA( CSRC_ )โ the process column over which the first column of the array A is 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
๐ฆ 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.
๐ ARGUMENTS ๐
FACT(global input)CHARACTERโ Specifies whether or not the factored form of the matrixA(IA:IA+N-1,JA:JA+N-1)is supplied on entry, and if not, whether the matrixA(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 submatrixA(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 submatricesB(IB:IB+N-1,JB:JB+NRHS-1)andX(IX:IX+N-1,JX:JX+NRHS-1).NRHS >= 0.A(local input/local output)COMPLEXpointer into the local memory to an array of local dimension(LLD_A,LOCc(JA+N-1)). On entry, the N-by-N matrixA(IA:IA+N-1,JA:JA+N-1). IfFACT = 'F'andEQUEDis not'N', thenA(IA:IA+N-1,JA:JA+N-1)must have been equilibrated by the scaling factors inRand/orC.A(IA:IA+N-1,JA:JA+N-1)is not modified ifFACT = 'F'or'N', or ifFACT = 'E'andEQUED = '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 arrayAindicating the first row ofsub( A ).JA(global input)INTEGERโ The column index in the global arrayAindicating the first column ofsub( A ).DESCA(global and local input)INTEGERarray of dimensionDLEN_. The array descriptor for the distributed matrixA.AF(local input or local output)COMPLEXpointer into the local memory to an array of local dimension(LLD_AF,LOCc(JA+N-1)). IfFACT = 'F', thenAF(IAF:IAF+N-1,JAF:JAF+N-1)is an input argument and on entry contains the factorsLandUfrom the factorizationA(IA:IA+N-1,JA:JA+N-1) = P*L*Uas computed byPCGETRF. IfEQUED .ne. 'N', thenAFis the factored form of the equilibrated matrixA(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 arrayAFindicating the first row ofsub( AF ).JAF(global input)INTEGERโ The column index in the global arrayAFindicating the first column ofsub( AF ).DESCAF(global and local input)INTEGERarray of dimensionDLEN_. The array descriptor for the distributed matrixAF.IPIV(local input or local output)INTEGERarray, dimensionLOCr(M_A)+MB_A. IfFACT = 'F', thenIPIVis an input argument and on entry contains the pivot indices from the factorizationA(IA:IA+N-1,JA:JA+N-1) = P*L*Uas computed byPCGETRF;IPIV(i)-> The global row local rowiwas swapped with. This array must be aligned withA( 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).
IfFACT = 'E', thenIPIVis an output argument and on exit it contains the pivot indices from the factorizationA(IA:IA+N-1,JA:JA+N-1) = P*L*Uof the equilibrated matrixA(IA:IA+N-1,JA:JA+N-1). ๐
EQUED(global input or global output) CHARACTER โ this tells you what kind of equilibration was done, bestie:= 'N': no equilibration (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 is an output variable. โจ
R(local input or local output) REAL array, dimensionLOCr(M_A)โ the row scale factors forA(IA:IA+N-1,JA:JA+N-1). ๐ธ IfEQUED = 'R'or'B',A(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) REAL array, dimensionLOCc(N_A)โ the column scale factors forA(IA:IA+N-1,JA:JA+N-1). ๐ IfEQUED = 'C'or'B',A(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 pointer into the local memory to an array of local dimension(LLD_B,LOCc(JB+NRHS-1)). ๐ On entry, the N-by-NRHS right-hand side matrixB(IB:IB+N-1,JB:JB+NRHS-1). On exit, ifEQUED = 'N',B(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) INTEGER array of dimensionDLEN_โ the array descriptor for the distributed matrixB. ๐X(local input/local output) COMPLEX pointer into the local memory to an array of local dimension(LLD_X, LOCc(JX+NRHS-1)). ๐ IfINFO = 0, the N-by-NRHS solution matrixX(IX:IX+N-1,JX:JX+NRHS-1)to the original system of equations. 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) INTEGER array of dimensionDLEN_โ the array descriptor for the distributed matrixX. ๐RCOND(global output) REAL โ the estimate of the reciprocal condition number of the matrixA(IA:IA+N-1,JA:JA+N-1)after equilibration (if 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) REAL array, dimensionLOCc(N_B)โ the estimated forward error bounds for each solution vectorX(j)(the j-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) REAL array, 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 array, 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 leastLWORK = MAX( PCGECON( LWORK ), PCGERFS( LWORK ) ) + LOCr( N_A ). ๐งฎ IfLWORK = -1, thenLWORKis 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 byPXERBLA. ๐RWORK(local workspace/local output) REAL array, 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 leastLRWORK = 2*LOCc(N_A). ๐งฎ IfLRWORK = -1, thenLRWORKis 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 byPXERBLA. ๐INFO(global output) INTEGER โ the tea on how it all went down:= 0: successful exit โจ< 0: ifINFO = -i, the i-th argument had an illegal value ๐ญ> 0: ifINFO = i, and i is<= 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. ๐ฉ
And that's a wrap on PCGESVX(l), bestie! ๐ This iconic page is from LAPACK version 1.5, dated 12 May 1997 โ and yes, PCGESVX(l) is the name. Now go slay those distributed linear algebra problems! โจ๐
๐ฆ 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