Logo ROOT   6.08/07
Reference Guide
IRootFinderMethod.h
Go to the documentation of this file.
1 // @(#)root/mathcore:$Id$
2 // Authors: David Gonzalez Maline 01/2008
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2006 , LCG ROOT MathLib Team *
7  * *
8  * *
9  **********************************************************************/
10 
11 // Header for the IRootFinderMethod interface
12 //
13 // Created by: David Gonzalez Maline : Fri Jan 25 2008
14 //
15 
16 #ifndef ROOT_Math_IRootFinderMethod
17 #define ROOT_Math_IRootFinderMethod
18 
19 #ifndef ROOT_Math_Error
20 #include "Math/Error.h"
21 #endif
22 
23 #ifndef ROOT_Math_IFunctionfwd
24 #include "Math/IFunctionfwd.h"
25 #endif
26 
27 namespace ROOT {
28 namespace Math {
29 
30 //___________________________________________________________________________________________
31 /**
32  Interface for finding function roots of one-dimensional functions
33 
34  @ingroup RootFinders
35 
36  */
37 
39 public:
40  /** Default Destructor. */
41  virtual ~IRootFinderMethod() {}
42 
43  /** Default Constructor. */
45 
46  // Common functionality
47 
48  /** Sets the function for algorithms using derivatives. */
49  virtual bool SetFunction(const ROOT::Math::IGradFunction&, double)
50  {
51  MATH_ERROR_MSG("SetFunction", "This method must be used with a Root Finder algorithm using derivatives");
52  return false;
53  }
54 
55  /** Sets the function for the rest of the algorithms.
56  The parameters set the interval where the root has to be calculated. */
57  virtual bool SetFunction(const ROOT::Math::IGenFunction& , double , double )
58  {
59  MATH_ERROR_MSG("SetFunction", "Algorithm requires derivatives");
60  return false;
61  }
62 
63  /** Returns the previously calculated root. */
64  virtual double Root() const = 0;
65 
66  /** Returns the status of the previous estimate */
67  virtual int Status() const = 0;
68 
69  // Methods to be Implemented in the derived classes
70 
71  /** Stimates the root for the function.
72  \@param maxIter maximum number of iterations.
73  \@param absTol desired absolute error in the minimum position.
74  \@param absTol desired relative error in the minimum position.
75  */
76  virtual bool Solve(int maxIter = 100, double absTol = 1E-8, double relTol = 1E-10) = 0;
77 
78  /** Return name of root finder algorithm */
79  virtual const char* Name() const = 0;
80 
81  /** This method is implemented only by the GSLRootFinder
82  and GSLRootFinderDeriv classes and will return an error if it's not one of them. */
83  virtual int Iterate() {
84  MATH_ERROR_MSG("Iterate", "This method must be used with a Root Finder algorithm wrapping the GSL Library");
85  return -1;
86  }
87 
88  /** Return number of iterations used to find the root
89  Must be implemented by derived classes
90  */
91  virtual int Iterations() const { return -1; }
92 
93 };
94 
95 } // namespace Math
96 } // namespace ROOT
97 
98 
99 #endif /* ROOT_Math_IRootFinderMethod */
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Definition: IFunction.h:133
const double absTol
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
virtual double Root() const =0
Returns the previously calculated root.
Interface (abstract class) for one-dimensional functions providing a gradient calculation.
Definition: IFunction.h:382
Interface for finding function roots of one-dimensional functions.
IRootFinderMethod()
Default Constructor.
#define MATH_ERROR_MSG(loc, str)
Definition: Error.h:50
Double_t E()
Definition: TMath.h:54
virtual int Iterations() const
Return number of iterations used to find the root Must be implemented by derived classes.
virtual bool SetFunction(const ROOT::Math::IGradFunction &, double)
Sets the function for algorithms using derivatives.
virtual bool Solve(int maxIter=100, double absTol=1E-8, double relTol=1E-10)=0
Stimates the root for the function.
Namespace for new Math classes and functions.
virtual const char * Name() const =0
Return name of root finder algorithm.
virtual ~IRootFinderMethod()
Default Destructor.
virtual int Status() const =0
Returns the status of the previous estimate.
virtual int Iterate()
This method is implemented only by the GSLRootFinder and GSLRootFinderDeriv classes and will return a...
virtual bool SetFunction(const ROOT::Math::IGenFunction &, double, double)
Sets the function for the rest of the algorithms.