nag_zgesvx (f07apc) (PDF version)
f07 Chapter Contents
f07 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_zgesvx (f07apc)

## 1  Purpose

nag_zgesvx (f07apc) uses the $LU$ factorization to compute the solution to a complex system of linear equations
 $AX=B or ATX=B or AHX=B ,$
where $A$ is an $n$ by $n$ matrix and $X$ and $B$ are $n$ by $r$ matrices. Error bounds on the solution and a condition estimate are also provided.

## 2  Specification

 #include #include
 void nag_zgesvx (Nag_OrderType order, Nag_FactoredFormType fact, Nag_TransType trans, Integer n, Integer nrhs, Complex a[], Integer pda, Complex af[], Integer pdaf, Integer ipiv[], Nag_EquilibrationType *equed, double r[], double c[], Complex b[], Integer pdb, Complex x[], Integer pdx, double *rcond, double ferr[], double berr[], double *recip_growth_factor, NagError *fail)

## 3  Description

nag_zgesvx (f07apc) performs the following steps:
1. Equilibration
The linear system to be solved may be badly scaled. However, the system can be equilibrated as a first stage by setting ${\mathbf{fact}}=\mathrm{Nag_EquilibrateAndFactor}$. In this case, real scaling factors are computed and these factors then determine whether the system is to be equilibrated. Equilibrated forms of the systems $AX=B$, ${A}^{\mathrm{T}}X=B$ and ${A}^{\mathrm{H}}X=B$ are
 $DR A DC DC-1X = DR B ,$
 $DR A DC T DR-1 X = DC B ,$
and
 $DR A DC H DR-1 X = DC B ,$
respectively, where ${D}_{R}$ and ${D}_{C}$ are diagonal matrices, with positive diagonal elements, formed from the computed scaling factors.
When equilibration is used, $A$ will be overwritten by ${D}_{R}A{D}_{C}$ and $B$ will be overwritten by ${D}_{R}B$ (or ${D}_{C}B$ when the solution of ${A}^{\mathrm{T}}X=B$ or ${A}^{\mathrm{H}}X=B$ is sought).
2. Factorization
The matrix $A$, or its scaled form, is copied and factored using the $LU$ decomposition
 $A=PLU ,$
where $P$ is a permutation matrix, $L$ is a unit lower triangular matrix, and $U$ is upper triangular.
This stage can be by-passed when a factored matrix (with scaled matrices and scaling factors) are supplied; for example, as provided by a previous call to nag_zgesvx (f07apc) with the same matrix $A$.
3. Condition Number Estimation
The $LU$ factorization of $A$ determines whether a solution to the linear system exists. If some diagonal element of $U$ is zero, then $U$ is exactly singular, no solution exists and the function returns with a failure. Otherwise the factorized form of $A$ is used to estimate the condition number of the matrix $A$. If the reciprocal of the condition number is less than machine precision then a warning code is returned on final exit.
4. Solution
The (equilibrated) system is solved for $X$ (${D}_{C}^{-1}X$ or ${D}_{R}^{-1}X$) using the factored form of $A$ (${D}_{R}A{D}_{C}$).
5. Iterative Refinement
Iterative refinement is applied to improve the computed solution matrix and to calculate error bounds and backward error estimates for the computed solution.
6. Construct Solution Matrix $X$
If equilibration was used, the matrix $X$ is premultiplied by ${D}_{C}$ (if ${\mathbf{trans}}=\mathrm{Nag_NoTrans}$) or ${D}_{R}$ (if ${\mathbf{trans}}=\mathrm{Nag_Trans}$ or $\mathrm{Nag_ConjTrans}$) so that it solves the original system before equilibration.

## 4  References

Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (1999) LAPACK Users' Guide (3rd Edition) SIAM, Philadelphia http://www.netlib.org/lapack/lug
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Higham N J (2002) Accuracy and Stability of Numerical Algorithms (2nd Edition) SIAM, Philadelphia

## 5  Arguments

