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

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_sparse_direct_real_gen_cond (f11mg)

## Purpose

nag_sparse_direct_real_gen_cond (f11mg) computes an estimate of the reciprocal of the condition number of a sparse matrix given an LU $LU$ factorization of the matrix computed by nag_sparse_direct_real_gen_lu (f11me).

## Syntax

[rcond, ifail] = f11mg(norm_p, n, il, lval, iu, uval, anorm)
[rcond, ifail] = nag_sparse_direct_real_gen_cond(norm_p, n, il, lval, iu, uval, anorm)

## Description

nag_sparse_direct_real_gen_cond (f11mg) estimates the condition number of a real sparse matrix A$A$, in either the 1$1$-norm or the $\infty$-norm:
 κ1(A) = ‖A‖1 ‖A − 1‖1   or   κ∞(A) = ‖A‖∞ ‖A − 1‖∞. $κ1(A)=‖A‖1 ‖A-1‖1 or κ∞(A)=‖A‖∞ ‖A-1‖∞.$
Note that κ(A) = κ1(AT)${\kappa }_{\infty }\left(A\right)={\kappa }_{1}\left({A}^{\mathrm{T}}\right)$.
Because the condition number is infinite if A$A$ is singular, the function actually returns an estimate of the reciprocal of the condition number.
The function should be preceded by a call to nag_sparse_direct_real_gen_norm (f11ml) to compute A1${‖A‖}_{1}$ or A${‖A‖}_{\infty }$, and a call to nag_sparse_direct_real_gen_lu (f11me) to compute the LU $LU$ factorization of A$A$. The function then estimates A11${‖{A}^{-1}‖}_{1}$ or A1${‖{A}^{-1}‖}_{\infty }$ and computes the reciprocal of the condition number.

None.

## Parameters

### Compulsory Input Parameters

1:     norm_p – string (length ≥ 1)
Indicates whether κ1(A)${\kappa }_{1}\left(A\right)$ or κ(A)${\kappa }_{\infty }\left(A\right)$ is to be estimated.
norm = '1'${\mathbf{norm}}=\text{'1'}$ or 'O'$\text{'O'}$
κ1(A)${\kappa }_{1}\left(A\right)$ is estimated.
norm = 'I'${\mathbf{norm}}=\text{'I'}$
κ(A)${\kappa }_{\infty }\left(A\right)$ is estimated.
Constraint: norm = '1'${\mathbf{norm}}=\text{'1'}$, 'O'$\text{'O'}$ or 'I'$\text{'I'}$.
2:     n – int64int32nag_int scalar
n$n$, the order of the matrix A$A$.
Constraint: n0${\mathbf{n}}\ge 0$.
3:     il( : $:$) – int64int32nag_int array
Note: the dimension of the array il must be at least as large as the dimension of the array of the same name in nag_sparse_direct_real_gen_lu (f11me).
Records the sparsity pattern of matrix L$L$ as computed by nag_sparse_direct_real_gen_lu (f11me).
4:     lval( : $:$) – double array
Note: the dimension of the array lval must be at least as large as the dimension of the array of the same name in nag_sparse_direct_real_gen_lu (f11me).
Records the nonzero values of matrix L$L$ and some nonzero values of matrix U$U$ as computed by nag_sparse_direct_real_gen_lu (f11me).
5:     iu( : $:$) – int64int32nag_int array
Note: the dimension of the array iu must be at least as large as the dimension of the array of the same name in nag_sparse_direct_real_gen_lu (f11me).
Records the sparsity pattern of matrix U$U$ as computed by nag_sparse_direct_real_gen_lu (f11me).
6:     uval( : $:$) – double array
Note: the dimension of the array uval must be at least as large as the dimension of the array of the same name in nag_sparse_direct_real_gen_lu (f11me).
Records some nonzero values of matrix U$U$ as computed by nag_sparse_direct_real_gen_lu (f11me).
7:     anorm – double scalar
If norm = '1'${\mathbf{norm}}=\text{'1'}$ or 'O'$\text{'O'}$, the 1$1$-norm of the matrix A$A$.
If norm = 'I'${\mathbf{norm}}=\text{'I'}$, the $\infty$-norm of the matrix A$A$.
anorm may be computed by calling nag_sparse_direct_real_gen_norm (f11ml) with the same value for the parameter norm_p.
Constraint: anorm0.0${\mathbf{anorm}}\ge 0.0$.

