PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_matop_real_symm_matrix_fun (f01ef)
Purpose
nag_matop_real_symm_matrix_fun (f01ef) computes the matrix function, , of a real symmetric by matrix . must also be a real symmetric matrix.
Syntax
Description
is computed using a spectral factorization of
where
is the diagonal matrix whose diagonal elements,
, are the eigenvalues of
, and
is an orthogonal matrix whose columns are the eigenvectors of
.
is then given by
where
is the diagonal matrix whose
th diagonal element is
. See for example Section 4.5 of
Higham (2008).
is assumed to be real.
References
Higham N J (2008) Functions of Matrices: Theory and Computation SIAM, Philadelphia, PA, USA
Parameters
Compulsory Input Parameters
- 1:
– string (length ≥ 1)
-
If
, the upper triangle of the matrix
is stored.
If , the lower triangle of the matrix is stored.
Constraint:
or .
- 2:
– 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
symmetric matrix
.
- If , the upper triangular part of must be stored and the elements of the array below the diagonal are not referenced.
- If , the lower triangular part of must be stored and the elements of the array above the diagonal are not referenced.
- 3:
– function handle or string containing name of m-file
-
The function
f evaluates
at a number of points
.
[iflag, fx, user] = f(iflag, n, x, user)
Input Parameters
- 1:
– int64int32nag_int scalar
-
- 2:
– int64int32nag_int scalar
-
, the number of function values required.
- 3:
– double array
-
The points at which the function is to be evaluated.
- 4:
– Any MATLAB object
f is called from
nag_matop_real_symm_matrix_fun (f01ef) with the object supplied to
nag_matop_real_symm_matrix_fun (f01ef).
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, or may be complex. If
iflag is returned as nonzero then
nag_matop_real_symm_matrix_fun (f01ef) will terminate the computation, with
.
- 2:
– double array
-
The function values.
should return the value , for .
- 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_symm_matrix_fun (f01ef), 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
.
If , the upper or lower triangular part of the by matrix function, .
- 2:
– Any MATLAB object
- 3:
– int64int32nag_int scalar
-
, unless you have set
iflag nonzero inside
f, in which case
iflag will be the value you set and
ifail will be set to
.
- 4:
– 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:
-
-
The computation of the spectral factorization failed to converge.
-
-
Constraint: or .
-
-
Constraint: .
-
-
An internal error occurred when computing the spectral factorization. Please contact
NAG.
-
-
Constraint: .
-
-
iflag was set to a nonzero value in
f.
-
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
Provided that
can be computed accurately then the computed matrix function will be close to the exact matrix function. See Section 10.2 of
Higham (2008) for details and further discussion.
Further Comments
The integer allocatable memory required is
n, and the double allocatable memory required is approximately
, where
nb is the block size required by
nag_lapack_dsyev (f08fa).
The cost of the algorithm is
plus the cost of evaluating
. If
is the
th computed eigenvalue of
, then the user-supplied function
f will be asked to evaluate the function
at
,
.
For further information on matrix functions, see
Higham (2008).
nag_matop_complex_herm_matrix_fun (f01ff) can be used to find the matrix function
for a complex Hermitian matrix
.
Example
This example finds the matrix cosine,
, of the symmetric matrix
Open in the MATLAB editor:
f01ef_example
function f01ef_example
fprintf('f01ef example results\n\n');
uplo = 'u';
a = [1, 2, 3, 4;
0, 1, 2, 3;
0, 0, 1, 2;
0, 0, 0, 1];
[cosa, user, iflag, ifail] = f01ef(uplo, a, @f);
[ifail] = x04ca(uplo, 'n', cosa, 'Symmetric f(A) = cos(A)');
function [iflag, fx, user] = f(iflag, n, x, user)
fx = cos(x);
f01ef example results
Symmetric f(A) = cos(A)
1 2 3 4
1 -0.5420 -0.6612 -0.0261 0.1580
2 0.2306 -0.3396 -0.0261
3 0.2306 -0.6612
4 -0.5420
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015