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 ga
fp_t gb
fp_t gc
fp_t gd
fp_t ge
fp_t gfa
fp_t gfb
fp_t gfc

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.

template<typename func2_t, class fp2_t>
inline int iterate_multip(func2_t &f, double func_tol, fp2_t storage[11])

Perform an iteration (adaptive multiprecision version)

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 \).

template<typename func2_t, class fp2_t>
inline int solve_bkt_multip(fp2_t &x1, fp2_t x2, func2_t &&f, fp2_t &err, double tol_loc = -1.0)

Solve func in region \( x_1<x<x_2 \) returning \( x_1 \) (adaptive multiprecision version)

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.

template<typename func2_t, class fp2_t>
inline int set_multip(func2_t &ff, fp2_t lower, fp2_t upper, double func_tol, fp2_t storage[11])

Set the information for the solver (adaptive multiprecision version)

Public Members

double pow_tol_func

Power for tolerance of function evaluations with adaptive multiprecision (default 1.33)

bool store_funcs

If true, store function evaluations.

o2scl::table<std::vector<fp_t>, fp_t> tab

For storing function evaluations.

int test_form

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

Protected Functions

template<class fp2_t>
inline int test_interval(fp2_t xx_lower, fp2_t xx_upper, fp2_t epsabs, fp2_t epsrel, fp2_t &tolerance, fp2_t &interval)

Floating point-type agnostic version of gsl_root_test_interval() .

template<typename func2_t, class fp2_t>
inline int solve_bkt_int_multip(fp2_t &x1, fp2_t x2, func2_t &f, double root_tol, double func_tol)

Solve func in region \( x_1<x<x_2 \) returning \( x_1 \) (internal multiprecision version)

Protected Attributes

fp_t groot

The present solution estimate.

fp_t gx_lower

The present lower limit.

fp_t gx_upper

The present upper limit.