None.

None.

### Output Parameters

1:     rcond – double scalar
An estimate of the reciprocal of the condition number of A$A$. rcond is set to zero if exact singularity is detected or the estimate underflows. If rcond is less than machine precision, A$A$ is singular to working precision.
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, norm ≠ '1'${\mathbf{norm}}\ne \text{'1'}$, 'O'$\text{'O'}$ or 'I'$\text{'I'}$, or n < 0${\mathbf{n}}<0$, or anorm < 0.0${\mathbf{anorm}}<0.0$.
ifail = 301${\mathbf{ifail}}=301$
Unable to allocate required internal workspace.

## Accuracy

The computed estimate rcond is never less than the true value ρ$\rho$, and in practice is nearly always less than 10ρ$10\rho$, although examples can be constructed where rcond is much larger.

## Further Comments

A call to nag_sparse_direct_real_gen_cond (f11mg) involves solving a number of systems of linear equations of the form Ax = b$Ax=b$ or ATx = b${A}^{\mathrm{T}}x=b$.

## Example

```function nag_sparse_direct_real_gen_cond_example
norm_p = '1';
n = int64(5);
icolzp = [int64(1); 3; 5; 7; 9; 12];
iprm = zeros(7*n, 1, 'int64');
irowix = [int64(1); 3; 1; 5; 2; 3; 2; 4; 3; 4; 5];
a = [2; 4; 1; -2; 1; 1; -1; 1; 1; 2; 3];
spec = 'M';
nz = icolzp(n+1) - 1;
thresh = 1;
nzlmx = int64(8*nz);
nzlumx = int64(8*nz);
nzumx = int64(8*nz);

% Calculate COLAMD permutation
[iprm, ifail] = nag_sparse_direct_real_gen_setup(spec, n, icolzp, irowix, iprm);

% Factorise
[iprm, nzlumx, il, lval, iu, uval, nnzl, nnzu, flop, ifail] = ...
nag_sparse_direct_real_gen_lu(n, irowix, a, iprm, thresh, nzlmx, nzlumx, nzumx);

% Calculate Norm
[anorm, ifail] = nag_sparse_direct_real_gen_norm(norm_p, n, icolzp, irowix, a);

% Calculate condition number
[rcond, ifail] = nag_sparse_direct_real_gen_cond(norm_p, n, il, lval, iu, uval, anorm);

fprintf('\nNorm = %7.3f\nCondition number = %7.3f\n', anorm, 1/rcond);
```
```

Norm =   6.000
Condition number =  20.250

```
```function f11mg_example
norm_p = '1';
n = int64(5);
icolzp = [int64(1); 3; 5; 7; 9; 12];
iprm = zeros(7*n, 1, 'int64');
irowix = [int64(1); 3; 1; 5; 2; 3; 2; 4; 3; 4; 5];
a = [2; 4; 1; -2; 1; 1; -1; 1; 1; 2; 3];
spec = 'M';
nz = icolzp(n+1) - 1;
thresh = 1;
nzlmx = int64(8*nz);
nzlumx = int64(8*nz);
nzumx = int64(8*nz);

% Calculate COLAMD permutation
[iprm, ifail] = f11md(spec, n, icolzp, irowix, iprm);

% Factorise
[iprm, nzlumx, il, lval, iu, uval, nnzl, nnzu, flop, ifail] = ...
f11me(n, irowix, a, iprm, thresh, nzlmx, nzlumx, nzumx);

% Calculate Norm
[anorm, ifail] = f11ml(norm_p, n, icolzp, irowix, a);

% Calculate condition number
[rcond, ifail] = f11mg(norm_p, n, il, lval, iu, uval, anorm);

fprintf('\nNorm = %7.3f\nCondition number = %7.3f\n', anorm, 1/rcond);
```
```

Norm =   6.000
Condition number =  20.250

```

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013