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


public static void f01ef(
	string uplo,
	int n,
	double[,] a,
	F01..::..F01EF_F f,
	out int iflag,
	out int ifail
Visual Basic
Public Shared Sub f01ef ( _
	uplo As String, _
	n As Integer, _
	a As Double(,), _
	f As F01..::..F01EF_F, _
	<OutAttribute> ByRef iflag As Integer, _
	<OutAttribute> ByRef ifail As Integer _
Visual C++
static void f01ef(
	String^ uplo, 
	int n, 
	array<double,2>^ a, 
	F01..::..F01EF_F^ f, 
	[OutAttribute] int% iflag, 
	[OutAttribute] int% ifail
static member f01ef : 
        uplo : string * 
        n : int * 
        a : float[,] * 
        f : F01..::..F01EF_F * 
        iflag : int byref * 
        ifail : int byref -> unit 


Type: System..::..String
On entry: if uplo="U", the upper triangle of the matrix A is stored.
If uplo="L", the lower triangle of the matrix A is stored.
Constraint: uplo="U" or "L".
Type: System..::..Int32
On entry: n, the order of the matrix A.
Constraint: n0.
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, dim2]
Note: dim1 must satisfy the constraint: dim1max1,n
Note: the second dimension of the array a must be at least n.
On entry: the n by n symmetric matrix A.
  • If uplo="U", the upper triangular part of A must be stored and the elements of the array below the diagonal are not referenced.
  • If uplo="L", the lower triangular part of A must be stored and the elements of the array above the diagonal are not referenced.
On exit: if ifail=0, the upper or lower triangular part of the n by n matrix function, fA.
Type: NagLibrary..::..F01..::..F01EF_F
The method f evaluates fzi at a number of points zi.

A delegate of type F01EF_F.

Type: System..::..Int32%
On exit: iflag=0, unless you have set iflag nonzero inside f, in which case iflag will be the value you set and ifail will be set to ifail=-6.
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).


fA is computed using a spectral factorization of A 
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
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.


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

Error Indicators and Warnings

Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (LDA) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
ifail<0andifail-999 or -6
If ifail=-i, the ith argument had an illegal value.
iflag has been set nonzero by the user.
Internal memory allocation failed.
The integer allocatable memory required is n, and the real allocatable memory required is approximately n+nb+4×n, where nb is the block size required by f08fa.
The algorithm to compute the spectral factorization failed to converge; i off-diagonal elements of an intermediate tridiagonal form did not converge to zero (see f08fa).
Note:  this failure is unlikely to occur.
An error occured, see message report.
Invalid Parameters value
Invalid dimension for array value
Negative dimension for array value
Invalid Parameters value


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.

Parallelism and Performance


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 method 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).
f01ff can be used to find the matrix function fA for a complex Hermitian matrix A.


This example finds the matrix cosine, cosA, of the symmetric matrix

Example program (C#): f01efe.cs

Example program data: f01efe.d

Example program results: f01efe.r

See Also