npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
findRootNewtonRaphson.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_FINDROOTNEWTONRAPHSON_HH_
2 #define NPSTAT_FINDROOTNEWTONRAPHSON_HH_
3 
4 /*!
5 // \file findRootNewtonRaphson.hh
6 //
7 // \brief Simple root finding when the derivative is known
8 //
9 // Author: I. Volobouev
10 //
11 // July 2016
12 */
13 
15 
16 namespace npstat {
17  /**
18  // Numerical equation solving for 1-d functions using
19  // the Newton–Raphson method.
20  //
21  // Input arguments are as follows:
22  //
23  // f -- The functor making up the equation to solve, returning
24  // a pair. The first element of the pair is the function
25  // value (for which "rhs" is the desired value) and the
26  // second element is the derivative.
27  //
28  // rhs -- The "right hand side" of the equation.
29  //
30  // x0 -- The starting point for the search.
31  //
32  // tol -- Tolerance parameter. Typically, the found solution
33  // will be within a factor of 1 +- tol of the real one.
34  //
35  // x -- Location where the solution will be stored.
36  //
37  // deriv -- Location to store the derivative at x (if desired).
38  //
39  // The function returns "true" if it finds the root, "false" otherwise.
40  //
41  // Typically, "Numeric" should be ether float or double.
42  */
43  template <typename Numeric>
45  Numeric rhs, Numeric x0,
46  Numeric tol, Numeric* x,
47  Numeric* deriv = 0);
48 }
49 
50 #include "npstat/nm/findRootNewtonRaphson.icc"
51 
52 #endif // NPSTAT_FINDROOTNEWTONRAPHSON_HH_
Interface definitions and concrete simple functors for a variety of functor-based calculations.
Definition: AbsArrayProjector.hh:14
bool findRootNewtonRaphson(const PairFunctor< Numeric > &f, Numeric rhs, Numeric x0, Numeric tol, Numeric *x, Numeric *deriv=0)
Definition: SimpleFunctors.hh:158