Go to the documentation of this file.
23 #ifndef O2SCL_ROOT_ROBBINS_MONRO_H
24 #define O2SCL_ROOT_ROBBINS_MONRO_H
31 #include <o2scl/funct.h>
32 #include <o2scl/root.h>
34 #ifndef DOXYGEN_NO_O2NS
40 template<
class func_t=funct,
class dfunc_t=func_t>
60 virtual const char *
type() {
return "root_robbins_monro"; }
64 virtual int solve(
double &x, func_t &func) {
70 for(
size_t i=0;i<this->
ntrial/2;i++) {
76 avg+=(
x2*((double)i)+avg)/((
double)(i+1));
77 double favg=func(avg);
89 for(
size_t i=0;i<this->
ntrial;i++) {
116 virtual int solve_de(
double &x, func_t &func, dfunc_t &df) {
122 for(
size_t i=0;i<this->
ntrial/2;i++) {
129 avg+=(
x2*((double)i)+avg)/((
double)(i+1));
130 double favg=func(avg);
131 if (fabs(favg)<this->
tol_rel) {
142 for(
size_t i=0;i<this->
ntrial;i++) {
163 #ifndef DOXYGEN_NO_O2NS
double tol_rel
The maximum value of the functions for success (default )
#define O2SCL_CONV2_RET(d, d2, n, b)
Set an error and return the error value, two-string version.
virtual const char * type()
Return the type, "root_robbins_monro".
virtual int solve_bkt(double &x1, double x2, func_t &f)
Solve func in region returning .
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
@ exc_emaxiter
exceeded max number of iterations
One-dimensional solver [abstract base].
static const double x2[5]
virtual int solve(double &x, func_t &func)
Solve func using x as an initial guess.
static const double x1[5]
One-dimensional root-finding for noisy functions.
double coeff
Coefficient for sequence (default 1.0)
virtual int solve_de(double &x, func_t &func, dfunc_t &df)
Solve func using x as an initial guess using derivatives df.
bool pr_averaging
If true, apply Polyak-Ruppert averaging.
double gamma
Exponent for sequence (default 1.0)
bool err_nonconv
If true, call the error handler if the solver does not converge (default true)
int ntrial
Maximum number of iterations (default 100)
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).