Top |
void | (*NcmIntegralNDF) () |
void | (*NcmIntegralNDGetDimensions) () |
NcmIntegralND * | ncm_integral_nd_ref () |
void | ncm_integral_nd_free () |
void | ncm_integral_nd_clear () |
void | ncm_integral_nd_set_method () |
void | ncm_integral_nd_set_error () |
void | ncm_integral_nd_set_maxeval () |
void | ncm_integral_nd_set_reltol () |
void | ncm_integral_nd_set_abstol () |
NcmIntegralNDMethod | ncm_integral_nd_get_method () |
NcmIntegralNDError | ncm_integral_nd_get_error () |
guint | ncm_integral_nd_get_maxeval () |
gdouble | ncm_integral_nd_get_reltol () |
gdouble | ncm_integral_nd_get_abstol () |
void | ncm_integral_nd_eval () |
#define | NCM_INTEGRAL_ND_DEFINE_TYPE_WITH_FREE() |
#define | NCM_INTEGRAL_ND_DEFINE_TYPE() |
double | abstol | Read / Write / Construct |
NcmIntegralNDError | error | Read / Write / Construct |
guint | maxeval | Read / Write / Construct |
NcmIntegralNDMethod | method | Read / Write / Construct |
double | reltol | Read / Write / Construct |
#define | NCM_TYPE_INTEGRAL_ND |
struct | NcmIntegralNDClass |
enum | NcmIntegralNDMethod |
enum | NcmIntegralNDError |
#define | NCM_INTEGRAL_ND_DEFAULT_RELTOL |
#define | NCM_INTEGRAL_ND_DEFAULT_ABSTOL |
NcmIntegralND |
This object is used to perform n-dimensional integration of a function using different methods.
The integration can be performed using the cubature library. The cubature library is a library for adaptive multidimensional integration. The original code can be found at https://github.com/stevengj/cubature.
To use this object, the user must initialize a child object that implements two functions: get_dimensions and integrand. To do so, the user must first define these two functions as the prototypes described in ncm_integral_nd.h. The get dimensions function should return the dimension of the arguments to be integrated and the function dimension. For instance, if the integrand is given by $F(x,y) = x + y$, the get dimensions function must return $(2,1)$, such that it will compute \begin{align} \int \int F(x, y) dxdy ,\end{align} returning a scalar for the integral evaluated in the given intervals.
This object can also be used with multi-dimensional functions that return an array instead of a scalar. Considering the integrand $F(x,y,z) = [x^2, y+z ]$, the get dimensions method should return $(3,2)$ and the object will compute the integral \begin{align} \int \int \int F(x,y,z) dxdy = [\frac{yzx^3}{3}, frac{x(y^2+z^2)}{2}] \end{align} for the given intervals.
Having the functions, the user must instantiate an object of the type NcmIntegralNDClass defined with these functions. To do so, one must call the macro NCM_INTEGRAL_ND_DEFINE_TYPE to define the new object type, which will later be instantiable. Examples of how to define the objects containing the integrand can be found in the test folder under test\textunderscore ncm\textunderscore integral\textunderscore nd.c. For an example of the Python implementation of the integrand in a class, check test\textunderscore py\textunderscore integralnd.py in the same folder. This object cannot be used without the child object containing the cited functions.
After defining the child class with the necessary functions, the user may use the integration object with the prefered method from the cubature library.
The user may provide the input values for: rel_tol
- ncm_integral_nd_set_reltol()
, abs_tol
- ncm_integral_nd_set_abstol()
,
integ_method
- ncm_integral_nd_set_method()
, max_eval
- ncm_integral_nd_set_maxeval()
, error
- ncm_integral_nd_set_error()
.
If these functions are not called, default parameters are chosen.
void (*NcmIntegralNDF) (NcmIntegralND *intnd
,NcmVector *x
,guint dim
,guint npoints
,guint fdim
,NcmVector *fval
);
The type of the function that must be implemented by a subclass of NcmIntegralND.
This function receives npoints
points in the array x
(size dim
* npoints
), and
returns an array (size fdim
* npoints
) of npoints
values of the integrand at all
points in x
. The x
is an array of doubles in row-major order
(i.e. the first dim
elements of x
are the coordinates of the first point, the next
dim
elements are the coordinates of the second point, and so on). The return value
is an array of fdim
values of the integrand at all points in x
(e.g. the first
fdim
elements are the values of the integrand at the first point, the next fdim
elements are the values of the integrand at the second point, and so on).
void (*NcmIntegralNDGetDimensions) (NcmIntegralND *intnd
,guint *dim
,guint *fdim
);
The type of the function that must be implemented by a subclass of NcmIntegralND.
This function returns the dimension of the integral argument and the dimension of the function to be integrated.
NcmIntegralND *
ncm_integral_nd_ref (NcmIntegralND *intnd
);
Increases the reference count of intnd
by one.
void
ncm_integral_nd_free (NcmIntegralND *intnd
);
Decreases the reference count of intnd
by one.
void
ncm_integral_nd_clear (NcmIntegralND **intnd
);
If *intnd
is different from NULL, decreases the reference
count of *intnd
by one and sets *intnd
to NULL.
void ncm_integral_nd_set_method (NcmIntegralND *intnd
,NcmIntegralNDMethod method
);
Sets the integration method to use.
void ncm_integral_nd_set_error (NcmIntegralND *intnd
,NcmIntegralNDError error
);
Sets the error measure to use.
void ncm_integral_nd_set_maxeval (NcmIntegralND *intnd
,guint maxeval
);
Sets the maximum number of function evaluations to use. Zero means unlimited.
void ncm_integral_nd_set_reltol (NcmIntegralND *intnd
,gdouble reltol
);
Sets the relative tolerance reltol
to use.
void ncm_integral_nd_set_abstol (NcmIntegralND *intnd
,gdouble abstol
);
Sets the absolute tolerance reltol
to use.
NcmIntegralNDMethod
ncm_integral_nd_get_method (NcmIntegralND *intnd
);
void ncm_integral_nd_eval (NcmIntegralND *intnd
,const NcmVector *xi
,const NcmVector *xf
,NcmVector *res
,NcmVector *err
);
Evaluated the integral $I_F(x_i, x_f) = \int_{x_i}^{x_f}F(x)\mathrm{d}x$.
#define NCM_INTEGRAL_ND_DEFINE_TYPE_WITH_FREE(MODULE, OBJ_NAME, ModuleObjName, module_obj_name, method_get_dimensions, method_integrand, user_data, user_data_free)
A convenience macro to define a subclass of NcmIntegralND with a custom user data type and a custom method to free the user data.
MODULE |
the name of the module defining the type, all capitalized |
|
OBJ_NAME |
the name of the type to define, all capitalized |
|
ModuleObjName |
the name of the type to define, camel case |
|
module_obj_name |
the name of the type to define, sneake case |
|
method_get_dimensions |
the name of the method that returns the dimension of the integral argument and the dimension of the function to be integrated |
|
method_integrand |
the name of the method that returns the value of the integrand at all points in |
|
user_data |
the type of the user data |
|
user_data_free |
the name of the method that frees the user data |
#define NCM_INTEGRAL_ND_DEFINE_TYPE(MODULE, OBJ_NAME, ModuleObjName, module_obj_name, method_get_dimensions, method_integrand, user_data)
A convenience macro to define a subclass of NcmIntegralND with a custom user data type.
MODULE |
the name of the module defining the type, all capitalized |
|
OBJ_NAME |
the name of the type to define, all capitalized |
|
ModuleObjName |
the name of the type to define, camel case |
|
module_obj_name |
the name of the type to define, sneake case |
|
method_get_dimensions |
the name of the method that returns the dimension of the integral argument and the dimension of the function to be integrated |
|
method_integrand |
the name of the method that returns the value of the integrand at all points in |
|
user_data |
the type of the user data |
The type of the method used to perform the integral.
adapative integration by partitioning the integration domain ("h-adaptive") and using the same fixed-degree quadrature in each subdomain, recursively, until convergence is achieved. |
||
adaptive integration by increasing the degree of (tensor-product Clenshaw-Curtis) quadrature rules ("p-adaptive"), rather than subdividing the domain ("h-adaptive"). Possibly better for smooth integrands in low dimensions. |
||
same as |
||
same as |
The type of the error estimation used to perform the integral.
error is estimated for each integrand separately |
||
error is estimated for each pair of integrands |
||
error is estimated for the L2 norm of the vector of integrands |
||
error is estimated for the L1 norm of the vector of integrands |
||
error is estimated for the L-infinity norm of the vector of integrands |
“abstol”
property “abstol” double
Integral absolute tolerance.
Owner: NcmIntegralND
Flags: Read / Write / Construct
Allowed values: >= 0
Default value: 0
“error”
property“error” NcmIntegralNDError
Error measure.
Owner: NcmIntegralND
Flags: Read / Write / Construct
Default value: NCM_INTEGRAL_ND_ERROR_INDIVIDUAL
“maxeval”
property “maxeval” guint
Maximum number of function evaluations (0 means unlimited).
Owner: NcmIntegralND
Flags: Read / Write / Construct
Default value: 0
“method”
property“method” NcmIntegralNDMethod
Integration method.
Owner: NcmIntegralND
Flags: Read / Write / Construct
Default value: NCM_INTEGRAL_ND_METHOD_CUBATURE_H