nag_matop_real_gen_matrix_actexp_rcomm (f01gbc) (PDF version)
f01 Chapter Contents
f01 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_matop_real_gen_matrix_actexp_rcomm (f01gbc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_matop_real_gen_matrix_actexp_rcomm (f01gbc) 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

#include <nag.h>
#include <nagf01.h>
void  nag_matop_real_gen_matrix_actexp_rcomm (Integer *irevcm, Integer n, Integer m, double b[], Integer pdb, double t, double tr, double b2[], Integer pdb2, double x[], Integer pdx, double y[], Integer pdy, double p[], double r[], double z[], double comm[], Integer icomm[], NagError *fail)

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 function 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:     irevcmInteger *Input/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 nag_matop_real_gen_matrix_actexp_rcomm (f01gbc) again with all other parameters unchanged.
On final exit: irevcm=0.
2:     nIntegerInput
On entry: n, the order of the matrix A.
Constraint: n0.
3:     mIntegerInput
On entry: the number of columns of the matrix B.
Constraint: m0.
4:     b[dim]doubleInput/Output
Note: the dimension, dim, of the array b must be at least pdb×m.
The i,jth element of the matrix B is stored in b[j-1×pdb+i-1].
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:     pdbIntegerInput
On entry: the stride separating matrix row elements in the array b.
Constraint: pdbn.
6:     tdoubleInput
On entry: the scalar t.
7:     trdoubleInput
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:     b2[dim]doubleInput/Output
Note: the dimension, dim, of the array b2 must be at least pdb2×m.
The i,jth element of the matrix is stored in b2[j-1×pdb2+i-1].
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:     pdb2IntegerInput
On entry: the stride separating matrix row elements in the array b2.
Constraint: pdb2n.
10:   x[dim]doubleInput/Output
Note: the dimension, dim, of the array x must be at least pdx×2.
The i,jth element of the matrix X is stored in x[j-1×pdx+i-1].
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:   pdxIntegerInput
On entry: the stride separating matrix row elements in the array x.
Constraint: pdxn.
12:   y[dim]doubleInput/Output
Note: the dimension, dim, of the array y must be at least pdy×2.
The i,jth element of the matrix Y is stored in y[j-1×pdy+i-1].
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:   pdyIntegerInput
On entry: the stride separating matrix row elements in the array y.
Constraint: pdyn.
14:   p[n]doubleInput/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:   r[n]doubleInput/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:   z[n]doubleInput/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:   comm[n×m+3×n+12]doubleCommunication Array
18:   icomm[2×n+40]IntegerCommunication Array
19:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, m=value.
Constraint: m0.
On entry, n=value.
Constraint: n0.
On initial entry, irevcm=value.
Constraint: irevcm=0.
On intermediate re-entry, irevcm=value.
Constraint: irevcm=1, 2, 3, 4 or 5.
NE_INT_2
On entry, pdb=value and n=value.
Constraint: pdbn.
On entry, pdb2=value and n=value.
Constraint: pdb2n.
On entry, pdx=value and n=value.
Constraint: pdxn.
On entry, pdy=value and n=value.
Constraint: pdyn.
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.
NW_SOME_PRECISION_LOSS
etAB has been computed using an IEEE double precision Taylor series, although the arithmetic precision is higher than IEEE double precision.

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

nag_matop_real_gen_matrix_actexp_rcomm (f01gbc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please 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 nag_matop_real_gen_matrix_actexp_rcomm (f01gbc). However, the trace of A is used in the preprocessing phase of the algorithm. If TrA 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.

9.2  When to use nag_matop_real_gen_matrix_actexp_rcomm (f01gbc)

nag_matop_real_gen_matrix_actexp_rcomm (f01gbc) 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 etAB will not, in general, be sparse even if A is sparse.
If A is small and dense then nag_matop_real_gen_matrix_actexp (f01gac) can be used to compute etAB without the use of a reverse communication interface.
The complex analog of nag_matop_real_gen_matrix_actexp_rcomm (f01gbc) is nag_matop_complex_gen_matrix_actexp_rcomm (f01hbc).

9.3  Use in Conjunction with NAG C Library Functions

To compute etAB, the following skeleton code can normally be used:
do {
f01gbc(&irevcm,n,m,b,tdb,t,tr,b2,tdb2,x,tdx,y,tdy,p,r,z,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^T Y ..
  }
  else if (irevcm == 4){
    .. Code to compute P=AZ ..
  }
  else if (irevcm == 5){
    .. Code to compute R=A^T 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 nag_dgemm (f16yac)) can be used. If A is triangular then nag_dtrmm (f16yfc) should be used. If A is symmetric, then nag_dsymm (f16ycc) should be used. For sparse A stored in coordinate storage format nag_sparse_nsym_matvec (f11xac) and nag_sparse_sym_matvec (f11xec) can be used. Alternatively if A is stored in compressed column format nag_superlu_matrix_product (f11mkc) 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 (f01gbce.c)

10.2  Program Data

Program Data (f01gbce.d)

10.3  Program Results

Program Results (f01gbce.r)


nag_matop_real_gen_matrix_actexp_rcomm (f01gbc) (PDF version)
f01 Chapter Contents
f01 Chapter Introduction
NAG Library Manual

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