NAG CL Interface
f01hbc (complex_gen_matrix_actexp_rcomm)
1
Purpose
f01hbc computes the action of the matrix exponential ${e}^{tA}$, on the matrix $B$, where $A$ is a complex $n$ by $n$ matrix, $B$ is a complex $n$ by $m$ matrix and $t$ is a complex scalar. It uses reverse communication for evaluating matrix products, so that the matrix $A$ is not accessed explicitly.
2
Specification
void 
f01hbc (Integer *irevcm,
Integer n,
Integer m,
Complex b[],
Integer pdb,
Complex t,
Complex tr,
Complex b2[],
Integer pdb2,
Complex x[],
Integer pdx,
Complex y[],
Integer pdy,
Complex p[],
Complex r[],
Complex z[],
Complex ccomm[],
double comm[],
Integer icomm[],
NagError *fail) 

The function may be called by the names: f01hbc or nag_matop_complex_gen_matrix_actexp_rcomm.
3
Description
${e}^{tA}B$ is computed using the algorithm described in
Al–Mohy and Higham (2011) which uses a truncated Taylor series to compute the
${e}^{tA}B$ without explicitly forming
${e}^{tA}$.
The algorithm does not explicity need to access the elements of $A$; it only requires the result of matrix multiplications of the form $AX$ or ${A}^{\mathrm{H}}Y$. A reverse communication interface is used, in which control is returned to the calling program whenever a matrix product is required.
4
References
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) 488511
Higham N J (2008) Functions of Matrices: Theory and Computation SIAM, Philadelphia, PA, USA
5
Arguments
Note: this function uses
reverse communication. Its use involves an initial entry, intermediate exits and reentries, and a final exit, as indicated by the
argument irevcm. Between intermediate exits and reentries,
all arguments other than b2, x, y, p and r must remain unchanged.

1:
$\mathbf{irevcm}$ – Integer *
Input/Output

On initial entry: must be set to $0$.
On intermediate exit:
${\mathbf{irevcm}}=1$,
$2$,
$3$,
$4$ or
$5$. The calling program must:

(a)if ${\mathbf{irevcm}}=1$: evaluate ${B}_{2}=AB$, where ${B}_{2}$ is an $n$ by $m$ matrix, and store the result in b2;
if ${\mathbf{irevcm}}=2$: evaluate $Y=AX$, where $X$ and $Y$ are $n$ by $2$ matrices, and store the result in y;
if ${\mathbf{irevcm}}=3$: evaluate $X={A}^{\mathrm{H}}Y$ and store the result in x;
if ${\mathbf{irevcm}}=4$: evaluate $p=Az$ and store the result in p;
if ${\mathbf{irevcm}}=5$: evaluate $r={A}^{\mathrm{H}}z$ and store the result in r.

(b)call f01hbc again with all other parameters unchanged.
On final exit: ${\mathbf{irevcm}}=0$.
Note: any values you return to f01hbc as part of the reverse communication procedure should not include floatingpoint NaN (Not a Number) or infinity values, since these are not handled by f01hbc. If your code inadvertently does return any NaNs or infinities, f01hbc is likely to produce unexpected results.

2:
$\mathbf{n}$ – Integer
Input

On entry: $n$, the order of the matrix $A$.
Constraint:
${\mathbf{n}}\ge 0$.

3:
$\mathbf{m}$ – Integer
Input

On entry: the number of columns of the matrix $B$.
Constraint:
${\mathbf{m}}\ge 0$.

4:
$\mathbf{b}\left[\mathit{dim}\right]$ – Complex
Input/Output

Note: the dimension,
dim, of the array
b
must be at least
${\mathbf{pdb}}\times {\mathbf{m}}$.
The $\left(i,j\right)$th element of the matrix $B$ is stored in ${\mathbf{b}}\left[\left(j1\right)\times {\mathbf{pdb}}+i1\right]$.
On initial entry: the $n$ by $m$ matrix $B$.
On intermediate exit:
if ${\mathbf{irevcm}}=1$, contains the $n$ by $m$ matrix $B$.
On intermediate reentry: must not be changed.
On final exit: the $n$ by $m$ matrix ${e}^{tA}B$.

