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 */
35 class BaseIntegratorOptions {
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
52  virtual ~BaseIntegratorOptions() { ClearExtra(); }
53 
54 
55  /// name of 1D integrator
56  virtual std::string Integrator() const = 0;
57 
58  /** non-static methods for retrivieng 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) funxtion calls
97  double fAbsTolerance; // absolute tolerance
98  double fRelTolerance; // relative tolerance
99 
100 
101  // extra options
102  ROOT::Math::IOptions * fExtraOptions; // 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 
122  virtual ~IntegratorOneDimOptions() {}
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 rule
138  /// values of 1,2,3,4,5,6 corresponds to 15,21,31,41,51,61 and they are used in GSL adaptive
139  /// values > 6 corresponds to the actual points and they are used by teh GaussLegendre integrator
140  void SetNPoints(unsigned int n) { fNCalls = n; }
141 
142  /// maximum number of function calls
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 
203  virtual ~IntegratorMultiDimOptions() {}
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:132
ROOT::Math::IntegratorMultiDimOptions::NCalls
unsigned int NCalls() const
maximum number of function calls
Definition: IntegratorOptions.h:232
ROOT::Math::IntegratorOneDimOptions::SetDefaultNPoints
static void SetDefaultNPoints(unsigned int n)
Definition: IntegratorOptions.cxx:270
n
const Int_t n
Definition: legend1.C:16
AllIntegrationTypes.h
ROOT::Math::IntegratorOneDimOptions::DefaultWKSize
static unsigned int DefaultWKSize()
Definition: IntegratorOptions.cxx:278
ROOT::Math::IntegratorMultiDimOptions::SetDefaultIntegrator
static void SetDefaultIntegrator(const char *name)
Definition: IntegratorOptions.cxx:338
ROOT::Math::BaseIntegratorOptions::WKSize
unsigned int WKSize() const
size of the workspace
Definition: IntegratorOptions.h:77
ROOT::Math::IntegratorOneDimOptions::SetNPoints
void SetNPoints(unsigned int n)
set number of points rule values of 1,2,3,4,5,6 corresponds to 15,21,31,41,51,61 and they are used in...
Definition: IntegratorOptions.h:150
ROOT::Math::BaseIntegratorOptions::AbsTolerance
double AbsTolerance() const
non-static methods for retrivieng options
Definition: IntegratorOptions.h:71
ROOT::Math::BaseIntegratorOptions::operator=
BaseIntegratorOptions & operator=(const BaseIntegratorOptions &opt)
assignment operators
Definition: IntegratorOptions.cxx:147
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:359
ROOT::Math::IntegratorMultiDimOptions::operator=
IntegratorMultiDimOptions & operator=(const IntegratorMultiDimOptions &rhs)
Definition: IntegratorOptions.h:221
ROOT::Math::IntegratorOneDimOptions::SetDefaultAbsTolerance
static void SetDefaultAbsTolerance(double tol)
Definition: IntegratorOptions.cxx:257
ROOT::Math::BaseIntegratorOptions::BaseIntegratorOptions
BaseIntegratorOptions()
protected constructor to avoid user creating this class
Definition: IntegratorOptions.cxx:135
ROOT::Math::IntegratorMultiDimOptions::IntegratorMultiDimOptions
IntegratorMultiDimOptions(IOptions *extraOpts=0)
Definition: IntegratorOptions.cxx:296
ROOT::Math::IntegratorOneDimOptions::DefaultIntegrator
static std::string DefaultIntegrator()
Definition: IntegratorOptions.cxx:246
ROOT::Math::BaseIntegratorOptions::ClearExtra
void ClearExtra()
Definition: IntegratorOptions.cxx:171
ROOT::Math::BaseIntegratorOptions::fIntegType
int fIntegType
Definition: IntegratorOptions.h:103
ROOT::Math::IntegratorOneDimOptions::SetIntegrator
void SetIntegrator(const char *name)
set 1D integrator name
Definition: IntegratorOptions.cxx:208
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:332
ROOT::Math::IntegratorMultiDimOptions::SetNCalls
void SetNCalls(unsigned int calls)
set maximum number of function calls
Definition: IntegratorOptions.h:229
ROOT::Math::IntegratorMultiDimOptions::Print
void Print(std::ostream &os=std::cout) const
print all the options
Definition: IntegratorOptions.cxx:324
ROOT::Math::IntegratorOneDimOptions::DefaultIntegratorType
static IntegrationOneDim::Type DefaultIntegratorType()
Definition: IntegratorOptions.cxx:251
ROOT::Math::IntegratorMultiDimOptions::DefaultWKSize
static unsigned int DefaultWKSize()
Definition: IntegratorOptions.cxx:381
ROOT::Math::IntegratorMultiDimOptions::IntegratorType
IntegrationMultiDim::Type IntegratorType() const
type of the integrator (return the enumeration type)
Definition: IntegratorOptions.h:238
ROOT::Math::IntegrationOneDim::Type
Type
enumeration specifying the integration types.
Definition: AllIntegrationTypes.h:60
ROOT::Math::IntegratorOneDimOptions::IntegratorType
IntegrationOneDim::Type IntegratorType() const
type of the integrator (return the enumeration type)
Definition: IntegratorOptions.h:159
ROOT::Math::IntegratorOneDimOptions::operator=
IntegratorOneDimOptions & operator=(const IntegratorOneDimOptions &rhs)
Definition: IntegratorOptions.h:140
ROOT::Math::IntegratorOneDimOptions::SetDefaultRelTolerance
static void SetDefaultRelTolerance(double tol)
Definition: IntegratorOptions.cxx:261
ROOT::Math::IntegratorMultiDimOptions::SetDefaultNCalls
static void SetDefaultNCalls(unsigned int ncall)
Definition: IntegratorOptions.cxx:373
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:226
ROOT::Math::BaseIntegratorOptions::SetWKSize
void SetWKSize(unsigned int size)
set workspace size
Definition: IntegratorOptions.h:93
ROOT::Math::IntegratorMultiDimOptions
Numerical multi dimensional integration options.
Definition: IntegratorOptions.h:204
ROOT::Math::BaseIntegratorOptions::~BaseIntegratorOptions
virtual ~BaseIntegratorOptions()
protected constructor to avoid user creating this class
Definition: IntegratorOptions.h:62
ROOT::Math::BaseIntegratorOptions::RelTolerance
double RelTolerance() const
absolute tolerance
Definition: IntegratorOptions.h:74
ROOT::Math::IntegratorOneDimOptions::SetDefaultIntegrator
static void SetDefaultIntegrator(const char *name)
Definition: IntegratorOptions.cxx:233
ROOT::Math::IntegratorMultiDimOptions::Default
static ROOT::Math::IOptions & Default(const char *name)
Definition: IntegratorOptions.cxx:385
ROOT::Math::IntegratorMultiDimOptions::SetDefaultRelTolerance
static void SetDefaultRelTolerance(double tol)
Definition: IntegratorOptions.cxx:364
ROOT::Math::IntegratorOneDimOptions::DefaultNPoints
static unsigned int DefaultNPoints()
Definition: IntegratorOptions.cxx:279
ROOT::Math::IntegrationMultiDim::Type
Type
enumeration specifying the integration types.
Definition: AllIntegrationTypes.h:75
ROOT::Math::BaseIntegratorOptions::fNCalls
unsigned int fNCalls
Definition: IntegratorOptions.h:106
ROOT::Math::IntegratorMultiDimOptions::FindDefault
static ROOT::Math::IOptions * FindDefault(const char *name)
Definition: IntegratorOptions.cxx:390
ROOT::Math::IntegratorMultiDimOptions::Integrator
std::string Integrator() const
name of multi-dim integrator
Definition: IntegratorOptions.cxx:320
ROOT::Math::IntegratorOneDimOptions::Default
static ROOT::Math::IOptions & Default(const char *name)
retrieve specific options - if not existing create a IOptions
Definition: IntegratorOptions.cxx:282
ROOT::Math::IOptions
Generic interface for defining configuration options of a numerical algorithm.
Definition: IOptions.h:41
ROOT::Math::IntegratorMultiDimOptions::SetIntegrator
void SetIntegrator(const char *name)
set multi-dim integrator name
Definition: IntegratorOptions.cxx:314
ROOT::Math::IntegratorOneDimOptions
Numerical one dimensional integration options.
Definition: IntegratorOptions.h:123
ROOT::Math::BaseIntegratorOptions::fExtraOptions
ROOT::Math::IOptions * fExtraOptions
Definition: IntegratorOptions.h:112
ROOT::Math::BaseIntegratorOptions::SetRelTolerance
void SetRelTolerance(double tol)
set the relative tolerance
Definition: IntegratorOptions.h:90
ROOT::Math::BaseIntegratorOptions::SetExtraOptions
void SetExtraOptions(const IOptions &opt)
set extra options (in this case pointer is cloned)
Definition: IntegratorOptions.cxx:177
ROOT::Math::IntegratorMultiDimOptions::DefaultIntegratorType
static IntegrationMultiDim::Type DefaultIntegratorType()
Definition: IntegratorOptions.cxx:353
ROOT::Math::IntegratorOneDimOptions::Print
void Print(std::ostream &os=std::cout) const
print all the options
Definition: IntegratorOptions.cxx:218
ROOT::Math::IntegratorOneDimOptions::DefaultRelTolerance
static double DefaultRelTolerance()
Definition: IntegratorOptions.cxx:277
ROOT::Math::IntegratorOneDimOptions::IntegratorOneDimOptions
IntegratorOneDimOptions(IOptions *extraOpts=0)
Definition: IntegratorOptions.cxx:189
ROOT::Math::IntegratorMultiDimOptions::DefaultIntegrator
static std::string DefaultIntegrator()
Definition: IntegratorOptions.cxx:348
ROOT::Math::BaseIntegratorOptions::SetAbsTolerance
void SetAbsTolerance(double tol)
non-static methods for setting options
Definition: IntegratorOptions.h:87
ROOT::Math::IntegratorMultiDimOptions::DefaultRelTolerance
static double DefaultRelTolerance()
Definition: IntegratorOptions.cxx:380
ROOT::Math::BaseIntegratorOptions::ExtraOptions
IOptions * ExtraOptions() const
return extra options
Definition: IntegratorOptions.h:81
ROOT::Math::BaseIntegratorOptions::fWKSize
unsigned int fWKSize
Definition: IntegratorOptions.h:105
ROOT::Math::IntegratorMultiDimOptions::~IntegratorMultiDimOptions
virtual ~IntegratorMultiDimOptions()
Definition: IntegratorOptions.h:213
name
char name[80]
Definition: TGX11.cxx:110
ROOT::Math::BaseIntegratorOptions::fRelTolerance
double fRelTolerance
Definition: IntegratorOptions.h:108
ROOT::Math::BaseIntegratorOptions
Base class for Numerical integration options common in 1D and multi-dimension This is an internal cla...
Definition: IntegratorOptions.h:45
ROOT::Math::IntegratorMultiDimOptions::DefaultNCalls
static unsigned int DefaultNCalls()
Definition: IntegratorOptions.cxx:382
ROOT::Math::IntegratorOneDimOptions::DefaultAbsTolerance
static double DefaultAbsTolerance()
Definition: IntegratorOptions.cxx:276
ROOT::Math::IntegratorMultiDimOptions::DefaultAbsTolerance
static double DefaultAbsTolerance()
Definition: IntegratorOptions.cxx:379
ROOT::Math::IntegratorOneDimOptions::FindDefault
static ROOT::Math::IOptions * FindDefault(const char *name)
Definition: IntegratorOptions.cxx:287
ROOT::Math::IntegratorOneDimOptions::SetDefaultWKSize
static void SetDefaultWKSize(unsigned int size)
Definition: IntegratorOptions.cxx:266
ROOT::Math::IntegratorOneDimOptions::Integrator
std::string Integrator() const
name of 1D integrator
Definition: IntegratorOptions.cxx:214
ROOT::Math::IntegratorOneDimOptions::NPoints
unsigned int NPoints() const
maximum number of function calls
Definition: IntegratorOptions.h:153
ROOT::Math::IntegratorMultiDimOptions::SetDefaultWKSize
static void SetDefaultWKSize(unsigned int size)
Definition: IntegratorOptions.cxx:369
ROOT
VSD Structures.
Definition: StringConv.hxx:21
Math
ROOT::Math::BaseIntegratorOptions::fAbsTolerance
double fAbsTolerance
Definition: IntegratorOptions.h:107