PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_matop_real_gen_matrix_cond_num (f01jb)
Purpose
nag_matop_real_gen_matrix_cond_num (f01jb) computes an estimate of the absolute condition number of a matrix function at a real by matrix in the -norm. Numerical differentiation is used to evaluate the derivatives of when they are required.
Syntax
[
a,
user,
iflag,
conda,
norma,
normfa,
ifail] = f01jb(
a,
f, 'n',
n, 'user',
user)
[
a,
user,
iflag,
conda,
norma,
normfa,
ifail] = nag_matop_real_gen_matrix_cond_num(
a,
f, 'n',
n, 'user',
user)
Description
The absolute condition number of
at
,
is given by the norm of the Fréchet derivative of
,
, which is defined by
where
is the Fréchet derivative in the direction
.
is linear in
and can therefore be written as
where the
operator stacks the columns of a matrix into one vector, so that
is
.
nag_matop_real_gen_matrix_cond_num (f01jb) computes an estimate
such that
, where
. The relative condition number can then be computed via
The algorithm used to find
is detailed in Section 3.4 of
Higham (2008).
The function
is supplied via function
f which evaluates
at a number of points
.
References
Higham N J (2008) Functions of Matrices: Theory and Computation SIAM, Philadelphia, PA, USA
Parameters
Compulsory Input Parameters
- 1:
– double array
-
The first dimension of the array
a must be at least
.
The second dimension of the array
a must be at least
.
The by matrix .
- 2:
– function handle or string containing name of m-file
-
The function
f evaluates
at a number of points
.
[iflag, fz, user] = f(iflag, nz, z, user)
Input Parameters
- 1:
– int64int32nag_int scalar
-
- 2:
– int64int32nag_int scalar
-
, the number of function values required.
- 3:
– complex array
-
The points at which the function is to be evaluated.
- 4:
– Any MATLAB object
f is called from
nag_matop_real_gen_matrix_cond_num (f01jb) with the object supplied to
nag_matop_real_gen_matrix_cond_num (f01jb).
Output Parameters
- 1:
– 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
; for instance
may not be defined. If
iflag is returned as nonzero then
nag_matop_real_gen_matrix_cond_num (f01jb) will terminate the computation, with
.
- 2:
– complex array
-
The function values.
should return the value , for . If lies on the real line, then so must .
- 3:
– Any MATLAB object
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the array
a.
, the order of the matrix .
Constraint:
.
- 2:
– Any MATLAB object
user is not used by
nag_matop_real_gen_matrix_cond_num (f01jb), 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:
– double array
-
The first dimension of the array
a will be
.
The second dimension of the array
a will be
.
The by matrix, .
- 2:
– Any MATLAB object
- 3:
– int64int32nag_int scalar
-
, unless
iflag has been set nonzero inside
f, in which case
iflag will be the value set and
ifail will be set to
.
- 4:
– double scalar
-
An estimate of the absolute condition number of at .
- 5:
– double scalar
-
The -norm of .
- 6:
– double scalar
-
The -norm of .
- 7:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
An internal error occurred when estimating the norm of the Fréchet derivative of
at
. Please contact
NAG.
-
-
An internal error occurred when evaluating the matrix function
. You can investigate further by calling
nag_matop_real_gen_matrix_fun_num (f01el) with the matrix
and the function
.
-
-
iflag has been set nonzero by the user-supplied function.
-
-
On entry, .
Input argument number is invalid.
-
-
On entry, argument lda is invalid.
Constraint: .
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
nag_matop_real_gen_matrix_cond_num (f01jb) uses the norm estimation function
nag_linsys_real_gen_norm_rcomm (f04yd) to estimate a quantity
, where
and
. 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_num (f01el). Approximately
of real allocatable memory is required by the routine, in addition to the memory used by the underlying matrix function routine.
If only is required, without an estimate of the condition number, then it is far more efficient to use the underlying matrix function routine.
Example
This example estimates the absolute and relative condition numbers of the matrix function
where
Open in the MATLAB editor:
f01jb_example
function f01jb_example
fprintf('f01jb example results\n\n');
a = [-1, -1, -2, 1;
0, 1, -1, 0;
-1, -2, 1, -1;
0, -1, 0, -1];
[a, user, iflag, conda, norma, normfa, ifail] = ...
f01jb(a, @fcos2);
fprintf('\nf(a) = cos(2A)\n');
fprintf('Estimated absolute condition number is: %7.2f\n', conda);
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] = fcos2(iflag, nz, z, user)
fz = cos(2*z);
f01jb example results
f(a) = cos(2A)
Estimated absolute condition number is: 4.10
Estimated relative condition number is: 14.48
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015