Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
o2scl::min_cern< func_t > Class Template Reference

One-dimensional minimization (CERNLIB) More...

#include <min_cern.h>

Inheritance diagram for o2scl::min_cern< func_t >:
o2scl::min_bkt_base< func_t > o2scl::min_base< func_t, func_t >

Public Member Functions

virtual int min_bkt (double &x, double a, double b, double &y, func_t &func)
 Calculate the minimum min of func between a and b. More...
 
int set_delta (double d)
 Set the value of $ \delta $. More...
 
virtual const char * type ()
 Return string denoting type ("min_cern")
 
- Public Member Functions inherited from o2scl::min_bkt_base< func_t >
virtual int min (double &x, double &fmin, func_t &func)
 Calculate the minimum min of func w.r.t 'x'. More...
 
virtual int min_de (double &x, double &fmin, func_t &func, func_t &df)
 Calculate the minimum min of func with derivative dfunc w.r.t 'x'. More...
 
- Public Member Functions inherited from o2scl::min_base< func_t, func_t >
virtual int print_iter (double x, double y, int iter, double value=0.0, double limit=0.0, std::string comment="")
 Print out iteration information. More...
 
virtual int bracket (double &ax, double &bx, double &cx, double &fa, double &fb, double &fc, func_t &func)
 Given interval (ax,bx), attempt to bracket a minimum for function func. More...
 

Public Attributes

int min_type
 Type of minimum found.
 
- Public Attributes inherited from o2scl::min_bkt_base< func_t >
int bracket_iter
 The number of iterations for automatically bracketing a minimum (default 20)
 
- Public Attributes inherited from o2scl::min_base< func_t, func_t >
int verbose
 Output control.
 
int ntrial
 Maximum number of iterations.
 
double tol_rel
 The tolerance for the minimum function value.
 
double tol_abs
 The tolerance for the location of the minimum.
 
int last_ntrial
 The number of iterations used in the most recent minimization.
 
int bracket_iter
 The number of iterations for automatically bracketing a minimum (default 20)
 
bool err_nonconv
 If true, call the error handler if the routine does not "converge".
 

Protected Member Functions

int nint (double x)
 C analog of Fortran's "Nearest integer" function.
 

Protected Attributes

double delta
 The value of delta as specified by the user.
 
bool delta_set
 True if the value of delta has been set.
 

Detailed Description

template<class func_t = funct11>
class o2scl::min_cern< func_t >

The golden section search is applied in the interval $ (a,b) $ using a fixed number $ n $ of function evaluations where

\[ n=\left[ 2.08 \ln(|a-b|/\mathrm{tol\_abs})+\frac{1}{2}\right]+1 \]

The accuracy depends on the function. A choice of $ \mathrm{tol\_abs}>10^{-8} $ usually results in a relative error of $x$ which is smaller than or of the order of $ \mathrm{tol\_abs} $ .

This routine strictly searches the interval $ (a,b) $ . If the function is nowhere flat in this interval, then min_bkt() will return either $ a $ or $ b $ and min_type is set to 1. Note that if there are more than 1 local minima in the specified interval, there is no guarantee that this method will find the global minimum.

Note
The number of function evaluations can be quite large if mmin::tol_abs is sufficiently small. If mmin::tol_abs is exactly zero, then the error handler will be called.

Based on the CERNLIB routines RMINFC and DMINFC, which was based on Fletcher87, and Krabs83 and is documented at http://wwwasdoc.web.cern.ch/wwwasdoc/shortwrupsdir/d503/top.html

Definition at line 75 of file min_cern.h.

Member Function Documentation

◆ min_bkt()

template<class func_t = funct11>
virtual int o2scl::min_cern< func_t >::min_bkt ( double &  x,
double  a,
double  b,
double &  y,
func_t &  func 
)
inlinevirtual

The initial value of x is ignored.

If there is no minimum in the given interval, then on exit x will be equal to either a or b and min_type will be set to 1 instead of zero. The error handler is not called, as this need not be interpreted as an error.

Implements o2scl::min_bkt_base< func_t >.

Definition at line 109 of file min_cern.h.

◆ set_delta()

template<class func_t = funct11>
int o2scl::min_cern< func_t >::set_delta ( double  d)
inline

If this is not called before min_bkt() is used, then the suggested value $ \delta=10 \mathrm{tol_abs} $ is used.

Definition at line 186 of file min_cern.h.


The documentation for this class was generated from the following file:

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).