| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#ifndef ESL_ROOTFINDER_INCLUDED |
| 6 |
#define ESL_ROOTFINDER_INCLUDED |
| 7 |
#include <esl_config.h> |
| 8 |
|
| 9 |
typedef struct { |
| 10 |
int (*func)(double, void*, double*); |
| 11 |
int (*fdf) (double, void*, double*, double*); |
| 12 |
void *params; |
| 13 |
|
| 14 |
double xl; |
| 15 |
double fl; |
| 16 |
double xr; |
| 17 |
double fr; |
| 18 |
|
| 19 |
double x0; |
| 20 |
double f0; |
| 21 |
|
| 22 |
double x; |
| 23 |
double fx; |
| 24 |
double dfx; |
| 25 |
int iter; |
| 26 |
|
| 27 |
double abs_tolerance; |
| 28 |
double rel_tolerance; |
| 29 |
double residual_tol; |
| 30 |
int max_iter; |
| 31 |
} ESL_ROOTFINDER; |
| 32 |
|
| 33 |
|
| 34 |
extern ESL_ROOTFINDER *esl_rootfinder_Create (int (*func)(double, void*, double*), void *params); |
| 35 |
extern ESL_ROOTFINDER *esl_rootfinder_CreateFDF(int (*fdf) (double, void*, double*, double*), void *params); |
| 36 |
|
| 37 |
extern int esl_rootfinder_SetBrackets(ESL_ROOTFINDER *R, double xl, double xr); |
| 38 |
extern int esl_rootfinder_SetAbsoluteTolerance(ESL_ROOTFINDER *R, double tol); |
| 39 |
extern int esl_rootfinder_SetRelativeTolerance(ESL_ROOTFINDER *R, double tol); |
| 40 |
extern int esl_rootfinder_SetResidualTolerance(ESL_ROOTFINDER *R, double tol); |
| 41 |
extern int esl_rootfinder_SetMaxIterations(ESL_ROOTFINDER *R, int maxiter); |
| 42 |
extern void esl_rootfinder_Destroy(ESL_ROOTFINDER *R); |
| 43 |
|
| 44 |
extern int esl_root_Bisection(ESL_ROOTFINDER *R, double xl, double xr, double *ret_x); |
| 45 |
extern int esl_root_NewtonRaphson(ESL_ROOTFINDER *R, double guess, double *ret_x); |
| 46 |
|
| 47 |
#endif |