/usr/include/root/Math/GSLMinimizer1D.h is in libroot-math-mathmore-dev 5.34.14-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | // @(#)root/mathmore:$Id$
// Author: L. Moneta, A. Zsenei 08/2005
/**********************************************************************
* *
* Copyright (c) 2004 moneta, CERN/PH-SFT *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this library (see file COPYING); if not, write *
* to the Free Software Foundation, Inc., 59 Temple Place, Suite *
* 330, Boston, MA 02111-1307 USA, or contact the author. *
* *
**********************************************************************/
// Header file for class GSLMinimizer1D
//
// Created by: moneta at Wed Dec 1 15:04:51 2004
//
// Last update: Wed Dec 1 15:04:51 2004
//
#ifndef ROOT_Math_GSLMinimizer1D
#define ROOT_Math_GSLMinimizer1D
#include "Math/IMinimizer1D.h"
#include "Math/GSLFunctionAdapter.h"
namespace ROOT {
namespace Math {
namespace Minim1D {
/**
Enumeration with One Dimensional Minimizer Algorithms.
The algorithms are implemented using GSL, see the
<A HREF="http://www.gnu.org/software/gsl/manual/gsl-ref_33.html#SEC447">GSL manual</A>.
The algorithms available are:
<ul>
<li><em>Golden Section Algorithm</em>, simplest method of bracketing the minimum of a function
<li><em>Brent Algorithm</em>, which combines a parabolic interpolation with the golden section algorithm
</ul>
@ingroup Min1D
*/
enum Type {kGOLDENSECTION,
kBRENT
};
}
class GSL1DMinimizerWrapper;
class GSLFunctionWrapper;
//______________________________________________________________________________________
/**
Minimizer for arbitrary one dimensional functions.
Implemented using GSL, for detailed description see:
<A HREF="http://www.gnu.org/software/gsl/manual/html_node/One-dimensional-Minimization.html">GSL online doc</A>
The algorithms uspported are only bracketing algorithm which do not use derivatives information.
The algorithms which can be chosen at construction time are GOLDENSECTION, whic is the simplest method
but the slowest and BRENT (the default one) which combines the golden section with a parabolic interpolation.
This class does not support copying
@ingroup Min1D
*/
class GSLMinimizer1D: public IMinimizer1D {
public:
/**
Construct the minimizer passing the minimizer type using the Minim1D::Algorithm enumeration
*/
explicit GSLMinimizer1D(Minim1D::Type type=Minim1D::kBRENT);
/**
Destructor: free allocated resources
*/
virtual ~GSLMinimizer1D();
private:
// usually copying is non trivial, so we make this unaccessible
GSLMinimizer1D(const GSLMinimizer1D &);
GSLMinimizer1D & operator = (const GSLMinimizer1D &);
public:
/**
Set, or reset, minimizer to use the function f and the initial search interval [xlow, xup], with a guess for the location of the minimum xmin.
The condition : \f$ f(xlow) > f(xmin) < f(xup)\f$ must be satisfied
*/
template <class UserFunc>
void SetFunction( const UserFunc & f, double xmin, double xlow, double xup) {
const void * p = &f;
SetFunction( &GSLFunctionAdapter<UserFunc>::F, const_cast<void *>(p), xmin, xlow, xup );
}
/**
Set, or reset, minimizer to use the function f and the initial search interval [xlow, xup], with a guess for the location of the minimum xmin.
The condition : \f$ f(xlow) > f(xmin) < f(xup) \f$ must be satisfied
Method specialized on the GSL function type
*/
void SetFunction( GSLFuncPointer f, void * params, double xmin, double xlow, double xup);
/**
Perform a minimizer iteration and
if an unexepcted problem occurr then an error code will be returned
*/
int Iterate();
/**
Return current estimate of the position of the minimum
*/
double XMinimum() const;
/**
Return current lower bound of the minimization interval
*/
double XLower() const;
/**
Return current upper bound of the minimization interval
*/
double XUpper() const;
/**
Return function value at current estimate of the minimum
*/
double FValMinimum() const;
/**
Return function value at current lower bound of the minimization interval
*/
double FValLower() const;
/**
Return function value at current upper bound of the minimization interval
*/
double FValUpper() const;
/**
Find minimum position iterating until convergence specified by the absolute and relative tolerance or
the maximum number of iteration is reached
Return true is result is successfull
\@param maxIter maximum number of iteration
\@param absTol desired absolute error in the minimum position
\@param absTol desired relative error in the minimum position
*/
bool Minimize( int maxIter, double absTol, double relTol);
/**
Return number of iteration used to find minimum
*/
int Iterations() const {
return fIter;
}
/**
Return status of last minimization
*/
int Status() const { return fStatus; }
/**
Return name of minimization algorithm
*/
const char * Name() const;
/**
Test convergence of the interval.
The test returns success if
\f[
|x_{min}-x_{truemin}| < epsAbs + epsRel *x_{truemin}
\f]
*/
static int TestInterval( double xlow, double xup, double epsAbs, double epsRel);
protected:
private:
double fXmin;
double fXlow;
double fXup;
double fMin;
double fLow;
double fUp;
int fIter;
int fStatus; // status of last minimization (==0 ok =1 failed)
bool fIsSet;
GSL1DMinimizerWrapper * fMinimizer;
GSLFunctionWrapper * fFunction;
};
} // end namespace Math
} // end namespace ROOT
#endif /* ROOT_Math_GSLMinimizer1D */
|