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
80 // usually copying is non trivial, so we delete this
85
86#if defined(__MAKECINT__) || defined(G__DICTIONARY)
87 bool SetFunction( const IGenFunction & , double , double ) override {
88 std::cerr <<"GSLRootFinderDeriv - Error : Algorithm requirs derivatives" << std::endl;
89 return false;
90 }
91#endif
92
93 bool SetFunction( const IGradFunction & f, double xstart) override {
94 const void * p = &f;
96 }
97
98
99 typedef double ( * GSLFuncPointer ) ( double, void *);
100 typedef void ( * GSLFdFPointer ) ( double, void *, double *, double *);
101 bool SetFunction( GSLFuncPointer f, GSLFuncPointer df, GSLFdFPointer fdf, void * p, double Root );
102
104
105 /// iterate (return GSL_SUCCESS in case of successful iteration)
106 int Iterate() override;
107
108 double Root() const override;
109
110 /// Find the root (return false if failed)
111 bool Solve( int maxIter = 100, double absTol = 1E-8, double relTol = 1E-10) override;
112
113 /// Return number of iterations
114 int Iterations() const override {
115 return fIter;
116 }
117
118 /// Return the status of last root finding
119 int Status() const override { return fStatus; }
120
121 const char * Name() const override;
122
123protected:
124
125 void SetSolver ( GSLRootFdFSolver * s );
126
127 void FreeSolver();
128
129private:
130
133
134 mutable double fRoot;
135 mutable double fPrevRoot;
136 int fIter;
139
140};
141
142} // namespace Math
143} // namespace ROOT
144
145
146#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...
GSLRootFinderDeriv & operator=(GSLRootFinderDeriv &&)=delete
GSLRootFinderDeriv(GSLRootFinderDeriv &&)=delete
GSLFunctionDerivWrapper * fFunction
int Iterations() const override
Return number of iterations.
GSLRootFinderDeriv & operator=(const GSLRootFinderDeriv &)=delete
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)
GSLRootFinderDeriv(const GSLRootFinderDeriv &)=delete
bool SetFunction(const IGradFunction &f, double xstart) override
Sets the function for algorithms using derivatives.
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.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...