Logo ROOT   6.13/01
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 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
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 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();
166  static IntegrationOneDim::Type DefaultIntegratorType();
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();
245  static IntegrationMultiDim::Type DefaultIntegratorType();
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
IntegratorMultiDimOptions & operator=(const IntegratorMultiDimOptions &rhs)
IntegratorOneDimOptions & operator=(const IntegratorOneDimOptions &rhs)
unsigned int NCalls() const
maximum number of function calls
void SetExtraOptions(const IOptions &opt)
set extra options (in this case pointer is cloned)
Namespace for new ROOT classes and functions.
Definition: TFoamSampler.h:19
Type
enumeration specifying the integration types.
void SetWKSize(unsigned int size)
set workspace size
IntegratorMultiDimOptions(const IntegratorMultiDimOptions &rhs)
void SetNCalls(unsigned int calls)
set maximum number of function calls
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...
double RelTolerance() const
absolute tolerance
void PrintDefault(const char *name, std::ostream &os)
print default options
IntegrationMultiDim::Type IntegratorType() const
type of the integrator (return the enumeration type)
BaseIntegratorOptions & operator=(const BaseIntegratorOptions &opt)
assignment operators
ROOT::Math::IOptions * fExtraOptions
IntegrationOneDim::Type IntegratorType() const
type of the integrator (return the enumeration type)
unsigned int WKSize() const
size of the workspace
Numerical multi dimensional integration options.
double AbsTolerance() const
non-static methods for retrivieng options
Numerical one dimensional integration options.
unsigned int NPoints() const
maximum number of function calls
virtual std::string Integrator() const =0
name of 1D integrator
Base class for Numerical integration options common in 1D and multi-dimension This is an internal cla...
Type
enumeration specifying the integration types.
void Print(std::ostream &os, const OptionType &opt)
virtual ~BaseIntegratorOptions()
protected constructor to avoid user creating this class
Namespace for new Math classes and functions.
Generic interface for defining configuration options of a numerical algorithm.
Definition: IOptions.h:30
IOptions * ExtraOptions() const
return extra options
IntegratorOneDimOptions(const IntegratorOneDimOptions &rhs)
BaseIntegratorOptions()
protected constructor to avoid user creating this class
void SetRelTolerance(double tol)
set the relative tolerance
void SetAbsTolerance(double tol)
non-static methods for setting options