Documentation


nr Namespace Reference


Detailed Description

This namespace contains all the methods from Numerical Recipes in C reimplented in C++ for AnimAl.


Classes

struct  dlinmin
 Minimization of an n-dimensional function along a given line, using information on gradient. More...

struct  dlinmin::F1dim
 value of the one-dimensional function More...

struct  dlinmin::DF1dim
 derivate of the one-dimensional function More...

struct  frprmn
 Minimization of an n-dimensional function, using information on gradient. More...

struct  frprmn::TooManyIterations
 Exception thrown when the maximum number of iterations is reached. More...

struct  linmin
 Minimization of an n-dimensional function along a given line, without information on gradient. More...

struct  linmin::F1dim
 One-dimensional function along the search direction. More...

struct  powell
 Minimization of an n-dimensional function, without information on gradient. More...

struct  powell::TooManyIterations
 Exception thrown when the maximum number of iterations is reached. More...

struct  Old_Traits
 Numerical Recipes methods: Traits for old-style programming. More...

struct  STL_Traits
 Numerical Recipes methods: Traits for programming using STL vectors. More...


Functions

template<class Real, class Func> Real brent (Real ax, Real bx, Real cx, Func(*func), Real tol, Real *xmin, unsigned int ITMAX=100, Real ZEPS=1.0e-10, Real CGOLD=0.3819660)
 Finds the minimum of a funtion using parabolic interpolation.

template<class Real, class Func, class DFunc> Real dbrent (Real ax, Real bx, Real cx, Func(*f), DFunc(*df), Real tol, Real *xmin, unsigned int ITMAX=10000, Real ZEPS=1.0e-10)
 Finds the minimum of a funtion using derivative and a variant of parabolic interpolation.

template<class Real, class Func> Real golden (Real ax, Real bx, Real cx, Func(*f), Real tol, Real *xmin)
 Finds the minimum of a funtion using the "golden section search" method.

template<class Real, class Func> void mnbrak (Real *ax, Real *bx, Real *cx, Real *fa, Real *fb, Real *fc, Func *func)
 Bracket the minimum of a funtion.

template<class T> T MAX (const T &a, const T &b)
 Maximum of two values. Operator > must be defined.

template<class T1, class T2> T2 MAX (const T1 &a, const T2 &b)
template<class T> T SQR (const T &a)
 Square value. Operator * must be defined.

template<class T> T SIGN (const T &a, const T &b)
 Strange function used in some Numerical Recipes programs.

void nrerror (const char *s)
 Print an error message. Exits using assert(false).


Function Documentation

template<class Real, class Func>
Real brent Real  ax,
Real  bx,
Real  cx,
Func *  func,
Real  tol,
Real *  xmin,
unsigned int  ITMAX = 100,
Real  ZEPS = 1.0e-10,
Real  CGOLD = 0.3819660
 

Finds the minimum of a funtion using parabolic interpolation.

Given a bracketing triplet of abcissas ax, bx and cx (such that bx is between ax and cx and f(bx) is less than both f(ax) and f(cx)), this routine performs a golden section search for the minimum, isolating it to a fractional precision of about tol. The abcissa of the minimum is returned as *xmin, and the minimum function value is the returned value. Template Func is similar with Real(Real)

Examples:
optimization_test.cpp.

Definition at line 17 of file brent.h.

References nrerror(), SHFT, and SIGN().

Referenced by nr::linmin< TraitsT >::linmin().

template<class Real, class Func, class DFunc>
Real dbrent Real  ax,
Real  bx,
Real  cx,
Func *  f,
DFunc *  df,
Real  tol,
Real *  xmin,
unsigned int  ITMAX = 10000,
Real  ZEPS = 1.0e-10
 

Finds the minimum of a funtion using derivative and a variant of parabolic interpolation.

Given a bracketing triplet of abcissas ax, bx and cx (such that bx is between ax and cx and f(bx) is less than both f(ax) and f(cx)), this routine performs a golden section search for the minimum, isolating it to a fractional precision of about tol. The abcissa of the minimum is returned as *xmin, and the minimum function value is the returned value. Func and DFunc template arguments must be similar with Real(Real).

Examples:
optimization_test.cpp.

Definition at line 19 of file dbrent.h.

References MOV3, nrerror(), and SIGN().

Referenced by nr::dlinmin< TraitsT >::dlinmin().

template<class Real, class Func>
Real golden Real  ax,
Real  bx,
Real  cx,
Func *  f,
Real  tol,
Real *  xmin
 

Finds the minimum of a funtion using the "golden section search" method.

Given a bracketing triplet of abcissas ax, bx and cx (such that bx is between ax and cx and f(bx) is less than both f(ax) and f(cx)), this routine performs a golden section search for the minimum, isolating it to a fractional precision of about tol. The abcissa of the minimum is returned as *xmin, and the minimum function value is the returned value. Template Func must be similar with Real(Real)

Examples:
optimization_test.cpp.

Definition at line 16 of file golden.h.

References SHFT2, and SHFT3.

template<class T1, class T2>
T2 MAX const T1 &  a,
const T2 &  b
[inline]
 

Definition at line 17 of file numrecipes/optimization/utils.h.

template<class T>
T MAX const T &  a,
const T &  b
[inline]
 

Maximum of two values. Operator > must be defined.

Definition at line 13 of file numrecipes/optimization/utils.h.

Referenced by mnbrak().

template<class Real, class Func>
void mnbrak Real *  ax,
Real *  bx,
Real *  cx,
Real *  fa,
Real *  fb,
Real *  fc,
Func *  func
 

Bracket the minimum of a funtion.

Given distinct initial points *ax and *bx, thie routines searches in downhill direction (defined by the function evaluated at the initial points) and returns new points *ax, *bx, *cx that bracket a minimum of the function. The abcissa of the minimum is somewhere between *ax and *cx. Also returned are the function values at the three points, *fa, *fb and *fc. Template Func is similar with Real(Real)

Examples:
optimization_test.cpp.

Definition at line 18 of file mnbrak.h.

References MAX(), SHFT, and SIGN().

Referenced by nr::dlinmin< TraitsT >::dlinmin(), and nr::linmin< TraitsT >::linmin().

void nrerror const char *  s  )  [inline]
 

Print an error message. Exits using assert(false).

Definition at line 31 of file numrecipes/optimization/utils.h.

Referenced by brent(), and dbrent().

template<class T>
T SIGN const T &  a,
const T &  b
[inline]
 

Strange function used in some Numerical Recipes programs.

Definition at line 28 of file numrecipes/optimization/utils.h.

Referenced by brent(), dbrent(), and mnbrak().

template<class T>
T SQR const T &  a  )  [inline]
 

Square value. Operator * must be defined.

Definition at line 23 of file numrecipes/optimization/utils.h.

Referenced by nr::powell< TraitsT >::powell().


Generated on Thu Dec 23 13:52:34 2004 by doxygen 1.3.6