ROOT
master
Reference Guide
Loading...
Searching...
No Matches
mathmoreIntegrationMultidim.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_math
3
/// \notebook -nodraw
4
/// Example on the usage of the multidimensional integration algorithm of MathMore.
5
///
6
/// Please refer to the web documentation for further details:
7
/// https://root.cern/manual/math/#numerical-integration
8
/// To execute the macro type the following:
9
///
10
/// ~~~{.cpp}
11
/// root[0] .x mathmoreIntegrationMultidim.C
12
/// ~~~
13
///
14
/// This tutorial requires having libMathMore built with ROOT.
15
///
16
/// To build mathmore you need to have a version of GSL >= 1.8 installed in your system
17
/// The ROOT configure will automatically find GSL if the script gsl-config (from GSL) is in your PATH,.
18
/// otherwise you need to configure root with the options --gsl-incdir and --gsl-libdir.
19
///
20
/// \macro_image
21
/// \macro_output
22
/// \macro_code
23
///
24
/// \authors A. Tolosa-Delgado
25
26
double
f2(
const
double
*
x
) {
27
return
x
[0] +
x
[1];
28
}
29
30
int
mathmoreIntegrationMultidim
() {
31
32
const
double
RESULT
= 1.0;
33
const
double
ERRORLIMIT
= 1
E
-3;
34
int
status = 0;
35
36
ROOT::Math::Functor
wf
(&f2,2);
37
double
a
[2] = {0,0};
38
double
b
[2] = {1,1};
39
40
ROOT::Math::IntegratorMultiDim
ig
(
ROOT::Math::IntegrationMultiDim::kADAPTIVE
);
41
ig
.SetFunction(
wf
);
42
double
val =
ig
.Integral(
a
,
b
);
43
std::cout <<
"integral result is "
<< val << std::endl;
44
status += std::fabs(val-
RESULT
) >
ERRORLIMIT
;
45
46
ROOT::Math::IntegratorMultiDim
ig2
(
ROOT::Math::IntegrationMultiDim::kVEGAS
);
47
ig2
.SetFunction(
wf
);
48
val =
ig2
.Integral(
a
,
b
);
49
std::cout <<
"integral result is "
<< val << std::endl;
50
status += std::fabs(val-
RESULT
) >
ERRORLIMIT
;
51
52
ROOT::Math::IntegratorMultiDim
ig3
(
wf
,
ROOT::Math::IntegrationMultiDim::kPLAIN
);
53
val =
ig3
.Integral(
a
,
b
);
54
std::cout <<
"integral result is "
<< val << std::endl;
55
status += std::fabs(val-
RESULT
) >
ERRORLIMIT
;
56
57
ROOT::Math::IntegratorMultiDim
ig4
(
wf
,
ROOT::Math::IntegrationMultiDim::kMISER
);
58
val =
ig4
.Integral(
a
,
b
);
59
std::cout <<
"integral result is "
<< val << std::endl;
60
status += std::fabs(val-
RESULT
) >
ERRORLIMIT
;
61
62
return
status;
63
}
b
#define b(i)
Definition
RSha256.hxx:100
a
#define a(i)
Definition
RSha256.hxx:99
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
ROOT::Math::Functor
Documentation for class Functor class.
Definition
Functor.h:49
ROOT::Math::IntegratorMultiDim
User class for performing multidimensional integration.
Definition
IntegratorMultiDim.h:47
ROOT::Math::IntegrationMultiDim::kADAPTIVE
@ kADAPTIVE
adaptive multi-dimensional integration
Definition
AllIntegrationTypes.h:49
ROOT::Math::IntegrationMultiDim::kVEGAS
@ kVEGAS
MC integration.
Definition
AllIntegrationTypes.h:50
ROOT::Math::IntegrationMultiDim::kPLAIN
@ kPLAIN
MC integration.
Definition
AllIntegrationTypes.h:52
ROOT::Math::IntegrationMultiDim::kMISER
@ kMISER
MC integration.
Definition
AllIntegrationTypes.h:51
x
Double_t x[n]
Definition
legend1.C:17
TMath::E
constexpr Double_t E()
Base of natural log: .
Definition
TMath.h:94
tutorials
math
mathmoreIntegrationMultidim.C
ROOT master - Reference Guide Generated on Sat Jul 19 2025 04:33:42 (GVA Time) using Doxygen 1.10.0