IRootFinderMethod.h

Go to the documentation of this file.
00001 // @(#)root/mathcore:$Id: IRootFinderMethod.h 32583 2010-03-12 09:57:42Z moneta $
00002 // Authors: David Gonzalez Maline    01/2008 
00003 
00004 /**********************************************************************
00005  *                                                                    *
00006  * Copyright (c) 2006 , LCG ROOT MathLib Team                         *
00007  *                                                                    *
00008  *                                                                    *
00009  **********************************************************************/
00010 
00011 // Header for the IRootFinderMethod interface
00012 // 
00013 // Created by: David Gonzalez Maline  : Fri Jan 25 2008
00014 // 
00015 
00016 #ifndef ROOT_Math_IRootFinderMethod
00017 #define ROOT_Math_IRootFinderMethod
00018 
00019 #ifndef ROOT_Math_Error
00020 #include "Math/Error.h"
00021 #endif
00022 
00023 #ifndef ROOT_Math_IFunctionfwd
00024 #include "Math/IFunctionfwd.h"
00025 #endif
00026 
00027 namespace ROOT {
00028 namespace Math {
00029 
00030 //___________________________________________________________________________________________
00031 /**
00032    Interface for finding function roots of one-dimensional functions
00033 
00034    @ingroup RootFinders
00035   
00036  */
00037 
00038 class IRootFinderMethod {
00039 public:
00040    /** Default Destructor. */
00041    virtual ~IRootFinderMethod() {}
00042 
00043    /** Default Constructor. */
00044    IRootFinderMethod() {}
00045    
00046    // Common functionality
00047 
00048    /** Sets the function for algorithms using derivatives.  */
00049    virtual bool SetFunction(const ROOT::Math::IGradFunction&, double)
00050    {
00051       MATH_ERROR_MSG("SetFunction", "This method must be used with a Root Finder algorithm using derivatives");
00052       return false;
00053    }
00054 
00055    /** Sets the function for the rest of the algorithms.
00056        The parameters set the interval where the root has to be calculated. */
00057    virtual bool SetFunction(const ROOT::Math::IGenFunction& , double , double )
00058    {
00059       MATH_ERROR_MSG("SetFunction", "Algorithm requires derivatives");
00060       return false;
00061    }
00062 
00063    /** Returns the previously calculated root. */
00064    virtual double Root() const = 0;
00065 
00066    /** Returns the status of the previous estimate */
00067    virtual int Status() const = 0; 
00068 
00069    // Methods to be Implemented in the derived classes
00070 
00071    /** Stimates the root for the function.  
00072        \@param maxIter maximum number of iterations.
00073        \@param absTol desired absolute error in the minimum position.
00074        \@param absTol desired relative error in the minimum position.
00075    */
00076    virtual bool Solve(int maxIter = 100, double absTol = 1E-8, double relTol = 1E-10) = 0;
00077 
00078    /** Return name of root finder algorithm */
00079    virtual const char* Name() const = 0;
00080    
00081    /** This method is  implemented only by the GSLRootFinder 
00082        and GSLRootFinderDeriv classes and will return an error if it's not one of them. */
00083    virtual int Iterate() {
00084       MATH_ERROR_MSG("Iterate", "This method must be used with a Root Finder algorithm wrapping the GSL Library");
00085       return -1;
00086    }
00087 
00088    /** Return number of iterations used to find the root 
00089        Must be implemented by derived classes 
00090    */
00091    virtual int Iterations() const { return -1; } 
00092 
00093 };
00094 
00095 } // namespace Math
00096 } // namespace ROOT
00097 
00098 
00099 #endif /* ROOT_Math_IRootFinderMethod */

Generated on Tue Jul 5 14:25:31 2011 for ROOT_528-00b_version by  doxygen 1.5.1