Class root_brent_gsl (o2scl)

O2scl : Class List

template<class func_t = funct, class fp_t = double>
class root_brent_gsl : public o2scl::root_bkt<funct, funct, double>

One-dimensional root-finding (GSL)

This class finds the root of a user-specified function. If test_form is 0 (the default), then solve_bkt() stops when the size of the bracket is smaller than root::tol_abs. If test_form is 1, then the function stops when the residual is less than root::tol_rel. If test_form is 2, then both tests are applied.

See the One-dimensional solvers section of the User’s guide for general information about O2scl solvers. An example demonstrating the usage of this class is given in examples/ex_fptr.cpp and the First function object example.

Todo

class root_brent_gsl

Future:

  • There is some duplication in the variables c x_lower, c x_upper, c a, and c b, which could be removed. Some better variable names would also be helpful.

  • Create a meaningful enum list for ref o2scl::root_brent_gsl::test_form.

  • There is code duplication between the test_interval here and in root_toms748.

Storage for solver state

fp_t a
fp_t b
fp_t c
fp_t d
fp_t e
fp_t fa
fp_t fb
fp_t fc

Public Functions

inline root_brent_gsl()
inline virtual const char *type()

Return the type, "root_brent_gsl".

inline int iterate(func_t &f)

Perform an iteration.

This function currently always returns success.

inline virtual int solve_bkt(fp_t &x1, fp_t x2, func_t &f)

Solve func in region \( x_1<x<x_2 \) returning \( x_1 \).

inline fp_t get_root()

Get the most recent value of the root.

inline fp_t get_lower()

Get the lower limit.

inline fp_t get_upper()

Get the upper limit.

inline int set(func_t &ff, fp_t lower, fp_t upper)

Set the information for the solver.

This function currently always returns success.

Public Members

int test_form

The type of convergence test applied: 0, 1, or 2 (default 0)

Protected Functions

inline int test_interval(fp_t xx_lower, fp_t xx_upper, fp_t epsabs, fp_t epsrel, fp_t &tolerance, fp_t &interval)

Floating point-type agnostic version of gsl_root_test_interval() .

Protected Attributes

fp_t root

The present solution estimate.

fp_t x_lower

The present lower limit.

fp_t x_upper

The present upper limit.