NAG FL Interface
d01eaf (md_adapt_multi)
1
Purpose
d01eaf computes approximations to the integrals of a vector of similar functions, each defined over the same multidimensional hyper-rectangular region. The routine uses an adaptive subdivision strategy, and also computes absolute error estimates.
2
Specification
Fortran Interface
Subroutine d01eaf ( |
ndim, a, b, mincls, maxcls, nfun, funsub, absreq, relreq, lenwrk, wrkstr, finest, absest, ifail) |
Integer, Intent (In) |
:: |
ndim, maxcls, nfun, lenwrk |
Integer, Intent (Inout) |
:: |
mincls, ifail |
Real (Kind=nag_wp), Intent (In) |
:: |
a(ndim), b(ndim), absreq, relreq |
Real (Kind=nag_wp), Intent (Inout) |
:: |
wrkstr(lenwrk) |
Real (Kind=nag_wp), Intent (Out) |
:: |
finest(nfun), absest(nfun) |
External |
:: |
funsub |
|
C Header Interface
#include <nag.h>
void |
d01eaf_ (const Integer *ndim, const double a[], const double b[], Integer *mincls, const Integer *maxcls, const Integer *nfun, void (NAG_CALL *funsub)(const Integer *ndim, const double z[], const Integer *nfun, double f[]), const double *absreq, const double *relreq, const Integer *lenwrk, double wrkstr[], double finest[], double absest[], Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
d01eaf_ (const Integer &ndim, const double a[], const double b[], Integer &mincls, const Integer &maxcls, const Integer &nfun, void (NAG_CALL *funsub)(const Integer &ndim, const double z[], const Integer &nfun, double f[]), const double &absreq, const double &relreq, const Integer &lenwrk, double wrkstr[], double finest[], double absest[], Integer &ifail) |
}
|
The routine may be called by the names d01eaf or nagf_quad_md_adapt_multi.
3
Description
d01eaf uses a globally adaptive method based on the algorithm described by
van Dooren and de Ridder (1976) and
Genz and Malik (1980). It is implemented for integrals in the form:
where
, for
.
Upon entry, unless
mincls has been set to a value less than or equal to
,
d01eaf divides the integration region into a number of subregions with randomly selected volumes. Inside each subregion the integrals and their errors are estimated. The initial number of subregions is chosen to be as large as possible without using more than
mincls calls to
funsub. The results are stored in a partially ordered list (a heap). The routine then proceeds in stages. At each stage the subregion with the largest error (measured using the maximum norm) is halved along the coordinate axis where the integrands have largest absolute fourth differences. The basic rule is applied to each half of this subregion and the results are stored in the list. The results from the two halves are used to update the global integral and error estimates (
finest and
absest) and the routine continues unless
where the norm
is the maximum norm, or further subdivision would use more than
maxcls calls to
funsub. If at some stage there is insufficient working storage to keep the results for the next subdivision, the routine switches to a less efficient mode; only if this mode of operation breaks down is insufficient storage reported.
4
References
Genz A C and Malik A A (1980) An adaptive algorithm for numerical integration over an N-dimensional rectangular region J. Comput. Appl. Math. 6 295–302
van Dooren P and de Ridder L (1976) An adaptive algorithm for numerical integration over an N-dimensional cube J. Comput. Appl. Math. 2 207–217
5
Arguments
-
1:
– Integer
Input
-
On entry: , the number of dimensions of the integrals.
Constraint:
.
-
2:
– Real (Kind=nag_wp) array
Input
-
On entry: the lower limits of integration,
, for .
-
3:
– Real (Kind=nag_wp) array
Input
-
On entry: the upper limits of integration,
, for .
-
4:
– Integer
Input/Output
-
On entry: must be set either to the minimum number of
funsub calls to be allowed, in which case
or to a negative value. In this case, the routine continues the calculation started in a previous call with the same integrands and integration limits: no arguments other than
mincls,
maxcls,
absreq,
relreq or
ifail must be changed between the calls.
On exit: gives the number of
funsub calls actually used by
d01eaf. For the continuation case (
on entry) this is the number of new
funsub calls on the current call to
d01eaf.
-
5:
– Integer
Input
-
On entry: the maximum number of
funsub calls to be allowed. In the continuation case this is the number of new
funsub calls to be allowed.
Constraints:
- ;
- ;
- .
-
6:
– Integer
Input
-
On entry: , the number of integrands.
Constraint:
.
-
7:
– Subroutine, supplied by the user.
External Procedure
-
funsub must evaluate the integrands
at a given point.
The specification of
funsub is:
Fortran Interface
Integer, Intent (In) |
:: |
ndim, nfun |
Real (Kind=nag_wp), Intent (In) |
:: |
z(ndim) |
Real (Kind=nag_wp), Intent (Out) |
:: |
f(nfun) |
|
C Header Interface
void |
funsub_ (const Integer *ndim, const double z[], const Integer *nfun, double f[]) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
funsub_ (const Integer &ndim, const double z[], const Integer &nfun, double f[]) |
}
|
-
1:
– Integer
Input
-
On entry: , the number of dimensions of the integrals.
-
2:
– Real (Kind=nag_wp) array
Input
-
On entry: the coordinates of the point at which the integrands must be evaluated.
-
3:
– Integer
Input
-
On entry: , the number of integrands.
-
4:
– Real (Kind=nag_wp) array
Output
-
On exit: the value of the th integrand at the given point.
funsub must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which
d01eaf is called. Arguments denoted as
Input must
not be changed by this procedure.
Note: funsub should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by
d01eaf. If your code inadvertently
does return any NaNs or infinities,
d01eaf is likely to produce unexpected results.
-
8:
– Real (Kind=nag_wp)
Input
-
On entry: the absolute accuracy required by you.
Constraint:
.
-
9:
– Real (Kind=nag_wp)
Input
-
On entry: the relative accuracy required by you.
Constraint:
.
-
10:
– Integer
Input
-
On entry: the dimension of the array
wrkstr as declared in the (sub)program from which
d01eaf is called.
Suggested value:
, where
is the value of
maxcls and
is defined under
maxcls. If
lenwrk is significantly smaller than this, the routine will not work as efficiently and may even fail.
Constraint:
.
-
11:
– Real (Kind=nag_wp) array
Input/Output
-
On entry: if
,
wrkstr must be unchanged from the previous call of
d01eaf.
On exit: contains information about the current subdivision which could be used in a continuation call.
-
12:
– Real (Kind=nag_wp) array
Output
-
On exit: specifies the best estimate obtained from the th integral, for .
-
13:
– Real (Kind=nag_wp) array
Output
-
On exit: specifies the estimated absolute accuracy of , for .
-
14:
– Integer
Input/Output
-
On 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 exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error 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:
-
maxcls too small to obtain required accuracy.
.
-
lenwrk too small for the routine to continue.
.
-
maxcls too small to make any progress.
.
-
On entry,
lenwrk is too small.
. Minimum possible dimension:
.
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
On entry, .
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.
7
Accuracy
An absolute error estimate for each integrand is output in the array
absest. The routine exits with
if
8
Parallelism and Performance
d01eaf 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.
Usually the running time for
d01eaf will be dominated by the time in
funsub, so the maximum time that could be used by
d01eaf will be proportional to
maxcls multiplied by the cost of a call to
funsub.
On a normal call, you should set on entry.
For some integrands, particularly those that are poorly behaved in a small part of the integration region,
d01eaf may terminate prematurely with values of
absest that are significantly smaller than the actual absolute errors. This behaviour should be suspected if the returned value of
mincls is small relative to the expected difficulty of the integrals. When this occurs
d01eaf should be called again, but with an entry value of
, (see specification of
maxcls) and the results compared with those from the previous call.
If the routine is called with
, the exact values of
finest and
absest on return will depend (within statistical limits) on the sequence of random numbers generated internally within
d01eaf by calls to
g05saf. Separate runs will produce identical answers unless the part of the program executed prior to calling
d01eaf also calls (directly or indirectly) routines from
Chapter G05, and, in addition, the series of such calls differs between runs.
Because of moderate instability in the application of the basic integration rule, approximately the last decimal digits may be inaccurate when using d01eaf for large values of .
10
Example
This example computes
where
,
. The program is intended to show how to exploit the continuation facility provided with
d01eaf: the routine exits with
(printing an explanatory error message) and is re-entered with
maxcls reset to a larger value. The program can be used with any values of
ndim and
nfun, except that the expression for
must be changed if
(see specification of
maxcls).
10.1
Program Text
10.2
Program Data
None.
10.3
Program Results