NAG CL Interface
f01efc (real_​symm_​matrix_​fun)

1 Purpose

f01efc computes the matrix function, fA, of a real symmetric n by n matrix A. fA must also be a real symmetric matrix.

2 Specification

#include <nag.h>
void  f01efc (Nag_OrderType order, Nag_UploType uplo, Integer n, double a[], Integer pda,
void (*f)(Integer *flag, Integer n, const double x[], double fx[], Nag_Comm *comm),
Nag_Comm *comm, Integer *flag, NagError *fail)
The function may be called by the names: f01efc or nag_matop_real_symm_matrix_fun.

3 Description

fA is computed using a spectral factorization of A
A = Q D QT ,  
where D is the diagonal matrix whose diagonal elements, di, are the eigenvalues of A, and Q is an orthogonal matrix whose columns are the eigenvectors of A. fA is then given by
fA = Q fD QT ,  
where fD is the diagonal matrix whose ith diagonal element is fdi. See for example Section 4.5 of Higham (2008). fdi is assumed to be real.

4 References

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

5 Arguments

1: order Nag_OrderType Input
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by order=Nag_RowMajor. See Section 3.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint: order=Nag_RowMajor or Nag_ColMajor.
2: uplo Nag_UploType Input
On entry: if uplo=Nag_Upper, the upper triangle of the matrix A is stored.
If uplo=Nag_Lower, the lower triangle of the matrix A is stored.
Constraint: uplo=Nag_Upper or Nag_Lower.
3: n Integer Input
On entry: n, the order of the matrix A.
Constraint: n0.
4: a[dim] double Input/Output
Note: the dimension, dim, of the array a must be at least pda×n.
On entry: the n by n symmetric matrix A.
If order=Nag_ColMajor, Aij is stored in a[j-1×pda+i-1].
If order=Nag_RowMajor, Aij is stored in a[i-1×pda+j-1].
If uplo=Nag_Upper, the upper triangular part of A must be stored and the elements of the array below the diagonal are not referenced.
If uplo=Nag_Lower, the lower triangular part of A must be stored and the elements of the array above the diagonal are not referenced.
On exit: if fail.code= NE_NOERROR, the upper or lower triangular part of the n by n matrix function, fA.
5: pda Integer Input
On entry: the stride separating row or column elements (depending on the value of order) of the matrix A in the array a.
Constraint: pdamax1,n.
6: f function, supplied by the user External Function
The function f evaluates fzi at a number of points zi.
The specification of f is:
void  f (Integer *flag, Integer n, const double x[], double fx[], Nag_Comm *comm)
1: flag Integer * Input/Output
On entry: flag will be zero.
On exit: flag 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 fx; for instance fx may not be defined, or may be complex. If flag is returned as nonzero then f01efc will terminate the computation, with fail.code= NE_USER_STOP.
2: n Integer Input
On entry: n, the number of function values required.
3: x[n] const double Input
On entry: the n points x1,x2,,xn at which the function f is to be evaluated.
4: fx[n] double Output
On exit: the n function values. fx[i-1] should return the value fxi, for i=1,2,,n.
5: comm Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to f.
userdouble *
iuserInteger *
pPointer 
The type Pointer will be void *. Before calling f01efc you may allocate memory and initialize these pointers with various quantities for use by f when called from f01efc (see Section 3.1.1 in the Introduction to the NAG Library CL Interface).
Note: f should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by f01efc. If your code inadvertently does return any NaNs or infinities, f01efc is likely to produce unexpected results.
7: comm Nag_Comm *
The NAG communication argument (see Section 3.1.1 in the Introduction to the NAG Library CL Interface).
8: flag Integer * Output
On exit: flag=0, unless you have set flag nonzero inside f, in which case flag will be the value you set and fail will be set to fail.code= NE_USER_STOP.
9: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

The value of fail gives the number of off-diagonal elements of an intermediate tridiagonal form that did not converge to zero (see f08fac).
NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_CONVERGENCE
The computation of the spectral factorization failed to converge.
NE_INT
On entry, n=value.
Constraint: n0.
NE_INT_2
On entry, pda=value and n=value.
Constraint: pdan.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
An internal error occurred when computing the spectral factorization. Please contact NAG.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_USER_STOP
Termination requested in f.

7 Accuracy

Provided that fD 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.

8 Parallelism and Performance

f01efc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f01efc makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9 Further Comments

The Integer allocatable memory required is n, and the double allocatable memory required is approximately n+nb+4×n, where nb is the block size required by f08fac.
The cost of the algorithm is On3 plus the cost of evaluating fD. If λ^i is the ith computed eigenvalue of A, then the user-supplied function f will be asked to evaluate the function f at fλ^i, i=1,2,,n.
For further information on matrix functions, see Higham (2008).
f01ffc can be used to find the matrix function fA for a complex Hermitian matrix A.

10 Example

This example finds the matrix cosine, cosA, of the symmetric matrix
A= 1 2 3 4 2 1 2 3 3 2 1 2 4 3 2 1 .  

10.1 Program Text

Program Text (f01efce.c)

10.2 Program Data

Program Data (f01efce.d)

10.3 Program Results

Program Results (f01efce.r)