cern_minimize Class Template Reference

#include <cern_minimize.h>

Inheritance diagram for cern_minimize:

minimize< param_t, func_t >

Detailed Description

template<class param_t, class func_t = funct<param_t>>
class cern_minimize< param_t, func_t >

One-dimensional minimization (CERNLIB).

This is rewritten from the CERNLIB routine D503: minfc.f.

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{tolx})+\frac{1}{2}\right]+1 \]

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

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:
The number of function evaluations can be quite large if multi_min::tolx is sufficiently small. If multi_min::tolx is exactly zero, then $ 10^{-8} $ will be used instead.
Based on Fletcher87, and Krabs83.

Definition at line 60 of file cern_minimize.h.


Public Member Functions

 cern_minimize ()
int nint (double x)
virtual int min_bkt (double &x, double a, double b, double &y, param_t &pa, func_t &func)
 Calculate the minimum min of func between a and b.
int set_delta (double d)
 Set the value of $ \delta $.
virtual const char * type ()
 Return string denoting type ("cern_minimize").

Data Fields

int min_type
 Type of minimum found.

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.

Member Function Documentation

virtual int min_bkt ( double &  x,
double  a,
double  b,
double &  y,
param_t &  pa,
func_t &  func 
) [inline, virtual]

Calculate the minimum min of func between a and b.

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.

Reimplemented from minimize< param_t, func_t >.

Definition at line 87 of file cern_minimize.h.

int set_delta ( double  d  )  [inline]

Set the value of $ \delta $.

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

Definition at line 158 of file cern_minimize.h.


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

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page