29 #define ROOTFIND_SUCCESS 0
37 #define ROOTFIND_SUCCESS_XCONVERGENCEONLY 1
39 #define ROOTFIND_FAILEDCONVERGENCE -1
41 #define ROOTFIND_BADINPUT -2
43 #define ROOTFIND_SOLNLOWERTHANXMIN -3
45 #define ROOTFIND_SOLNHIGHERTHANXMAX -4
192 bool theSame(doublereal x2, doublereal x1, doublereal factor = 1.0)
const;
218 int solve(doublereal xmin, doublereal xmax,
int itmax, doublereal& funcTargetValue, doublereal* xbest);
232 doublereal
func(doublereal x);
246 void setTol(doublereal rtolf, doublereal atolf, doublereal rtolx = 0.0, doublereal atolx = 0.0);
398 double deltaXConverged;
399 double deltaFConverged;
402 std::string reasoning;
421 deltaXConverged(-1.0E300),
422 deltaFConverged(-1.0E300),
void setDeltaX(doublereal deltaXNorm)
Set the minimum value of deltaX.
doublereal DeltaXnorm_
Delta X norm. This is the nominal value of deltaX that will be used by the program.
doublereal fx_minTried_
Internal variable tracking f(x) of smallest x tried.
bool FuncIsGenerallyDecreasing_
Boolean indicating whether the function is decreasing with x.
doublereal x_maxTried_
Internal variable tracking largest x tried.
std::vector< struct rfTable > rfHistory_
Vector of iteration histories.
void setFuncIsGenerallyDecreasing(bool value)
Set the function behavior flag.
Structure containing the iteration history.
int specifiedDeltaXnorm_
Boolean indicating whether DeltaXnorm_ has been specified by the user or not.
RootFind & operator=(const RootFind &right)
Assignment operator.
void printTable()
Print the iteration history table.
doublereal delXNonzero(doublereal x1) const
Calculate a deltaX from an input value of x.
doublereal m_atolx
Absolute tolerance for the value of x.
doublereal m_rtolx
Relative tolerance for the value of x.
bool writeLogAllowed_
Boolean to turn on the possibility of writing a log file.
doublereal m_rtolf
Relative tolerance for the value of f and x.
doublereal DeltaXMax_
Delta X Max. This is the maximum value of deltaX that will be used by the program.
doublereal x_minTried_
Internal variable tracking smallest x tried.
void setTol(doublereal rtolf, doublereal atolf, doublereal rtolx=0.0, doublereal atolx=0.0)
Set the tolerance parameters for the rootfinder.
doublereal deltaXControlled(doublereal x2, doublereal x1) const
Calculate a controlled, nonzero delta between two numbers.
Root finder for 1D problems.
void setFuncIsGenerallyIncreasing(bool value)
Set the function behavior flag.
Virtual base class for DAE residual function evaluators.
doublereal m_funcTargetValue
Target value for the function. We seek the value of f that is equal to this value.
bool FuncIsGenerallyIncreasing_
Boolean indicating whether the function is an increasing with x.
doublereal fx_maxTried_
Internal variable tracking f(x) of largest x tried.
ResidEval * m_residFunc
Pointer to the residual function evaluator.
int solve(doublereal xmin, doublereal xmax, int itmax, doublereal &funcTargetValue, doublereal *xbest)
Using a line search method, find the root of a 1D function.
void setDeltaXMax(doublereal deltaX)
Set the maximum value of deltaX.
doublereal m_maxstep
Maximum number of step sizes.
doublereal delXMeaningful(doublereal x1) const
Calculate a deltaX from an input value of x.
doublereal deltaXConverged_
Value of delta X that is needed for convergence.
RootFind(ResidEval *resid)
Constructor for the object.
void setPrintLvl(int printLvl)
Set the print level from the rootfinder.
doublereal m_atolf
Absolute tolerance for the value of f.
int specifiedDeltaXMax_
Boolean indicating whether DeltaXMax_ has been specified by the user or not.
bool theSame(doublereal x2, doublereal x1, doublereal factor=1.0) const
Function to decide whether two real numbers are the same or not.
doublereal func(doublereal x)
Return the function value.