Go to the documentation of this file.
26 #ifndef O2SCL_ROOT_CERN_H
27 #define O2SCL_ROOT_CERN_H
31 #include <o2scl/string_conv.h>
32 #include <o2scl/root.h>
72 #ifdef DOXYGEN_NO_O2NS
73 template<
class func_t=funct>
class root_cern :
public root
84 eps=0.1490116119384766e-07;
122 virtual const char *
type() {
return "root_cern"; }
154 virtual int solve(
double &ux, func_t &func) {
160 if (
maxf<=0) lmaxf=200;
165 if (this->tol_rel<=0.0 || this->
tol_abs<=0.0) {
167 std::string str=
"Invalid value of tol_rel ("+
dtos(this->
tol_rel)+
168 ") or tol_abs ("+
dtos(this->
tol_abs)+
") in root_cern::solve().";
172 int iflag=0, numf=0, nfcall=0, nier6=-1, nier7=-1, nier8=0;
173 double fnorm=0.0, difit=0.0, xnorm=0.0;
176 if (xnorm<fabs(ux)) {
181 double delta=
scale*xnorm;
182 if (set==
false) delta=
scale;
184 double wmat, farr, w0arr, w1arr, w2arr;
186 bool solve_done=
false;
187 while (solve_done==
false) {
212 if (fnorm<fabs(fky)) fnorm=fabs(fky);
231 if (eta<fabs(w0arr)) eta=fabs(w0arr);
241 if (w0arr<0.0) sknorm=-sknorm;
248 double temp=w0arr/(sknorm*w0arr);
254 double temp2=fky/w0arr;
255 if (h*fabs(temp2)>delta)
256 temp2=(temp2>=0.0) ? fabs(delta/h) : -fabs(delta/h);
265 if (xnorm<fabs(w1arr)) xnorm=fabs(w1arr);
266 if (difit<fabs(ux-w1arr)) difit=fabs(ux-w1arr);
275 bool lcv=(fnorm<fnorm1 && difit<difit1 && nsing==0);
280 if (fnorm<fnorm1 || difit<difit1) nier7=0;
281 if (difit>
eps*xnorm) nier8=0;
296 if (!std::isfinite(ux)) {
314 "root_cern::solve().",
329 std::string s2=
"Variable tol_abs too small, J singular, ";
330 s2+=
"or bad scaling in root_cern::solve().";
340 if (!std::isfinite(ux)) {
348 #ifndef DOXYGEN_INTERNAL
double tol_rel
The maximum value of the functions for success (default )
@ exc_esing
apparent singularity detected
@ exc_erange
output range error, e.g. exp(1e100)
#define O2SCL_CONV2_RET(d, d2, n, b)
Set an error and return the error value, two-string version.
std::string dtos(const fp_t &x, int prec=6, bool auto_prec=false)
Convert a double to a string.
@ exc_efailed
generic failure
double tol_abs
The minimum allowable stepsize (default )
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
double eps
The smallest floating point number (default )
int get_info()
Get the value of INFO from the last call to solve() (default 0)
@ exc_emaxiter
exceeded max 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 maxf
Maximum number of function evaluations.
int verbose
Output control (default 0)
One-dimensional solver [abstract base].
virtual int solve(double &ux, func_t &func)
Solve func using x as an initial guess, returning x.
double scale
The original scale parameter from CERNLIB (default 10.0)
@ exc_einval
invalid argument supplied by user
#define O2SCL_CONV_RET(d, n, b)
Set a "convergence" error and return the error value.
@ exc_enoprog
iteration is not making progress toward solution
virtual const char * type()
Return the type, "root_cern".
One-dimensional version of cern_mroot.
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
@ exc_erunaway
iterative process is out of control
#define O2SCL_CONV(d, n, b)
Set a "convergence" error.
int info
Internal storage for the value of info.
bool err_nonconv
If true, call the error handler if the solver does not converge (default true)
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).