Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_matop_complex_gen_matrix_log (f01fj)

Purpose

nag_matop_complex_gen_matrix_log (f01fj) computes the principal matrix logarithm, $\mathrm{log}\left(A\right)$, of a complex $n$ by $n$ matrix $A$, with no eigenvalues on the closed negative real line.

Syntax

[a, ifail] = f01fj(a, 'n', n)
[a, ifail] = nag_matop_complex_gen_matrix_log(a, 'n', n)

Description

Any nonsingular matrix $A$ has infinitely many logarithms. For a matrix with no eigenvalues on the closed negative real line, the principal logarithm is the unique logarithm whose spectrum lies in the strip $\left\{z:-\pi <\mathrm{Im}\left(z\right)<\pi \right\}$. If $A$ is nonsingular but has eigenvalues on the negative real line, the principal logarithm is not defined, but nag_matop_complex_gen_matrix_log (f01fj) will return a non-principal logarithm.
$\mathrm{log}\left(A\right)$ is computed using the inverse scaling and squaring algorithm for the matrix logarithm described in Al–Mohy and Higham (2011).

References

Al–Mohy A H and Higham N J (2011) Improved inverse scaling and squaring algorithms for the matrix logarithm SIAM J. Sci. Comput. 34(4) C152–C169
Higham N J (2008) Functions of Matrices: Theory and Computation SIAM, Philadelphia, PA, USA

Parameters

Compulsory Input Parameters

1:     $\mathrm{a}\left(\mathit{lda},:\right)$ – complex array
The first dimension of the array a must be at least ${\mathbf{n}}$.
The second dimension of the array a must be at least ${\mathbf{n}}$.
The $n$ by $n$ matrix $A$.

Optional Input Parameters

1:     $\mathrm{n}$int64int32nag_int scalar
Default: the first dimension of the array a.
$n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.

Output Parameters

1:     $\mathrm{a}\left(\mathit{lda},:\right)$ – complex array
The first dimension of the array a will be ${\mathbf{n}}$.
The second dimension of the array a will be ${\mathbf{n}}$.
The $n$ by $n$ principal matrix logarithm, $\mathrm{log}\left(A\right)$, unless ${\mathbf{ifail}}={\mathbf{2}}$, in which case a non-principal logarithm is returned.
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

${\mathbf{ifail}}=1$
$A$ is singular so the logarithm cannot be computed.
W  ${\mathbf{ifail}}=2$
$A$ was found to have eigenvalues on the negative real line. The principal logarithm is not defined in this case, so a non-principal logarithm was returned.
W  ${\mathbf{ifail}}=3$
$\mathrm{log}\left(A\right)$ has been computed using an IEEE double precision Padé approximant, although the arithmetic precision is higher than IEEE double precision.
${\mathbf{ifail}}=4$
${\mathbf{ifail}}=-1$
Constraint: ${\mathbf{n}}\ge 0$.
${\mathbf{ifail}}=-3$
Constraint: $\mathit{lda}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

Accuracy

For a normal matrix $A$ (for which ${A}^{\mathrm{H}}A=A{A}^{\mathrm{H}}$), the Schur decomposition is diagonal and the algorithm reduces to evaluating the logarithm of the eigenvalues of $A$ and then constructing $\mathrm{log}\left(A\right)$ using the Schur vectors. This should give a very accurate result. In general, however, no error bounds are available for the algorithm. See Al–Mohy and Higham (2011) and Section 9.4 of Higham (2008) for details and further discussion.
The sensitivity of the computation of $\mathrm{log}\left(A\right)$ is worst when $A$ has an eigenvalue of very small modulus or has a complex conjugate pair of eigenvalues lying close to the negative real axis.
If estimates of the condition number of the matrix logarithm are required then nag_matop_complex_gen_matrix_cond_log (f01kj) should be used.

The cost of the algorithm is $O\left({n}^{3}\right)$ floating-point operations (see Al–Mohy and Higham (2011)). The complex allocatable memory required is approximately $3×{n}^{2}$.
If the Fréchet derivative of the matrix logarithm is required then nag_matop_complex_gen_matrix_frcht_log (f01kk) should be used.
nag_matop_real_gen_matrix_log (f01ej) can be used to find the principal logarithm of a real matrix.

Example

This example finds the principal matrix logarithm of the matrix
 $A = 1.0+2.0i 0.0+1.0i 1.0+0.0i 3.0+2.0i 0.0+3.0i -2.0+0.0i 0.0+0.0i 1.0+0.0i 1.0+0.0i -2.0+0.0i 3.0+2.0i 0.0+3.0i 2.0+0.0i 0.0+1.0i 0.0+1.0i 2.0+3.0i .$
```function f01fj_example

fprintf('f01fj example results\n\n');

a =  [1.0+2.0i,  0.0+1.0i, 1.0+0.0i, 3.0+2.0i;
0.0+3.0i, -2.0+0.0i, 0.0+0.0i, 1.0+0.0i;
1.0+0.0i, -2.0+0.0i, 3.0+2.0i, 0.0+3.0i;
2.0+0.0i,  0.0+1.0i, 0.0+1.0i, 2.0+3.0i];

% Compute log(a)
[loga, ifail] = f01fj(a);

disp('f(A) = log(A)');
disp(loga);

```
```f01fj example results

f(A) = log(A)
1.0390 + 1.1672i   0.2859 + 0.3998i   0.0516 - 0.2562i   0.7586 - 0.4678i
-2.7481 + 2.6187i   1.1898 - 2.2287i   0.1369 - 0.9128i   2.1771 - 1.0118i
-0.8514 + 0.3927i  -0.2517 - 0.4791i   1.3839 + 0.2129i   1.1920 + 0.4240i
1.1970 - 0.1242i  -0.6813 + 0.3969i   0.0051 + 0.3511i   0.7867 + 0.7502i

```