CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 public:
20  enum { DefaultMaxIter = 100 };
21 
22 private:
23  // Maximum number of iterations
24  int fMaxIter;
25  double fTolerance;
26  // interval limits [a,b] which should bracket the root
27  double fA;
28  double fB;
29  // root
30  double fRoot;
31 
32 public:
33  // default constructor
35 
36  NAEquationSolver(const int iterations, const double tol)
37  : fMaxIter(iterations), fTolerance(tol), fA(0.0), fB(0.0), fRoot(0.0){};
38 
39  // copy constructor
40  NAEquationSolver(const NAEquationSolver& right);
41 
42  // destructor
44 
45  // operators
47  bool operator==(const NAEquationSolver& right) const;
48  bool operator!=(const NAEquationSolver& right) const;
49 
50  int GetMaxIterations(void) const { return fMaxIter; }
51  void SetMaxIterations(const int iterations) { fMaxIter = iterations; }
52 
53  double GetTolerance(void) const { return fTolerance; }
54  void SetTolerance(const double epsilon) { fTolerance = epsilon; }
55 
56  double GetIntervalLowerLimit(void) const { return fA; }
57  double GetIntervalUpperLimit(void) const { return fB; }
58 
59  void SetIntervalLimits(const double Limit1, const double Limit2);
60 
61  double GetRoot(void) const { return fRoot; }
62 
63  // Calculates the root by the Brent's method
64  bool Brent(Function& theFunction);
65 };
66 
67 #include "GeneratorInterface/Hydjet2Interface/interface/EquationSolver.icc"
68 
69 #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