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_dgtcon (f07cg)

## Purpose

nag_lapack_dgtcon (f07cg) estimates the reciprocal condition number of a real $n$ by $n$ tridiagonal matrix $A$, using the $LU$ factorization returned by nag_lapack_dgttrf (f07cd).

## Syntax

[rcond, info] = f07cg(norm_p, dl, d, du, du2, ipiv, anorm, 'n', n)
[rcond, info] = nag_lapack_dgtcon(norm_p, dl, d, du, du2, ipiv, anorm, 'n', n)

## Description

nag_lapack_dgtcon (f07cg) should be preceded by a call to nag_lapack_dgttrf (f07cd), which uses Gaussian elimination with partial pivoting and row interchanges to factorize the matrix $A$ as
 $A=PLU ,$
where $P$ is a permutation matrix, $L$ is unit lower triangular with at most one nonzero subdiagonal element in each column, and $U$ is an upper triangular band matrix, with two superdiagonals. nag_lapack_dgtcon (f07cg) then utilizes the factorization to estimate either ${‖{A}^{-1}‖}_{1}$ or ${‖{A}^{-1}‖}_{\infty }$, from which the estimate of the reciprocal of the condition number of $A$, $1/\kappa \left(A\right)$ is computed as either
 $1 / κ1 A = 1 / A1 A-11$
or
 $1 / κ∞ A = 1 / A∞ A-1∞ .$
$1/\kappa \left(A\right)$ is returned, rather than $\kappa \left(A\right)$, since when $A$ is singular $\kappa \left(A\right)$ is infinite.
Note that ${\kappa }_{\infty }\left(A\right)={\kappa }_{1}\left({A}^{\mathrm{T}}\right)$.

## References

Higham N J (2002) Accuracy and Stability of Numerical Algorithms (2nd Edition) SIAM, Philadelphia

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{norm_p}$ – string (length ≥ 1)
Specifies the norm to be used to estimate $\kappa \left(A\right)$.
${\mathbf{norm_p}}=\text{'1'}$ or $\text{'O'}$
Estimate ${\kappa }_{1}\left(A\right)$.
${\mathbf{norm_p}}=\text{'I'}$
Estimate ${\kappa }_{\infty }\left(A\right)$.
Constraint: ${\mathbf{norm_p}}=\text{'1'}$, $\text{'O'}$ or $\text{'I'}$.
2:     $\mathrm{dl}\left(:\right)$ – double array
The dimension of the array dl must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}-1\right)$
Must contain the $\left(n-1\right)$ multipliers that define the matrix $L$ of the $LU$ factorization of $A$.
3:     $\mathrm{d}\left(:\right)$ – double array
The dimension of the array d must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
Must contain the $n$ diagonal elements of the upper triangular matrix $U$ from the $LU$ factorization of $A$.
4:     $\mathrm{du}\left(:\right)$ – double array
The dimension of the array du must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}-1\right)$
Must contain the $\left(n-1\right)$ elements of the first superdiagonal of $U$.
5:     $\mathrm{du2}\left(:\right)$ – double array
The dimension of the array du2 must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}-2\right)$
Must contain the $\left(n-2\right)$ elements of the second superdiagonal of $U$.
6:     $\mathrm{ipiv}\left(:\right)$int64int32nag_int array
The dimension of the array ipiv must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
Must contain the $n$ pivot indices that define the permutation matrix $P$. At the $i$th step, row $i$ of the matrix was interchanged with row ${\mathbf{ipiv}}\left(i\right)$, and ${\mathbf{ipiv}}\left(i\right)$ must always be either $i$ or $\left(i+1\right)$, ${\mathbf{ipiv}}\left(i\right)=i$ indicating that a row interchange was not performed.
7:     $\mathrm{anorm}$ – double scalar
If ${\mathbf{norm_p}}=\text{'1'}$ or $\text{'O'}$, the $1$-norm of the original matrix $A$.
If ${\mathbf{norm_p}}=\text{'I'}$, the $\infty$-norm of the original matrix $A$.
anorm must be computed either before calling nag_lapack_dgttrf (f07cd) or else from a copy of the original matrix $A$ (see Example).
Constraint: ${\mathbf{anorm}}\ge 0.0$.

### Optional Input Parameters

1:     $\mathrm{n}$int64int32nag_int scalar
Default: the dimension of the arrays d, ipiv.
$n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.

### Output Parameters

1:     $\mathrm{rcond}$ – double scalar
Contains an estimate of the reciprocal condition number.
2:     $\mathrm{info}$int64int32nag_int scalar
${\mathbf{info}}=0$ unless the function detects an error (see Error Indicators and Warnings).

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

## Accuracy

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 condition number estimation typically requires between four and five solves and never more than eleven solves, following the factorization. The total number of floating-point operations required to perform a solve is proportional to $n$.
The complex analogue of this function is nag_lapack_zgtcon (f07cu).

## Example

This example estimates the condition number in the $1$-norm of the tridiagonal matrix $A$ given by
 $A = 3.0 2.1 0.0 0.0 0.0 3.4 2.3 -1.0 0.0 0.0 0.0 3.6 -5.0 1.9 0.0 0.0 0.0 7.0 -0.9 8.0 0.0 0.0 0.0 -6.0 7.1 .$
```function f07cg_example

fprintf('f07cg example results\n\n');

% Tridiagonal matrix A stored as diagonals:
du = [        2.1    -1.0      1.9     8.0];
d  = [3.0     2.3    -5.0     -0.9     7.1];
dl = [3.4     3.6     7.0     -6.0        ];
n  = numel(d);

% Factorize A.
[dlf, df, duf, du2f, ipiv, info] = ...
f07cd(dl, d, du);

% 1-norm of A (construct column preserving matrix)
a = [0 du; d; dl 0];
anorm = norm(a,1);

norm_p = '1-norm';
[rcond, info] = f07cg( ...
norm_p, dlf, df, duf, du2f, ipiv, anorm);

fprintf('Estimate of condition number = %10.2e\n', 1/rcond);

```
```f07cg example results

Estimate of condition number =   9.27e+01
```