Logo ROOT  
Reference Guide
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 /// set gradient the function to minimize
95 void SetFunction(const ROOT::Math::IMultiGradFunction & func) override;
96
97
98 /// method to perform the minimization
99 bool Minimize() override;
100
101
102 /// return expected distance reached from the minimum
103 double Edm() const override { return fEdm; } // not impl. }
104
105
106 /// return pointer to gradient values at the minimum
107 const double * MinGradient() const override;
108
109 /// number of function calls to reach the minimum
110 unsigned int NCalls() const override { return fNCalls; }
111
112 /// number of free variables (real dimension of the problem)
113 /// this is <= Function().NDim() which is the total
114// virtual unsigned int NFree() const { return fNFree; }
115
116 /// minimizer provides error and error matrix
117 bool ProvidesError() const override { return true; }
118
119 /// return errors at the minimum
120 const double * Errors() const override { return (fErrors.size() > 0) ? &fErrors.front() : 0; }
121// {
122// static std::vector<double> err;
123// err.resize(fDim);
124// return &err.front();
125// }
126
127 /** return covariance matrices elements
128 if the variable is fixed the matrix is zero
129 The ordering of the variables is the same as in errors
130 */
131 double CovMatrix(unsigned int , unsigned int ) const override;
132
133 /// return covariance matrix status
134 int CovMatrixStatus() const override;
135
136protected:
137
138 /// Internal method to perform minimization
139 /// template on the type of method function
140 template<class Func>
141 bool DoMinimize(const Func & f);
142
143
144private:
145
146 bool fUseGradFunction = false; // flag to indicate if using external gradients
147 unsigned int fNFree; // dimension of the internal function to be minimized
148 unsigned int fNCalls; // number of function calls
149
150 ROOT::Math::GSLMultiFit * fGSLMultiFit; // pointer to GSL multi fit solver
151
152 double fEdm; // edm value
153 double fLSTolerance; // Line Search Tolerance
154 std::vector<double> fErrors;
155 std::vector<double> fCovMatrix; // cov matrix (stored as cov[ i * dim + j]
156
157
158
159};
160
161 } // end namespace Math
162
163} // end namespace ROOT
164
165
166#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(int type=0)
Default constructor.
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:62
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
Definition: IFunction.h:343
Namespace for new Math classes and functions.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.