]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TUHKMgen/UHKM/EquationSolver.h
updated macros for making PPR plots
[u/mrichter/AliRoot.git] / TUHKMgen / UHKM / EquationSolver.h
CommitLineData
b1c2e580 1
2#ifndef NAEquationSolver_h
3#define NAEquationSolver_h 1
4#include <Rtypes.h>
5#include "MathUtil.h"
6/*
7
8 Nikolai Amelin, Ludmila Malinina, Timur Pocheptsov (C) JINR/Dubna
9 amelin@sunhe.jinr.ru, malinina@sunhe.jinr.ru, pocheptsov@sunhe.jinr.ru
10 November. 2, 2005
11
12*/
13//This equation solver class is taken from GEANT4 and modified!!
14
15
16#define DefaultTolerance 5.0e-14
17
18template <class Function>
19class NAEquationSolver {
20
21 public:
22 enum {DefaultMaxIter = 100};
23
24 private:
25 // Maximum number of iterations
26 Int_t fMaxIter;
27 Double_t fTolerance;
28 // interval limits [a,b] which should bracket the root
29 Double_t fA;
30 Double_t fB;
31 // root
32 Double_t fRoot;
33
34 public:
35 // default constructor
36 NAEquationSolver() : fMaxIter(DefaultMaxIter), fTolerance(DefaultTolerance),
37 fA(0.0), fB(0.0), fRoot(0.0) {};
38
39 NAEquationSolver(const Int_t iterations, const Double_t tol) :
40 fMaxIter(iterations), fTolerance(tol),
41 fA(0.0), fB(0.0), fRoot(0.0) {};
42
43 // copy constructor
44 NAEquationSolver(const NAEquationSolver & right);
45
46 // destructor
47 ~NAEquationSolver() {};
48
49 // operators
50 NAEquationSolver & operator=(const NAEquationSolver & right);
51 Bool_t operator==(const NAEquationSolver & right) const;
52 Bool_t operator!=(const NAEquationSolver & right) const;
53
54 Int_t GetMaxIterations(void) const {return fMaxIter;}
55 void SetMaxIterations(const Int_t iterations) {fMaxIter=iterations;}
56
57 Double_t GetTolerance(void) const {return fTolerance;}
58 void SetTolerance(const Double_t epsilon) {fTolerance = epsilon;}
59
60 Double_t GetIntervalLowerLimit(void) const {return fA;}
61 Double_t GetIntervalUpperLimit(void) const {return fB;}
62
63 void SetIntervalLimits(const Double_t Limit1, const Double_t Limit2);
64
65 Double_t GetRoot(void) const {return fRoot;}
66
67 // Calculates the root by the Brent's method
68 Bool_t Brent(Function& theFunction);
69};
70
71#include "EquationSolver.icc"
72
73#endif