test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EquationSolver.h
Go to the documentation of this file.
1 /*
2 
3 Nikolai Amelin, Ludmila Malinina, Timur Pocheptsov (C) JINR/Dubna
4 amelin@sunhe.jinr.ru, malinina@sunhe.jinr.ru, pocheptsov@sunhe.jinr.ru
5 November. 2, 2005
6 
7 */
8 //This equation solver class is taken from GEANT4 and modified!!
9 
10 #ifndef NAEquationSolver_h
11 #define NAEquationSolver_h 1
12 #include <Rtypes.h>
13 #include "MathUtil.h"
14 
15 #define DefaultTolerance 5.0e-14
16 
17 template <class Function>
19 
20  public:
21  enum {DefaultMaxIter = 100};
22 
23  private:
24  // Maximum number of iterations
25  int fMaxIter;
26  double fTolerance;
27  // interval limits [a,b] which should bracket the root
28  double fA;
29  double fB;
30  // root
31  double fRoot;
32 
33  public:
34  // default constructor
36  fA(0.0), fB(0.0), fRoot(0.0) {};
37 
38  NAEquationSolver(const int iterations, const double tol) :
39  fMaxIter(iterations), fTolerance(tol),
40  fA(0.0), fB(0.0), fRoot(0.0) {};
41 
42  // copy constructor
43  NAEquationSolver(const NAEquationSolver & right);
44 
45  // destructor
47 
48  // operators
50  bool operator==(const NAEquationSolver & right) const;
51  bool operator!=(const NAEquationSolver & right) const;
52 
53  int GetMaxIterations(void) const {return fMaxIter;}
54  void SetMaxIterations(const int iterations) {fMaxIter=iterations;}
55 
56  double GetTolerance(void) const {return fTolerance;}
57  void SetTolerance(const double epsilon) {fTolerance = epsilon;}
58 
59  double GetIntervalLowerLimit(void) const {return fA;}
60  double GetIntervalUpperLimit(void) const {return fB;}
61 
62  void SetIntervalLimits(const double Limit1, const double Limit2);
63 
64  double GetRoot(void) const {return fRoot;}
65 
66  // Calculates the root by the Brent's method
67  bool Brent(Function& theFunction);
68 };
69 
70 #include "GeneratorInterface/Hydjet2Interface/src/EquationSolver.icc"
71 
72 #endif
bool operator==(const NAEquationSolver &right) const
NAEquationSolver(const int iterations, const double tol)
void SetTolerance(const double epsilon)
void SetMaxIterations(const int iterations)
NAEquationSolver & operator=(const NAEquationSolver &right)
double GetRoot(void) const
#define DefaultTolerance
int GetMaxIterations(void) const
bool Brent(Function &theFunction)
double GetIntervalLowerLimit(void) const
bool operator!=(const NAEquationSolver &right) const
double GetTolerance(void) const
void SetIntervalLimits(const double Limit1, const double Limit2)
double GetIntervalUpperLimit(void) const