NAG Library Routine Document

f01gbf  (real_gen_matrix_actexp_rcomm)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

f01gbf computes the action of the matrix exponential etA, on the matrix B, where A is a real n by n matrix, B is a real n by m matrix and t is a real scalar. It uses reverse communication for evaluating matrix products, so that the matrix A is not accessed explicitly.

2
Specification

Fortran Interface
Subroutine f01gbf ( irevcm, n, m, b, ldb, t, tr, b2, ldb2, x, ldx, y, ldy, p, r, z, comm, icomm, ifail)
Integer, Intent (In):: n, m, ldb, ldb2, ldx, ldy
Integer, Intent (Inout):: irevcm, icomm(2*n+40), ifail
Real (Kind=nag_wp), Intent (In):: t, tr
Real (Kind=nag_wp), Intent (Inout):: b(ldb,*), b2(ldb2,*), x(ldx,*), y(ldy,*), p(n), r(n), z(n), comm(n*m+3*n+12)
C Header Interface
#include nagmk26.h
void  f01gbf_ ( Integer *irevcm, const Integer *n, const Integer *m, double b[], const Integer *ldb, const double *t, const double *tr, double b2[], const Integer *ldb2, double x[], const Integer *ldx, double y[], const Integer *ldy, double p[], double r[], double z[], double comm[], Integer icomm[], Integer *ifail)

3
Description

etAB is computed using the algorithm described in Al–Mohy and Higham (2011) which uses a truncated Taylor series to compute the etAB without explicitly forming etA.
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 ATY. 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) 488-511
Higham N J (2008) Functions of Matrices: Theory and Computation SIAM, Philadelphia, PA, USA

5
Arguments

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:     irevcm – IntegerInput/Output
On initial entry: must be set to 0.
On intermediate exit: irevcm=1, 2, 3, 4 or 5. The calling program must:
(a) if irevcm=1: evaluate B2=AB, where B2 is an n by m matrix, and store the result in b2;
if irevcm=2: evaluate Y=AX, where X and Y are n by 2 matrices, and store the result in y;
if irevcm=3: evaluate X=ATY and store the result in x;
if irevcm=4: evaluate p=Az and store the result in p;
if irevcm=5: evaluate r=ATz and store the result in r.
(b) call f01gbf again with all other parameters unchanged.
On final exit: irevcm=0.
Note: any values you return to f01gbf 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 f01gbf. If your code inadvertently does return any NaNs or infinities, f01gbf is likely to produce unexpected results.
2:     n – IntegerInput
On entry: n, the order of the matrix A.
Constraint: n0.
3:     m – IntegerInput
On entry: the number of columns of the matrix B.
Constraint: m0.
4:     bldb* – Real (Kind=nag_wp) arrayInput/Output
Note: the second dimension of the array b must be at least m.
On initial entry: the n by m matrix B.
On intermediate exit: if irevcm=1, contains the n by m matrix B.
On intermediate re-entry: must not be changed.
On final exit: the n by m matrix etAB.
5:     ldb – IntegerInput
On entry: the first dimension of the array b as declared in the (sub)program from which f01gbf is called.
Constraint: ldbn.
6:     t – Real (Kind=nag_wp)Input
On entry: the scalar t.
7:     tr – Real (Kind=nag_wp)Input
On entry: the trace of A. If this is not available then any number can be supplied (0 is a reasonable default); however, in the trivial case, n=1, the result etrtB is immediately returned in the first row of B. See Section 9.
8:     b2ldb2* – Real (Kind=nag_wp) arrayInput/Output
Note: the second dimension of the array b2 must be at least m.
On initial entry: need not be set.
On intermediate re-entry: if irevcm=1, must contain AB.
On final exit: the array is undefined.
9:     ldb2 – IntegerInput
On initial entry: the first dimension of the array b2 as declared in the (sub)program from which f01gbf is called.
Constraint: ldb2n.
10:   xldx* – Real (Kind=nag_wp) arrayInput/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 irevcm=2, contains the current n by 2 matrix X.
On intermediate re-entry: if irevcm=3, must contain ATY.
On final exit: the array is undefined.
11:   ldx – IntegerInput
On entry: the first dimension of the array x as declared in the (sub)program from which f01gbf is called.
Constraint: ldxn.
12:   yldy* – Real (Kind=nag_wp) arrayInput/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 irevcm=3, contains the current n by 2 matrix Y.
On intermediate re-entry: if irevcm=2, must contain AX.
On final exit: the array is undefined.
13:   ldy – IntegerInput
On entry: the first dimension of the array y as declared in the (sub)program from which f01gbf is called.
Constraint: ldyn.
14:   pn – Real (Kind=nag_wp) arrayInput/Output
On initial entry: need not be set.
On intermediate re-entry: if irevcm=4, must contain Az.
On final exit: the array is undefined.
15:   rn – Real (Kind=nag_wp) arrayInput/Output
On initial entry: need not be set.
On intermediate re-entry: if irevcm=5, must contain ATz.
On final exit: the array is undefined.
16:   zn – Real (Kind=nag_wp) arrayInput/Output
On initial entry: need not be set.
On intermediate exit: if irevcm=4 or 5, contains the vector z.
On intermediate re-entry: must not be changed.
On final exit: the array is undefined.
17:   commn×m+3×n+12 – Real (Kind=nag_wp) arrayCommunication Array
18:   icomm2×n+40 – Integer arrayCommunication Array
19:   ifail – IntegerInput/Output
On initial entry: ifail must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, because for this routine the values of the output arguments may be useful even if ifail0 on exit, the recommended value is -1. When the value -1​ or ​1 is used it is essential to test the value of ifail on exit.
On final exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry 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:
ifail=2
etAB has been computed using an IEEE double precision Taylor series, although the arithmetic precision is higher than IEEE double precision.
ifail=-1
On initial entry, irevcm=value.
Constraint: irevcm=0.
On intermediate re-entry, irevcm=value.
Constraint: irevcm=1, 2, 3, 4 or 5.
ifail=-2
On initial entry, n=value.
Constraint: n0.
ifail=-3
On initial entry, m=value.
Constraint: m0.
ifail=-5
On initial entry, ldb=value and n=value.
Constraint: ldbn.
ifail=-9
On initial entry, ldb2=value and n=value.
Constraint: ldb2n.
ifail=-11
On initial entry, ldx=value and n=value.
Constraint: ldxn.
ifail=-13
On initial entry, ldy=value and n=value.
Constraint: ldyn.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

