![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
Typedefs | |
| using | NewtonFunc = std::function<void(double x, double* f, double* df)> |
| Synchronous function and derivative evaluator for newton(). | |
| using | RidderFunc = std::function<double(double x)> |
| Synchronous scalar function evaluator for ridder(). | |
Functions | |
| int | newton (double x1, double x2, double *rts, double xacc, const NewtonFunc &func) |
| Find a root with Newton steps and a bisection fallback. | |
| double | ridder (double x1, double x2, double xacc, const RidderFunc &func) |
| Estimate a bracketed root with derivative-free Ridder iterations. | |
Variables | |
| constexpr int | MAXIT = 60 |
| Maximum iterations. | |
| using openswmm::findroot::NewtonFunc = std::function<void(double x, double* f, double* df)> |
Synchronous function and derivative evaluator for newton().
| [in] | x | Candidate root, in the caller's independent-variable units. |
| [out] | f | Non-null solver-owned slot for f(x). |
| [out] | df | Non-null solver-owned slot for df/dx. |
| using openswmm::findroot::RidderFunc = std::function<double(double x)> |
Synchronous scalar function evaluator for ridder().
| [in] | x | Candidate root in caller-selected units. |
| int openswmm::findroot::newton | ( | double | x1, |
| double | x2, | ||
| double * | rts, | ||
| double | xacc, | ||
| const NewtonFunc & | func ) |
Find a root with Newton steps and a bisection fallback.
| [in] | x1 | Bracket endpoint where f(x1) < 0, regardless of coordinate order. |
| [in] | x2 | Bracket endpoint where f(x2) > 0. |
| [in,out] | rts | Non-null caller-owned initial guess inside the bracket; overwritten with the final estimate on both convergence and iteration exhaustion. |
| [in] | xacc | Positive absolute step tolerance in the units of x1 and x2. |
| [in] | func | Nonempty synchronous callback producing f and df/dx for each candidate. It is not retained; callback exceptions propagate. |
The caller must orient and validate the bracket. This function does not pre-evaluate endpoints; preserving callback sequence matches legacy findroot_Newton(). Newton steps outside the bracket, or steps that converge too slowly, are replaced by bisection.
| double openswmm::findroot::ridder | ( | double | x1, |
| double | x2, | ||
| double | xacc, | ||
| const RidderFunc & | func ) |
Estimate a bracketed root with derivative-free Ridder iterations.
| [in] | x1 | First finite bracket coordinate. |
| [in] | x2 | Second finite bracket coordinate; endpoint function values must have opposite signs unless an endpoint is already a root. |
| [in] | xacc | Positive absolute tolerance in the units of x1 and x2, applied to successive estimates and bracket width. |
| [in] | func | Nonempty synchronous evaluator, not retained. Exceptions propagate; callback invocation order follows legacy findroot_Ridder(). |
|
constexpr |
Maximum iterations.