# ?gesc2

Solves a system of linear equations using the LU factorization with complete pivoting computed by ?getc2.

## Syntax

call sgesc2( n, a, lda, rhs, ipiv, jpiv, scale )

call dgesc2( n, a, lda, rhs, ipiv, jpiv, scale )

call cgesc2( n, a, lda, rhs, ipiv, jpiv, scale )

call zgesc2( n, a, lda, rhs, ipiv, jpiv, scale )

## Description

This routine solves a system of linear equations

`A*X = scale*RHS`

with a general n-by-n matrix A using the LU factorization with complete pivoting computed by ?getc2.

## Input Parameters

n

  INTEGER. The order of the matrix A.

a, rhs

  REAL for sgesc2

  DOUBLE PRECISION for dgesc2

  COMPLEX for cgesc2

  COMPLEX*16 for zgesc2.

  Arrays:

  `a(lda,*)` contains the LU part of the factorization of the n-by-n matrix A computed by ?getc2:

  ```A = P*L*U*Q```.

  The second dimension of a must be at least `max(1, n)`;

  rhs(n) contains on entry the right hand side vector for the system of equations.

lda

  INTEGER. The first dimension of a; at least `max(1, n)`.

ipiv

  INTEGER.

  Array, DIMENSION at least `max(1,n)`.

  The pivot indices: for `1 ≤ i ≤ n`, row i of the matrix has been interchanged with row ipiv(i).

jpiv

  INTEGER.

  Array, DIMENSION at least `max(1,n)`.

  The pivot indices: for `1 ≤ j ≤ n`, column j of the matrix has been interchanged with column `jpiv(j)`.

## Output Parameters

rhs

  On exit, overwritten with the solution vector X.

scale

  REAL for sgesc2/cgesc2

  DOUBLE PRECISION for dgesc2/zgesc2

  Contains the scale factor. scale is chosen in the range `0 ≤ scale ≤ 1` to prevent overflow in the solution.

Parent topic: Auxiliary Routines