A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/njn__root_8hpp_source.html below:

NCBI C++ ToolKit: src/algo/blast/gumbel_params/njn_root.hpp Source File

1 #ifndef ALGO_BLAST_GUMBEL_PARAMS__INCLUDED_NJN_ROOT 2 #define ALGO_BLAST_GUMBEL_PARAMS__INCLUDED_NJN_ROOT 61

template <typename

T

>

64  double

(*f_) (

double

,

const T

&),

65  double

(*df_) (

double

,

const T

&),

78

template <typename

T

>

81  double

(*f_) (

double

,

const T

&),

92

template <typename

T

>

95  double

(*f_) (

double

,

const T

&),

104

template <typename

T

>

107  double

(*f_) (

double

,

const T

&),

125  double

(*f_) (

double

),

126  double

(*df_) (

double

),

140  double

(*f_) (

double

),

152  double

(*f_) (

double

),

161  double

(*f_) (

double

),

167  bool

isLargest_ =

false

);

188  double f

(

double

x_,

const double

&y_) {

return

(*

s_f

) (x_);}

189  double df

(

double

x_,

const double

&y_) {

return

(*

s_df

) (x_);}

193  double

(*f_) (

double

x_),

194  double

(*df_) (

double

x_),

209  double

(*f_) (

double

x_),

222  double

(*f_) (

double

x_),

230  return hunt

(y_,

f

,

ZERO

, p_, q_, tol_, rtol_, itmax_);

235  double

(*f_) (

double

x_),

244  return huntExtreme

(y_,

f

,

ZERO

, p_, q_, tol_, rtol_, itmax_, isLargest_);

247  template

<

typename

T>

250  double

(*f_) (

double

,

const T

&),

251  double

(*df_) (

double

,

const T

&),

263  assert

(p_ != HUGE_VAL && p_ != -HUGE_VAL);

264  assert

(q_ != HUGE_VAL && q_ != -HUGE_VAL);

267  double fp

= (*f_) (p_, param_) - y_;

268  double

fq = (*f_) (q_, param_) - y_;

270  IoUtil::abort

(

"Root::newtonRaphson : root not bracketed"

);

272  if

(

fp

== 0.0)

return

p_;

273  if

(fq == 0.0)

return

q_;

275  if

(p_ == q_)

IoUtil::abort

(

"Root::newtonRaphson : p_ == q_"

);

279  if

(q_ < p_)

swap

(p_, q_);

282  if

(x_ < p_ || q_ < x_) x = 0.5 * (p_ + q_);

285  if

(

fp

> 0.0)

swap

(p_, q_);

294

dxold = dx = p_ - q_;

297  Int4

*itmax = itmax_ == 0 ? &iter: itmax_;

299  for

( ; 0 < *itmax; --*itmax) {

301

fx = (*f_) (x, param_) - y_;

304

}

else if

(fx < 0.0) {

309

dfx = (*df_) (x, param_) - y_;

312  if

((dfx * (x-p_) - fx) * (dfx * (x - q_) - fx) >= 0.0 ||

313

2.0 *

fabs

(fx) >

fabs

(dfx * dx)) {

317

dxold = 0.5 * (p_ - q_);

320  if

(

fabs

(dxold) <= tol_)

return

x;

329  if

(

fabs

(dxold) < tol_ ||

fabs

(dxold) < rtol_ *

fabs

(x)) {

330  if

(((*f_) ((x -

Function::signum

(dxold) * tol_), param_) - y_) * fx < 0.0)

return

x;

338  template

<

typename

T>

341  double

(*f_) (

double

,

const T

&),

349  assert

(p_ != HUGE_VAL && p_ != -HUGE_VAL);

350  assert

(q_ != HUGE_VAL && q_ != -HUGE_VAL);

353  double fp

= (*f_) (p_, param_) - y_;

354  double

fq = (*f_) (q_, param_) - y_;

358  if

(

fp

== 0.0)

return

p_;

359  if

(fq == 0.0)

return

q_;

361  if

(p_ == q_)

IoUtil::abort

(

"Root::bisection : p_ == q_"

);

364  if

(

fp

> 0.0)

swap

(p_, q_);

370  Int4

*itmax = itmax_ == 0 ? &iter: itmax_;

373  for

( ; 0 < *itmax; --*itmax) {

375

fx = (*f_) (x, param_) - y_;

383  if

(Approx::absRelApprox <double> (p_, x, tol_, rtol_))

return

x;

389  template

<

typename

T>

392  double

(*f_) (

double

,

const T

&),

400  assert

(p_ != HUGE_VAL && p_ != -HUGE_VAL);

401  assert

(q_ != HUGE_VAL && q_ != -HUGE_VAL);

405  double

x0 = 0.5 * (p_ + q_);

406  double

fx0 = (*f_) (x0, param_) - y_;

407  if

(fx0 == 0.0)

return

x0;

410  if

(q_ < p_)

swap

(p_, q_);

413  double

del = 0.5 * (q_ - p_);

418  Int4

*itmax = itmax_ == 0 ? &iter: itmax_;

420  while

(tol_ <= del) {

423  for

(

size_t i

= 0;

i

< pts && 0 < *itmax;

i

++, --*itmax) {

425

fx = (*f_) (x, param_) - y_;

426  if

(fx * fx0 < 0.0)

return

bisection <T> (y_, f_, param_, x, x0, tol_, rtol_, itmax);

429  if

(iter == 0)

return FAILED

;

438  template

<

typename

T>

441  double

(*f_) (

double

,

const T

&),

451  Int4

*itmax = itmax_ == 0 ? &iter: itmax_;

454  if

(q_ < p_)

swap

(p_, q_);

457  double

x = hunt <T> (y_, f_, param_, p_, q_, tol_, rtol_, itmax);

462  while

(0 < *itmax && x !=

FAILED

) {

464

x = hunt <T> (y_, f_, param_, x, q_, tol_, rtol_, itmax);

467  while

(0 < *itmax && x !=

FAILED

) {

469

x = hunt <T> (y_, f_, param_, p_, x, tol_, rtol_, itmax);

void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)

int32_t Int4

4-byte (32-bit) signed integer

#define END_NCBI_SCOPE

End previously defined NCBI scope.

#define END_SCOPE(ns)

End the previously defined scope.

#define BEGIN_NCBI_SCOPE

Define ncbi namespace.

#define BEGIN_SCOPE(ns)

Define a new scope.

Defines Limits for the types used in NCBI C/C++ toolkit.

double f(double x_, const double &y_)

double huntExtreme(double y_, double(*f_)(double, const T &), const T &param_, double p_, double q_, double tol_, double rtol_, Int4 *itmax_, bool isLargest_)

double hunt(double y_, double(*f_)(double, const T &), const T &param_, double p_, double q_, double tol_, double rtol_, Int4 *itmax_)

double df(double x_, const double &y_)

double bisection(double y_, double(*f_)(double, const T &), const T &param_, double p_, double q_, double tol_, double rtol_, Int4 *itmax_)

double newtonRaphson(double y_, double(*f_)(double, const T &), double(*df_)(double, const T &), const T &param_, double p_, double x_, double q_, double tol_, double rtol_, Int4 *itmax_)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4