All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
min_brent_boost.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2013-2014, Andrew W. Steiner
5 
6  This file is part of O2scl.
7 
8  O2scl is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  O2scl 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
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with O2scl. If not, see <http://www.gnu.org/licenses/>.
20 
21  -------------------------------------------------------------------
22 */
23 #ifndef O2SCL_MIN_BRENT_BOOST_H
24 #define O2SCL_MIN_BRENT_BOOST_H
25 
26 /** \file min_brent_boost.h
27  \brief File defining \ref o2scl::min_brent_boost
28 */
29 
30 #include <boost/math/tools/minima.hpp>
31 
32 #include <o2scl/min.h>
33 
34 #ifndef DOXYGEN_NO_O2NS
35 namespace o2scl {
36 #endif
37 
38  /** \brief One-dimensional minimization using Brent's method (GSL)
39  */
40  template<class func_t=funct11> class min_brent_boost :
41  public min_bkt_base<func_t> {
42 
43  public:
44 
45  min_brent_boost() {
46  }
47 
48  virtual ~min_brent_boost() {}
49 
50  /** \brief Calculate the minimum \c fmin of \c func
51  with \c x2 bracketed between \c x1 and \c x3.
52 
53  The initial value of \c x2 is ignored.
54  */
55  virtual int min_bkt(double &x2, double x1, double x3, double &fmin,
56  func_t &func) {
57  std::pair<double,double> res;
58  size_t digits;
59  if (this->tol_rel>1.0) digits=1;
60  else if (this->tol_rel<=0.0) digits=18;
61  else digits=((size_t)(-log10(this->tol_rel)));
62  res=boost::math::tools::brent_find_minima(func,x1,x3,digits);
63  x2=res.first;
64  fmin=res.second;
65  return success;
66  }
67 
68  /// Return string denoting type ("min_brent_boost")
69  virtual const char *type() { return "min_brent_boost"; }
70 
71  };
72 
73 #ifndef DOXYGEN_NO_O2NS
74 }
75 #endif
76 
77 #endif
One-dimensional bracketing minimization [abstract base].
Definition: min.h:229
double tol_rel
The tolerance for the minimum function value.
Definition: min.h:65
virtual const char * type()
Return string denoting type ("min_brent_boost")
virtual int min_bkt(double &x2, double x1, double x3, double &fmin, func_t &func)
Calculate the minimum fmin of func with x2 bracketed between x1 and x3.
static const double x3[11]
Definition: inte_qng_gsl.h:94
One-dimensional minimization using Brent's method (GSL)
static const double x2[5]
Definition: inte_qng_gsl.h:66
static const double x1[5]
Definition: inte_qng_gsl.h:48
Success.
Definition: err_hnd.h:47

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).
Hosted at Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads..