Go to the documentation of this file.
44 #ifndef O2SCL_ROOT_STEF_H
45 #define O2SCL_ROOT_STEF_H
53 #include <o2scl/misc.h>
54 #include <o2scl/root.h>
56 #ifndef DOXYGEN_NO_O2NS
109 template<
class func_t=funct,
class dfunc_t=func_t>
class root_stef :
110 public root_de<func_t,dfunc_t> {
143 virtual const char *
type() {
return "root_stef"; }
160 double x_new, f_new, df_new;
175 df_new=(*dfp)(x_new);
184 if (!std::isfinite(f_new)) {
185 std::string str=
"Function not finite (returned "+
dtos(f_new)+
186 ") in root_stef::iterate().";
198 double v=(x_new-2*xt+x_1t);
209 if (!std::isfinite(df_new)) {
210 std::string str=
"Derivative not finite (returned "+
dtos(df_new)+
211 ") in root_stef::iterate().";
221 virtual int solve_de(
double &xx, func_t &fun, dfunc_t &dfun) {
234 status2=gsl_root_test_delta(
root,xx,this->
tol_abs,tol_rel2);
257 if (iter>=this->ntrial) {
258 std::string str=((std::string)
"Function solve_de() exceeded the ")+
259 "maximum number of iterations, "+
itos(this->ntrial)+
".";
274 void set(func_t &fun, dfunc_t &dfun,
double guess) {
292 #ifndef DOXYGEN_NO_O2NS
double tol_rel
The maximum value of the functions for success (default )
double x_1
Previous value of root.
virtual const char * type()
Return the type, "root_stef".
std::string dtos(const fp_t &x, int prec=6, bool auto_prec=false)
Convert a double to a string.
func_t * fp
The function to solve.
double root
The present solution estimate.
int last_ntrial
The number of iterations used in the most recent solve.
@ exc_ezerodiv
tried to divide by zero
double tol_abs
The minimum allowable stepsize (default )
double tol_rel2
The relative tolerance for subsequent solutions (default )
void set(func_t &fun, dfunc_t &dfun, double guess)
Set the information for the solver.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
int iterate()
Perform an iteration.
@ exc_emaxiter
exceeded max number of iterations
int count
Number of iterations.
virtual int print_iter(double x, double y, int iter, double value=0.0, double limit=0.0, std::string comment="")
Print out iteration information.
int verbose
Output control (default 0)
One-dimensional solver [abstract base].
virtual int solve_de(double &xx, func_t &fun, dfunc_t &dfun)
Solve func using x as an initial guess using derivatives df.
#define O2SCL_CONV_RET(d, n, b)
Set a "convergence" error and return the error value.
One-dimensional with solver with derivatives [abstract base].
@ gsl_continue
iteration has not converged
std::string itos(int x)
Convert an integer to a string.
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
bool test_residual
True if we should test the residual also (default false)
double df
Derivative value.
dfunc_t * dfp
The derivative.
virtual int get_errno() const =0
Return the last error number.
bool err_nonconv
If true, call the error handler if the solver does not converge (default true)
err_hnd_type * err_hnd
The global error handler pointer.
int ntrial
Maximum number of iterations (default 100)
Steffenson equation solver (GSL)
@ exc_ebadfunc
problem with user-supplied function
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).