Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_lapack_zptsvx (f07jp)

## Purpose

nag_lapack_zptsvx (f07jp) uses the factorization
 A = LDLH $A=LDLH$
to compute the solution to a complex system of linear equations
 AX = B , $AX=B ,$
where A$A$ is an n$n$ by n$n$ Hermitian positive definite tridiagonal matrix and X$X$ and B$B$ are n$n$ by r$r$ matrices. Error bounds on the solution and a condition estimate are also provided.

## Syntax

[df, ef, x, rcond, ferr, berr, info] = f07jp(fact, d, e, df, ef, b, 'n', n, 'nrhs_p', nrhs_p)
[df, ef, x, rcond, ferr, berr, info] = nag_lapack_zptsvx(fact, d, e, df, ef, b, 'n', n, 'nrhs_p', nrhs_p)

## Description

nag_lapack_zptsvx (f07jp) performs the following steps:
1. If fact = 'N'${\mathbf{fact}}=\text{'N'}$, the matrix A$A$ is factorized as A = LDLH$A=LD{L}^{\mathrm{H}}$, where L$L$ is a unit lower bidiagonal matrix and D$D$ is diagonal. The factorization can also be regarded as having the form A = UHDU$A={U}^{\mathrm{H}}DU$.
2. If the leading i$i$ by i$i$ principal minor is not positive definite, then the function returns with info = i${\mathbf{info}}=i$. Otherwise, the factored form of A$A$ is used to estimate the condition number of the matrix A$A$. If the reciprocal of the condition number is less than machine precision, infon + 1${\mathbf{info}}\ge {\mathbf{n}}+1$ is returned as a warning, but the function still goes on to solve for X$X$ and compute error bounds as described below.
3. The system of equations is solved for X$X$ using the factored form of A$A$.
4. Iterative refinement is applied to improve the computed solution matrix and to calculate error bounds and backward error estimates for it.

## 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

## Parameters

### Compulsory Input Parameters

1:     fact – string (length ≥ 1)
Specifies whether or not the factorized form of the matrix A$A$ has been supplied.
fact = 'F'${\mathbf{fact}}=\text{'F'}$
df and ef contain the factorized form of the matrix A$A$. df and ef will not be modified.
fact = 'N'${\mathbf{fact}}=\text{'N'}$
The matrix A$A$ will be copied to df and ef and factorized.
Constraint: fact = 'F'${\mathbf{fact}}=\text{'F'}$ or 'N'$\text{'N'}$.
2:     d( : $:$) – double array
Note: the dimension of the array d must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The n$n$ diagonal elements of the tridiagonal matrix A$A$.
3:     e( : $:$) – complex array
Note: the dimension of the array e must be at least max (1,n1)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}-1\right)$.
The (n1)$\left(n-1\right)$ subdiagonal elements of the tridiagonal matrix A$A$.
4:     df( : $:$) – double array
Note: the dimension of the array df must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
If fact = 'F'${\mathbf{fact}}=\text{'F'}$, df must contain the n$n$ diagonal elements of the diagonal matrix D$D$ from the LDLH$LD{L}^{\mathrm{H}}$ factorization of A$A$.
5:     ef( : $:$) – complex array
Note: the dimension of the array ef must be at least max (1,n1)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}-1\right)$.
If fact = 'F'${\mathbf{fact}}=\text{'F'}$, ef must contain the (n1)$\left(n-1\right)$ subdiagonal elements of the unit bidiagonal factor L$L$ from the LDLH$LD{L}^{\mathrm{H}}$ factorization of A$A$.
6:     b(ldb, : $:$) – complex array
The first dimension of the array b must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The second dimension of the array must be at least max (1,nrhs)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nrhs}}\right)$
The n$n$ by r$r$ right-hand side matrix B$B$.

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array b The dimension of the arrays d, df.
n$n$, the order of the matrix A$A$.
Constraint: n0${\mathbf{n}}\ge 0$.
2:     nrhs_p – int64int32nag_int scalar
Default: The second dimension of the array b.
r$r$, the number of right-hand sides, i.e., the number of columns of the matrix B$B$.
Constraint: nrhs0${\mathbf{nrhs}}\ge 0$.

### Input Parameters Omitted from the MATLAB Interface

ldb ldx work rwork

### Output Parameters

