RootSolver Namespace Reference


Classes

struct  RootTr
struct  RootSolver::RootTr< float >
struct  RootSolver::RootTr< double >

Functions

template<typename T, typename Func>
Brent (int &numIter, const Func &f, T aPt, T bPt, T tol=RootTr< T >::tolerance(), const unsigned MAXITER=RootTr< T >::maxIter)
 Brent's root solver.


Function Documentation

template<typename T, typename Func>
T RootSolver::Brent ( int &  numIter,
const Func &  f,
aPt,
bPt,
tol = RootTr<T>::tolerance(),
const unsigned  MAXITER = RootTr<T>::maxIter 
) [inline]

Brent's root solver.

Template Parameters:
T Type for x and f(x) - must be floating point
Func Function object describing function to solve where T f(x) = Func::operator()(const T& x)
Parameters:
[out] numIter Number of iterations required for convergence to specified tolerance. If equal to MAXITER, the solution is not within specified tolerance.
[in] f Instance of function to solve
[in] aPt Lower bound
[in] bPt Upper bound
[in] tol Tolerance for solve - essentially the spread of the bracket. This can be specified in absolute terms, or, if given by an integer cast to T, the number of significant digits to solve for in x. The default is given by the RootTr class. Note that epsilon is also considered for specifying the spread of the bracket.
[in] MAXITER Maximum iterations. Default (100). If reached, a message is written to cerr but the program otherwise completes
Returns:
x where f(x) = 0
Example
 *     #include <functional>
 *     #include "RootSolver.H"
 *     // Func is not allowed to be local until the C++0x standard
 *     struct Func : public std::unary_function<Real, Real>
 *     {
 *       Real operator()(const Real& a_x) const
 *         {
 *           return 5*std::pow(a_x, 5) - 3*std::pow(a_x, 3) + a_x;
 *         }
 *     };
 *     void foo()
 *     {
 *       int numIter;
 *       const Real xmin = -1.;
 *       const Real xmax =  1.;
 *       const Real x0 = RootSolver::Brent(numIter, Func(), xmin, xmax);
 *       if (numIter == RootTr<Real>::maxIter)
 *         {
 *           std::cout << "Uh oh\n";
 *         }
 *     }
 *                                                                  

References MayDay::Abort(), Abs(), CH_assert, and min().


Generated on Tue May 23 03:28:07 2017 for Chombo + EB + MF by  doxygen 1.5.5