Content

Solve a System of Linear Equations (svx)

svx (defined in namespace flens::lapack) uses the \(LU\) factorization to compute the solution to a real system of linear equations

\[ A X = B, \]

where \(A\) is an \(n \times n\) matrix and \(X\) and \(B\) are \(n \times n_{rhs}\) matrices.

Error bounds on the solution and a condition estimate are also provided.

Description

The following steps are performed:

Interface

fact

(input)
Specifies whether or not the factored form of the matrix \(A\) is supplied on entry, and if not, whether the matrix \(A\) should be equilibrated before it is factored.

Factored

On entry, \(AF\) and \(piv\) contain the factored form of \(A\). If equed is not None, the matrix \(A\) has been equilibrated with scaling factors given by \(R\) and \(C\). \(A\), \(AF\), and \(piv\) are not modified.

NotFactored

The matrix \(A\) will be copied to \(AF\) and factored.

Equilibrate

The matrix \(A\) will be equilibrated if necessary, then copied to \(AF\) and factored.

trans

(input)
Specifies the form of the system of equations:

NoTrans

\(A X = B\)

Trans

\(A^T X = B\)

ConjTrans

\(A^H X = B\)

A

(input/output) real valued GeMatrix
On entry, the \(n \times n\) matrix \(A\). If fact = Factored and equed is not None, then \(A\) must have been equilibrated by the scaling factors in \(R\) and/or \(C\). \(A\) is not modified if fact = Factored or NotFactored, or if fact = Equilibrate and equed = None on exit.

On exit, if equed is not None, \(A\) is scaled as follows:

Row

\(A\leftarrow \text{diag}(r) \, A\)

Column

\(A\leftarrow A \, \text{diag}(c)\)

Both

\(A\leftarrow \text{diag}(r)\, A \,\text{diag}(c)\)

AF

(input or output) real valued GeMatrix
If fact = Factored, then \(AF\) is an input argument and on entry contains the factors \(L\) and \(U\) from the factorization \(A = P L U\) as computed by trf. If equed is not None, then AF is the factored form of the equilibrated matrix A.

If fact = NotFactored, then \(AF\) is an output argument and on exit returns the factors \(L\) and \(U\) from the factorization \(A = P L U\) of the original matrix \(A\).

If fact = Equilibrate, then \(AF\) is an output argument and on exit returns the factors \(L\) and \(U\) from the factorization \(A = PLU\) of the equilibrated matrix \(A\) (see the description of \(A\) for the form of the equilibrated matrix).

piv

(input or output) INTEGER array, dimension (N)
If fact = Factored, then \(piv\) is an input argument and on entry contains the pivot indices from the factorization \(A = P L U\) as computed by trf; row \(i\) of the matrix was interchanged with row \(piv_i\).

If fact = NotFactored, then \(piv\) is an output argument and on exit contains the pivot indices from the factorization \(A = P L U\) of the original matrix \(A\).

If fact = Equilibrate, then \(piv\) is an output argument and on exit contains the pivot indices from the factorization \(A = P L U\) of the equilibrated matrix \(A\).

equed

(input or output)
Specifies the form of equilibration that was done.

None

No equilibration (always true if FACT = 'N').

Row

Row equilibration, i.e., A has been premultiplied by diag(r).

Column

Column equilibration, i.e., A has been postmultiplied by diag(c).

Both

Both row and column equilibration, i.e., A has been replaced by diag(r) A diag(c).

equed is an input argument if fact = Factored; otherwise, it is an output argument.

r

(input or output) real valued DenseVector
The row scale factors for \(A\). If equed equals Row or Both, \(A\) is multiplied on the left by \(\text{diag}(r)\); if equed equals None or Column, \(r\) is not accessed. \(r\) is an input argument if fact = Factored; otherwise, \(r\) is an output argument. If fact = Factored and equed equals Row or Both, each element of \(r\) must be positive.

c

(input or output) real valued DenseVector
The column scale factors for \(A\). If equed equals Column or Both, \(A\) is multiplied on the right by \(\text{diag}(c)\); if equed equals None or Row, \(c\) is not accessed. \(c\) is an input argument if fact = Factored; otherwise, \(C\) is an output argument. If fact = Factored and equed equals Column or Both, each element of \(c\) must be positive.

B

(input/output) real valued GeMatrix
On entry, the \(n \times n_{rhs}\) right hand side matrix \(B\).
On exit,

  • if equed = None, \(B\) is not modified;

  • if trans = NoTrans and equed = Row or Both, \(B\) is overwritten by \(\text{diag}(r) B\);

  • if trans = Trans or ConjTrans and equed = Column or Both, \(B\) is overwritten by \(\text{diag}(c) B\).

X

(output) real values GeMatrix
If the return value equals or \(n+1\), the \(n \times n_{rhs}\) solution matrix \(X\) to the original system of equations. Note that \(A\) and \(B\) are modified on exit if equed does not equal None, and the solution to the equilibrated system is \(\text{diag}(c)^{-1} X\) if trans = NoTrans and equed equals Column or Both, or \(\text{diag}(r)^{-1} X\) if trans = Trans or ConjTrans and equed = Row or Both.

rCond

(output) real number
The estimate of the reciprocal condition number of the matrix \(A\) after equilibration (if done). If \(rCond\) is less than the machine precision (in particular, if \(rCond = 0\)), the matrix is singular to working precision. This condition is indicated by a return value \(i>0\).

fErr

(output) real valued DenseVector
The estimated forward error bound for each solution vector \(X_{\cdot, j}\) (the \(j\)-th column of the solution matrix \(X\)). If \(X_{\text{true}}\) is the true solution corresponding to \(X_{\cdot, j}\), \(fErr_j\) is an estimated upper bound for the magnitude of the largest element in \(X_{\cdot,j} - X_{\text{true}}\) divided by the magnitude of the largest element in \(X_{\cdot, j}\). The estimate is as reliable as the estimate for \(rCond\), and is almost always a slight overestimate of the true error.

bErr

(output) real valued DenseVector
The componentwise relative backward error of each solution vector \(X_{\cdot, j}\) (i.e., the smallest relative change in any element of \(A\) or \(B\) that makes \(X_{\cdot, j}\) an exact solution).

work

(workspace/output) real valued DenseVector, dimension (4n)
On exit, work(1) contains the reciprocal pivot growth factor \(\text{norm}(A) / \text{norm}(U)\). The “max absolute element” norm is used. If work(1) is much less than \(1\), then the stability of the \(LU\) factorization of the (equilibrated) matrix \(A\) could be poor. This also means that the solution \(X\), condition estimator \(rCond\), and forward error bound \(fErr\) could be unreliable. If factorization fails with \(0< i \leq N\), then work(1) contains the reciprocal pivot growth factor for the leading \(i\) columns of A.

iWork

(workspace) integer valued DenseVector, dimension (n)

Return value:

\(i=0\)

successful exit

\(0< i \leq n\)

\(U_{i,i}\) is exactly zero. The factorization has been completed, but the factor U is exactly singular, so the solution and error bounds could not be computed. \(rCond =0 \) is returned.

\(i=n+1\)

\(U\) is nonsingular, but \(rCond\) is less than machine precision, meaning that the matrix is singular to working precision. Nevertheless, the solution and error bounds are computed because there are a number of situations where the computed solution can be more accurate than the value of \(rCond\) would suggest.