CMS 3D CMS Logo

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/src/EquationSolver.icc"
68 
69 #endif
NAEquationSolver::SetTolerance
void SetTolerance(const double epsilon)
Definition: EquationSolver.h:54
NAEquationSolver::operator==
bool operator==(const NAEquationSolver &right) const
Definition: EquationSolver.cc:34
NAEquationSolver::GetIntervalUpperLimit
double GetIntervalUpperLimit(void) const
Definition: EquationSolver.h:57
NAEquationSolver::fMaxIter
int fMaxIter
Definition: EquationSolver.h:24
NAEquationSolver::fB
double fB
Definition: EquationSolver.h:28
NAEquationSolver::NAEquationSolver
NAEquationSolver(const int iterations, const double tol)
Definition: EquationSolver.h:36
NAEquationSolver::Brent
bool Brent(Function &theFunction)
geometryDiff.epsilon
int epsilon
Definition: geometryDiff.py:26
NAEquationSolver::fA
double fA
Definition: EquationSolver.h:27
NAEquationSolver::GetTolerance
double GetTolerance(void) const
Definition: EquationSolver.h:53
NAEquationSolver::operator=
NAEquationSolver & operator=(const NAEquationSolver &right)
Definition: EquationSolver.cc:24
NAEquationSolver::GetMaxIterations
int GetMaxIterations(void) const
Definition: EquationSolver.h:50
NAEquationSolver
Definition: EquationSolver.h:18
NAEquationSolver::GetRoot
double GetRoot(void) const
Definition: EquationSolver.h:61
NAEquationSolver::fRoot
double fRoot
Definition: EquationSolver.h:30
NAEquationSolver::GetIntervalLowerLimit
double GetIntervalLowerLimit(void) const
Definition: EquationSolver.h:56
NAEquationSolver::DefaultMaxIter
Definition: EquationSolver.h:20
NAEquationSolver::SetMaxIterations
void SetMaxIterations(const int iterations)
Definition: EquationSolver.h:51
NAEquationSolver::SetIntervalLimits
void SetIntervalLimits(const double Limit1, const double Limit2)
MathUtil.h
NAEquationSolver::~NAEquationSolver
~NAEquationSolver()
Definition: EquationSolver.h:43
NAEquationSolver::operator!=
bool operator!=(const NAEquationSolver &right) const
Definition: EquationSolver.cc:42
NAEquationSolver::NAEquationSolver
NAEquationSolver()
Definition: EquationSolver.h:34
reco::parser::Function
Function
Definition: Function.h:18
DefaultTolerance
#define DefaultTolerance
Definition: EquationSolver.h:15
NAEquationSolver::fTolerance
double fTolerance
Definition: EquationSolver.h:25