hide long namesshow long names
hide short namesshow short names
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 AA, in either the 11-norm or the -norm:
κ1(A) = A1 A11   or   κ(A) = A A1.
κ1(A)=A1 A-11   or   κ(A)=A A-1.
Note that κ(A) = κ1(AT)κ(A)=κ1(AT).
Because the condition number is infinite if AA 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 A1A1 or AA, and a call to nag_sparse_direct_real_gen_lu (f11me) to compute the LU LU  factorization of AA. The function then estimates A11A-11 or A1A-1 and computes the reciprocal of the condition number.

References

None.

Parameters

Compulsory Input Parameters

1:     norm_p – string (length ≥ 1)
Indicates whether κ1(A)κ1(A) or κ(A)κ(A) is to be estimated.
norm = '1'norm='1' or 'O''O'
κ1(A)κ1(A) is estimated.
norm = 'I'norm='I'
κ(A)κ(A) is estimated.
Constraint: norm = '1'norm='1', 'O''O' or 'I''I'.
2:     n – int64int32nag_int scalar
nn, the order of the matrix AA.
Constraint: n0n0.
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 LL 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 LL and some nonzero values of matrix UU 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 UU 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 UU as computed by nag_sparse_direct_real_gen_lu (f11me).
7:     anorm – double scalar
If norm = '1'norm='1' or 'O''O', the 11-norm of the matrix AA.
If norm = 'I'norm='I', the -norm of the matrix AA.
anorm may be computed by calling nag_sparse_direct_real_gen_norm (f11ml) with the same value for the parameter norm_p.
Constraint: anorm0.0anorm0.0.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

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

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,norm'1'norm'1', 'O''O' or 'I''I',
orn < 0n<0,
oranorm < 0.0anorm<0.0.
  ifail = 301ifail=301
Unable to allocate required internal workspace.

Accuracy

The computed estimate rcond is never less than the true value ρρ, and in practice is nearly always less than 10ρ10ρ, 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 = bAx=b or ATx = bATx=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