# NAG CL Interfacef01hac (complex_​gen_​matrix_​actexp)

Settings help

CL Name Style:

## 1Purpose

f01hac computes the action of the matrix exponential ${e}^{tA}$, on the matrix $B$, where $A$ is a complex $n×n$ matrix, $B$ is a complex $n×m$ matrix and $t$ is a complex scalar.

## 2Specification

 #include
 void f01hac (Integer n, Integer m, Complex a[], Integer pda, Complex b[], Integer pdb, Complex t, NagError *fail)
The function may be called by the names: f01hac or nag_matop_complex_gen_matrix_actexp.

## 3Description

${e}^{tA}B$ is computed using the algorithm described in Al–Mohy and Higham (2011) which uses a truncated Taylor series to compute the product ${e}^{tA}B$ without explicitly forming ${e}^{tA}$.

## 4References

Al–Mohy A H and Higham N J (2011) Computing the action of the matrix exponential, with an application to exponential integrators SIAM J. Sci. Statist. Comput. 33(2) 488-511
Higham N J (2008) Functions of Matrices: Theory and Computation SIAM, Philadelphia, PA, USA

## 5Arguments

1: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
2: $\mathbf{m}$Integer Input
On entry: $m$, the number of columns of the matrix $B$.
Constraint: ${\mathbf{m}}\ge 0$.
3: $\mathbf{a}\left[\mathit{dim}\right]$Complex Input/Output
Note: the dimension, dim, of the array a must be at least ${\mathbf{pda}}×{\mathbf{n}}$.
The $\left(i,j\right)$th element of the matrix $A$ is stored in ${\mathbf{a}}\left[\left(j-1\right)×{\mathbf{pda}}+i-1\right]$.
On entry: the $n×n$ matrix $A$.
On exit: $A$ is overwritten during the computation.
4: $\mathbf{pda}$Integer Input
On entry: the stride separating matrix row elements in the array a.
Constraint: ${\mathbf{pda}}\ge {\mathbf{n}}$.
5: $\mathbf{b}\left[\mathit{dim}\right]$Complex Input/Output
Note: the dimension, dim, of the array b must be at least ${\mathbf{pdb}}×{\mathbf{m}}$.
The $\left(i,j\right)$th element of the matrix $B$ is stored in ${\mathbf{b}}\left[\left(j-1\right)×{\mathbf{pdb}}+i-1\right]$.
On entry: the $n×m$ matrix $B$.
On exit: the $n×m$ matrix ${e}^{tA}B$.
6: $\mathbf{pdb}$Integer Input
On entry: the stride separating matrix row elements in the array b.
Constraint: ${\mathbf{pdb}}\ge {\mathbf{n}}$.
7: $\mathbf{t}$Complex Input
On entry: the scalar $t$.
8: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

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 $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_INT
On entry, ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{m}}\ge 0$.
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 0$.
NE_INT_2
On entry, ${\mathbf{pda}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pda}}\ge {\mathbf{n}}$.
On entry, ${\mathbf{pdb}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdb}}\ge {\mathbf{n}}$.
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.
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.
NW_SOME_PRECISION_LOSS
${e}^{tA}B$ has been computed using an IEEE double precision Taylor series, although the arithmetic precision is higher than IEEE double precision.

## 7Accuracy

For a Hermitian matrix $A$ (for which ${A}^{\mathrm{H}}=A$) the computed matrix ${e}^{tA}B$ is guaranteed to be close to the exact matrix, that is, the method is forward stable. No such guarantee can be given for non-Hermitian matrices. See Section 4 of Al–Mohy and Higham (2011) for details and further discussion.

## 8Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
f01hac is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f01hac 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.

## 9Further Comments

The matrix ${e}^{tA}B$ could be computed by explicitly forming ${e}^{tA}$ using f01fcc and multiplying $B$ by the result. However, experiments show that it is usually both more accurate and quicker to use f01hac.
The cost of the algorithm is $\mathit{O}\left({n}^{2}m\right)$. The precise cost depends on $A$ since a combination of balancing, shifting and scaling is used prior to the Taylor series evaluation.
Approximately ${n}^{2}+\left(2m+8\right)n$ of complex allocatable memory is required by f01hac.
f01gac can be used to compute ${e}^{tA}B$ for real $A$, $B$, and $t$. f01hbc provides an implementation of the algorithm with a reverse communication interface, which returns control to the calling program when matrix multiplications are required. This should be used if $A$ is large and sparse.

## 10Example

This example computes ${e}^{tA}B$, where
 $A = ( 0.5+0.0i -0.2+0.0i 1.0+0.1i 0.0+0.4i 0.3+0.0i 0.5+1.2i 3.1+0.0i 1.0+0.2i 0.0+2.0i 0.1+0.0i 1.2+0.2i 0.5+0.0i 1.0+0.3i 0.0+0.2i 0.0+0.9i 0.5+0.0i ) ,$
 $B = ( 0.4+0.0i 1.2+0.0i 1.3+0.0i -0.2+0.1i 0.0+0.3i 2.1+0.0i 0.4+0.0i -0.9+0.0i )$
and
 $t=-0.5+0.0i .$

### 10.1Program Text

Program Text (f01hace.c)

### 10.2Program Data

Program Data (f01hace.d)

### 10.3Program Results

Program Results (f01hace.r)