Logo ROOT   6.08/07
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 
14 #ifndef ROOT_Math_AllIntegrationTypes
16 #endif
17 
18 #include <string>
19 #include <iostream>
20 
21 namespace ROOT {
22 
23 
24 namespace Math {
25 
26  class IOptions;
27 
28 
29 //_______________________________________________________________________________
30 /**
31  Base class for Numerical integration options
32  common in 1D and multi-dimension
33  This is an internal class and is not supposed to be instantiated by the user
34 
35  @ingroup Integration
36 */
38 
39 protected:
40 
41  /// protected constructor to avoid user creating this class
43 
44 public:
45 
46  // copy constructor
48 
49  /// assignment operators
51 
52 
53  /// protected constructor to avoid user creating this class
55 
56 
57  /// name of 1D integrator
58  virtual std::string Integrator() const = 0;
59 
60  /** non-static methods for retrivieng options */
61 
62  /// absolute tolerance
63  double AbsTolerance() const { return fAbsTolerance; }
64 
65  /// absolute tolerance
66  double RelTolerance() const { return fRelTolerance; }
67 
68  /// size of the workspace
69  unsigned int WKSize() const { return fWKSize; }
70 
71 
72  /// return extra options
73  IOptions * ExtraOptions() const { return fExtraOptions; }
74 
75  /** non-static methods for setting options */
76 
77 
78  /// set the abs tolerance
79  void SetAbsTolerance(double tol) { fAbsTolerance = tol; }
80 
81  /// set the relative tolerance
82  void SetRelTolerance(double tol) { fRelTolerance = tol; }
83 
84  /// set workspace size
85  void SetWKSize(unsigned int size) { fWKSize = size; }
86 
87  /// set extra options (in this case pointer is cloned)
88  void SetExtraOptions(const IOptions & opt);
89 
90 
91 protected:
92 
93  void ClearExtra();
94 
95  int fIntegType; // Integrator type (value converted from enum)
96 
97  unsigned int fWKSize; // workspace size
98  unsigned int fNCalls; // (max) funxtion calls
99  double fAbsTolerance; // absolute tolerance
100  double fRelTolerance; // relative tolerance
101 
102 
103  // extra options
105 
106 };
107 
108 //_______________________________________________________________________________
109 /**
110  Numerical one dimensional integration options
111 
112  @ingroup Integration
113 */
114 
116 
117 public:
118 
119 
120  // constructor using the default options
121  // can pass a pointer to extra options (N.B. pointer will be managed by the class)
122  IntegratorOneDimOptions(IOptions * extraOpts = 0);
123 
125 
126  // copy constructor
129  {}
130 
131  // assignment operator
133  if (this == &rhs) return *this;
134  static_cast<BaseIntegratorOptions &>(*this) = rhs;
135  return *this;
136  }
137 
138  // specific method for one-dim
139  /// set number of points rule
140  /// values of 1,2,3,4,5,6 corresponds to 15,21,31,41,51,61 and they are used in GSL adaptive
141  /// values > 6 corresponds to the actual points and they are used by teh GaussLegendre integrator
142  void SetNPoints(unsigned int n) { fNCalls = n; }
143 
144  /// maximum number of function calls
145  unsigned int NPoints() const { return fNCalls; }
146 
147  /// name of 1D integrator
148  std::string Integrator() const;
149 
150  /// type of the integrator (return the enumeration type)
152 
153  /// set 1D integrator name
154  void SetIntegrator(const char * name);
155 
156  /// print all the options
157  void Print(std::ostream & os = std::cout) const;
158 
159  // static methods for setting and retrieving the default options
160 
161  static void SetDefaultIntegrator(const char * name);
162  static void SetDefaultAbsTolerance(double tol);
163  static void SetDefaultRelTolerance(double tol);
164  static void SetDefaultWKSize(unsigned int size);
165  static void SetDefaultNPoints(unsigned int n);
166 
167  static std::string DefaultIntegrator();
168  static IntegrationOneDim::Type DefaultIntegratorType();
169  static double DefaultAbsTolerance();
170  static double DefaultRelTolerance();
171  static unsigned int DefaultWKSize();
172  static unsigned int DefaultNPoints();
173 
174  /// retrieve specific options - if not existing create a IOptions
175  static ROOT::Math::IOptions & Default(const char * name);
176 
177  // find specific options - return 0 if not existing
178  static ROOT::Math::IOptions * FindDefault(const char * name);
179 
180  /// print only the specified default options
181  static void PrintDefault(const char * name = 0, std::ostream & os = std::cout);
182 
183 
184 private:
185 
186 
187 };
188 
189 //_______________________________________________________________________________
190 /**
191  Numerical multi dimensional integration options
192 
193  @ingroup Integration
194 */
195 
197 
198 public:
199 
200 
201  // constructor using the default options
202  // can pass a pointer to extra options (N.B. pointer will be managed by the class)
203  IntegratorMultiDimOptions(IOptions * extraOpts = 0);
204 
206 
207  // copy constructor
210  {}
211 
212  // assignment operator
214  if (this == &rhs) return *this;
215  static_cast<BaseIntegratorOptions &>(*this) = rhs;
216  return *this;
217  }
218 
219  // specific method for multi-dim
220  /// set maximum number of function calls
221  void SetNCalls(unsigned int calls) { fNCalls = calls; }
222 
223  /// maximum number of function calls
224  unsigned int NCalls() const { return fNCalls; }
225 
226  /// name of multi-dim integrator
227  std::string Integrator() const;
228 
229  /// type of the integrator (return the enumeration type)
231 
232  /// set multi-dim integrator name
233  void SetIntegrator(const char * name);
234 
235  /// print all the options
236  void Print(std::ostream & os = std::cout) const;
237 
238  // static methods for setting and retrieving the default options
239 
240  static void SetDefaultIntegrator(const char * name);
241  static void SetDefaultAbsTolerance(double tol);
242  static void SetDefaultRelTolerance(double tol);
243  static void SetDefaultWKSize(unsigned int size);
244  static void SetDefaultNCalls(unsigned int ncall);
245 
246  static std::string DefaultIntegrator();
247  static IntegrationMultiDim::Type DefaultIntegratorType();
248  static double DefaultAbsTolerance();
249  static double DefaultRelTolerance();
250  static unsigned int DefaultWKSize();
251  static unsigned int DefaultNCalls();
252 
253  // retrieve specific options
254  static ROOT::Math::IOptions & Default(const char * name);
255 
256  // find specific options - return 0 if not existing
257  static ROOT::Math::IOptions * FindDefault(const char * name);
258 
259  /// print only the specified default options
260  static void PrintDefault(const char * name = 0, std::ostream & os = std::cout);
261 
262 
263 private:
264 
265 
266 };
267 
268 
269  } // end namespace Math
270 
271 } // end namespace ROOT
272 
273 #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)
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
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.
const double tol
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
int ncall
Definition: stressTF1.cxx:20
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:32
IOptions * ExtraOptions() const
return extra options
IntegratorOneDimOptions(const IntegratorOneDimOptions &rhs)
BaseIntegratorOptions()
protected constructor to avoid user creating this class
const Int_t n
Definition: legend1.C:16
char name[80]
Definition: TGX11.cxx:109
void SetRelTolerance(double tol)
set the relative tolerance
void SetAbsTolerance(double tol)
non-static methods for setting options