Logo ROOT   6.10/09
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 #include "Math/Error.h"
20 
21 #include "Math/IFunctionfwd.h"
22 
23 namespace ROOT {
24 namespace Math {
25 
26 //___________________________________________________________________________________________
27 /**
28  Interface for finding function roots of one-dimensional functions
29 
30  @ingroup RootFinders
31 
32  */
33 
35 public:
36  /** Default Destructor. */
37  virtual ~IRootFinderMethod() {}
38 
39  /** Default Constructor. */
41 
42  // Common functionality
43 
44  /** Sets the function for algorithms using derivatives. */
45  virtual bool SetFunction(const ROOT::Math::IGradFunction&, double)
46  {
47  MATH_ERROR_MSG("SetFunction", "This method must be used with a Root Finder algorithm using derivatives");
48  return false;
49  }
50 
51  /** Sets the function for the rest of the algorithms.
52  The parameters set the interval where the root has to be calculated. */
53  virtual bool SetFunction(const ROOT::Math::IGenFunction& , double , double )
54  {
55  MATH_ERROR_MSG("SetFunction", "Algorithm requires derivatives");
56  return false;
57  }
58 
59  /** Returns the previously calculated root. */
60  virtual double Root() const = 0;
61 
62  /** Returns the status of the previous estimate */
63  virtual int Status() const = 0;
64 
65  // Methods to be Implemented in the derived classes
66 
67  /** Stimates the root for the function.
68  \@param maxIter maximum number of iterations.
69  \@param absTol desired absolute error in the minimum position.
70  \@param absTol desired relative error in the minimum position.
71  */
72  virtual bool Solve(int maxIter = 100, double absTol = 1E-8, double relTol = 1E-10) = 0;
73 
74  /** Return name of root finder algorithm */
75  virtual const char* Name() const = 0;
76 
77  /** This method is implemented only by the GSLRootFinder
78  and GSLRootFinderDeriv classes and will return an error if it's not one of them. */
79  virtual int Iterate() {
80  MATH_ERROR_MSG("Iterate", "This method must be used with a Root Finder algorithm wrapping the GSL Library");
81  return -1;
82  }
83 
84  /** Return number of iterations used to find the root
85  Must be implemented by derived classes
86  */
87  virtual int Iterations() const { return -1; }
88 
89 };
90 
91 } // namespace Math
92 } // namespace ROOT
93 
94 
95 #endif /* ROOT_Math_IRootFinderMethod */
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Definition: IFunction.h:134
const double absTol
Namespace for new ROOT classes and functions.
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:392
Interface for finding function roots of one-dimensional functions.
IRootFinderMethod()
Default Constructor.
#define MATH_ERROR_MSG(loc, str)
Definition: Error.h:50
constexpr Double_t E()
Definition: TMath.h:74
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.