1:     orderNag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 3.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or Nag_ColMajor.
2:     factNag_FactoredFormTypeInput
On entry: specifies whether or not the factorized form of the matrix $A$ is supplied on entry, and if not, whether the matrix $A$ should be equilibrated before it is factorized.
${\mathbf{fact}}=\mathrm{Nag_Factored}$
af and ipiv contain the factorized form of $A$. If ${\mathbf{equed}}\ne \mathrm{Nag_NoEquilibration}$, the matrix $A$ has been equilibrated with scaling factors given by r and c. a, af and ipiv are not modified.
${\mathbf{fact}}=\mathrm{Nag_NotFactored}$
The matrix $A$ will be copied to af and factorized.
${\mathbf{fact}}=\mathrm{Nag_EquilibrateAndFactor}$
The matrix $A$ will be equilibrated if necessary, then copied to af and factorized.
Constraint: ${\mathbf{fact}}=\mathrm{Nag_Factored}$, $\mathrm{Nag_NotFactored}$ or $\mathrm{Nag_EquilibrateAndFactor}$.
3:     transNag_TransTypeInput
On entry: specifies the form of the system of equations.
${\mathbf{trans}}=\mathrm{Nag_NoTrans}$
$AX=B$ (No transpose).
${\mathbf{trans}}=\mathrm{Nag_Trans}$
${A}^{\mathrm{T}}X=B$ (Transpose).
${\mathbf{trans}}=\mathrm{Nag_ConjTrans}$
${A}^{\mathrm{H}}X=B$ (Conjugate transpose).
Constraint: ${\mathbf{trans}}=\mathrm{Nag_NoTrans}$, $\mathrm{Nag_Trans}$ or $\mathrm{Nag_ConjTrans}$.
4:     nIntegerInput
On entry: $n$, the number of linear equations, i.e., the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
5:     nrhsIntegerInput
On entry: $r$, the number of right-hand sides, i.e., the number of columns of the matrix $B$.
Constraint: ${\mathbf{nrhs}}\ge 0$.
6:     a[$\mathit{dim}$]ComplexInput/Output
Note: the dimension, dim, of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pda}}×{\mathbf{n}}\right)$.
The $\left(i,j\right)$th element of the matrix $A$ is stored in
• ${\mathbf{a}}\left[\left(j-1\right)×{\mathbf{pda}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{a}}\left[\left(i-1\right)×{\mathbf{pda}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the $n$ by $n$ matrix $A$.
If ${\mathbf{fact}}=\mathrm{Nag_Factored}$ and ${\mathbf{equed}}\ne \mathrm{Nag_NoEquilibration}$, a must have been equilibrated by the scaling factors in r and/or c.
On exit: if ${\mathbf{fact}}=\mathrm{Nag_Factored}$ or $\mathrm{Nag_NotFactored}$, or if ${\mathbf{fact}}=\mathrm{Nag_EquilibrateAndFactor}$ and ${\mathbf{equed}}=\mathrm{Nag_NoEquilibration}$, a is not modified.
If ${\mathbf{fact}}=\mathrm{Nag_EquilibrateAndFactor}$ or ${\mathbf{equed}}\ne \mathrm{Nag_NoEquilibration}$, $A$ is scaled as follows:
• if ${\mathbf{equed}}=\mathrm{Nag_RowEquilibration}$, $A={D}_{R}A$;
• if ${\mathbf{equed}}=\mathrm{Nag_ColumnEquilibration}$, $A=A{D}_{C}$;
• if ${\mathbf{equed}}=\mathrm{Nag_RowAndColumnEquilibration}$, $A={D}_{R}A{D}_{C}$.
7:     pdaIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array a.
Constraint: ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
8:     af[$\mathit{dim}$]ComplexInput/Output
Note: the dimension, dim, of the array af must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdaf}}×{\mathbf{n}}\right)$.
The $\left(i,j\right)$th element of the matrix is stored in
• ${\mathbf{af}}\left[\left(j-1\right)×{\mathbf{pdaf}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{af}}\left[\left(i-1\right)×{\mathbf{pdaf}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: if ${\mathbf{fact}}=\mathrm{Nag_Factored}$, af contains the factors $L$ and $U$ from the factorization $A=PLU$ as computed by nag_zgetrf (f07arc). If ${\mathbf{equed}}\ne \mathrm{Nag_NoEquilibration}$, af is the factorized form of the equilibrated matrix $A$.
If ${\mathbf{fact}}=\mathrm{Nag_NotFactored}$ or $\mathrm{Nag_EquilibrateAndFactor}$, af need not be set.
On exit: if ${\mathbf{fact}}=\mathrm{Nag_NotFactored}$, af returns the factors $L$ and $U$ from the factorization $A=PLU$ of the original matrix $A$.
If ${\mathbf{fact}}=\mathrm{Nag_EquilibrateAndFactor}$, af 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).
If ${\mathbf{fact}}=\mathrm{Nag_Factored}$, af is unchanged from entry.
9:     pdafIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array af.
Constraint: ${\mathbf{pdaf}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
10:   ipiv[$\mathit{dim}$]IntegerInput/Output
Note: the dimension, dim, of the array ipiv must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: if ${\mathbf{fact}}=\mathrm{Nag_Factored}$, ipiv contains the pivot indices from the factorization $A=PLU$ as computed by nag_zgetrf (f07arc); at the $i$th step row $i$ of the matrix was interchanged with row ${\mathbf{ipiv}}\left[i-1\right]$. ${\mathbf{ipiv}}\left[i-1\right]=i$ indicates a row interchange was not required.
If ${\mathbf{fact}}=\mathrm{Nag_NotFactored}$ or $\mathrm{Nag_EquilibrateAndFactor}$, ipiv need not be set.
On exit: if ${\mathbf{fact}}=\mathrm{Nag_NotFactored}$, ipiv contains the pivot indices from the factorization $A=PLU$ of the original matrix $A$.
If ${\mathbf{fact}}=\mathrm{Nag_EquilibrateAndFactor}$, ipiv contains the pivot indices from the factorization $A=PLU$ of the equilibrated matrix $A$.
If ${\mathbf{fact}}=\mathrm{Nag_Factored}$, ipiv is unchanged from entry.
11:   equedNag_EquilibrationType*Input/Output
On entry: if ${\mathbf{fact}}=\mathrm{Nag_NotFactored}$ or $\mathrm{Nag_EquilibrateAndFactor}$, equed need not be set.
If ${\mathbf{fact}}=\mathrm{Nag_Factored}$, equed must specify the form of the equilibration that was performed as follows:
• if ${\mathbf{equed}}=\mathrm{Nag_NoEquilibration}$, no equilibration;
• if ${\mathbf{equed}}=\mathrm{Nag_RowEquilibration}$, row equilibration, i.e., $A$ has been premultiplied by ${D}_{R}$;
• if ${\mathbf{equed}}=\mathrm{Nag_ColumnEquilibration}$, column equilibration, i.e., $A$ has been postmultiplied by ${D}_{C}$;
• if ${\mathbf{equed}}=\mathrm{Nag_RowAndColumnEquilibration}$, both row and column equilibration, i.e., $A$ has been replaced by ${D}_{R}A{D}_{C}$.
On exit: if ${\mathbf{fact}}=\mathrm{Nag_Factored}$, equed is unchanged from entry.
Otherwise, if no constraints are violated, equed specifies the form of equilibration that was performed as specified above.
Constraint: if ${\mathbf{fact}}=\mathrm{Nag_Factored}$, ${\mathbf{equed}}=\mathrm{Nag_NoEquilibration}$, $\mathrm{Nag_RowEquilibration}$, $\mathrm{Nag_ColumnEquilibration}$ or $\mathrm{Nag_RowAndColumnEquilibration}$.
12:   r[$\mathit{dim}$]doubleInput/Output
Note: the dimension, dim, of the array r must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: if ${\mathbf{fact}}=\mathrm{Nag_NotFactored}$ or $\mathrm{Nag_EquilibrateAndFactor}$, r need not be set.
If ${\mathbf{fact}}=\mathrm{Nag_Factored}$ and ${\mathbf{equed}}=\mathrm{Nag_RowEquilibration}$ or $\mathrm{Nag_RowAndColumnEquilibration}$, r must contain the row scale factors for $A$, ${D}_{R}$; each element of r must be positive.
On exit: if ${\mathbf{fact}}=\mathrm{Nag_Factored}$, r is unchanged from entry.
Otherwise, if no constraints are violated and ${\mathbf{equed}}=\mathrm{Nag_RowEquilibration}$ or $\mathrm{Nag_RowAndColumnEquilibration}$, r contains the row scale factors for $A$, ${D}_{R}$, such that $A$ is multiplied on the left by ${D}_{R}$; each element of r is positive.
13:   c[$\mathit{dim}$]doubleInput/Output
Note: the dimension, dim, of the array c must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: if ${\mathbf{fact}}=\mathrm{Nag_NotFactored}$ or $\mathrm{Nag_EquilibrateAndFactor}$, c need not be set.
If ${\mathbf{fact}}=\mathrm{Nag_Factored}$ or ${\mathbf{equed}}=\mathrm{Nag_ColumnEquilibration}$ or $\mathrm{Nag_RowAndColumnEquilibration}$, c must contain the column scale factors for $A$, ${D}_{C}$; each element of c must be positive.
On exit: if ${\mathbf{fact}}=\mathrm{Nag_Factored}$, c is unchanged from entry.
Otherwise, if no constraints are violated and ${\mathbf{equed}}=\mathrm{Nag_ColumnEquilibration}$ or $\mathrm{Nag_RowAndColumnEquilibration}$, c contains the row scale factors for $A$, ${D}_{C}$; each element of c is positive.
14:   b[$\mathit{dim}$]ComplexInput/Output
Note: the dimension, dim, of the array b must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdb}}×{\mathbf{nrhs}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×{\mathbf{pdb}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
The $\left(i,j\right)$th element of the matrix $B$ is stored in
• ${\mathbf{b}}\left[\left(j-1\right)×{\mathbf{pdb}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{b}}\left[\left(i-1\right)×{\mathbf{pdb}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the $n$ by $r$ right-hand side matrix $B$.
On exit: if ${\mathbf{equed}}=\mathrm{Nag_NoEquilibration}$, b is not modified.
If ${\mathbf{trans}}=\mathrm{Nag_NoTrans}$ and ${\mathbf{equed}}=\mathrm{Nag_RowEquilibration}$ or $\mathrm{Nag_RowAndColumnEquilibration}$, b is overwritten by ${D}_{R}B$.
If ${\mathbf{trans}}=\mathrm{Nag_Trans}$ or $\mathrm{Nag_ConjTrans}$ and ${\mathbf{equed}}=\mathrm{Nag_ColumnEquilibration}$ or $\mathrm{Nag_RowAndColumnEquilibration}$, b is overwritten by ${D}_{C}B$.
15:   pdbIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array b.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nrhs}}\right)$.
16:   x[$\mathit{dim}$]ComplexOutput
Note: the dimension, dim, of the array x must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdx}}×{\mathbf{nrhs}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×{\mathbf{pdx}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
The $\left(i,j\right)$th element of the matrix $X$ is stored in
• ${\mathbf{x}}\left[\left(j-1\right)×{\mathbf{pdx}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{x}}\left[\left(i-1\right)×{\mathbf{pdx}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On exit: if NE_NOERROR or NE_SINGULAR_WP, the $n$ by $r$ solution matrix $X$ to the original system of equations. Note that the arrays $A$ and $B$ are modified on exit if ${\mathbf{equed}}\ne \mathrm{Nag_NoEquilibration}$, and the solution to the equilibrated system is ${D}_{C}^{-1}X$ if ${\mathbf{trans}}=\mathrm{Nag_NoTrans}$ and ${\mathbf{equed}}=\mathrm{Nag_ColumnEquilibration}$ or $\mathrm{Nag_RowAndColumnEquilibration}$, or ${D}_{R}^{-1}X$ if ${\mathbf{trans}}=\mathrm{Nag_Trans}$ or $\mathrm{Nag_ConjTrans}$ and ${\mathbf{equed}}=\mathrm{Nag_RowEquilibration}$ or $\mathrm{Nag_RowAndColumnEquilibration}$.
17:   pdxIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array x.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{pdx}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdx}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nrhs}}\right)$.
18:   rconddouble *Output
On exit: if no constraints are violated, an estimate of the reciprocal condition number of the matrix $A$ (after equilibration if that is performed), computed as ${\mathbf{rcond}}=1.0/\left({‖A‖}_{1}{‖{A}^{-1}‖}_{1}\right)$.
19:   ferr[nrhs]doubleOutput
On exit: if NE_NOERROR or NE_SINGULAR_WP, an estimate of the forward error bound for each computed solution vector, such that ${‖{\stackrel{^}{x}}_{j}-{x}_{j}‖}_{\infty }/{‖{x}_{j}‖}_{\infty }\le {\mathbf{ferr}}\left[j-1\right]$ where ${\stackrel{^}{x}}_{j}$ is the $j$th column of the computed solution returned in the array x and ${x}_{j}$ is the corresponding column of the exact solution $X$. The estimate is as reliable as the estimate for rcond, and is almost always a slight overestimate of the true error.
20:   berr[nrhs]doubleOutput
On exit: if NE_NOERROR or NE_SINGULAR_WP, an estimate of the component-wise relative backward error of each computed solution vector ${\stackrel{^}{x}}_{j}$ (i.e., the smallest relative change in any element of $A$ or $B$ that makes ${\stackrel{^}{x}}_{j}$ an exact solution).
21:   recip_growth_factordouble *Output
On exit: if NE_NOERROR, the reciprocal pivot growth factor $‖A‖/‖U‖$, where $‖.‖$ denotes the maximum absolute element norm. If ${\mathbf{recip_growth_factor}}\ll 1$, the stability of the $LU$ factorization of (equilibrated) $A$ could be poor. This also means that the solution x, condition estimate rcond, and forward error bound ferr could be unreliable. If the factorization fails with NE_SINGULAR, then ${\mathbf{recip_growth_factor}}$ contains the reciprocal pivot growth factor for the leading ${\mathbf{fail}}\mathbf{.}\mathbf{errnum}$ columns of $A$.
22:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_BAD_PARAM
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INT
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{nrhs}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nrhs}}\ge 0$.
On entry, ${\mathbf{pda}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pda}}>0$.
On entry, ${\mathbf{pdaf}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdaf}}>0$.
On entry, ${\mathbf{pdb}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdb}}>0$.
On entry, ${\mathbf{pdx}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdx}}>0$.
NE_INT_2
On entry, ${\mathbf{pda}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry, ${\mathbf{pdaf}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdaf}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry, ${\mathbf{pdb}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry, ${\mathbf{pdb}}=〈\mathit{\text{value}}〉$ and ${\mathbf{nrhs}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nrhs}}\right)$.
On entry, ${\mathbf{pdx}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdx}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry, ${\mathbf{pdx}}=〈\mathit{\text{value}}〉$ and ${\mathbf{nrhs}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdx}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nrhs}}\right)$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_SINGULAR
$U\left(〈\mathit{\text{value}}〉,〈\mathit{\text{value}}〉\right)$ 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. ${\mathbf{rcond}}=0.0$ is returned.
NE_SINGULAR_WP
$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.

