NAG Library Function Document

nag_matop_complex_herm_matrix_fun (f01ffc)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

nag_matop_complex_herm_matrix_fun (f01ffc) computes the matrix function, fA, of a complex Hermitian n by n matrix A. fA must also be a complex Hermitian matrix.

2
Specification

#include <nag.h>
#include <nagf01.h>
void  nag_matop_complex_herm_matrix_fun (Nag_OrderType order, Nag_UploType uplo, Integer n, Complex 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 QH ,  
where D is the real diagonal matrix whose diagonal elements, di, are the eigenvalues of A, Q is a unitary matrix whose columns are the eigenvectors of A. fA is then given by
fA = Q fD QH ,  
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_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 3.3.1.3 in How to Use the NAG Library and its Documentation for a more detailed explanation of the use of this argument.
Constraint: order=Nag_RowMajor or Nag_ColMajor.
2:     uplo Nag_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:     n IntegerInput
On entry: n, the order of the matrix A.
Constraint: n0.
4:     a[dim] ComplexInput/Output
Note: the dimension, dim, of the array a must be at least pda×n.
On entry: the n by n Hermitian 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 IntegerInput
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 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:     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 nag_matop_complex_herm_matrix_fun (f01ffc) will terminate the computation, with fail.code= NE_USER_STOP.
2:     n IntegerInput
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:     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 nag_matop_complex_herm_matrix_fun (f01ffc) you may allocate memory and initialize these pointers with various quantities for use by f when called from nag_matop_complex_herm_matrix_fun (f01ffc) (see Section 3.3.1.1 in How to Use the NAG Library and its Documentation).
Note: f should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by nag_matop_complex_herm_matrix_fun (f01ffc). If your code inadvertently does return any NaNs or infinities, nag_matop_complex_herm_matrix_fun (f01ffc) is likely to produce unexpected results.
7:     comm Nag_Comm *
The NAG communication argument (see Section 3.3.1.1 in How to Use the NAG Library and its Documentation).
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 3.7 in How to Use the NAG Library and its Documentation).

6
Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation 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 2.7.6 in How to Use the NAG Library and its Documentation 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 2.7.5 in How to Use the NAG Library and its Documentation for further information.
NE_USER_STOP
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_complex_herm_matrix_fun (f01ffc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_matop_complex_herm_matrix_fun (f01ffc) 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, the double allocatable memory required is 4×n-2 and the Complex allocatable memory required is approximately n+nb+1×n, where nb is the block size required by nag_zheev (f08fnc).
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, for i=1,2,,n.
For further information on matrix functions, see Higham (2008).
nag_matop_real_symm_matrix_fun (f01efc) can be used to find the matrix function fA for a real symmetric matrix A.

10
Example

This example finds the matrix cosine, cosA, of the Hermitian matrix
A= 1 2+i 3+2i 4+3i 2-i 1 2+i 3+2i 3-2i 2-i 1 2+i 4-3i 3-2i 2-i 1 .  

10.1
Program Text

Program Text (f01ffce.c)

10.2
Program Data

Program Data (f01ffce.d)

10.3
Program Results

Program Results (f01ffce.r)

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