![]() |
|
|||
File indexing completed on 2025-09-18 09:31:37
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 // usually copying is non trivial, so we delete this 0080 GSLRootFinder(const GSLRootFinder &) = delete; 0081 GSLRootFinder &operator=(const GSLRootFinder &) = delete; 0082 GSLRootFinder(GSLRootFinder &&) = delete; 0083 GSLRootFinder &operator=(GSLRootFinder &&) = delete; 0084 0085 #if defined(__MAKECINT__) || defined(G__DICTIONARY) 0086 bool SetFunction( const IGradFunction & , double ) override { 0087 std::cerr <<"GSLRootFinder - Error : this method must be used with a Root Finder algorithm using derivatives" << std::endl; 0088 return false; 0089 } 0090 #endif 0091 0092 bool SetFunction( const IGenFunction & f, double xlow, double xup) override; 0093 0094 typedef double ( * GSLFuncPointer ) ( double, void *); 0095 bool SetFunction( GSLFuncPointer f, void * params, double xlow, double xup); 0096 0097 using IRootFinderMethod::SetFunction; 0098 0099 // iterate to find ROOTS return GSL_CONTINUE if iteration was successful or another error 0100 int Iterate() override; 0101 0102 double Root() const override; 0103 0104 //double XLower() const; 0105 0106 //double XUpper() const; 0107 0108 /// Find the root 0109 bool Solve( int maxIter = 100, double absTol = 1E-8, double relTol = 1E-10) override; 0110 0111 /// Return number of iterations 0112 int Iterations() const override { 0113 return fIter; 0114 } 0115 0116 /// Return the status of last root finding 0117 int Status() const override { return fStatus; } 0118 0119 const char * Name() const override; 0120 0121 0122 protected: 0123 0124 0125 void SetSolver ( GSLRootFSolver * s ); 0126 0127 void FreeSolver(); 0128 0129 private: 0130 0131 GSLFunctionWrapper * fFunction; 0132 GSLRootFSolver * fS; 0133 0134 double fRoot; 0135 double fXlow; 0136 double fXup; 0137 int fIter; 0138 int fStatus; 0139 bool fValidInterval; 0140 0141 }; 0142 0143 } // namespace Math 0144 } // namespace ROOT 0145 0146 0147 #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 |
![]() ![]() |