## 7  Accuracy

For each right-hand side vector $b$, the computed solution $\stackrel{^}{x}$ is the exact solution of a perturbed system of equations $\left(A+E\right)\stackrel{^}{x}=b$, where
 $E≤cnεPLU ,$
$c\left(n\right)$ is a modest linear function of $n$, and $\epsilon$ is the machine precision. See Section 9.3 of Higham (2002) for further details.
If $x$ is the true solution, then the computed solution $\stackrel{^}{x}$ satisfies a forward error bound of the form
 $x-x^∞ x^∞ ≤ wc condA,x^,b$
where $\mathrm{cond}\left(A,\stackrel{^}{x},b\right)={‖\left|{A}^{-1}\right|\left(\left|A\right|\left|\stackrel{^}{x}\right|+\left|b\right|\right)‖}_{\infty }/{‖\stackrel{^}{x}‖}_{\infty }\le \mathrm{cond}\left(A\right)={‖\left|{A}^{-1}\right|\left|A\right|‖}_{\infty }\le {\kappa }_{\infty }\left(A\right)$. If $\stackrel{^}{x}$ is the $j$th column of $X$, then ${w}_{c}$ is returned in ${\mathbf{berr}}\left[j-1\right]$ and a bound on ${‖x-\stackrel{^}{x}‖}_{\infty }/{‖\stackrel{^}{x}‖}_{\infty }$ is returned in ${\mathbf{ferr}}\left[j-1\right]$. See Section 4.4 of Anderson et al. (1999) for further details.