1:     df( : $:$) – double array
Note: the dimension of the array df must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
If fact = 'N'${\mathbf{fact}}=\text{'N'}$, df contains the n$n$ diagonal elements of the diagonal matrix D$D$ from the LDLH$LD{L}^{\mathrm{H}}$ factorization of A$A$.
2:     ef( : $:$) – complex array
Note: the dimension of the array ef must be at least max (1,n1)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}-1\right)$.
If fact = 'N'${\mathbf{fact}}=\text{'N'}$, ef contains the (n1)$\left(n-1\right)$ subdiagonal elements of the unit bidiagonal factor L$L$ from the LDLH$LD{L}^{\mathrm{H}}$ factorization of A$A$.
3:     x(ldx, : $:$) – complex array
The first dimension of the array x will be max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The second dimension of the array will be max (1,nrhs)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nrhs}}\right)$
ldxmax (1,n)$\mathit{ldx}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
If ${\mathbf{INFO}}={\mathbf{0}}$ or n + 1$\mathbf{n}+{\mathbf{1}}$, the n$n$ by r$r$ solution matrix X$X$.
4:     rcond – double scalar
The reciprocal condition number of the matrix A$A$. If rcond is less than the machine precision (in particular, if rcond = 0.0${\mathbf{rcond}}=0.0$), the matrix is singular to working precision. This condition is indicated by a return code of infon + 1${\mathbf{info}}\ge {\mathbf{n}}+1$.
5:     ferr(nrhs_p) – double array
The forward error bound for each solution vector j${\stackrel{^}{x}}_{j}$ (the j$j$th column of the solution matrix X$X$). If xj${x}_{j}$ is the true solution corresponding to j${\stackrel{^}{x}}_{j}$, ferr(j)${\mathbf{ferr}}\left(j\right)$ is an estimated upper bound for the magnitude of the largest element in (jxj${\stackrel{^}{x}}_{j}-{x}_{j}$) divided by the magnitude of the largest element in j${\stackrel{^}{x}}_{j}$.
6:     berr(nrhs_p) – double array
The component-wise relative backward error of each solution vector j${\stackrel{^}{x}}_{j}$ (i.e., the smallest relative change in any element of A$A$ or B$B$ that makes j${\stackrel{^}{x}}_{j}$ an exact solution).
7:     info – int64int32nag_int scalar
info = 0${\mathbf{info}}=0$ unless the function detects an error (see Section [Error Indicators and Warnings]).

## Error Indicators and Warnings

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

info = i${\mathbf{info}}=-i$
If info = i${\mathbf{info}}=-i$, parameter i$i$ had an illegal value on entry. The parameters are numbered as follows:
1: fact, 2: n, 3: nrhs_p, 4: d, 5: e, 6: df, 7: ef, 8: b, 9: ldb, 10: x, 11: ldx, 12: rcond, 13: ferr, 14: berr, 15: work, 16: rwork, 17: info.
It is possible that info refers to a parameter that is omitted from the MATLAB interface. This usually indicates that an error in one of the other input parameters has caused an incorrect value to be inferred.
INFO > 0andINFON${\mathbf{INFO}}>0 \text{and} {\mathbf{INFO}}\le {\mathbf{N}}$
If info = i${\mathbf{info}}=i$ and in$i\le {\mathbf{n}}$, the leading minor of order i$i$ of A$A$ is not positive definite, so the factorization could not be completed, and the solution has not been computed. rcond = 0.0${\mathbf{rcond}}=0.0$ is returned.
W INFO = N + 1${\mathbf{INFO}}={\mathbf{N}}+1$
The diagonal matrix D$D$ 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.

## Accuracy

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

The number of floating point operations required for the factorization, and for the estimation of the condition number of A $A$ is proportional to n $n$. The number of floating point operations required for the solution of the equations, and for the estimation of the forward and backward error is proportional to nr $nr$, where r $r$ is the number of right-hand sides.
The condition estimation is based upon Equation (15.11) of Higham (2002). For further details of the error estimation, see Section 4.4 of Anderson et al. (1999).
The real analogue of this function is nag_lapack_dptsvx (f07jb).

## Example

```function nag_lapack_zptsvx_example
fact = 'Not factored';
d = [16;
41;
46;
21];
e = [ 16 + 16i;
18 - 9i;
1 - 4i];
df = zeros(4, 1);
ef = complex(zeros(3, 1));
b = [ 64 + 16i,  -16 - 32i;
93 + 62i,  61 - 66i;
78 - 80i,  71 - 74i;
14 - 27i,  35 + 15i];
[dfOut, efOut, x, rcond, ferr, berr, info] = nag_lapack_zptsvx(fact, d, e, df, ef, b)
```
```

dfOut =

16
9
1
4

efOut =

1.0000 + 1.0000i
2.0000 - 1.0000i
1.0000 - 4.0000i

x =

2.0000 + 1.0000i  -3.0000 - 2.0000i
1.0000 + 1.0000i   1.0000 + 1.0000i
1.0000 - 2.0000i   1.0000 - 2.0000i
1.0000 - 1.0000i   2.0000 + 1.0000i

rcond =

1.0862e-04

ferr =

1.0e-11 *

0.9038
0.6093

berr =

0
0

info =

0

```
```function f07jp_example
fact = 'Not factored';
d = [16;
41;
46;
21];
e = [ 16 + 16i;
18 - 9i;
1 - 4i];
df = zeros(4, 1);
ef = complex(zeros(3, 1));
b = [ 64 + 16i,  -16 - 32i;
93 + 62i,  61 - 66i;
78 - 80i,  71 - 74i;
14 - 27i,  35 + 15i];
[dfOut, efOut, x, rcond, ferr, berr, info] = f07jp(fact, d, e, df, ef, b)
```
```

dfOut =

16
9
1
4

efOut =

1.0000 + 1.0000i
2.0000 - 1.0000i
1.0000 - 4.0000i

x =

2.0000 + 1.0000i  -3.0000 - 2.0000i
1.0000 + 1.0000i   1.0000 + 1.0000i
1.0000 - 2.0000i   1.0000 - 2.0000i
1.0000 - 1.0000i   2.0000 + 1.0000i

rcond =

1.0862e-04

ferr =

1.0e-11 *

0.9038
0.6093

berr =

0
0

info =

0

```