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///
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
26double f2(const double * x) {
27 return x[0] + x[1];
28}
29
31
32 const double RESULT = 1.0;
33 const double ERRORLIMIT = 1E-3;
34 int status = 0;
35
37 double a[2] = {0,0};
38 double b[2] = {1,1};
39
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
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
53 val = ig3.Integral(a,b);
54 std::cout << "integral result is " << val << std::endl;
55 status += std::fabs(val-RESULT) > ERRORLIMIT;
56
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}
#define b(i)
Definition RSha256.hxx:100
#define a(i)
Definition RSha256.hxx:99
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Documentation for class Functor class.
Definition Functor.h:49
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:94