Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::BrentSolver Class Reference

Brent's method nonlinear zero finder. More...

#include <mitsuba/core/brent.h>

Classes

struct  Result
 Return value of BrentSolver::solve() More...
 

Public Member Functions

 BrentSolver (size_t maxIterations=100, Float absAccuracy=1e-6f, Float absAccuracyPos=1e-6f, Float relAccuracyPos=1e-6f)
 Create a new Brent-style solver with the specified accuracy requirements. More...
 
Result solve (const boost::function< Float(Float)> &func, Float min, Float max) const
 Find a zero in the given interval. More...
 
Result solve (const boost::function< Float(Float)> &func, Float min, Float max, Float initial) const
 Find a zero in the given interval with an initial guess. More...
 
Result solve (const boost::function< Float(Float)> &func, Float x0, Float y0, Float x1, Float y1, Float x2, Float y2) const
 

Protected Attributes

size_t m_maxIterations
 
Float m_absAccuracy
 
Float m_absAccuracyPos
 
Float m_relAccuracyPos
 

Detailed Description

Brent's method nonlinear zero finder.

The implementation is transcribed from the Apache Commons Java implementation. The supplied function is required to be continuous, but not necessarily smooth.

Constructor & Destructor Documentation

mitsuba::BrentSolver::BrentSolver ( size_t  maxIterations = 100,
Float  absAccuracy = 1e-6f,
Float  absAccuracyPos = 1e-6f,
Float  relAccuracyPos = 1e-6f 
)
inline

Create a new Brent-style solver with the specified accuracy requirements.

Parameters
maxIterationsMax. number of successive iterations (default: 100)
absAccuracyAbsolute accuracy requirement – the iterations will stop when |f(x)| < absAccuracy.
absAccuracyPosAbsolute accuracy requirement of the position – the iterations will stop when |minX-maxX| < absAccuracyPos.
absAccuracyPosAbsolute accuracy requirement of the position – the iterations will stop when |minX-maxX|/minX < relAccuracyPos.

Member Function Documentation

Result mitsuba::BrentSolver::solve ( const boost::function< Float(Float)> &  func,
Float  min,
Float  max 
) const

Find a zero in the given interval.

Requires that the values of the function at the endpoints have opposite signs.

Parameters
minthe lower bound for the interval.
maxthe upper bound for the interval.
Returns
the value where the function is zero
Result mitsuba::BrentSolver::solve ( const boost::function< Float(Float)> &  func,
Float  min,
Float  max,
Float  initial 
) const

Find a zero in the given interval with an initial guess.

Requires that the values of the function at the endpoints have opposite signs (note that it is allowed to have endpoints with the same sign if the initial point has opposite sign function-wise).

Parameters
minthe lower bound for the interval.
maxthe upper bound for the interval.
initialthe start value to use (must be set to min if no initial point is known)
Returns
the value where the function is zero
Result mitsuba::BrentSolver::solve ( const boost::function< Float(Float)> &  func,
Float  x0,
Float  y0,
Float  x1,
Float  y1,
Float  x2,
Float  y2 
) const

Find a zero starting search according to the three provided points.

Parameters
x0old approximation for the root
y0function value at the approximation for the root
x1last calculated approximation for the root
y1function value at the last calculated approximation for the root
x2bracket point (must be set to x0 if no bracket point is known, this will force starting with linear interpolation)
y2function value at the bracket point.
Returns
the value where the function is zero

Member Data Documentation

Float mitsuba::BrentSolver::m_absAccuracy
protected
Float mitsuba::BrentSolver::m_absAccuracyPos
protected
size_t mitsuba::BrentSolver::m_maxIterations
protected
Float mitsuba::BrentSolver::m_relAccuracyPos
protected

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