For a symmetric matrix A (for which AT=A) the computed matrix etAB is guaranteed to be close to the exact matrix, that is, the method is forward stable. No such guarantee can be given for non-symmetric matrices. See Section 4 of Al–Mohy and Higham (2011) for details and further discussion.

8
Parallelism and Performance

f01gbf 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
Further Comments

9.1
Use of TrA

The elements of A are not explicitly required by f01gbf. However, the trace of A is used in the preprocessing phase of the algorithm. If TrA 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.2
When to use f01gbf

f01gbf 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 etAB will not, in general, be sparse even if A is sparse.
If A is small and dense then f01gaf can be used to compute etAB without the use of a reverse communication interface.
The complex analog of f01gbf is f01hbf.

9.3
Use in Conjunction with NAG Library Routines

To compute etAB, the following skeleton code can normally be used:
revcm: Do 
  Call f01gbf(irevcm,n,m,b,ldb,t,tr,b2,ldb2,x,ldx,y,ldy,p,r,z, &
              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^t y ..
  Else If (irevcm == 4) Then
      .. Code to compute p=az ..
  Else If (irevcm == 5) Then 
      .. Code to compute r=a^t 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 f06yaf (dgemm)) can be used. If A is triangular then f06yff (dtrmm) should be used. If A is symmetric, then f06ycf (dsymm) should be used. For sparse A stored in coordinate storage format f11xaf and f11xef can be used. Alternatively if A is stored in compressed column format f11mkf can be used.

10
Example

This example computes etAB, where
A = 0.4 -0.2 1.3 0.6 0.3 0.8 1.0 1.0 3.0 4.8 0.2 0.7 0.5 0.0 -5.0 0.7 ,  
B = 0.1 1.1 1.7 -0.2 0.5 1.0 0.4 -0.2 ,  
and
t=-0.2 .  

10.1
Program Text

Program Text (f01gbfe.f90)

10.2
Program Data

Program Data (f01gbfe.d)

10.3
Program Results

Program Results (f01gbfe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017