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_complex_gen_matrix_cond_num (f01kb)

Purpose

nag_matop_complex_gen_matrix_cond_num (f01kb) computes an estimate of the absolute condition number of a matrix function ff at a complex nn by nn matrix AA in the 11-norm. Numerical differentiation is used to evaluate the derivatives of ff when they are required.

Syntax

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

Description

The absolute condition number of ff at AA, condabs(f,A)condabs(f,A) is given by the norm of the Fréchet derivative of ff, L(A,E)L(A,E), which is defined by
L(X) := maxE0 (L(X,E))/(E) .
L(X) := maxE0 L(X,E) E .
The Fréchet derivative in the direction EE, L(X,E)L(X,E) is linear in EE and can therefore be written as
vec (L(X,E)) = K(X) vec(E) ,
vec ( L(X,E) ) = K(X) vec(E) ,
where the vecvec operator stacks the columns of a matrix into one vector, so that K(X)K(X) is n2 × n2n2×n2. nag_matop_complex_gen_matrix_cond_num (f01kb) computes an estimate γγ such that γ K(X)1 γ K(X) 1 , where K(X)1 [ n1 L(X)1 , n L(X)1 ] K(X) 1 [ n-1 L(X) 1 , n L(X) 1 ] . The relative condition number can then be computed via
condrel (f,A) = ( condabs (f,A) A1 )/(f(A)1) .
cond rel (f,A) = cond abs (f,A) A1 f(A) 1 .
The algorithm used to find γγ is detailed in Section 3.4 of Higham (2008).
The function ff is supplied via function f which evaluates f(zi)f(zi) at a number of points zizi.

References

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

Parameters

Compulsory Input Parameters

1:     a(lda, : :) – complex array
The first dimension of the array a must be at least max (1,n)max(1,n)
The second dimension of the array must be at least nn
The nn by nn matrix AA.
2:     f – function handle or string containing name of m-file
The function f evaluates f(zi)f(zi) at a number of points zizi.
[iflag, fz, user] = f(iflag, nz, z, user)

Input Parameters

1:     iflag – int64int32nag_int scalar
iflag will be zero.
2:     nz – int64int32nag_int scalar
nznz, the number of function values required.
3:     z(nz) – complex array
The nznz points z1,z2,,znzz1,z2,,znz at which the function ff is to be evaluated.
4:     user – Any MATLAB object
f is called from nag_matop_complex_gen_matrix_cond_num (f01kb) with the object supplied to nag_matop_complex_gen_matrix_cond_num (f01kb).

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 f(z)f(z); for instance f(z)f(z) may not be defined. If iflag is returned as nonzero then nag_matop_complex_gen_matrix_cond_num (f01kb) will terminate the computation, with ifail = 3ifail=3.
2:     fz(nz) – complex array
The nznz function values. fz(i)fzi should return the value f(zi)f(zi), for i = 1,2,,nzi=1,2,,nz.
3:     user – Any MATLAB object

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array a.
nn, the order of the matrix AA.
Constraint: n0n0.
2:     user – Any MATLAB object
user is not used by nag_matop_complex_gen_matrix_cond_num (f01kb), 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.

Input Parameters Omitted from the MATLAB Interface

lda iuser ruser

Output Parameters

1:     a(lda, : :) – complex array
The first dimension of the array a will be max (1,n)max(1,n)
The second dimension of the array will be nn
ldamax (1,n)ldamax(1,n).
The nn by nn matrix, f(A)f(A).
2:     user – Any MATLAB object
3:     iflag – int64int32nag_int scalar
iflag = 0iflag=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 = 3ifail=3.
4:     conda – double scalar
An estimate of the absolute condition number of ff at AA.
5:     norma – double scalar
The 11-norm of AA.
6:     normfa – double scalar
The 11-norm of f(A)f(A).
7:     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
An internal error occurred when estimating the norm of the Fréchet derivative of ff at AA. Please contact NAG.
  ifail = 2ifail=2
An internal error occurred while evaluating the matrix function f(A)f(A). You can investigate further by calling nag_matop_complex_gen_matrix_fun_num (f01fl) with the matrix AA and the function ff.
  ifail = 3ifail=3
iflag has been set nonzero by the user-supplied function.
  ifail = 1ifail=-1
On entry, n < 0n<0.
  ifail = 3ifail=-3
On entry, parameter lda is invalid.
Constraint: ldanldan.
  ifail = 999ifail=-999
Allocation of memory failed.

Accuracy

nag_matop_complex_gen_matrix_cond_num (f01kb) uses the norm estimation function nag_linsys_real_gen_norm_rcomm (f04yd) to estimate a quantity γγ, where γ K(X)1 γ K(X) 1  and K(X)1 [ n1 L(X)1 , n L(X)1 ] K(X) 1 [ n-1 L(X) 1 , n L(X) 1 ] . For further details on the accuracy of norm estimation, see the documentation for nag_linsys_complex_gen_norm_rcomm (f04zd).

Further Comments

Approximately 6n26n2 of complex allocatable memory is required by the routine, in addition to the memory used by the underlying matrix function routine nag_matop_complex_gen_matrix_fun_num (f01fl).
nag_matop_complex_gen_matrix_cond_num (f01kb) returns the matrix function f(A)f(A). This is computed using nag_matop_complex_gen_matrix_fun_num (f01fl). If only f(A)f(A) is required, without an estimate of the condition number, then it is far more efficient to use nag_matop_complex_gen_matrix_fun_num (f01fl) directly.
The real analogue of this function is nag_matop_real_gen_matrix_cond_num (f01jb).

Example

function nag_matop_complex_gen_matrix_cond_num_example
a = [2+0i, 0+1i, 1+1i, 0+3i;
     1+1i, 0+2i, 2+2i, 0+0i;
     0+0i, 2+0i, 1+2i, 1+0i;
     1+1i, 3+0i, 0+0i, 1+2i];
% Find absolute condition number estimate
[a, user, iflag, conda, norma, normfa, ifail] = nag_matop_complex_gen_matrix_cond_num(a, @fsin2);

fprintf('\nF(a) = sin(2a)\n');
fprintf('Estimated absolute condition number is: %7.2f\n', conda);

%  Find relative condition number estimate
eps = nag_machine_precision;
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 and so the\nrelative condition number is undefined.\n');
end


function [iflag, fz, user] = fsin2(iflag, nz, z, user)
  fz = sin(2*z);
 

F(a) = sin(2a)
Estimated absolute condition number is: 2016.99
Estimated relative condition number is:   12.86

function f01kb_example
a = [2+0i, 0+1i, 1+1i, 0+3i;
     1+1i, 0+2i, 2+2i, 0+0i;
     0+0i, 2+0i, 1+2i, 1+0i;
     1+1i, 3+0i, 0+0i, 1+2i];
% Find absolute condition number estimate
[a, user, iflag, conda, norma, normfa, ifail] = f01kb(a, @fsin2);

fprintf('\nF(a) = sin(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 and so the\nrelative condition number is undefined.\n');
end


function [iflag, fz, user] = fsin2(iflag, nz, z, user)
  fz = sin(2*z);
 

F(a) = sin(2a)
Estimated absolute condition number is: 2016.99
Estimated relative condition number is:   12.86


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