ZeroIn< Subject, Ordinate, Abscissa > Class Template Reference

#include <zeroin.h>

Inheritance diagram for ZeroIn< Subject, Ordinate, Abscissa >:

Inheritance graph
[legend]
Collaboration diagram for ZeroIn< Subject, Ordinate, Abscissa >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 ZeroIn ()
void setLowerBound (const Abscissa &ax)
 Set the lower bound of the range that will be searched for a solution.
Abscissa getLowerBound () const
void setUpperBound (const Abscissa &bx)
 Set the upper bound of the range that will be searched for a solution.
Abscissa getUpperBound () const
void setTolerance (const Abscissa &tol)
 set tolerance of the solution
void setMethod (Ordinate(Subject::*method)(const Abscissa &))
void visit (Subject *subject)
 ZeroIn visit method.
bool isSolved (void) const
bool isSolved (const Ordinate &error)
Abscissa getSolution (void) const
Ordinate getError (void) const


Detailed Description

template<class Subject, class Ordinate = double, class Abscissa = double>
class ZeroIn< Subject, Ordinate, Abscissa >

Examples:

/home/john/freesteam/zeroin.h.


Constructor & Destructor Documentation

template<class Subject, class Ordinate = double, class Abscissa = double>
ZeroIn< Subject, Ordinate, Abscissa >::ZeroIn (  )  [inline]


Member Function Documentation

template<class Subject, class Ordinate = double, class Abscissa = double>
void ZeroIn< Subject, Ordinate, Abscissa >::setLowerBound ( const Abscissa &  ax  )  [inline]

template<class Subject, class Ordinate = double, class Abscissa = double>
Abscissa ZeroIn< Subject, Ordinate, Abscissa >::getLowerBound (  )  const [inline]

See also:
setLowerBound

template<class Subject, class Ordinate = double, class Abscissa = double>
void ZeroIn< Subject, Ordinate, Abscissa >::setUpperBound ( const Abscissa &  bx  )  [inline]

template<class Subject, class Ordinate = double, class Abscissa = double>
Abscissa ZeroIn< Subject, Ordinate, Abscissa >::getUpperBound (  )  const [inline]

See also:
setUpperBound

template<class Subject, class Ordinate = double, class Abscissa = double>
void ZeroIn< Subject, Ordinate, Abscissa >::setTolerance ( const Abscissa &  tol  )  [inline]

template<class Subject, class Ordinate = double, class Abscissa = double>
void ZeroIn< Subject, Ordinate, Abscissa >::setMethod ( Ordinate(Subject::*)(const Abscissa &)  method  )  [inline]

template<class Subject, class Ordinate = double, class Abscissa = double>
void ZeroIn< Subject, Ordinate, Abscissa >::visit ( Subject *  subject  )  [inline]

ZeroIn visit method.

This is a visitor pattern implementation of the Brent ZEROIN routine adapted from the C math library version.

USAGE

See also:
brent.shar at http://www.netlib.org/c/
Original documentation:

function ZEROIN - obtain a function zero within the given range

Input double zeroin(ax,bx,f,tol) double ax; Root will be sought for within a range [ax,bx] double bx;

double (*f)(double x); Name of the function whose zero will be sought for

double tol; Acceptable tolerance for the root value. May be specified as 0.0 to cause the program to find the root as accurate as possible

Output Zeroin returns an estimate for the root with accuracy 4*EPSILON*abs(x) + tol

Algorithm

G.Forsythe, M.Malcolm, C.Moler, Computer methods for mathematical computations. M., Mir, 1980, p.180 of the Russian edition

The function makes use of the bissection procedure combined with the linear or quadric inverse interpolation.

At every step program operates on three abscissae - a, b, and c.

b - the last and the best approximation to the root a - the last but one approximation c - the last but one or even earlier approximation than a that 1) |f(b)| <= |f(c)| 2) f(b) and f(c) have opposite signs, i.e. b and c confine the root

< Distance from the last but one to the last approximation

< Actual tolerance

< Interpolation step is calculated in the form p/q; division

< operations is delayed until the last moment

< Step at this iteration

References DBL_EPSILON, and fabs().

Referenced by Region3::set_pT(), SolverBase< Units, OtherProp, Units, 0, OtherPropAlt, 0 >::solve(), SatCurve< Ordinate, Abscissa, OrdinateAlt, AbscissaAlt >::solve(), and B23Curve< Ordinate, Abscissa, OrdinateAlternative, AbscissaAlternative >::solve().

template<class Subject, class Ordinate = double, class Abscissa = double>
bool ZeroIn< Subject, Ordinate, Abscissa >::isSolved ( void   )  const [inline]

template<class Subject, class Ordinate = double, class Abscissa = double>
bool ZeroIn< Subject, Ordinate, Abscissa >::isSolved ( const Ordinate &  error  )  [inline]

References fabs().

template<class Subject, class Ordinate = double, class Abscissa = double>
Abscissa ZeroIn< Subject, Ordinate, Abscissa >::getSolution ( void   )  const [inline]

template<class Subject, class Ordinate = double, class Abscissa = double>
Ordinate ZeroIn< Subject, Ordinate, Abscissa >::getError ( void   )  const [inline]


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

Generated on Tue Feb 10 18:37:37 2009 for freesteam by  doxygen 1.5.6