Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
GSLRootFinder.h
Go to the documentation of this file.
1// @(#)root/mathmore:$Id$
2// Author: L. Moneta, A. Zsenei 08/2005
3
4 /**********************************************************************
5 * *
6 * Copyright (c) 2004 ROOT Foundation, CERN/PH-SFT *
7 * *
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU General Public License *
10 * as published by the Free Software Foundation; either version 2 *
11 * of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this library (see file COPYING); if not, write *
20 * to the Free Software Foundation, Inc., 59 Temple Place, Suite *
21 * 330, Boston, MA 02111-1307 USA, or contact the author. *
22 * *
23 **********************************************************************/
24
25// Header file for class GSLRootFinder
26//
27// Created by: moneta at Sun Nov 14 11:27:11 2004
28//
29// Last update: Sun Nov 14 11:27:11 2004
30//
31#ifndef ROOT_Math_GSLRootFinder
32#define ROOT_Math_GSLRootFinder
33
34
36
37#include "Math/IFunctionfwd.h"
38
40
41#include <iostream>
42
43namespace ROOT {
44namespace Math {
45
46
47 class GSLRootFSolver;
48 class GSLFunctionWrapper;
49
50
51//________________________________________________________________________________________________________
52 /**
53 Base class for GSL Root-Finding algorithms for one dimensional functions which do not use function derivatives.
54 For finding the roots users should not use this class directly but instantiate the derived classes,
55 for example ROOT::Math::Roots::Brent for using the Brent algorithm.
56 All the classes defining the alhorithms are defined in the header Math/RootFinderAlgorithm.h
57 They possible types implementing root bracketing algorithms which they do not require function
58 derivatives are:
59 <ul>
60 <li>ROOT::Math::Roots::Bisection
61 <li>ROOT::Math::Roots::FalsePos
62 <li>ROOT::Math::Roots::Brent
63 </ul>
64
65 See also the specific classes for the documentation.
66 See the GSL <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Root-Bracketing-Algorithms.html"> online manual</A> for
67 information on the GSL Root-Finding algorithms
68
69 @ingroup RootFinders
70 */
71
72
74
75 public:
77 ~GSLRootFinder() override;
78
79 // usually copying is non trivial, so we delete this
80 GSLRootFinder(const GSLRootFinder &) = delete;
84
85#if defined(__MAKECINT__) || defined(G__DICTIONARY)
86 bool SetFunction( const IGradFunction & , double ) override {
87 std::cerr <<"GSLRootFinder - Error : this method must be used with a Root Finder algorithm using derivatives" << std::endl;
88 return false;
89 }
90#endif
91
92 bool SetFunction( const IGenFunction & f, double xlow, double xup) override;
93
94 typedef double ( * GSLFuncPointer ) ( double, void *);
95 bool SetFunction( GSLFuncPointer f, void * params, double xlow, double xup);
96
98
99 // iterate to find ROOTS return GSL_CONTINUE if iteration was successful or another error
100 int Iterate() override;
101
102 double Root() const override;
103
104 //double XLower() const;
105
106 //double XUpper() const;
107
108 /// Find the root
109 bool Solve( int maxIter = 100, double absTol = 1E-8, double relTol = 1E-10) override;
110
111 /// Return number of iterations
112 int Iterations() const override {
113 return fIter;
114 }
115
116 /// Return the status of last root finding
117 int Status() const override { return fStatus; }
118
119 const char * Name() const override;
120
121
122 protected:
123
124
125 void SetSolver ( GSLRootFSolver * s );
126
127 void FreeSolver();
128
129 private:
130
133
134 double fRoot;
135 double fXlow;
136 double fXup;
137 int fIter;
140
141 };
142
143} // namespace Math
144} // namespace ROOT
145
146
147#endif /* ROOT_Math_GSLRootFinder */
#define f(i)
Definition RSha256.hxx:104
Wrapper class to the gsl_function C structure.
Root-Finder implementation class using GSL.
Base class for GSL Root-Finding algorithms for one dimensional functions which do not use function de...
GSLRootFinder(GSLRootFinder &&)=delete
double(* GSLFuncPointer)(double, void *)
const char * Name() const override
double GSLRootFinder::XLower() const { return fXlow; }
GSLFunctionWrapper * fFunction
int Status() const override
Return the status of last root finding.
int Iterate() override
This method is implemented only by the GSLRootFinder and GSLRootFinderDeriv classes and will return a...
void SetSolver(GSLRootFSolver *s)
GSLRootFinder & operator=(const GSLRootFinder &)=delete
int Iterations() const override
Return number of iterations.
GSLRootFinder(const GSLRootFinder &)=delete
GSLRootFinder & operator=(GSLRootFinder &&)=delete
double Root() const override
Returns the previously calculated root.
bool Solve(int maxIter=100, double absTol=1E-8, double relTol=1E-10) override
Find the root.
bool SetFunction(const IGenFunction &f, double xlow, double xup) override
Sets the function for the rest of the algorithms.
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Definition IFunction.h:112
Interface (abstract class) for one-dimensional functions providing a gradient calculation.
Definition IFunction.h:254
Interface for finding function roots of one-dimensional functions.
virtual bool SetFunction(const ROOT::Math::IGradFunction &, double)
Sets the function for algorithms using derivatives.
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...