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_matop_real_gen_matrix_cond_usd (f01jc)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_matop_real_gen_matrix_cond_usd (f01jc) computes an estimate of the absolute condition number of a matrix function f at a real n by n matrix A in the 1-norm, using analytical derivatives of f you have supplied.

Syntax

[a, user, iflag, conda, norma, normfa, ifail] = f01jc(a, f, 'n', n, 'user', user)
[a, user, iflag, conda, norma, normfa, ifail] = nag_matop_real_gen_matrix_cond_usd(a, f, 'n', n, 'user', user)

Description

The absolute condition number of f at A, condabsf,A is given by the norm of the Fréchet derivative of f, LA, which is defined by
LX := maxE0 LX,E E ,  
where LX,E is the Fréchet derivative in the direction E. LX,E is linear in E and can therefore be written as
vec LX,E = KX vecE ,  
where the vec operator stacks the columns of a matrix into one vector, so that KX is n2×n2. nag_matop_real_gen_matrix_cond_usd (f01jc) computes an estimate γ such that γ KX 1 , where KX 1 n-1 LX 1 , n LX 1 . The relative condition number can then be computed via
cond rel f,A = cond abs f,A A1 fA 1 .  
The algorithm used to find γ is detailed in Section 3.4 of Higham (2008).
The function f, and the derivatives of f, are returned by function f which, given an integer m, evaluates fmzi at a number of (generally complex) points zi, for i=1,2,,nz. For any z on the real line, fz must also be real. nag_matop_real_gen_matrix_cond_usd (f01jc) is therefore appropriate for functions that can be evaluated on the complex plane and whose derivatives, of arbitrary order, can also be evaluated on the complex plane.

References

Higham N J (2008) Functions of Matrices: Theory and Computation SIAM, Philadelphia, PA, USA

Parameters

Compulsory Input Parameters

1:     alda: – double array
The first dimension of the array a must be at least n.
The second dimension of the array a must be at least n.
The n by n matrix A.
2:     f – function handle or string containing name of m-file
Given an integer m, the function f evaluates fmzi at a number of points zi.
[iflag, fz, user] = f(m, iflag, nz, z, user)

Input Parameters

1:     m int64int32nag_int scalar
The order, m, of the derivative required.
If m=0, fzi should be returned. For m>0, fmzi should be returned.
2:     iflag int64int32nag_int scalar
iflag will be zero.
3:     nz int64int32nag_int scalar
nz, the number of function or derivative values required.
4:     znz – complex array
The nz points z1,z2,,znz at which the function f is to be evaluated.
5:     user – Any MATLAB object
f is called from nag_matop_real_gen_matrix_cond_usd (f01jc) with the object supplied to nag_matop_real_gen_matrix_cond_usd (f01jc).

Output Parameters

1:     iflag int64int32nag_int scalar
iflag should either be unchanged from its entry value of zero, or may be set nonzero to indicate that there is a problem in evaluating the function fz; for instance fz may not be defined. If iflag is returned as nonzero then nag_matop_real_gen_matrix_cond_usd (f01jc) will terminate the computation, with ifail=3.
2:     fznz – complex array
The nz function or derivative values. fzi should return the value fmzi, for i=1,2,,nz. If zi lies on the real line, then so must fmzi.
3:     user – Any MATLAB object

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the first dimension of the array a.
n, the order of the matrix A.
Constraint: n0.
2:     user – Any MATLAB object
user is not used by nag_matop_real_gen_matrix_cond_usd (f01jc), but is passed to f. Note that for large objects it may be more efficient to use a global variable which is accessible from the m-files than to use user.

Output Parameters

1:     alda: – double array
The first dimension of the array a will be n.
The second dimension of the array a will be n.
The n by n matrix, fA.
2:     user – Any MATLAB object
3:     iflag int64int32nag_int scalar
iflag=0, unless iflag has been set nonzero inside f, in which case iflag will be the value set and ifail will be set to ifail=3.
4:     conda – double scalar
An estimate of the absolute condition number of f at A.
5:     norma – double scalar
The 1-norm of A.
6:     normfa – double scalar
The 1-norm of fA.
7:     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
An internal error occurred when estimating the norm of the Fréchet derivative of f at A. Please contact NAG.
   ifail=2
An internal error occurred when evaluating the matrix function fA. You can investigate further by calling nag_matop_real_gen_matrix_fun_usd (f01em) with the matrix A and the function f.
   ifail=3
iflag has been set nonzero by the user-supplied function.
   ifail=-1
On entry, n<0.
Input argument number _ is invalid.
   ifail=-3
On entry, argument lda is invalid.
Constraint: ldan.
   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

nag_matop_real_gen_matrix_cond_usd (f01jc) uses the norm estimation routine nag_linsys_real_gen_norm_rcomm (f04yd) to estimate a quantity γ, where γ KX 1  and KX 1 n-1 LX 1 , n LX 1 . For further details on the accuracy of norm estimation, see the documentation for nag_linsys_real_gen_norm_rcomm (f04yd).

Further Comments

The matrix function is computed using the underlying matrix function routine nag_matop_real_gen_matrix_fun_usd (f01em). Approximately 6n2 of real allocatable memory is required by the routine, in addition to the memory used by the underlying matrix function routine.
If only fA is required, without an estimate of the condition number, then it is far more efficient to use the underlying matrix function routine directly.
The complex analogue of this function is nag_matop_complex_gen_matrix_cond_usd (f01kc).

Example

This example estimates the absolute and relative condition numbers of the matrix function e2A where
A= 0 -1 -1 1 -2 0 1 -1 2 -1 2 -2 -1 -2 0 -1 .  
function f01jc_example


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

a = [ 0,  -1,  -1,   1;
     -2,   0,   1,  -1;
      2,  -1,   2,  -2;
     -1,  -2,   0,  -1];

% Find absolute condition number estimate
[a, user, iflag, conda, norma, normfa, ifail] = ...
f01jc(a, @fexp2);

fprintf('\nf(A) = exp(2A)\n');
fprintf('Estimated absolute condition number is: %7.2f\n', conda);

%  Find relative condition number estimate
eps = x02aj;
if normfa > eps
   cond_rel = conda*norma/normfa;
   fprintf('Estimated relative condition number is: %7.2f\n', cond_rel);
else
  fprintf('The estimated norm of f(A) is effectively zero;\n');
  fprintf('the relative condition number is therefore undefined.\n');
end



function [iflag, fz, user] = fexp2(m, iflag, nz, z, user)
  fz = 2^double(m)*exp(2*z);
f01jc example results


f(A) = exp(2A)
Estimated absolute condition number is:  183.90
Estimated relative condition number is:   13.90

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