PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
cubature.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005 Steven G. Johnson
3  *
4  * Portions (see comments) based on HIntLib (also distributed under
5  * the GNU GPL), copyright (c) 2002-2005 Rudolf Schuerer.
6  *
7  * Portions (see comments) based on GNU GSL (also distributed under
8  * the GNU GPL), copyright (c) 1996-2000 Brian Gough.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */
25 
26 #ifndef _cubature_h
27 #define _cubature_h 1
28 
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #endif
33 
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <math.h>
37 #include <limits.h>
38 #include <float.h>
39 
40 /* Adaptive multidimensional integration on hypercubes (or, really,
41  hyper-rectangles) using cubature rules.
42 
43  A cubature rule takes a function and a hypercube and evaluates
44  the function at a small number of points, returning an estimate
45  of the integral as well as an estimate of the error, and also
46  a suggested dimension of the hypercube to subdivide.
47 
48  Given such a rule, the adaptive integration is simple:
49 
50  1) Evaluate the cubature rule on the hypercube(s).
51  Stop if converged.
52 
53  2) Pick the hypercube with the largest estimated error,
54  and divide it in two along the suggested dimension.
55 
56  3) Goto (1).
57 
58 */
59 
60 typedef double (*integrand) (unsigned ndim, const double *x, void *);
61 
62 /* Integrate the function f from xmin[dim] to xmax[dim], with at
63  most maxEval function evaluations (0 for no limit),
64  until the given absolute is achieved relative error. val returns
65  the integral, and estimated_error returns the estimate for the
66  absolute error in val. The return value of the function is 0
67  on success and non-zero if there was an error. */
68 int adapt_integrate(integrand f, void *fdata,
69  unsigned dim, const double *xmin, const double *xmax,
70  unsigned maxEval,
71  double reqAbsError, double reqRelError,
72  double *val, double *estimated_error);
73 
74 #ifdef __cplusplus
75 }
76 #endif
77 
78 #endif /* ifndef _cubature_h */
79 
double(* integrand)(unsigned ndim, const double *x, void *)
Definition: cubature.h:60
int adapt_integrate(integrand f, void *fdata, unsigned dim, const double *xmin, const double *xmax, unsigned maxEval, double reqAbsError, double reqRelError, double *val, double *estimated_error)
Definition: cubature.c:701