5:
$\mathbf{pdb}$ – Integer
Input

On entry: the stride separating matrix row elements in the array
b.
Constraint:
${\mathbf{pdb}}\ge {\mathbf{n}}$.

6:
$\mathbf{t}$ – Complex
Input

On entry: the scalar $t$.

7:
$\mathbf{tr}$ – Complex
Input

On entry: the trace of
$A$. If this is not available then any number can be supplied (
$0.0$ is a reasonable default); however, in the trivial case,
$n=1$, the result
${e}^{{\mathbf{tr}}t}B$ is immediately returned in the first row of
$B$. See
Section 9.

8:
$\mathbf{b2}\left[\mathit{dim}\right]$ – Complex
Input/Output

Note: the dimension,
dim, of the array
b2
must be at least
${\mathbf{pdb2}}\times {\mathbf{m}}$.
The $\left(i,j\right)$th element of the matrix is stored in ${\mathbf{b2}}\left[\left(j1\right)\times {\mathbf{pdb2}}+i1\right]$.
On initial entry: need not be set.
On intermediate reentry: if ${\mathbf{irevcm}}=1$, must contain $AB$.
On final exit: the array is undefined.

9:
$\mathbf{pdb2}$ – Integer
Input

On entry: the stride separating matrix row elements in the array
b2.
Constraint:
${\mathbf{pdb2}}\ge {\mathbf{n}}$.

10:
$\mathbf{x}\left[\mathit{dim}\right]$ – Complex
Input/Output

Note: the dimension,
dim, of the array
x
must be at least
${\mathbf{pdx}}\times 2$.
The $\left(i,j\right)$th element of the matrix $X$ is stored in ${\mathbf{x}}\left[\left(j1\right)\times {\mathbf{pdx}}+i1\right]$.
On initial entry: need not be set.
On intermediate exit:
if ${\mathbf{irevcm}}=2$, contains the current $n$ by $2$ matrix $X$.
On intermediate reentry: if ${\mathbf{irevcm}}=3$, must contain ${A}^{\mathrm{H}}Y$.
On final exit: the array is undefined.

11:
$\mathbf{pdx}$ – Integer
Input

On entry: the stride separating matrix row elements in the array
x.
Constraint:
${\mathbf{pdx}}\ge {\mathbf{n}}$.

12:
$\mathbf{y}\left[\mathit{dim}\right]$ – Complex
Input/Output

Note: the dimension,
dim, of the array
y
must be at least
${\mathbf{pdy}}\times 2$.
The $\left(i,j\right)$th element of the matrix $Y$ is stored in ${\mathbf{y}}\left[\left(j1\right)\times {\mathbf{pdy}}+i1\right]$.
On initial entry: need not be set.
On intermediate exit:
if ${\mathbf{irevcm}}=3$, contains the current $n$ by $2$ matrix $Y$.
On intermediate reentry: if ${\mathbf{irevcm}}=2$, must contain $AX$.
On final exit: the array is undefined.

13:
$\mathbf{pdy}$ – Integer
Input

On entry: the stride separating matrix row elements in the array
y.
Constraint:
${\mathbf{pdy}}\ge {\mathbf{n}}$.

14:
$\mathbf{p}\left[{\mathbf{n}}\right]$ – Complex
Input/Output

On initial entry: need not be set.
On intermediate reentry: if ${\mathbf{irevcm}}=4$, must contain $Az$.
On final exit: the array is undefined.

15:
$\mathbf{r}\left[{\mathbf{n}}\right]$ – Complex
Input/Output

On initial entry: need not be set.
On intermediate reentry: if ${\mathbf{irevcm}}=5$, must contain ${A}^{\mathrm{H}}z$.
On final exit: the array is undefined.

16:
$\mathbf{z}\left[{\mathbf{n}}\right]$ – Complex
Input/Output

On initial entry: need not be set.
On intermediate exit:
if ${\mathbf{irevcm}}=4$ or $5$, contains the vector $z$.
On intermediate reentry: must not be changed.
On final exit: the array is undefined.

