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
00032 #include "Math/IFunction.h"
00033 #include "Math/IParamFunction.h"
00034 #include "Math/Derivator.h"
00035 #include "GSLDerivator.h"
00036
00037 #include "Math/OneDimFunctionAdapter.h"
00038
00039
00040 #include "gsl/gsl_deriv.h"
00041
00042
00043
00044 namespace ROOT {
00045 namespace Math {
00046
00047 Derivator::Derivator() {
00048 fDerivator = new GSLDerivator();
00049 }
00050
00051 Derivator::Derivator(const IGenFunction &f)
00052 {
00053
00054 fDerivator = new GSLDerivator();
00055 fDerivator->SetFunction(f);
00056 }
00057
00058 Derivator::Derivator(const GSLFuncPointer &f, void * p)
00059 {
00060
00061 fDerivator = new GSLDerivator();
00062 fDerivator->SetFunction(f,p);
00063
00064 }
00065
00066 Derivator::~Derivator()
00067 {
00068 if (fDerivator) delete fDerivator;
00069 }
00070
00071
00072 Derivator::Derivator(const Derivator &)
00073 {
00074 }
00075
00076 Derivator & Derivator::operator = (const Derivator &rhs)
00077 {
00078 if (this == &rhs) return *this;
00079
00080 return *this;
00081 }
00082
00083
00084 void Derivator::SetFunction(const IGenFunction &f) {
00085 fDerivator->SetFunction(f);
00086 }
00087
00088 void Derivator::SetFunction( const GSLFuncPointer &f, void * p) {
00089 fDerivator->SetFunction(f,p);
00090 }
00091
00092
00093 double Derivator::Eval( double x, double h) const {
00094 return fDerivator->EvalCentral(x, h);
00095 }
00096
00097 double Derivator::EvalCentral( double x, double h) const {
00098 return fDerivator->EvalCentral(x, h);
00099 }
00100
00101 double Derivator::EvalForward( double x, double h) const {
00102 return fDerivator->EvalForward(x, h);
00103 }
00104
00105 double Derivator::EvalBackward( double x, double h) const {
00106 return fDerivator->EvalBackward(x, h);
00107 }
00108
00109
00110 double Derivator::Eval(const IGenFunction & f, double x, double h ) {
00111 return GSLDerivator::EvalCentral(f, x, h );
00112 }
00113
00114 double Derivator::EvalCentral(const IGenFunction & f, double x, double h) {
00115 return GSLDerivator::EvalCentral(f,x,h);
00116 }
00117
00118 double Derivator::EvalForward(const IGenFunction & f, double x, double h) {
00119 return GSLDerivator::EvalForward(f, x, h);
00120 }
00121
00122 double Derivator::EvalBackward(const IGenFunction & f, double x, double h) {
00123 return GSLDerivator::EvalBackward(f, x, h);
00124 }
00125
00126 double Derivator::Eval(const IMultiGenFunction & f, const double * x, unsigned int icoord, double h ) {
00127
00128 GSLDerivator d;
00129 OneDimMultiFunctionAdapter<> adapter(f,x,icoord);
00130 d.SetFunction( &GSLFunctionAdapter<OneDimMultiFunctionAdapter<> >::F,static_cast<void *>(&adapter) );
00131 return d.EvalCentral(x[icoord],h);
00132 }
00133
00134 double Derivator::Eval(IParamFunction & f, double x, const double * p, unsigned int ipar, double h ) {
00135
00136 GSLDerivator d;
00137 const double xx = x;
00138 OneDimParamFunctionAdapter<IParamFunction &> adapter(f,&xx,p,ipar);
00139 d.SetFunction( &GSLFunctionAdapter<OneDimParamFunctionAdapter<IParamFunction &> >::F,static_cast<void *>(&adapter) );
00140 return d.EvalCentral(p[ipar],h);
00141 }
00142
00143 double Derivator::Eval(IParamMultiFunction & f, const double * x, const double * p, unsigned int ipar, double h ) {
00144
00145 GSLDerivator d;
00146 OneDimParamFunctionAdapter<IParamMultiFunction &> adapter(f,x,p,ipar);
00147 d.SetFunction( &GSLFunctionAdapter<OneDimParamFunctionAdapter<IParamMultiFunction &> >::F,static_cast<void *>(&adapter) );
00148 return d.EvalCentral(p[ipar],h);
00149 }
00150
00151
00152 double Derivator::Result() const { return fDerivator->Result(); }
00153
00154 double Derivator::Error() const { return fDerivator->Error(); }
00155
00156 int Derivator::Status() const { return fDerivator->Status(); }
00157
00158
00159
00160 }
00161 }