## 8  Further Comments

The factorization of $A$ requires approximately $\frac{8}{3}{n}^{3}$ floating point operations.
Estimating the forward error involves solving a number of systems of linear equations of the form $Ax=b$ or ${A}^{\mathrm{T}}x=b$; the number is usually $4$ or $5$ and never more than $11$. Each solution involves approximately $8{n}^{2}$ operations.
In practice the condition number estimator is very reliable, but it can underestimate the true condition number; see Section 15.3 of Higham (2002) for further details.
The real analogue of this function is nag_dgesvx (f07abc).

## 9  Example

This example solves the equations
 $AX=B ,$
where $A$ is the general matrix
 $A= -1.34+02.55i 0.28+3.17i -6.39-02.20i 0.72-00.92i -1.70-14.10i 33.10-1.50i -1.50+13.40i 12.90+13.80i -3.29-02.39i -1.91+4.42i -0.14-01.35i 1.72+01.35i 2.41+00.39i -0.56+1.47i -0.83-00.69i -1.96+00.67i$
and
 $B= 26.26+51.78i 31.32-06.70i 64.30-86.80i 158.60-14.20i -5.75+25.31i -2.15+30.19i 1.16+02.57i -2.56+07.55i .$
Error estimates for the solutions, information on scaling, an estimate of the reciprocal of the condition number of the scaled matrix $A$ and an estimate of the reciprocal of the pivot growth factor for the factorization of $A$ are also output.

### 9.1  Program Text

Program Text (f07apce.c)

### 9.2  Program Data

Program Data (f07apce.d)

### 9.3  Program Results

Program Results (f07apce.r)

nag_zgesvx (f07apc) (PDF version)
f07 Chapter Contents
f07 Chapter Introduction
NAG C Library Manual