11 #ifndef _ROOTSOLVER_H_    12 #define _ROOTSOLVER_H_   127 template <
typename T, 
typename Func>
   138   const int prec = (int)tol;
   139   if (((T)prec) == tol)
   141       tol = std::pow(10., -std::abs(prec));
   163   for (i = 0; i < MAXITER; i++)
   185       const T tol1  = 2.0 * eps * 
Abs(bPt) + 0.5 * tol;
   186       const T xm    = 0.5 * (c - bPt);
   188       if (
Abs(xm) <= tol1 || fb == 0.0)
   206               p = s * (2.0 * xm * q * (q-r) - (bPt-aPt) * (r-1.0));
   207               q = (q-1.0) * (r-1.0) * (s-1.0);
   215           if (2.0 * p < 
std::min(((
float)3.0)*xm*q-
Abs(tol1*q),
   247           if (xm < 0) bPt = bPt - tol1;
   248           else        bPt = bPt + tol1;
   256       pout()  << 
"RootSolver::Brent: exceeded maximum iterations: "   257                  << MAXITER << std::endl;
 std::ostream & pout()
Use this in place of std::cout for program output. 
 
Definition: RootSolver.H:32
 
#define CH_assert(cond)
Definition: CHArray.H:37
 
IndexTM< T, N > min(const IndexTM< T, N > &a_p1, const IndexTM< T, N > &a_p2)
Definition: IndexTMI.H:394
 
T 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. 
Definition: RootSolver.H:128
 
static double eps()
Definition: RootSolver.H:63
 
T Abs(const T &a_a)
Definition: Misc.H:53
 
Definition: RootSolver.H:29
 
static double tolerance()
Definition: RootSolver.H:68
 
static float tolerance()
Definition: RootSolver.H:49
 
static float eps()
Definition: RootSolver.H:44
 
static void Abort(const char *const a_msg=m_nullString)
Print out message to cerr and exit via abort() (if serial) or MPI_Abort() (if parallel).