Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
IntegratorOptions.h
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Author: L. Moneta Fri Aug 15 2008
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2008 LCG ROOT Math Team, CERN/PH-SFT *
7 * *
8 * *
9 **********************************************************************/
10
11#ifndef ROOT_Math_IntegratorOptions
12#define ROOT_Math_IntegratorOptions
13
15
16#include <string>
17#include <iostream>
18
19namespace ROOT {
20
21
22namespace Math {
23
24 class IOptions;
25
26
27//_______________________________________________________________________________
28/**
29 Base class for Numerical integration options
30 common in 1D and multi-dimension
31 This is an internal class and is not supposed to be instantiated by the user
32
33 @ingroup Integration
34*/
36
37protected:
38
39 /// protected constructor to avoid user creating this class
41
42public:
43
44 // copy constructor
46
47 /// assignment operators
49
50
51 /// protected constructor to avoid user creating this class
53
54
55 /// name of 1D integrator
56 virtual std::string Integrator() const = 0;
57
58 /** non-static methods for retrieving options */
59
60 /// absolute tolerance
61 double AbsTolerance() const { return fAbsTolerance; }
62
63 /// absolute tolerance
64 double RelTolerance() const { return fRelTolerance; }
65
66 /// size of the workspace
67 unsigned int WKSize() const { return fWKSize; }
68
69
70 /// return extra options
71 IOptions * ExtraOptions() const { return fExtraOptions; }
72
73 /** non-static methods for setting options */
74
75
76 /// set the abs tolerance
77 void SetAbsTolerance(double tol) { fAbsTolerance = tol; }
78
79 /// set the relative tolerance
80 void SetRelTolerance(double tol) { fRelTolerance = tol; }
81
82 /// set workspace size
83 void SetWKSize(unsigned int size) { fWKSize = size; }
84
85 /// set extra options (in this case pointer is cloned)
86 void SetExtraOptions(const IOptions & opt);
87
88
89protected:
90
91 void ClearExtra();
92
93 int fIntegType; ///< Integrator type (value converted from enum)
94
95 unsigned int fWKSize; ///< workspace size
96 unsigned int fNCalls; ///< (max) function calls
97 double fAbsTolerance; ///< absolute tolerance
98 double fRelTolerance; ///< relative tolerance
99
100
101 // extra options
103
104};
105
106//_______________________________________________________________________________
107/**
108 Numerical one dimensional integration options
109
110 @ingroup Integration
111*/
112
114
115public:
116
117
118 /// constructor using the default options
119 /// can pass a pointer to extra options (N.B. pointer will be managed by the class)
120 IntegratorOneDimOptions(IOptions * extraOpts = 0);
121
123
124 /// copy constructor
127 {}
128
129 /// assignment operator
131 if (this == &rhs) return *this;
132 static_cast<BaseIntegratorOptions &>(*this) = rhs;
133 return *this;
134 }
135
136 // specific method for one-dim
137 /// Set number of points for active integration rule.
138 /// - For the GSL adaptive integrator, `n = 1,2,3,4,5,6` correspond to the 15,21,31,41,51,61-point integration rules.
139 /// - For the GaussLegendre integrator, use values > 6, which correspond to the actual number of points being evaluated.
140 void SetNPoints(unsigned int n) { fNCalls = n; }
141
142 /// Number of points used by current integration rule. \see SetNPoints().
143 unsigned int NPoints() const { return fNCalls; }
144
145 /// name of 1D integrator
146 std::string Integrator() const;
147
148 /// type of the integrator (return the enumeration type)
150
151 /// set 1D integrator name
152 void SetIntegrator(const char * name);
153
154 /// print all the options
155 void Print(std::ostream & os = std::cout) const;
156
157 // static methods for setting and retrieving the default options
158
159 static void SetDefaultIntegrator(const char * name);
160 static void SetDefaultAbsTolerance(double tol);
161 static void SetDefaultRelTolerance(double tol);
162 static void SetDefaultWKSize(unsigned int size);
163 static void SetDefaultNPoints(unsigned int n);
164
165 static std::string DefaultIntegrator();
167 static double DefaultAbsTolerance();
168 static double DefaultRelTolerance();
169 static unsigned int DefaultWKSize();
170 static unsigned int DefaultNPoints();
171
172 /// retrieve specific options - if not existing create a IOptions
173 static ROOT::Math::IOptions & Default(const char * name);
174
175 /// find specific options - return 0 if not existing
176 static ROOT::Math::IOptions * FindDefault(const char * name);
177
178 /// print only the specified default options
179 static void PrintDefault(const char * name = 0, std::ostream & os = std::cout);
180
181
182private:
183
184
185};
186
187//_______________________________________________________________________________
188/**
189 Numerical multi dimensional integration options
190
191 @ingroup Integration
192*/
193
195
196public:
197
198
199 /// constructor using the default options
200 /// can pass a pointer to extra options (N.B. pointer will be managed by the class)
201 IntegratorMultiDimOptions(IOptions * extraOpts = 0);
202
204
205 /// copy constructor
208 {}
209
210 /// assignment operator
212 if (this == &rhs) return *this;
213 static_cast<BaseIntegratorOptions &>(*this) = rhs;
214 return *this;
215 }
216
217 // specific method for multi-dim
218 /// set maximum number of function calls
219 void SetNCalls(unsigned int calls) { fNCalls = calls; }
220
221 /// maximum number of function calls
222 unsigned int NCalls() const { return fNCalls; }
223
224 /// name of multi-dim integrator
225 std::string Integrator() const;
226
227 /// type of the integrator (return the enumeration type)
229
230 /// set multi-dim integrator name
231 void SetIntegrator(const char * name);
232
233 /// print all the options
234 void Print(std::ostream & os = std::cout) const;
235
236 // static methods for setting and retrieving the default options
237
238 static void SetDefaultIntegrator(const char * name);
239 static void SetDefaultAbsTolerance(double tol);
240 static void SetDefaultRelTolerance(double tol);
241 static void SetDefaultWKSize(unsigned int size);
242 static void SetDefaultNCalls(unsigned int ncall);
243
244 static std::string DefaultIntegrator();
246 static double DefaultAbsTolerance();
247 static double DefaultRelTolerance();
248 static unsigned int DefaultWKSize();
249 static unsigned int DefaultNCalls();
250
251 /// retrieve specific options
252 static ROOT::Math::IOptions & Default(const char * name);
253
254 /// find specific options - return 0 if not existing
255 static ROOT::Math::IOptions * FindDefault(const char * name);
256
257 /// print only the specified default options
258 static void PrintDefault(const char * name = 0, std::ostream & os = std::cout);
259
260
261private:
262
263
264};
265
266
267 } // end namespace Math
268
269} // end namespace ROOT
270
271#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
char name[80]
Definition TGX11.cxx:110
Base class for Numerical integration options common in 1D and multi-dimension This is an internal cla...
int fIntegType
Integrator type (value converted from enum)
BaseIntegratorOptions()
protected constructor to avoid user creating this class
virtual std::string Integrator() const =0
name of 1D integrator
void SetAbsTolerance(double tol)
non-static methods for setting options
double RelTolerance() const
absolute tolerance
virtual ~BaseIntegratorOptions()
protected constructor to avoid user creating this class
void SetExtraOptions(const IOptions &opt)
set extra options (in this case pointer is cloned)
double fAbsTolerance
absolute tolerance
double fRelTolerance
relative tolerance
void SetRelTolerance(double tol)
set the relative tolerance
unsigned int WKSize() const
size of the workspace
double AbsTolerance() const
non-static methods for retrieving options
BaseIntegratorOptions & operator=(const BaseIntegratorOptions &opt)
assignment operators
unsigned int fNCalls
(max) function calls
unsigned int fWKSize
workspace size
void SetWKSize(unsigned int size)
set workspace size
IOptions * ExtraOptions() const
return extra options
Generic interface for defining configuration options of a numerical algorithm.
Definition IOptions.h:31
Numerical multi dimensional integration options.
static void SetDefaultWKSize(unsigned int size)
static void SetDefaultIntegrator(const char *name)
void Print(std::ostream &os=std::cout) const
print all the options
static void SetDefaultNCalls(unsigned int ncall)
static ROOT::Math::IOptions * FindDefault(const char *name)
find specific options - return 0 if not existing
void SetIntegrator(const char *name)
set multi-dim integrator name
static IntegrationMultiDim::Type DefaultIntegratorType()
static ROOT::Math::IOptions & Default(const char *name)
retrieve specific options
void SetNCalls(unsigned int calls)
set maximum number of function calls
IntegratorMultiDimOptions(const IntegratorMultiDimOptions &rhs)
copy constructor
static void PrintDefault(const char *name=0, std::ostream &os=std::cout)
print only the specified default options
unsigned int NCalls() const
maximum number of function calls
IntegratorMultiDimOptions & operator=(const IntegratorMultiDimOptions &rhs)
assignment operator
std::string Integrator() const
name of multi-dim integrator
IntegrationMultiDim::Type IntegratorType() const
type of the integrator (return the enumeration type)
Numerical one dimensional integration options.
static void SetDefaultNPoints(unsigned int n)
IntegrationOneDim::Type IntegratorType() const
type of the integrator (return the enumeration type)
static void SetDefaultAbsTolerance(double tol)
void Print(std::ostream &os=std::cout) const
print all the options
void SetIntegrator(const char *name)
set 1D integrator name
static void SetDefaultRelTolerance(double tol)
std::string Integrator() const
name of 1D integrator
void SetNPoints(unsigned int n)
Set number of points for active integration rule.
static void SetDefaultIntegrator(const char *name)
IntegratorOneDimOptions(const IntegratorOneDimOptions &rhs)
copy constructor
static void PrintDefault(const char *name=0, std::ostream &os=std::cout)
print only the specified default options
static ROOT::Math::IOptions & Default(const char *name)
retrieve specific options - if not existing create a IOptions
static void SetDefaultWKSize(unsigned int size)
static IntegrationOneDim::Type DefaultIntegratorType()
static ROOT::Math::IOptions * FindDefault(const char *name)
find specific options - return 0 if not existing
unsigned int NPoints() const
Number of points used by current integration rule.
IntegratorOneDimOptions & operator=(const IntegratorOneDimOptions &rhs)
assignment operator
Type
enumeration specifying the integration types.
Type
enumeration specifying the integration types.
const Int_t n
Definition legend1.C:16
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...