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
73 /// set the function to minimize
74 void SetFunction(const ROOT::Math::IMultiGenFunction & func) override;
75
76
77 /// method to perform the minimization
78 bool Minimize() override;
79
80
81 /// return expected distance reached from the minimum
82 double Edm() const override { return fEdm; } // not impl. }
83
84
85 /// return pointer to gradient values at the minimum
86 const double * MinGradient() const override;
87
88 /// number of function calls to reach the minimum
89 unsigned int NCalls() const override { return fNCalls; }
90
91 /// number of free variables (real dimension of the problem)
92 /// this is <= Function().NDim() which is the total
93// virtual unsigned int NFree() const { return fNFree; }
94
95 /// minimizer provides error and error matrix
96 bool ProvidesError() const override { return true; }
97
98 /// return errors at the minimum
99 const double * Errors() const override { return (!fErrors.empty()) ? &fErrors.front() : nullptr; }
100// {
101// static std::vector<double> err;
102// err.resize(fDim);
103// return &err.front();
104// }
105
106 /** return covariance matrices elements
107 if the variable is fixed the matrix is zero
108 The ordering of the variables is the same as in errors
109 */
110 double CovMatrix(unsigned int , unsigned int ) const override;
111
112 /// return covariance matrix status
113 int CovMatrixStatus() const override;
114
115protected:
116
117 /// Internal method to perform minimization
118 /// template on the type of method function
119 template<class Func>
120 bool DoMinimize(const Func & f);
121
122
123private:
124
125 bool fUseGradFunction = false; // flag to indicate if using external gradients
126 unsigned int fNFree; // dimension of the internal function to be minimized
127 unsigned int fNCalls; // number of function calls
128
129 ROOT::Math::GSLMultiFit * fGSLMultiFit; // pointer to GSL multi fit solver
130
131 double fEdm; // edm value
132 double fLSTolerance; // Line Search Tolerance
133 std::vector<double> fErrors;
134 std::vector<double> fCovMatrix; // cov matrix (stored as cov[ i * dim + j]
135
136
137
138};
139
140 } // end namespace Math
141
142} // end namespace ROOT
143
144
145#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
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...