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)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

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

References

None.

Parameters

Compulsory Input Parameters

1:     norm_p – string (length ≥ 1)
Indicates whether κ1A or κA is to be estimated.
norm_p='1' or 'O'
κ1A is estimated.
norm_p='I'
κA is estimated.
Constraint: norm_p='1', 'O' or 'I'.
2:     n int64int32nag_int scalar
n, the order of the matrix A.
Constraint: n0.
3:     il: int64int32nag_int array
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 as computed by nag_sparse_direct_real_gen_lu (f11me).
4:     lval: – double array
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 and some nonzero values of matrix U as computed by nag_sparse_direct_real_gen_lu (f11me).
5:     iu: int64int32nag_int array
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 as computed by nag_sparse_direct_real_gen_lu (f11me).
6:     uval: – double array
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 as computed by nag_sparse_direct_real_gen_lu (f11me).
7:     anorm – double scalar
If norm_p='1' or 'O', the 1-norm of the matrix A.
If norm_p='I', the -norm of the matrix A.
anorm may be computed by calling nag_sparse_direct_real_gen_norm (f11ml) with the same value for the argument norm_p.
Constraint: anorm0.0.

Optional Input Parameters

None.

Output Parameters

1:     rcond – double scalar
An estimate of the reciprocal of the condition number of A. rcond is set to zero if exact singularity is detected or the estimate underflows. If rcond is less than machine precision, A is singular to working precision.
2:     ifail int64int32nag_int scalar
ifail=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
Constraint: anorm0.0.
Constraint: n0.
On entry, norm_p=_.
Constraint: norm_p='1', 'O' or 'I'.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

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

Example

This example estimates the condition number in the 1-norm of the matrix A, where
A= 2.00 1.00 0 0 0 0 0 1.00 -1.00 0 4.00 0 1.00 0 1.00 0 0 0 1.00 2.00 0 -2.00 0 0 3.00 .  
Here A is nonsymmetric and must first be factorized by nag_sparse_direct_real_gen_lu (f11me). The true condition number in the 1-norm is 20.25.
function f11mg_example


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

% Sparse matrix A
n      = int64(5);
a      = [        2;  4; 1; -2; 1;  1; -1; 1; 1; 2; 3];
icolzp = [int64(1); 3; 5;  7; 9; 12];
irowix = [int64(1); 3; 1;  5; 2;  3;  2; 4; 3; 4; 5];
nz     = icolzp(n+1) - 1;

% Calculate COLAMD permutation
spec   = 'M';
iprm   = zeros(7*n, 1, 'int64');

[iprm, ifail] = f11md( ...
                       spec, n, icolzp, irowix, iprm);


% Factorise
thresh = 1;
nzlmx  = int64(8*nz);
nzlumx = int64(8*nz);
nzumx  = int64(8*nz);

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

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

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

fprintf('Norm             = %7.3f\n', anorm);
fprintf('Condition number = %7.3f\n', 1/rcond);


f11mg example results

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–2015