OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
findroot.c File Reference
#include <math.h>
#include "findroot.h"
Include dependency graph for findroot.c:

Macros

#define SIGN(a, b)   ((b) >= 0.0 ? fabs(a) : -fabs(a))
 
#define MAXIT   60
 

Functions

int findroot_Newton (double x1, double x2, double *rts, double xacc, newton_callback func, void *p)
 Finds the root of a function using Newton's method.
 
double findroot_Ridder (double x1, double x2, double xacc, ridder_callback func, void *p)
 Finds the root of a function using Ridder's method.
 

Macro Definition Documentation

◆ MAXIT

#define MAXIT   60

◆ SIGN

#define SIGN (   a,
 
)    ((b) >= 0.0 ? fabs(a) : -fabs(a))

Function Documentation

◆ findroot_Newton()

int findroot_Newton ( double  x1,
double  x2,
double *  rts,
double  xacc,
newton_callback  func,
void *  p 
)

Finds the root of a function using Newton's method.

Parameters
x1Lower bound of the bracketing interval.
x2Upper bound of the bracketing interval.
rtsPointer to the root.
xaccDesired accuracy of the root.
funcCallback function for the function and its derivative.
pPointer to additional data.
Returns
Number of function evaluations used or 0 if the maximum allowed iterations were exceeded.

◆ findroot_Ridder()

double findroot_Ridder ( double  x1,
double  x2,
double  xacc,
ridder_callback  func,
void *  p 
)

Finds the root of a function using Ridder's method.

Parameters
x1Lower bound of the bracketing interval.
x2Upper bound of the bracketing interval.
xaccDesired accuracy of the root.
funcCallback function for the function.
pPointer to additional data.
Returns
The root of the function.