File indexing completed on 2025-01-18 10:10:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef ROOT_Math_MinimTransformFunction
0015 #define ROOT_Math_MinimTransformFunction
0016
0017
0018 #include "Math/IFunction.h"
0019
0020 #include "Math/MinimTransformVariable.h"
0021
0022
0023 #include <vector>
0024 #include <map>
0025 #include <memory>
0026 #include <iostream>
0027
0028 namespace ROOT {
0029
0030 namespace Math {
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 class MinimTransformFunction : public IMultiGradFunction {
0042
0043 public:
0044
0045 typedef ROOT::Math::IMultiGradFunction BaseGradFunc;
0046 typedef ROOT::Math::IMultiGradFunction::BaseFunc BaseFunc;
0047
0048
0049
0050
0051
0052
0053
0054
0055 MinimTransformFunction ( const IMultiGradFunction * f, const std::vector<ROOT::Math::EMinimVariableType> & types, const std::vector<double> & values,
0056 const std::map<unsigned int, std::pair<double, double> > & bounds);
0057
0058
0059
0060
0061
0062 ~MinimTransformFunction () override { }
0063
0064
0065
0066 unsigned int NDim() const override { return fIndex.size(); }
0067
0068 unsigned int NTot() const { return fFunc->NDim(); }
0069
0070
0071 IMultiGenFunction * Clone() const override {
0072 return nullptr;
0073 }
0074
0075
0076
0077
0078 const double * Transformation( const double * x) const {
0079 Transformation(x, &fX[0]);
0080 return &fX.front();
0081 }
0082
0083
0084
0085 void Transformation( const double * xint, double * xext) const;
0086
0087
0088 void InvTransformation(const double * xext, double * xint) const;
0089
0090
0091 void InvStepTransformation(const double * x, const double * sext, double * sint) const;
0092
0093
0094 void GradientTransformation(const double * x, const double *gExt, double * gInt) const;
0095
0096
0097
0098 void MatrixTransformation(const double * x, const double *covInt, double * covExt) const;
0099
0100
0101 const IMultiGradFunction *OriginalFunction() const { return fFunc; }
0102
0103
0104 private:
0105
0106
0107 double DoEval(const double * x) const override {
0108 #ifndef DO_THREADSAFE
0109 return (*fFunc)(Transformation(x));
0110 #else
0111 std::vector<double> xext(fVariables.size() );
0112 Transformation(x, &xext[0]);
0113 return (*fFunc)(&xext[0]);
0114 #endif
0115 }
0116
0117
0118 double DoDerivative (const double * x, unsigned int icoord ) const override {
0119 const MinimTransformVariable & var = fVariables[ fIndex[icoord] ];
0120 double dExtdInt = (var.IsLimited() ) ? var.DerivativeIntToExt( x[icoord] ) : 1.0;
0121 double deriv = fFunc->Derivative( Transformation(x) , fIndex[icoord] );
0122
0123 return deriv * dExtdInt;
0124 }
0125
0126
0127 MinimTransformFunction( const MinimTransformFunction & ) :
0128 BaseFunc(), BaseGradFunc()
0129 {}
0130
0131
0132 MinimTransformFunction & operator= ( const MinimTransformFunction & ) {
0133 return *this;
0134 }
0135
0136
0137
0138 private:
0139
0140 mutable std::vector<double> fX;
0141 std::vector<MinimTransformVariable> fVariables;
0142 std::vector<unsigned int> fIndex;
0143 const IMultiGradFunction * fFunc;
0144
0145 };
0146
0147 }
0148
0149 }
0150
0151
0152 #endif