File indexing completed on 2025-01-18 10:10:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #ifndef ROOT_Math_GSL_RootFinderDeriv
0032 #define ROOT_Math_GSL_RootFinderDeriv
0033
0034
0035 #include "Math/GSLFunctionAdapter.h"
0036
0037 #include "Math/IFunctionfwd.h"
0038 #include "Math/IFunction.h"
0039
0040 #include "Math/IRootFinderMethod.h"
0041
0042 #include <iostream>
0043
0044 namespace ROOT {
0045 namespace Math {
0046
0047
0048 class GSLRootFdFSolver;
0049 class GSLFunctionDerivWrapper;
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074 class GSLRootFinderDeriv: public IRootFinderMethod {
0075
0076 public:
0077 GSLRootFinderDeriv();
0078 ~GSLRootFinderDeriv() override;
0079
0080 private:
0081
0082 GSLRootFinderDeriv(const GSLRootFinderDeriv &);
0083 GSLRootFinderDeriv & operator = (const GSLRootFinderDeriv &);
0084
0085 public:
0086
0087
0088
0089 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
0090 bool SetFunction( const IGenFunction & , double , double ) override {
0091 std::cerr <<"GSLRootFinderDeriv - Error : Algorithm requirs derivatives" << std::endl;
0092 return false;
0093 }
0094 #endif
0095
0096 bool SetFunction( const IGradFunction & f, double xstart) override {
0097 const void * p = &f;
0098 return SetFunction( &GSLFunctionAdapter<IGradFunction>::F, &GSLFunctionAdapter<IGradFunction>::Df, &GSLFunctionAdapter<IGradFunction>::Fdf, const_cast<void *>(p), xstart );
0099 }
0100
0101
0102 typedef double ( * GSLFuncPointer ) ( double, void *);
0103 typedef void ( * GSLFdFPointer ) ( double, void *, double *, double *);
0104 bool SetFunction( GSLFuncPointer f, GSLFuncPointer df, GSLFdFPointer fdf, void * p, double Root );
0105
0106 using IRootFinderMethod::SetFunction;
0107
0108
0109 int Iterate() override;
0110
0111 double Root() const override;
0112
0113
0114 bool Solve( int maxIter = 100, double absTol = 1E-8, double relTol = 1E-10) override;
0115
0116
0117 int Iterations() const override {
0118 return fIter;
0119 }
0120
0121
0122 int Status() const override { return fStatus; }
0123
0124 const char * Name() const override;
0125
0126 protected:
0127
0128 void SetSolver ( GSLRootFdFSolver * s );
0129
0130 void FreeSolver();
0131
0132 private:
0133
0134 GSLFunctionDerivWrapper * fFunction;
0135 GSLRootFdFSolver * fS;
0136
0137 mutable double fRoot;
0138 mutable double fPrevRoot;
0139 int fIter;
0140 int fStatus;
0141 bool fValidPoint;
0142
0143 };
0144
0145 }
0146 }
0147
0148
0149 #endif