Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
GSLRootFinderDeriv.h
Go to the documentation of this file.
1// @(#)root/mathmore:$Id$
2// Authors: 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 GSLRootFinderDeriv
26//
27// Created by: moneta at Sun Nov 21 16:26:03 2004
28//
29// Last update: Sun Nov 21 16:26:03 2004
30//
31#ifndef ROOT_Math_GSL_RootFinderDeriv
32#define ROOT_Math_GSL_RootFinderDeriv
33
34
36
37#include "Math/IFunctionfwd.h"
38#include "Math/IFunction.h"
39
41
42#include <iostream>
43
44namespace ROOT {
45namespace Math {
46
47
48 class GSLRootFdFSolver;
49 class GSLFunctionDerivWrapper;
50
51
52//_____________________________________________________________________________________
53 /**
54 Base class for GSL Root-Finding algorithms for one dimensional functions which use function derivatives.
55 For finding the roots users should not use this class directly but instantiate the derived classes,
56 for example ROOT::Math::Roots::Newton for using the Newton algorithm.
57 All the classes defining the alhorithms are defined in the header Math/RootFinderAlgorithm.h
58 They possible types implementing root bracketing algorithms which use function
59 derivatives are:
60 <ul>
61 <li>ROOT::Math::Roots::Newton
62 <li>ROOT::Math::Roots::Secant
63 <li>ROOT::Math::Roots::Steffenson
64 </ul>
65
66 See also those classes for the documentation.
67 See the GSL <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Root-Finding-Algorithms-using-Derivatives.html"> online manual</A> for
68 information on the GSL Root-Finding algorithms
69
70 @ingroup RootFinders
71 */
72
73
75
76public:
78 ~GSLRootFinderDeriv() override;
79
80private:
81 // usually copying is non trivial, so we make this unaccessible
84
85public:
86
87
88
89#if defined(__MAKECINT__) || defined(G__DICTIONARY)
90 bool SetFunction( const IGenFunction & , double , double ) override {
91 std::cerr <<"GSLRootFinderDeriv - Error : Algorithm requirs derivatives" << std::endl;
92 return false;
93 }
94#endif
95
96 bool SetFunction( const IGradFunction & f, double xstart) override {
97 const void * p = &f;
99 }
100
101
102 typedef double ( * GSLFuncPointer ) ( double, void *);
103 typedef void ( * GSLFdFPointer ) ( double, void *, double *, double *);
104 bool SetFunction( GSLFuncPointer f, GSLFuncPointer df, GSLFdFPointer fdf, void * p, double Root );
105
107
108 /// iterate (return GSL_SUCCESS in case of successful iteration)
109 int Iterate() override;
110
111 double Root() const override;
112
113 /// Find the root (return false if failed)
114 bool Solve( int maxIter = 100, double absTol = 1E-8, double relTol = 1E-10) override;
115
116 /// Return number of iterations
117 int Iterations() const override {
118 return fIter;
119 }
120
121 /// Return the status of last root finding
122 int Status() const override { return fStatus; }
123
124 const char * Name() const override;
125
126protected:
127
128 void SetSolver ( GSLRootFdFSolver * s );
129
130 void FreeSolver();
131
132private:
133
136
137 mutable double fRoot;
138 mutable double fPrevRoot;
139 int fIter;
142
143};
144
145} // namespace Math
146} // namespace ROOT
147
148
149#endif /* ROOT_Math_GSL_RootFinderDeriv */
#define f(i)
Definition RSha256.hxx:104
winID h TVirtualViewer3D TVirtualGLPainter p
Class for adapting any C++ functor class to C function pointers used by GSL.
class to wrap a gsl_function_fdf (with derivatives)
Root-Finder with derivatives implementation class using GSL.
Base class for GSL Root-Finding algorithms for one dimensional functions which use function derivativ...
GSLFunctionDerivWrapper * fFunction
int Iterations() const override
Return number of iterations.
const char * Name() const override
Return name of root finder algorithm.
int Status() const override
Return the status of last root finding.
int Iterate() override
iterate (return GSL_SUCCESS in case of successful iteration)
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 (return false if failed)
bool SetFunction(const IGradFunction &f, double xstart) override
Sets the function for algorithms using derivatives.
GSLRootFinderDeriv & operator=(const GSLRootFinderDeriv &)
void SetSolver(GSLRootFdFSolver *s)
double(* GSLFuncPointer)(double, void *)
void(* GSLFdFPointer)(double, void *, double *, double *)
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.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.