00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef ROOT_Math_WrappedMultiTF1
00014 #define ROOT_Math_WrappedMultiTF1
00015
00016
00017 #ifndef ROOT_Math_IParamFunction
00018 #include "Math/IParamFunction.h"
00019 #endif
00020
00021 #ifndef ROOT_TF1
00022 #include "TF1.h"
00023 #endif
00024
00025 namespace ROOT {
00026
00027 namespace Math {
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class WrappedMultiTF1 : public ROOT::Math::IParamMultiGradFunction {
00040
00041 public:
00042
00043 typedef ROOT::Math::IParamMultiGradFunction BaseParamFunc;
00044 typedef ROOT::Math::IParamMultiFunction::BaseFunc BaseFunc;
00045
00046
00047
00048
00049
00050
00051
00052
00053 WrappedMultiTF1 (TF1 & f, unsigned int dim = 0 );
00054
00055
00056
00057
00058 virtual ~WrappedMultiTF1 () {}
00059
00060
00061
00062
00063 WrappedMultiTF1(const WrappedMultiTF1 & rhs);
00064
00065
00066
00067
00068 WrappedMultiTF1 & operator = (const WrappedMultiTF1 & rhs);
00069
00070
00071
00072
00073
00074
00075
00076 IMultiGenFunction * Clone() const {
00077 return new WrappedMultiTF1(*this);
00078 }
00079
00080
00081 unsigned int NDim() const {
00082 return fDim;
00083 }
00084
00085
00086
00087
00088
00089 const double * Parameters() const {
00090 return (fParams.size() > 0) ? &fParams.front() : 0;
00091 }
00092
00093
00094 void SetParameters(const double * p) {
00095 std::copy(p,p+fParams.size(),fParams.begin());
00096 }
00097
00098
00099 unsigned int NPar() const {
00100 return fParams.size();
00101 }
00102
00103
00104 std::string ParameterName(unsigned int i) const {
00105 return std::string(fFunc->GetParName(i));
00106 }
00107
00108
00109 void ParameterGradient(const double * x, const double * par, double * grad ) const;
00110
00111
00112
00113 static void SetDerivPrecision(double eps);
00114
00115
00116 static double GetDerivPrecision();
00117
00118
00119 private:
00120
00121
00122 double DoEvalPar (const double * x, const double * p ) const {
00123 if (fFunc->GetMethodCall() ) fFunc->InitArgs(x,p);
00124 return fFunc->EvalPar(x,p);
00125 }
00126
00127
00128 double DoParameterDerivative(const double * x, const double * p, unsigned int ipar) const;
00129
00130
00131 bool fLinear;
00132 TF1 * fFunc;
00133 unsigned int fDim;
00134 std::vector<double> fParams;
00135
00136 static double fgEps;
00137 };
00138
00139 }
00140
00141 }
00142
00143
00144 #endif