// @(#)root/mathcore:$Id$
// Authors: David Gonzalez Maline    01/2008 

/**********************************************************************
 *                                                                    *
 * Copyright (c) 2006 , LCG ROOT MathLib Team                         *
 *                                                                    *
 *                                                                    *
 **********************************************************************/

// Header for the IRootFinderMethod interface
// 
// Created by: David Gonzalez Maline  : Fri Jan 25 2008
// 

#ifndef ROOT_Math_IRootFinderMethod
#define ROOT_Math_IRootFinderMethod

#ifndef ROOT_Math_Error
#include "Math/Error.h"
#endif

#ifndef ROOT_Math_IFunctionfwd
#include "Math/IFunctionfwd.h"
#endif

namespace ROOT {
namespace Math {

//___________________________________________________________________________________________
/**
   Interface for finding function roots of one-dimensional functions

   @ingroup RootFinders
  
 */

class IRootFinderMethod {
public:
   /** Default Destructor. */
   virtual ~IRootFinderMethod() {}

   /** Default Constructor. */
   IRootFinderMethod() {}
   
   // Common functionality

   /** Sets the function for algorithms using derivatives.  */
   virtual bool SetFunction(const ROOT::Math::IGradFunction&, double)
   {
      MATH_ERROR_MSG("SetFunction", "This method must be used with a Root Finder algorithm using derivatives");
      return false;
   }

   /** Sets the function for the rest of the algorithms.
       The parameters set the interval where the root has to be calculated. */
   virtual bool SetFunction(const ROOT::Math::IGenFunction& , double , double )
   {
      MATH_ERROR_MSG("SetFunction", "Algorithm requires derivatives");
      return false;
   }

   /** Returns the previously calculated root. */
   virtual double Root() const = 0;

   /** Returns the status of the previous estimate */
   virtual int Status() const = 0; 

   // Methods to be Implemented in the derived classes

   /** Stimates the root for the function.  
       \@param maxIter maximum number of iterations.
       \@param absTol desired absolute error in the minimum position.
       \@param absTol desired relative error in the minimum position.
   */
   virtual bool Solve(int maxIter = 100, double absTol = 1E-8, double relTol = 1E-10) = 0;

   /** Return name of root finder algorithm */
   virtual const char* Name() const = 0;
   
   /** This method is  implemented only by the GSLRootFinder 
       and GSLRootFinderDeriv classes and will return an error if it's not one of them. */
   virtual int Iterate() {
      MATH_ERROR_MSG("Iterate", "This method must be used with a Root Finder algorithm wrapping the GSL Library");
      return -1;
   }

   /** Return number of iterations used to find the root 
       Must be implemented by derived classes 
   */
   virtual int Iterations() const { return -1; } 

};

} // namespace Math
} // namespace ROOT


#endif /* ROOT_Math_IRootFinderMethod */
 IRootFinderMethod.h:1
 IRootFinderMethod.h:2
 IRootFinderMethod.h:3
 IRootFinderMethod.h:4
 IRootFinderMethod.h:5
 IRootFinderMethod.h:6
 IRootFinderMethod.h:7
 IRootFinderMethod.h:8
 IRootFinderMethod.h:9
 IRootFinderMethod.h:10
 IRootFinderMethod.h:11
 IRootFinderMethod.h:12
 IRootFinderMethod.h:13
 IRootFinderMethod.h:14
 IRootFinderMethod.h:15
 IRootFinderMethod.h:16
 IRootFinderMethod.h:17
 IRootFinderMethod.h:18
 IRootFinderMethod.h:19
 IRootFinderMethod.h:20
 IRootFinderMethod.h:21
 IRootFinderMethod.h:22
 IRootFinderMethod.h:23
 IRootFinderMethod.h:24
 IRootFinderMethod.h:25
 IRootFinderMethod.h:26
 IRootFinderMethod.h:27
 IRootFinderMethod.h:28
 IRootFinderMethod.h:29
 IRootFinderMethod.h:30
 IRootFinderMethod.h:31
 IRootFinderMethod.h:32
 IRootFinderMethod.h:33
 IRootFinderMethod.h:34
 IRootFinderMethod.h:35
 IRootFinderMethod.h:36
 IRootFinderMethod.h:37
 IRootFinderMethod.h:38
 IRootFinderMethod.h:39
 IRootFinderMethod.h:40
 IRootFinderMethod.h:41
 IRootFinderMethod.h:42
 IRootFinderMethod.h:43
 IRootFinderMethod.h:44
 IRootFinderMethod.h:45
 IRootFinderMethod.h:46
 IRootFinderMethod.h:47
 IRootFinderMethod.h:48
 IRootFinderMethod.h:49
 IRootFinderMethod.h:50
 IRootFinderMethod.h:51
 IRootFinderMethod.h:52
 IRootFinderMethod.h:53
 IRootFinderMethod.h:54
 IRootFinderMethod.h:55
 IRootFinderMethod.h:56
 IRootFinderMethod.h:57
 IRootFinderMethod.h:58
 IRootFinderMethod.h:59
 IRootFinderMethod.h:60
 IRootFinderMethod.h:61
 IRootFinderMethod.h:62
 IRootFinderMethod.h:63
 IRootFinderMethod.h:64
 IRootFinderMethod.h:65
 IRootFinderMethod.h:66
 IRootFinderMethod.h:67
 IRootFinderMethod.h:68
 IRootFinderMethod.h:69
 IRootFinderMethod.h:70
 IRootFinderMethod.h:71
 IRootFinderMethod.h:72
 IRootFinderMethod.h:73
 IRootFinderMethod.h:74
 IRootFinderMethod.h:75
 IRootFinderMethod.h:76
 IRootFinderMethod.h:77
 IRootFinderMethod.h:78
 IRootFinderMethod.h:79
 IRootFinderMethod.h:80
 IRootFinderMethod.h:81
 IRootFinderMethod.h:82
 IRootFinderMethod.h:83
 IRootFinderMethod.h:84
 IRootFinderMethod.h:85
 IRootFinderMethod.h:86
 IRootFinderMethod.h:87
 IRootFinderMethod.h:88
 IRootFinderMethod.h:89
 IRootFinderMethod.h:90
 IRootFinderMethod.h:91
 IRootFinderMethod.h:92
 IRootFinderMethod.h:93
 IRootFinderMethod.h:94
 IRootFinderMethod.h:95
 IRootFinderMethod.h:96
 IRootFinderMethod.h:97
 IRootFinderMethod.h:98
 IRootFinderMethod.h:99