NAG FL Interfacef01hbf (complex_​gen_​matrix_​actexp_​rcomm)

▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

1Purpose

f01hbf 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. It uses reverse communication for evaluating matrix products, so that the matrix $A$ is not accessed explicitly.

2Specification

Fortran Interface
 Subroutine f01hbf ( n, m, b, ldb, t, tr, b2, ldb2, x, ldx, y, ldy, p, r, z, comm,
 Integer, Intent (In) :: n, m, ldb, ldb2, ldx, ldy Integer, Intent (Inout) :: irevcm, icomm(2*n+40), ifail Real (Kind=nag_wp), Intent (Inout) :: comm(3*n+14) Complex (Kind=nag_wp), Intent (In) :: t, tr Complex (Kind=nag_wp), Intent (Inout) :: b(ldb,*), b2(ldb2,*), x(ldx,*), y(ldy,*), p(n), r(n), z(n), ccomm(n*(m+2))
#include <nag.h>
 void f01hbf_ (Integer *irevcm, const Integer *n, const Integer *m, Complex b[], const Integer *ldb, const Complex *t, const Complex *tr, Complex b2[], const Integer *ldb2, Complex x[], const Integer *ldx, Complex y[], const Integer *ldy, Complex p[], Complex r[], Complex z[], Complex ccomm[], double comm[], Integer icomm[], Integer *ifail)
The routine may be called by the names f01hbf or nagf_matop_complex_gen_matrix_actexp_rcomm.

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 ${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.

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

Note:  this routine uses reverse communication. Its use involves an initial entry, intermediate exits and re-entries, and a final exit, as indicated by the argument irevcm. Between intermediate exits and re-entries, 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:
1. (a)if ${\mathbf{irevcm}}=1$: evaluate ${B}_{2}=AB$, where ${B}_{2}$ is an $n×m$ matrix, and store the result in b2;
if ${\mathbf{irevcm}}=2$: evaluate $Y=AX$, where $X$ and $Y$ are $n×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.
2. (b)call f01hbf again with all other parameters unchanged.
On final exit: ${\mathbf{irevcm}}=0$.
Note: any values you return to f01hbf as part of the reverse communication procedure should not include floating-point NaN (Not a Number) or infinity values, since these are not handled by f01hbf. If your code does inadvertently return any NaNs or infinities, f01hbf 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({\mathbf{ldb}},*\right)$Complex (Kind=nag_wp) array Input/Output
Note: the second dimension of the array b must be at least ${\mathbf{m}}$.
On initial entry: the $n×m$ matrix $B$.
On intermediate exit: if ${\mathbf{irevcm}}=1$, contains the $n×m$ matrix $B$.
On intermediate re-entry: must not be changed.
On final exit: the $n×m$ matrix ${e}^{tA}B$.
5: $\mathbf{ldb}$Integer Input
On entry: the first dimension of the array b as declared in the (sub)program from which f01hbf is called.
Constraint: ${\mathbf{ldb}}\ge {\mathbf{n}}$.
6: $\mathbf{t}$Complex (Kind=nag_wp) Input
On entry: the scalar $t$.
7: $\mathbf{tr}$Complex (Kind=nag_wp) 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({\mathbf{ldb2}},*\right)$Complex (Kind=nag_wp) array Input/Output
Note: the second dimension of the array b2 must be at least ${\mathbf{m}}$.
On initial entry: need not be set.
On intermediate re-entry: if ${\mathbf{irevcm}}=1$, must contain $AB$.
On final exit: the array is undefined.
9: $\mathbf{ldb2}$Integer Input
On initial entry: the first dimension of the array b2 as declared in the (sub)program from which f01hbf is called.
Constraint: ${\mathbf{ldb2}}\ge {\mathbf{n}}$.
10: $\mathbf{x}\left({\mathbf{ldx}},*\right)$Complex (Kind=nag_wp) array Input/Output
Note: the second dimension of the array x must be at least $2$.
On initial entry: need not be set.
On intermediate exit: if ${\mathbf{irevcm}}=2$, contains the current $n×2$ matrix $X$.
On intermediate re-entry: if ${\mathbf{irevcm}}=3$, must contain ${A}^{\mathrm{H}}Y$.
On final exit: the array is undefined.
11: $\mathbf{ldx}$Integer Input
On entry: the first dimension of the array x as declared in the (sub)program from which f01hbf is called.
Constraint: ${\mathbf{ldx}}\ge {\mathbf{n}}$.
12: $\mathbf{y}\left({\mathbf{ldy}},*\right)$Complex (Kind=nag_wp) array Input/Output
Note: the second dimension of the array y must be at least $2$.
On initial entry: need not be set.
On intermediate exit: if ${\mathbf{irevcm}}=3$, contains the current $n×2$ matrix $Y$.
On intermediate re-entry: if ${\mathbf{irevcm}}=2$, must contain $AX$.
On final exit: the array is undefined.
13: $\mathbf{ldy}$Integer Input
On entry: the first dimension of the array y as declared in the (sub)program from which f01hbf is called.
Constraint: ${\mathbf{ldy}}\ge {\mathbf{n}}$.
14: $\mathbf{p}\left({\mathbf{n}}\right)$Complex (Kind=nag_wp) array Input/Output
On initial entry: need not be set.
On intermediate re-entry: if ${\mathbf{irevcm}}=4$, must contain $Az$.
On final exit: the array is undefined.
15: $\mathbf{r}\left({\mathbf{n}}\right)$Complex (Kind=nag_wp) array Input/Output
On initial entry: need not be set.
On intermediate re-entry: 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 (Kind=nag_wp) array Input/Output
On initial entry: need not be set.
On intermediate exit: if ${\mathbf{irevcm}}=4$ or $5$, contains the vector $z$.
On intermediate re-entry: must not be changed.
On final exit: the array is undefined.
17: $\mathbf{ccomm}\left({\mathbf{n}}×\left({\mathbf{m}}+2\right)\right)$Complex (Kind=nag_wp) array Communication Array
18: $\mathbf{comm}\left(3×{\mathbf{n}}+14\right)$Real (Kind=nag_wp) array Communication Array
19: $\mathbf{icomm}\left(2×{\mathbf{n}}+40\right)$Integer array Communication Array
20: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=2$
${e}^{tA}B$ has been computed using an IEEE double precision Taylor series, although the arithmetic precision is higher than IEEE double precision.
${\mathbf{ifail}}=-1$
On initial entry, ${\mathbf{irevcm}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{irevcm}}=0$.
On intermediate re-entry, ${\mathbf{irevcm}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{irevcm}}=1$, $2$, $3$, $4$ or $5$.
${\mathbf{ifail}}=-2$
On initial entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 0$.
${\mathbf{ifail}}=-3$
On initial entry, ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{m}}\ge 0$.
${\mathbf{ifail}}=-5$
On initial entry, ${\mathbf{ldb}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ldb}}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=-9$
On initial entry, ${\mathbf{ldb2}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ldb2}}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=-11$
On initial entry, ${\mathbf{ldx}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ldx}}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=-13$
On initial entry, ${\mathbf{ldy}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ldy}}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7Accuracy

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 non-Hermitian matrices. See Section 4 of Al–Mohy and Higham (2011) for details and further discussion.

