nag_matop_real_symm_matrix_fun (f01efc) (PDF version)
f01 Chapter Contents
f01 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_matop_real_symm_matrix_fun (f01efc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_matop_real_symm_matrix_fun (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>
#include <nagf01.h>
void  nag_matop_real_symm_matrix_fun (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)

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:     orderNag_OrderTypeInput
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 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint: order=Nag_RowMajor or Nag_ColMajor.
2:     uploNag_UploTypeInput
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:     nIntegerInput
On entry: n, the order of the matrix A.
Constraint: n0.
4:     a[dim]doubleInput/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: the upper or lower triangular part of the n by n matrix function, fA.
5:     pdaIntegerInput
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:     ffunction, supplied by the userExternal 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:     flagInteger *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 nag_matop_real_symm_matrix_fun (f01efc) will terminate the computation, with fail.code= NE_USER_STOP.
2:     nIntegerInput
On entry: n, the number of function values required.
3:     x[n]const doubleInput
On entry: the n points x1,x2,,xn at which the function f is to be evaluated.
4:     fx[n]doubleOutput
On exit: the n function values. fx[i-1] should return the value fxi, for i=1,2,,n.
5:     commNag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to f.
userdouble *
iuserInteger *
The type Pointer will be void *. Before calling nag_matop_real_symm_matrix_fun (f01efc) you may allocate memory and initialize these pointers with various quantities for use by f when called from nag_matop_real_symm_matrix_fun (f01efc) (see Section in the Essential Introduction).
7:     commNag_Comm *Communication Structure
The NAG communication argument (see Section in the Essential Introduction).
8:     flagInteger *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:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

Dynamic memory allocation failed.
On entry, argument value had an illegal value.
The computation of the spectral factorization failed to converge.
On entry, n=value.
Constraint: n0.
On entry, pda=value and n=value.
Constraint: pdan.
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.
An internal error occurred when computing the spectral factorization. Please contact NAG.
flag was set to a nonzero value 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

nag_matop_real_symm_matrix_fun (f01efc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_matop_real_symm_matrix_fun (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 Users' Note for your implementation for any additional implementation-specific information.

9  Further Comments

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).
nag_matop_complex_herm_matrix_fun (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)

nag_matop_real_symm_matrix_fun (f01efc) (PDF version)
f01 Chapter Contents
f01 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2014