Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
GSLNLSMinimizer.h
Go to the documentation of this file.
1// @(#)root/mathmore:$Id$
2// Author: L. Moneta Wed Dec 20 17:16:32 2006
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7 * *
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU General Public License *
10 * as published by the Free Software Foundation; either version 2 *
11 * of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this library (see file COPYING); if not, write *
20 * to the Free Software Foundation, Inc., 59 Temple Place, Suite *
21 * 330, Boston, MA 02111-1307 USA, or contact the author. *
22 * *
23 **********************************************************************/
24
25// Header file for class GSLNLSMinimizer
26
27#ifndef ROOT_Math_GSLNLSMinimizer
28#define ROOT_Math_GSLNLSMinimizer
29
30
31
32#include "Math/BasicMinimizer.h"
33
34#include "Math/IFunctionfwd.h"
35
37
39
41
42#include <vector>
43
44namespace ROOT {
45
46 namespace Math {
47
48 class GSLMultiFit;
49
50//_____________________________________________________________________________________________________
51/**
52 GSLNLSMinimizer class for Non Linear Least Square fitting
53 It Uses the Levemberg-Marquardt algorithm from
54 <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Nonlinear-Least_002dSquares-Fitting.html">
55 GSL Non Linear Least Square fitting</A>.
56
57 @ingroup MultiMin
58*/
60
61public:
62
63 /**
64 Default constructor
65 */
66 GSLNLSMinimizer (int type = 0);
67
68 /**
69 Destructor (no operations)
70 */
71 ~GSLNLSMinimizer () override;
72
73private:
74 // usually copying is non trivial, so we make this unaccessible
75
76 /**
77 Copy constructor
78 */
80
81 /**
82 Assignment operator
83 */
85 if (this == &rhs) return *this; // time saving self-test
86 return *this;
87 }
88
89public:
90
91 /// set the function to minimize
92 void SetFunction(const ROOT::Math::IMultiGenFunction & func) override;
93
94
95 /// method to perform the minimization
96 bool Minimize() override;
97
98
99 /// return expected distance reached from the minimum
100 double Edm() const override { return fEdm; } // not impl. }
101
102
103 /// return pointer to gradient values at the minimum
104 const double * MinGradient() const override;
105
106 /// number of function calls to reach the minimum
107 unsigned int NCalls() const override { return fNCalls; }
108
109 /// number of free variables (real dimension of the problem)
110 /// this is <= Function().NDim() which is the total
111// virtual unsigned int NFree() const { return fNFree; }
112
113 /// minimizer provides error and error matrix
114 bool ProvidesError() const override { return true; }
115
116 /// return errors at the minimum
117 const double * Errors() const override { return (!fErrors.empty()) ? &fErrors.front() : nullptr; }
118// {
119// static std::vector<double> err;
120// err.resize(fDim);
121// return &err.front();
122// }
123
124 /** return covariance matrices elements
125 if the variable is fixed the matrix is zero
126 The ordering of the variables is the same as in errors
127 */
128 double CovMatrix(unsigned int , unsigned int ) const override;
129
130 /// return covariance matrix status
131 int CovMatrixStatus() const override;
132
133protected:
134
135 /// Internal method to perform minimization
136 /// template on the type of method function
137 template<class Func>
138 bool DoMinimize(const Func & f);
139
140
141private:
142
143 bool fUseGradFunction = false; // flag to indicate if using external gradients
144 unsigned int fNFree; // dimension of the internal function to be minimized
145 unsigned int fNCalls; // number of function calls
146
147 ROOT::Math::GSLMultiFit * fGSLMultiFit; // pointer to GSL multi fit solver
148
149 double fEdm; // edm value
150 double fLSTolerance; // Line Search Tolerance
151 std::vector<double> fErrors;
152 std::vector<double> fCovMatrix; // cov matrix (stored as cov[ i * dim + j]
153
154
155
156};
157
158 } // end namespace Math
159
160} // end namespace ROOT
161
162
163#endif /* ROOT_Math_GSLNLSMinimizer */
#define f(i)
Definition RSha256.hxx:104
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Base Minimizer class, which defines the basic functionality of various minimizer implementations (apa...
GSLMultiFit, internal class for implementing GSL non linear least square GSL fitting.
Definition GSLMultiFit.h:53
GSLNLSMinimizer class for Non Linear Least Square fitting It Uses the Levemberg-Marquardt algorithm f...
double CovMatrix(unsigned int, unsigned int) const override
return covariance matrices elements if the variable is fixed the matrix is zero The ordering of the v...
unsigned int NCalls() const override
number of function calls to reach the minimum
int CovMatrixStatus() const override
return covariance matrix status
void SetFunction(const ROOT::Math::IMultiGenFunction &func) override
set the function to minimize
std::vector< double > fErrors
std::vector< double > fCovMatrix
~GSLNLSMinimizer() override
Destructor (no operations)
bool DoMinimize(const Func &f)
Internal method to perform minimization template on the type of method function.
bool ProvidesError() const override
number of free variables (real dimension of the problem) this is <= Function().NDim() which is the to...
double Edm() const override
return expected distance reached from the minimum
bool Minimize() override
method to perform the minimization
GSLNLSMinimizer & operator=(const GSLNLSMinimizer &rhs)
Assignment operator.
GSLNLSMinimizer(const GSLNLSMinimizer &)
Copy constructor.
const double * MinGradient() const override
return pointer to gradient values at the minimum
ROOT::Math::GSLMultiFit * fGSLMultiFit
const double * Errors() const override
return errors at the minimum
Documentation for the abstract class IBaseFunctionMultiDim.
Definition IFunction.h:61
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...