Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 class GSLMultiFit2;
50
51//_____________________________________________________________________________________________________
52/**
53 GSLNLSMinimizer class for Non Linear Least Square fitting
54 It Uses the Levemberg-Marquardt algorithm from
55 <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Nonlinear-Least_002dSquares-Fitting.html">
56 GSL Non Linear Least Square fitting</A>.
57
58 @ingroup MultiMin
59*/
61
62public:
63
64 /**
65 Constructor from a type
66 */
67 explicit GSLNLSMinimizer (int type);
68 /**
69 Constructor from name
70 */
71 explicit GSLNLSMinimizer (const char * = nullptr);
72
73
74 /**
75 Destructor (no operations)
76 */
77 ~GSLNLSMinimizer () override;
78
79 /// set the function to minimize
80 void SetFunction(const ROOT::Math::IMultiGenFunction & func) override;
81
82
83 /// method to perform the minimization
84 bool Minimize() override;
85
86
87 /// return expected distance reached from the minimum
88 double Edm() const override { return fEdm; } // not impl. }
89
90
91 /// return pointer to gradient values at the minimum
92 const double * MinGradient() const override;
93
94 /// number of function calls to reach the minimum
95 unsigned int NCalls() const override { return fNCalls; }
96
97 /// number of free variables (real dimension of the problem)
98 /// this is <= Function().NDim() which is the total
99// virtual unsigned int NFree() const { return fNFree; }
100
101 /// minimizer provides error and error matrix
102 bool ProvidesError() const override { return true; }
103
104 /// return errors at the minimum
105 const double * Errors() const override { return (!fErrors.empty()) ? &fErrors.front() : nullptr; }
106// {
107// static std::vector<double> err;
108// err.resize(fDim);
109// return &err.front();
110// }
111
112 /** return covariance matrices elements
113 if the variable is fixed the matrix is zero
114 The ordering of the variables is the same as in errors
115 */
116 double CovMatrix(unsigned int , unsigned int ) const override;
117
118 /// return covariance matrix status
119 int CovMatrixStatus() const override;
120
121protected:
122
123 /// Internal method to perform minimization
124 /// template on the type of method function
125 template<class Func, class FitterType>
126 bool DoMinimize(const Func & f, FitterType * fitter);
127
128
129private:
130
131 bool fUseGradFunction = false; // flag to indicate if using external gradients
132 unsigned int fNFree; // dimension of the internal function to be minimized
133 unsigned int fNCalls; // number of function calls
134
135 ROOT::Math::GSLMultiFit * fGSLMultiFit = nullptr; // pointer to old GSL multi fit solver
136 ROOT::Math::GSLMultiFit2 * fGSLMultiFit2 = nullptr; // pointer to new GSL multi fit driver
137
138 double fEdm; // edm value
139 double fLSTolerance; // Line Search Tolerance
140 std::vector<double> fErrors;
141 std::vector<double> fCovMatrix; // cov matrix (stored as cov[ i * dim + j]
142
143
144
145};
146
147 } // end namespace Math
148
149} // end namespace ROOT
150
151
152#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...
GSLMultiFit2, internal class for implementing GSL non linear least square GSL fitting New class imple...
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)
GSLNLSMinimizer(int type)
Constructor from a type.
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 DoMinimize(const Func &f, FitterType *fitter)
Internal method to perform minimization template on the type of method function.
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
ROOT::Math::GSLMultiFit2 * fGSLMultiFit2
const double * Errors() const override
return errors at the minimum
Documentation for the abstract class IBaseFunctionMultiDim.
Definition IFunction.h:63
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...