Logo ROOT  
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/// Please refer to the web documentation for further details:
6/// https://root.cern.ch/root/htmldoc/guides/users-guide/MathLibraries.html#numerical-integration
7/// To execute the macro type the following:
8///
9/// ~~~{.cpp}
10/// root[0] .x mathmoreIntegrationMultidim.C
11/// ~~~
12///
13/// This tutorial requires having libMathMore built with ROOT.
14///
15/// To build mathmore you need to have a version of GSL >= 1.8 installed in your system
16/// The ROOT configure will automatically find GSL if the script gsl-config (from GSL) is in your PATH,.
17/// otherwise you need to configure root with the options --gsl-incdir and --gsl-libdir.
18///
19/// \macro_image
20/// \macro_output
21/// \macro_code
22///
23/// \authors A. Tolosa-Delgado
24
25double f2(const double * x) {
26 return x[0] + x[1];
27}
28
29int mathmoreIntegrationMultidim() {
30
31 const double RESULT = 1.0;
32 const double ERRORLIMIT = 1E-3;
33 int status = 0;
34
35 ROOT::Math::Functor wf(&f2,2);
36 double a[2] = {0,0};
37 double b[2] = {1,1};
38
40 ig.SetFunction(wf);
41 double val = ig.Integral(a,b);
42 std::cout << "integral result is " << val << std::endl;
43 status += std::fabs(val-RESULT) > ERRORLIMIT;
44
46 ig2.SetFunction(wf);
47 val = ig2.Integral(a,b);
48 std::cout << "integral result is " << val << std::endl;
49 status += std::fabs(val-RESULT) > ERRORLIMIT;
50
52 val = ig3.Integral(a,b);
53 std::cout << "integral result is " << val << std::endl;
54 status += std::fabs(val-RESULT) > ERRORLIMIT;
55
57 val = ig4.Integral(a,b);
58 std::cout << "integral result is " << val << std::endl;
59 status += std::fabs(val-RESULT) > ERRORLIMIT;
60
61 return status;
62}
#define b(i)
Definition RSha256.hxx:100
#define a(i)
Definition RSha256.hxx:99
Documentation for class Functor class.
Definition Functor.h:47
User class for performing multidimensional integration.
@ kADAPTIVE
adaptive multi-dimensional integration
Double_t x[n]
Definition legend1.C:17
constexpr Double_t E()
Base of natural log: .
Definition TMath.h:93