Logo ROOT  
Reference Guide
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 
19 namespace ROOT {
20 
21 
22 namespace 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 
37 protected:
38 
39  /// protected constructor to avoid user creating this class
41 
42 public:
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 
89 protected:
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 
115 public:
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 
182 private:
183 
184 
185 };
186 
187 //_______________________________________________________________________________
188 /**
189  Numerical multi dimensional integration options
190 
191  @ingroup Integration
192 */
193 
195 
196 public:
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 
261 private:
262 
263 
264 };
265 
266 
267  } // end namespace Math
268 
269 } // end namespace ROOT
270 
271 #endif
ROOT::Math::IntegratorOneDimOptions::~IntegratorOneDimOptions
virtual ~IntegratorOneDimOptions()
Definition: IntegratorOptions.h:122
ROOT::Math::IntegratorOneDimOptions::IntegratorOneDimOptions
IntegratorOneDimOptions(const IntegratorOneDimOptions &rhs)
copy constructor
Definition: IntegratorOptions.h:125
ROOT::Math::IntegratorMultiDimOptions::NCalls
unsigned int NCalls() const
maximum number of function calls
Definition: IntegratorOptions.h:222
ROOT::Math::IntegratorOneDimOptions::SetDefaultNPoints
static void SetDefaultNPoints(unsigned int n)
Definition: IntegratorOptions.cxx:260
n
const Int_t n
Definition: legend1.C:16
AllIntegrationTypes.h
ROOT::Math::IntegratorOneDimOptions::DefaultWKSize
static unsigned int DefaultWKSize()
Definition: IntegratorOptions.cxx:268
ROOT::Math::IntegratorMultiDimOptions::SetDefaultIntegrator
static void SetDefaultIntegrator(const char *name)
Definition: IntegratorOptions.cxx:328
ROOT::Math::BaseIntegratorOptions::WKSize
unsigned int WKSize() const
size of the workspace
Definition: IntegratorOptions.h:67
ROOT::Math::IntegratorOneDimOptions::SetNPoints
void SetNPoints(unsigned int n)
Set number of points for active integration rule.
Definition: IntegratorOptions.h:140
ROOT::Math::BaseIntegratorOptions::AbsTolerance
double AbsTolerance() const
non-static methods for retrieving options
Definition: IntegratorOptions.h:61
ROOT::Math::BaseIntegratorOptions::operator=
BaseIntegratorOptions & operator=(const BaseIntegratorOptions &opt)
assignment operators
Definition: IntegratorOptions.cxx:137
ROOT::Math::BaseIntegratorOptions::Integrator
virtual std::string Integrator() const =0
name of 1D integrator
ROOT::Math::IntegratorMultiDimOptions::SetDefaultAbsTolerance
static void SetDefaultAbsTolerance(double tol)
Definition: IntegratorOptions.cxx:349
ROOT::Math::IntegratorMultiDimOptions::operator=
IntegratorMultiDimOptions & operator=(const IntegratorMultiDimOptions &rhs)
assignment operator
Definition: IntegratorOptions.h:211
ROOT::Math::IntegratorOneDimOptions::SetDefaultAbsTolerance
static void SetDefaultAbsTolerance(double tol)
Definition: IntegratorOptions.cxx:247
ROOT::Math::BaseIntegratorOptions::BaseIntegratorOptions
BaseIntegratorOptions()
protected constructor to avoid user creating this class
Definition: IntegratorOptions.cxx:125
ROOT::Math::IntegratorMultiDimOptions::IntegratorMultiDimOptions
IntegratorMultiDimOptions(IOptions *extraOpts=0)
constructor using the default options can pass a pointer to extra options (N.B.
Definition: IntegratorOptions.cxx:286
ROOT::Math::IntegratorOneDimOptions::DefaultIntegrator
static std::string DefaultIntegrator()
Definition: IntegratorOptions.cxx:236
ROOT::Math::BaseIntegratorOptions::ClearExtra
void ClearExtra()
Definition: IntegratorOptions.cxx:161
ROOT::Math::BaseIntegratorOptions::fIntegType
int fIntegType
Integrator type (value converted from enum)
Definition: IntegratorOptions.h:93
ROOT::Math::IntegratorOneDimOptions::SetIntegrator
void SetIntegrator(const char *name)
set 1D integrator name
Definition: IntegratorOptions.cxx:198
ROOT::Math::IntegratorMultiDimOptions::PrintDefault
static void PrintDefault(const char *name=0, std::ostream &os=std::cout)
print only the specified default options
Definition: IntegratorOptions.cxx:322
ROOT::Math::IntegratorMultiDimOptions::SetNCalls
void SetNCalls(unsigned int calls)
set maximum number of function calls
Definition: IntegratorOptions.h:219
ROOT::Math::IntegratorMultiDimOptions::Print
void Print(std::ostream &os=std::cout) const
print all the options
Definition: IntegratorOptions.cxx:314
ROOT::Math::IntegratorMultiDimOptions::IntegratorMultiDimOptions
IntegratorMultiDimOptions(const IntegratorMultiDimOptions &rhs)
copy constructor
Definition: IntegratorOptions.h:206
ROOT::Math::IntegratorOneDimOptions::DefaultIntegratorType
static IntegrationOneDim::Type DefaultIntegratorType()
Definition: IntegratorOptions.cxx:241
ROOT::Math::IntegratorMultiDimOptions::DefaultWKSize
static unsigned int DefaultWKSize()
Definition: IntegratorOptions.cxx:371
ROOT::Math::IntegratorMultiDimOptions::IntegratorType
IntegrationMultiDim::Type IntegratorType() const
type of the integrator (return the enumeration type)
Definition: IntegratorOptions.h:228
ROOT::Math::IntegrationOneDim::Type
Type
enumeration specifying the integration types.
Definition: AllIntegrationTypes.h:32
ROOT::Math::IntegratorOneDimOptions::IntegratorType
IntegrationOneDim::Type IntegratorType() const
type of the integrator (return the enumeration type)
Definition: IntegratorOptions.h:149
ROOT::Math::IntegratorOneDimOptions::operator=
IntegratorOneDimOptions & operator=(const IntegratorOneDimOptions &rhs)
assignment operator
Definition: IntegratorOptions.h:130
ROOT::Math::IntegratorOneDimOptions::SetDefaultRelTolerance
static void SetDefaultRelTolerance(double tol)
Definition: IntegratorOptions.cxx:251
ROOT::Math::IntegratorMultiDimOptions::SetDefaultNCalls
static void SetDefaultNCalls(unsigned int ncall)
Definition: IntegratorOptions.cxx:363
ROOT::Math::IntegratorOneDimOptions::PrintDefault
static void PrintDefault(const char *name=0, std::ostream &os=std::cout)
print only the specified default options
Definition: IntegratorOptions.cxx:216
ROOT::Math::BaseIntegratorOptions::SetWKSize
void SetWKSize(unsigned int size)
set workspace size
Definition: IntegratorOptions.h:83
ROOT::Math::IntegratorMultiDimOptions
Numerical multi dimensional integration options.
Definition: IntegratorOptions.h:194
ROOT::Math::BaseIntegratorOptions::~BaseIntegratorOptions
virtual ~BaseIntegratorOptions()
protected constructor to avoid user creating this class
Definition: IntegratorOptions.h:52
ROOT::Math::BaseIntegratorOptions::RelTolerance
double RelTolerance() const
absolute tolerance
Definition: IntegratorOptions.h:64
ROOT::Math::IntegratorOneDimOptions::SetDefaultIntegrator
static void SetDefaultIntegrator(const char *name)
Definition: IntegratorOptions.cxx:223
ROOT::Math::IntegratorMultiDimOptions::Default
static ROOT::Math::IOptions & Default(const char *name)
retrieve specific options
Definition: IntegratorOptions.cxx:375
size
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Math::IntegratorMultiDimOptions::SetDefaultRelTolerance
static void SetDefaultRelTolerance(double tol)
Definition: IntegratorOptions.cxx:354
ROOT::Math::IntegratorOneDimOptions::DefaultNPoints
static unsigned int DefaultNPoints()
Definition: IntegratorOptions.cxx:269
ROOT::Math::IntegrationMultiDim::Type
Type
enumeration specifying the integration types.
Definition: AllIntegrationTypes.h:47
ROOT::Math::BaseIntegratorOptions::fNCalls
unsigned int fNCalls
(max) function calls
Definition: IntegratorOptions.h:96
ROOT::Math::IntegratorMultiDimOptions::FindDefault
static ROOT::Math::IOptions * FindDefault(const char *name)
find specific options - return 0 if not existing
Definition: IntegratorOptions.cxx:380
ROOT::Math::IntegratorMultiDimOptions::Integrator
std::string Integrator() const
name of multi-dim integrator
Definition: IntegratorOptions.cxx:310
ROOT::Math::IntegratorOneDimOptions::Default
static ROOT::Math::IOptions & Default(const char *name)
retrieve specific options - if not existing create a IOptions
Definition: IntegratorOptions.cxx:272
ROOT::Math::IOptions
Generic interface for defining configuration options of a numerical algorithm.
Definition: IOptions.h:31
ROOT::Math::IntegratorMultiDimOptions::SetIntegrator
void SetIntegrator(const char *name)
set multi-dim integrator name
Definition: IntegratorOptions.cxx:304
ROOT::Math::IntegratorOneDimOptions
Numerical one dimensional integration options.
Definition: IntegratorOptions.h:113
ROOT::Math::BaseIntegratorOptions::fExtraOptions
ROOT::Math::IOptions * fExtraOptions
Definition: IntegratorOptions.h:102
ROOT::Math::BaseIntegratorOptions::SetRelTolerance
void SetRelTolerance(double tol)
set the relative tolerance
Definition: IntegratorOptions.h:80
ROOT::Math::BaseIntegratorOptions::SetExtraOptions
void SetExtraOptions(const IOptions &opt)
set extra options (in this case pointer is cloned)
Definition: IntegratorOptions.cxx:167
ROOT::Math::IntegratorMultiDimOptions::DefaultIntegratorType
static IntegrationMultiDim::Type DefaultIntegratorType()
Definition: IntegratorOptions.cxx:343
ROOT::Math::IntegratorOneDimOptions::Print
void Print(std::ostream &os=std::cout) const
print all the options
Definition: IntegratorOptions.cxx:208
ROOT::Math::IntegratorOneDimOptions::DefaultRelTolerance
static double DefaultRelTolerance()
Definition: IntegratorOptions.cxx:267
ROOT::Math::IntegratorOneDimOptions::IntegratorOneDimOptions
IntegratorOneDimOptions(IOptions *extraOpts=0)
constructor using the default options can pass a pointer to extra options (N.B.
Definition: IntegratorOptions.cxx:179
ROOT::Math::IntegratorMultiDimOptions::DefaultIntegrator
static std::string DefaultIntegrator()
Definition: IntegratorOptions.cxx:338
ROOT::Math::BaseIntegratorOptions::SetAbsTolerance
void SetAbsTolerance(double tol)
non-static methods for setting options
Definition: IntegratorOptions.h:77
ROOT::Math::IntegratorMultiDimOptions::DefaultRelTolerance
static double DefaultRelTolerance()
Definition: IntegratorOptions.cxx:370
ROOT::Math::BaseIntegratorOptions::ExtraOptions
IOptions * ExtraOptions() const
return extra options
Definition: IntegratorOptions.h:71
ROOT::Math::BaseIntegratorOptions::fWKSize
unsigned int fWKSize
workspace size
Definition: IntegratorOptions.h:95
ROOT::Math::IntegratorMultiDimOptions::~IntegratorMultiDimOptions
virtual ~IntegratorMultiDimOptions()
Definition: IntegratorOptions.h:203
name
char name[80]
Definition: TGX11.cxx:110
ROOT::Math::BaseIntegratorOptions::fRelTolerance
double fRelTolerance
relative tolerance
Definition: IntegratorOptions.h:98
ROOT::Math::BaseIntegratorOptions
Base class for Numerical integration options common in 1D and multi-dimension This is an internal cla...
Definition: IntegratorOptions.h:35
ROOT::Math::IntegratorMultiDimOptions::DefaultNCalls
static unsigned int DefaultNCalls()
Definition: IntegratorOptions.cxx:372
ROOT::Math::IntegratorOneDimOptions::DefaultAbsTolerance
static double DefaultAbsTolerance()
Definition: IntegratorOptions.cxx:266
ROOT::Math::IntegratorMultiDimOptions::DefaultAbsTolerance
static double DefaultAbsTolerance()
Definition: IntegratorOptions.cxx:369
ROOT::Math::IntegratorOneDimOptions::FindDefault
static ROOT::Math::IOptions * FindDefault(const char *name)
find specific options - return 0 if not existing
Definition: IntegratorOptions.cxx:277
ROOT::Math::IntegratorOneDimOptions::SetDefaultWKSize
static void SetDefaultWKSize(unsigned int size)
Definition: IntegratorOptions.cxx:256
ROOT::Math::IntegratorOneDimOptions::Integrator
std::string Integrator() const
name of 1D integrator
Definition: IntegratorOptions.cxx:204
ROOT::Math::IntegratorOneDimOptions::NPoints
unsigned int NPoints() const
Number of points used by current integration rule.
Definition: IntegratorOptions.h:143
ROOT::Math::IntegratorMultiDimOptions::SetDefaultWKSize
static void SetDefaultWKSize(unsigned int size)
Definition: IntegratorOptions.cxx:359
ROOT
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: EExecutionPolicy.hxx:4
Math
Namespace for new Math classes and functions.
ROOT::Math::BaseIntegratorOptions::fAbsTolerance
double fAbsTolerance
absolute tolerance
Definition: IntegratorOptions.h:97