00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef ROOT_Math_GSL_RootFinderDeriv
00032 #define ROOT_Math_GSL_RootFinderDeriv
00033
00034
00035 #ifndef ROOT_Math_GSLFunctionAdapter
00036 #include "Math/GSLFunctionAdapter.h"
00037 #endif
00038
00039 #ifndef ROOT_Math_IFunctionfwd
00040 #include "Math/IFunctionfwd.h"
00041 #endif
00042 #ifndef ROOT_Math_IFunction
00043 #include "Math/IFunction.h"
00044 #endif
00045
00046 #ifndef ROOT_Math_IRootFinderMethod
00047 #include "Math/IRootFinderMethod.h"
00048 #endif
00049
00050 #include <iostream>
00051
00052 namespace ROOT {
00053 namespace Math {
00054
00055
00056 class GSLRootFdFSolver;
00057 class GSLFunctionDerivWrapper;
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 class GSLRootFinderDeriv: public IRootFinderMethod {
00083
00084 public:
00085 GSLRootFinderDeriv();
00086 virtual ~GSLRootFinderDeriv();
00087
00088 private:
00089
00090 GSLRootFinderDeriv(const GSLRootFinderDeriv &);
00091 GSLRootFinderDeriv & operator = (const GSLRootFinderDeriv &);
00092
00093 public:
00094
00095
00096
00097 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
00098 bool SetFunction( const IGenFunction & , double , double ) {
00099 std::cerr <<"GSLRootFinderDeriv - Error : Algorithm requirs derivatives" << std::endl;
00100 return false;
00101 }
00102 #endif
00103
00104 bool SetFunction( const IGradFunction & f, double xstart) {
00105 const void * p = &f;
00106 return SetFunction( &GSLFunctionAdapter<IGradFunction>::F, &GSLFunctionAdapter<IGradFunction>::Df, &GSLFunctionAdapter<IGradFunction>::Fdf, const_cast<void *>(p), xstart );
00107 }
00108
00109
00110 typedef double ( * GSLFuncPointer ) ( double, void *);
00111 typedef void ( * GSLFdFPointer ) ( double, void *, double *, double *);
00112 bool SetFunction( GSLFuncPointer f, GSLFuncPointer df, GSLFdFPointer fdf, void * p, double Root );
00113
00114 using IRootFinderMethod::SetFunction;
00115
00116
00117 int Iterate();
00118
00119 double Root() const;
00120
00121
00122 bool Solve( int maxIter = 100, double absTol = 1E-8, double relTol = 1E-10);
00123
00124
00125 int Iterations() const {
00126 return fIter;
00127 }
00128
00129
00130 int Status() const { return fStatus; }
00131
00132 const char * Name() const;
00133
00134 protected:
00135
00136 void SetSolver ( GSLRootFdFSolver * s );
00137
00138 void FreeSolver();
00139
00140 private:
00141
00142 GSLFunctionDerivWrapper * fFunction;
00143 GSLRootFdFSolver * fS;
00144
00145 mutable double fRoot;
00146 mutable double fPrevRoot;
00147 int fIter;
00148 int fStatus;
00149 bool fValidPoint;
00150
00151 };
00152
00153 }
00154 }
00155
00156
00157 #endif