|
||||
File indexing completed on 2025-01-18 10:10:17
0001 // @(#)root/mathmore:$Id$ 0002 // Author: L. Moneta, A. Zsenei 08/2005 0003 0004 /********************************************************************** 0005 * * 0006 * Copyright (c) 2004 ROOT Foundation, CERN/PH-SFT * 0007 * * 0008 * This library is free software; you can redistribute it and/or * 0009 * modify it under the terms of the GNU General Public License * 0010 * as published by the Free Software Foundation; either version 2 * 0011 * of the License, or (at your option) any later version. * 0012 * * 0013 * This library is distributed in the hope that it will be useful, * 0014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 0016 * General Public License for more details. * 0017 * * 0018 * You should have received a copy of the GNU General Public License * 0019 * along with this library (see file COPYING); if not, write * 0020 * to the Free Software Foundation, Inc., 59 Temple Place, Suite * 0021 * 330, Boston, MA 02111-1307 USA, or contact the author. * 0022 * * 0023 **********************************************************************/ 0024 0025 // Header file for class GSLRootFinder 0026 // 0027 // Created by: moneta at Sun Nov 14 11:27:11 2004 0028 // 0029 // Last update: Sun Nov 14 11:27:11 2004 0030 // 0031 #ifndef ROOT_Math_GSLRootFinder 0032 #define ROOT_Math_GSLRootFinder 0033 0034 0035 #include "Math/GSLFunctionAdapter.h" 0036 0037 #include "Math/IFunctionfwd.h" 0038 0039 #include "Math/IRootFinderMethod.h" 0040 0041 #include <iostream> 0042 0043 namespace ROOT { 0044 namespace Math { 0045 0046 0047 class GSLRootFSolver; 0048 class GSLFunctionWrapper; 0049 0050 0051 //________________________________________________________________________________________________________ 0052 /** 0053 Base class for GSL Root-Finding algorithms for one dimensional functions which do not use function derivatives. 0054 For finding the roots users should not use this class directly but instantiate the derived classes, 0055 for example ROOT::Math::Roots::Brent for using the Brent algorithm. 0056 All the classes defining the alhorithms are defined in the header Math/RootFinderAlgorithm.h 0057 They possible types implementing root bracketing algorithms which they do not require function 0058 derivatives are: 0059 <ul> 0060 <li>ROOT::Math::Roots::Bisection 0061 <li>ROOT::Math::Roots::FalsePos 0062 <li>ROOT::Math::Roots::Brent 0063 </ul> 0064 0065 See also the specific classes for the documentation. 0066 See the GSL <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Root-Bracketing-Algorithms.html"> online manual</A> for 0067 information on the GSL Root-Finding algorithms 0068 0069 @ingroup RootFinders 0070 */ 0071 0072 0073 class GSLRootFinder: public IRootFinderMethod { 0074 0075 public: 0076 GSLRootFinder(); 0077 ~GSLRootFinder() override; 0078 0079 private: 0080 // usually copying is non trivial, so we make this unaccessible 0081 GSLRootFinder(const GSLRootFinder &); 0082 GSLRootFinder & operator = (const GSLRootFinder &); 0083 0084 public: 0085 0086 0087 #if defined(__MAKECINT__) || defined(G__DICTIONARY) 0088 bool SetFunction( const IGradFunction & , double ) override { 0089 std::cerr <<"GSLRootFinder - Error : this method must be used with a Root Finder algorithm using derivatives" << std::endl; 0090 return false; 0091 } 0092 #endif 0093 0094 bool SetFunction( const IGenFunction & f, double xlow, double xup) override; 0095 0096 typedef double ( * GSLFuncPointer ) ( double, void *); 0097 bool SetFunction( GSLFuncPointer f, void * params, double xlow, double xup); 0098 0099 using IRootFinderMethod::SetFunction; 0100 0101 // iterate to find ROOTS return GSL_CONTINUE if iteration was successful or another error 0102 int Iterate() override; 0103 0104 double Root() const override; 0105 0106 //double XLower() const; 0107 0108 //double XUpper() const; 0109 0110 /// Find the root 0111 bool Solve( int maxIter = 100, double absTol = 1E-8, double relTol = 1E-10) override; 0112 0113 /// Return number of iterations 0114 int Iterations() const override { 0115 return fIter; 0116 } 0117 0118 /// Return the status of last root finding 0119 int Status() const override { return fStatus; } 0120 0121 const char * Name() const override; 0122 0123 0124 protected: 0125 0126 0127 void SetSolver ( GSLRootFSolver * s ); 0128 0129 void FreeSolver(); 0130 0131 private: 0132 0133 GSLFunctionWrapper * fFunction; 0134 GSLRootFSolver * fS; 0135 0136 double fRoot; 0137 double fXlow; 0138 double fXup; 0139 int fIter; 0140 int fStatus; 0141 bool fValidInterval; 0142 0143 }; 0144 0145 } // namespace Math 0146 } // namespace ROOT 0147 0148 0149 #endif /* ROOT_Math_GSLRootFinder */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |