F07 Chapter Contents
F07 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF07ASF (ZGETRS)

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

F07ASF (ZGETRS) solves a complex system of linear equations with multiple right-hand sides,
 $AX=B , ATX=B or AHX=B ,$
where $A$ has been factorized by F07ARF (ZGETRF).

## 2  Specification

 SUBROUTINE F07ASF ( TRANS, N, NRHS, A, LDA, IPIV, B, LDB, INFO)
 INTEGER N, NRHS, LDA, IPIV(*), LDB, INFO COMPLEX (KIND=nag_wp) A(LDA,*), B(LDB,*) CHARACTER(1) TRANS
The routine may be called by its LAPACK name zgetrs.

## 3  Description

F07ASF (ZGETRS) is used to solve a complex system of linear equations $AX=B$, ${A}^{\mathrm{T}}X=B$ or ${A}^{\mathrm{H}}X=B$, the routine must be preceded by a call to F07ARF (ZGETRF) which computes the $LU$ factorization of $A$ as $A=PLU$. The solution is computed by forward and backward substitution.
If ${\mathbf{TRANS}}=\text{'N'}$, the solution is computed by solving $PLY=B$ and then $UX=Y$.
If ${\mathbf{TRANS}}=\text{'T'}$, the solution is computed by solving ${U}^{\mathrm{T}}Y=B$ and then ${L}^{\mathrm{T}}{P}^{\mathrm{T}}X=Y$.
If ${\mathbf{TRANS}}=\text{'C'}$, the solution is computed by solving ${U}^{\mathrm{H}}Y=B$ and then ${L}^{\mathrm{H}}{P}^{\mathrm{T}}X=Y$.

## 4  References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

## 5  Parameters

1:     $\mathrm{TRANS}$ – CHARACTER(1)Input
On entry: indicates the form of the equations.
${\mathbf{TRANS}}=\text{'N'}$
$AX=B$ is solved for $X$.
${\mathbf{TRANS}}=\text{'T'}$
${A}^{\mathrm{T}}X=B$ is solved for $X$.
${\mathbf{TRANS}}=\text{'C'}$
${A}^{\mathrm{H}}X=B$ is solved for $X$.
Constraint: ${\mathbf{TRANS}}=\text{'N'}$, $\text{'T'}$ or $\text{'C'}$.
2:     $\mathrm{N}$ – INTEGERInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{N}}\ge 0$.
3:     $\mathrm{NRHS}$ – INTEGERInput
On entry: $r$, the number of right-hand sides.
Constraint: ${\mathbf{NRHS}}\ge 0$.
4:     $\mathrm{A}\left({\mathbf{LDA}},*\right)$ – COMPLEX (KIND=nag_wp) arrayInput
Note: the second dimension of the array A must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On entry: the $LU$ factorization of $A$, as returned by F07ARF (ZGETRF).
5:     $\mathrm{LDA}$ – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F07ASF (ZGETRS) is called.
Constraint: ${\mathbf{LDA}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
6:     $\mathrm{IPIV}\left(*\right)$ – INTEGER arrayInput
Note: the dimension of the array IPIV must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On entry: the pivot indices, as returned by F07ARF (ZGETRF).
7:     $\mathrm{B}\left({\mathbf{LDB}},*\right)$ – COMPLEX (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array B must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{NRHS}}\right)$.
On entry: the $n$ by $r$ right-hand side matrix $B$.
On exit: the $n$ by $r$ solution matrix $X$.
8:     $\mathrm{LDB}$ – INTEGERInput
On entry: the first dimension of the array B as declared in the (sub)program from which F07ASF (ZGETRS) is called.
Constraint: ${\mathbf{LDB}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
9:     $\mathrm{INFO}$ – INTEGEROutput
On exit: ${\mathbf{INFO}}=0$ unless the routine detects an error (see Section 6).

## 6  Error Indicators and Warnings

${\mathbf{INFO}}<0$
If ${\mathbf{INFO}}=-i$, argument $i$ had an illegal value. An explanatory message is output, and execution of the program is terminated.

## 7  Accuracy

For each right-hand side vector $b$, the computed solution $x$ is the exact solution of a perturbed system of equations $\left(A+E\right)x=b$, where
 $E≤cnεPLU ,$
$c\left(n\right)$ is a modest linear function of $n$, and $\epsilon$ is the machine precision.
If $\stackrel{^}{x}$ is the true solution, then the computed solution $x$ satisfies a forward error bound of the form
 $x-x^∞ x∞ ≤cncondA,xε$
where $\mathrm{cond}\left(A,x\right)={‖\left|{A}^{-1}\right|\left|A\right|\left|x\right|‖}_{\infty }/{‖x‖}_{\infty }\le \mathrm{cond}\left(A\right)={‖\left|{A}^{-1}\right|\left|A\right|‖}_{\infty }\le {\kappa }_{\infty }\left(A\right)$.
Note that $\mathrm{cond}\left(A,x\right)$ can be much smaller than $\mathrm{cond}\left(A\right)$, and $\mathrm{cond}\left({A}^{\mathrm{H}}\right)$ (which is the same as $\mathrm{cond}\left({A}^{\mathrm{T}}\right)$) can be much larger (or smaller) than $\mathrm{cond}\left(A\right)$.
Forward and backward error bounds can be computed by calling F07AVF (ZGERFS), and an estimate for ${\kappa }_{\infty }\left(A\right)$ can be obtained by calling F07AUF (ZGECON) with ${\mathbf{NORM}}=\text{'I'}$.

## 8  Parallelism and Performance

F07ASF (ZGETRS) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
F07ASF (ZGETRS) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

The total number of real floating-point operations is approximately $8{n}^{2}r$.
This routine may be followed by a call to F07AVF (ZGERFS) to refine the solution and return an error estimate.
The real analogue of this routine is F07AEF (DGETRS).

## 10  Example

This example solves the system of equations $AX=B$, where
 $A= -1.34+2.55i 0.28+3.17i -6.39-2.20i 0.72-0.92i -0.17-1.41i 3.31-0.15i -0.15+1.34i 1.29+1.38i -3.29-2.39i -1.91+4.42i -0.14-1.35i 1.72+1.35i 2.41+0.39i -0.56+1.47i -0.83-0.69i -1.96+0.67i$
and
 $B= 26.26+51.78i 31.32-06.70i 6.43-08.68i 15.86-01.42i -5.75+25.31i -2.15+30.19i 1.16+02.57i -2.56+07.55i .$
Here $A$ is nonsymmetric and must first be factorized by F07ARF (ZGETRF).

### 10.1  Program Text

Program Text (f07asfe.f90)

### 10.2  Program Data

Program Data (f07asfe.d)

### 10.3  Program Results

Program Results (f07asfe.r)