8Parallelism and Performance

f01hbf 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 routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9.1Use of $\mathbit{T}\mathbit{r}\left(\mathbit{A}\right)$

The elements of $A$ are not explicitly required by f01hbf. 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 subroutine then any number can be supplied ($0$ is recommended). This will not affect the stability of the algorithm, but it may reduce its efficiency.

9.2When to use f01hbf

f01hbf is designed to be used when $A$ is large and sparse. Whenever a matrix multiplication is required, the routine 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 f01haf can be used to compute ${e}^{tA}B$ without the use of a reverse communication interface.
The real analog of f01hbf is f01gbf.

9.3Use in Conjunction with NAG Library Routines

To compute ${e}^{tA}B$, the following skeleton code can normally be used:
```revcm: Do
Call f01hbf(irevcm,n,m,b,ldb,t,tr,b2,ldb2,x,ldx,y,ldx,p,r,z, &
ccomm,comm,icomm,ifail)
If (irevcm == 0) Then
Exit revcm
Else If (irevcm == 1) Then
.. Code to compute b2=ab ..
Else If (irevcm == 2) Then
.. Code to compute y=ax ..
Else If (irevcm == 3) Then
.. Code to compute x=a^h y ..
Else If (irevcm == 4) Then
.. Code to compute p=az ..
Else If (irevcm == 5) Then
.. Code to compute r=a^h z ..
End If
End Do revcm```
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 f06zaf can be used. If $A$ is triangular then f06zff should be used. If $A$ is Hermitian, then f06zcf should be used. If $A$ is symmetric, then f06ztf should be used. For sparse $A$ stored in coordinate storage format f11xnf and f11xsf can be used.

10Example

This example computes ${e}^{tA}B$ where
 $A = ( 0.7+0.8i -0.2+0.0i 1.0+0.0i 0.6+0.5i 0.3+0.7i 0.7+0.0i 0.9+3.0i 1.0+0.8i 0.3+3.0i -0.7+0.0i 0.2+0.6i 0.7+0.5i 0.0+0.9i 4.0+0.0i 0.0+0.0i 0.2+0.0i ) ,$
 $B = ( 0.1+0.0i 1.2+0.1i 1.3+0.9i -0.2+2.0i 4.0+0.6i -1.0+0.8i 0.4+0.0i -0.9+0.0i )$
and
 $t=1.1+0.0i .$
$A$ is stored in compressed column storage format (CCS) and matrix multiplications are performed using the routine matmul.

10.1Program Text

Program Text (f01hbfe.f90)

10.2Program Data

Program Data (f01hbfe.d)

10.3Program Results

Program Results (f01hbfe.r)