# p?gesv

Computes the solution to the system of linear equations with a square distributed matrix and multiple right-hand sides.

## Syntax

call psgesv(n, nrhs, a, ia, ja, desca, ipiv, b, ib, jb, descb, info)

call pdgesv(n, nrhs, a, ia, ja, desca, ipiv, b, ib, jb, descb, info)

call pcgesv(n, nrhs, a, ia, ja, desca, ipiv, b, ib, jb, descb, info)

call pzgesv(n, nrhs, a, ia, ja, desca, ipiv, b, ib, jb, descb, info)

## Description

The routine p?gesv computes the solution to a real or complex system of linear equations `sub(A)*X = sub(B)`, where `sub(A) = A(ia:ia+n-1, ja:ja+n-1)` is an n-by-n distributed matrix and X and `sub(B) = B(ib:ib+n-1, jb:jb+nrhs-1)` are n-by-nrhs distributed matrices.

The LU decomposition with partial pivoting and row interchanges is used to factor sub(A) as `sub(A) = P*L*U`, where P is a permutation matrix, L is unit lower triangular, and U is upper triangular. L and U are stored in sub(A). The factored form of sub(A) is then used to solve the system of equations `sub(A)*X = sub(B)`.

## Input Parameters

n

  (global) INTEGER. The number of rows and columns to be operated on, that is, the order of the distributed submatrix `sub(A) (n ≥ 0)`.

nrhs

  (global) INTEGER. The number of right hand sides, that is, the number of columns of the distributed submatrices B and X `(nrhs ≥ 0)`.

a, b

  (local)

  REAL for psgesv

  DOUBLE PRECISION for pdgesv

  COMPLEX for pcgesv

  DOUBLE COMPLEX for pzgesv.

  Pointers into the local memory to arrays of local dimension a`(lld_a,LOCc(ja+n-1))` and `b(lld_b,LOCc(jb+nrhs-1))`, respectively.

  On entry, the array a contains the local pieces of the n-by-n distributed matrix sub(A) to be factored.

  On entry, the array b contains the right hand side distributed matrix sub(B).

ia, ja

  (global) INTEGER. The row and column indices in the global array A indicating the first row and the first column of sub(A), respectively.

desca

  (global and local) INTEGER array, dimension (dlen_). The array descriptor for the distributed matrix A.

ib, jb

  (global) INTEGER. The row and column indices in the global array B indicating the first row and the first column of sub(B), respectively.

descb

  (global and local) INTEGER array, dimension (dlen_). The array descriptor for the distributed matrix B.

## Output Parameters

a

  Overwritten by the factors L and U from the factorization sub(A) = P*L*U; the unit diagonal elements of L are not stored .

b

  Overwritten by the solution distributed matrix X.

ipiv

  (local) INTEGER array.

  The dimension of ipiv is (`LOCr(m_a)+mb_a)`. This array contains the pivoting information. The (local) row i of the matrix was interchanged with the (global) row ipiv(i).

  This array is tied to the distributed matrix A.

info

  (global) INTEGER. If `info=0`, the execution is successful.

  info < 0:

  If the i-th argument is an array and the j-th entry had an illegal value, then `info = -(i*100+j)`; if the i-th argument is a scalar and had an illegal value, then `info = -i`.

  `info > 0`:

  If info = k, U(ia+k-1,ja+k-1) is exactly zero. The factorization has been completed, but the factor U is exactly singular, so the solution could not be computed.

Parent topic: Driver Routines