17:
$\mathbf{ccomm}\left[{\mathbf{n}}\times \left({\mathbf{m}}+2\right)\right]$ – Complex
Communication Array


18:
$\mathbf{comm}\left[3\times {\mathbf{n}}+14\right]$ – double
Communication Array


19:
$\mathbf{icomm}\left[2\times {\mathbf{n}}+40\right]$ – Integer
Communication Array


20:
$\mathbf{fail}$ – NagError *
Input/Output

The NAG error argument (see
Section 7 in the Introduction to the NAG Library CL Interface).
6
Error 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 $\u2329\mathit{\text{value}}\u232a$ had an illegal value.
 NE_INT

On entry, ${\mathbf{m}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{m}}\ge 0$.
On entry, ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{n}}\ge 0$.
On initial entry, ${\mathbf{irevcm}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{irevcm}}=0$.
On intermediate reentry, ${\mathbf{irevcm}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{irevcm}}=1$, $2$, $3$, $4$ or $5$.
 NE_INT_2

On entry, ${\mathbf{pdb}}=\u2329\mathit{\text{value}}\u232a$ and ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{pdb}}\ge {\mathbf{n}}$.
On entry, ${\mathbf{pdb2}}=\u2329\mathit{\text{value}}\u232a$ and ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{pdb2}}\ge {\mathbf{n}}$.
On entry, ${\mathbf{pdx}}=\u2329\mathit{\text{value}}\u232a$ and ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{pdx}}\ge {\mathbf{n}}$.
On entry, ${\mathbf{pdy}}=\u2329\mathit{\text{value}}\u232a$ and ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{pdy}}\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.
7
Accuracy
For an 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 nonHermitian matrices. See Section 4 of
Al–Mohy and Higham (2011) for details and further discussion.
8
Parallelism and Performance
f01hbc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
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 implementationspecific information.
The elements of $A$ are not explicitly required by f01hbc. However, the trace of $A$ is used in the preprocessing phase of the algorithm. If $Tr\left(A\right)$ is not available to the calling function then any number can be supplied ($0$ is recommended). This will not affect the stability of the algorithm, but it may reduce its efficiency.
f01hbc is designed to be used when $A$ is large and sparse. Whenever a matrix multiplication is required, the function will return control to the calling program so that the multiplication can be done in the most efficient way possible. Note that ${e}^{tA}B$ will not, in general, be sparse even if $A$ is sparse.
If
$A$ is small and dense then
f01hac can be used to compute
${e}^{tA}B$ without the use of a reverse communication interface.
The real analog of
f01hbc is
f01gbc.
To compute
${e}^{tA}B$, the following skeleton code can normally be used:
do {
f01hbc(&irevcm,n,m,b,tdb,t,tr,b2,tdb2,x,tdx,y,tdy,p,r,z,ccomm,comm, &
icomm,&fail);
if (irevcm == 1) {
.. Code to compute B2=AB ..
}
else if (irevcm == 2){
.. Code to compute Y=AX ..
}
else if (irevcm == 3){
.. Code to compute X=A^H Y ..
}
else if (irevcm == 4){
.. Code to compute P=AZ ..
}
else if (irevcm == 5){
.. Code to compute R=A^H Z ..
}
} (while irevcm !=0)
The code used to compute the matrix products will vary depending on the way
$A$ is stored. If all the elements of
$A$ are stored explicitly, then
f16zac can be used. If
$A$ is triangular then
f16zfc should be used. If
$A$ is Hermitian, then
f16zcc should be used. If
$A$ is symmetric, then
f16ztc should be used. For sparse
$A$ stored in coordinate storage format
f11xnc and
f11xsc can be used. For sparse
$A$ stored in compressed column storage format (CCS) the program text of
Section 10 contains the function matmul to perform matrix products.
10
Example
This example computes
${e}^{tA}B$ where
and
$A$ is stored in compressed column storage format (CCS) and matrix multiplications are performed using the function matmul.
10.1
Program Text
10.2
Program Data
10.3
Program Results