f01gbf computes the action of the matrix exponential , on the matrix , where is a real matrix, is a real matrix and is a real scalar. It uses reverse communication for evaluating matrix products, so that the matrix is not accessed explicitly.
The routine may be called by the names f01gbf or nagf_matop_real_gen_matrix_actexp_rcomm.
3Description
is computed using the algorithm described in Al–Mohy and Higham (2011) which uses a truncated Taylor series to compute the without explicitly forming .
The algorithm does not explicity need to access the elements of ; it only requires the result of matrix multiplications of the form or . 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 thanb2, x, y, p and r must remain unchanged.
1: – IntegerInput/Output
On initial entry: must be set to .
On intermediate exit:
, , , or . The calling program must:
(a)if : evaluate , where is an matrix, and store the result in b2; if : evaluate , where and are matrices, and store the result in y; if : evaluate and store the result in x; if : evaluate and store the result in p; if : evaluate and store the result in r.
(b)call f01gbf again with all other parameters unchanged.
On final exit: .
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 does inadvertently return any NaNs or infinities, f01gbf is likely to produce unexpected results.
2: – IntegerInput
On entry: , the order of the matrix .
Constraint:
.
3: – IntegerInput
On entry: the number of columns of the matrix .
Constraint:
.
4: – Real (Kind=nag_wp) arrayInput/Output
Note: the second dimension of the array b
must be at least
.
On initial entry: the matrix .
On intermediate exit:
if , contains the matrix .
On intermediate re-entry: must not be changed.
On final exit: the matrix .
5: – IntegerInput
On entry: the first dimension of the array b as declared in the (sub)program from which f01gbf is called.
Constraint:
.
6: – Real (Kind=nag_wp)Input
On entry: the scalar .
7: – Real (Kind=nag_wp)Input
On entry: the trace of . If this is not available then any number can be supplied ( is a reasonable default); however, in the trivial case, , the result is immediately returned in the first row of . See Section 9.
8: – Real (Kind=nag_wp) arrayInput/Output
Note: the second dimension of the array b2
must be at least
.
On initial entry: need not be set.
On intermediate re-entry: if , must contain .
On final exit: the array is undefined.
9: – IntegerInput
On initial entry: the first dimension of the array b2 as declared in the (sub)program from which f01gbf is called.
Constraint:
.
10: – Real (Kind=nag_wp) arrayInput/Output
Note: the second dimension of the array x
must be at least
.
On initial entry: need not be set.
On intermediate exit:
if , contains the current matrix .
On intermediate re-entry: if , must contain .
On final exit: the array is undefined.
11: – IntegerInput
On entry: the first dimension of the array x as declared in the (sub)program from which f01gbf is called.
Constraint:
.
12: – Real (Kind=nag_wp) arrayInput/Output
Note: the second dimension of the array y
must be at least
.
On initial entry: need not be set.
On intermediate exit:
if , contains the current matrix .
On intermediate re-entry: if , must contain .
On final exit: the array is undefined.
13: – IntegerInput
On entry: the first dimension of the array y as declared in the (sub)program from which f01gbf is called.
Constraint:
.
14: – Real (Kind=nag_wp) arrayInput/Output
On initial entry: need not be set.
On intermediate re-entry: if , must contain .
On final exit: the array is undefined.
15: – Real (Kind=nag_wp) arrayInput/Output
On initial entry: need not be set.
On intermediate re-entry: if , must contain .
On final exit: the array is undefined.
16: – Real (Kind=nag_wp) arrayInput/Output
On initial entry: need not be set.
On intermediate exit:
if or , contains the vector .
On intermediate re-entry: must not be changed.
On final exit: the array is undefined.
17: – Real (Kind=nag_wp) arrayCommunication Array
18: – Integer arrayCommunication Array
19: – IntegerInput/Output
On initial entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended since useful values can be provided in some output arguments even when on exit. When the value or is used it is essential to test the value of ifail on exit.
On final exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
has been computed using an IEEE double precision Taylor series, although the arithmetic precision is higher than IEEE double precision.
On initial entry, . Constraint: .
On intermediate re-entry, . Constraint: , , , or .
On initial entry, . Constraint: .
On initial entry, . Constraint: .
On initial entry, and . Constraint: .
On initial entry, and . Constraint: .
On initial entry, and . Constraint: .
On initial entry, and . Constraint: .
An unexpected error has been triggered by this routine. Please
contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
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.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
7Accuracy
For a symmetric matrix (for which ) the computed matrix 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.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
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.
9Further Comments
9.1Use of
The elements of are not explicitly required by f01gbf. However, the trace of is used in the preprocessing phase of the algorithm. If is not available to the calling subroutine then any number can be supplied ( is recommended). This will not affect the stability of the algorithm, but it may reduce its efficiency.
9.2When to use f01gbf
f01gbf is designed to be used when 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 will not, in general, be sparse even if is sparse.
If is small and dense then f01gaf can be used to compute without the use of a reverse communication interface.
To compute , 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 is stored. If all the elements of are stored explicitly, then f06yaf) can be used. If is triangular then f06yff should be used. If is symmetric, then f06ycf should be used. For sparse stored in coordinate storage format f11xafandf11xef can be used. Alternatively if is stored in compressed column format f11mkf can be used.