File indexing completed on 2025-09-15 09:11:18
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
0081 GSLRootFinderDeriv(const GSLRootFinderDeriv &) = delete;
0082 GSLRootFinderDeriv &operator=(const GSLRootFinderDeriv &) = delete;
0083 GSLRootFinderDeriv(GSLRootFinderDeriv &&) = delete;
0084 GSLRootFinderDeriv &operator=(GSLRootFinderDeriv &&) = delete;
0085
0086 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
0087 bool SetFunction( const IGenFunction & , double , double ) override {
0088 std::cerr <<"GSLRootFinderDeriv - Error : Algorithm requirs derivatives" << std::endl;
0089 return false;
0090 }
0091 #endif
0092
0093 bool SetFunction( const IGradFunction & f, double xstart) override {
0094 const void * p = &f;
0095 return SetFunction( &GSLFunctionAdapter<IGradFunction>::F, &GSLFunctionAdapter<IGradFunction>::Df, &GSLFunctionAdapter<IGradFunction>::Fdf, const_cast<void *>(p), xstart );
0096 }
0097
0098
0099 typedef double ( * GSLFuncPointer ) ( double, void *);
0100 typedef void ( * GSLFdFPointer ) ( double, void *, double *, double *);
0101 bool SetFunction( GSLFuncPointer f, GSLFuncPointer df, GSLFdFPointer fdf, void * p, double Root );
0102
0103 using IRootFinderMethod::SetFunction;
0104
0105
0106 int Iterate() override;
0107
0108 double Root() const override;
0109
0110
0111 bool Solve( int maxIter = 100, double absTol = 1E-8, double relTol = 1E-10) override;
0112
0113
0114 int Iterations() const override {
0115 return fIter;
0116 }
0117
0118
0119 int Status() const override { return fStatus; }
0120
0121 const char * Name() const override;
0122
0123 protected:
0124
0125 void SetSolver ( GSLRootFdFSolver * s );
0126
0127 void FreeSolver();
0128
0129 private:
0130
0131 GSLFunctionDerivWrapper * fFunction;
0132 GSLRootFdFSolver * fS;
0133
0134 mutable double fRoot;
0135 mutable double fPrevRoot;
0136 int fIter;
0137 int fStatus;
0138 bool fValidPoint;
0139
0140 };
0141
0142 }
0143 }
0144
0145
0146 #endif