PLUTO
4.4-patch2
|
Collection of root-finder algorithms. More...
#include "pluto.h"
Functions | |
int | Brent (double(*Func)(double, void *), void *param, double x1, double x2, double abs_acc, double rel_acc, double *xroot) |
int | Ridder (double(*Func)(double, void *), void *param, double x1, double x2, double abs_acc, double rel_acc, double *xroot) |
int | QuadraticSolve (double a, double b, double c, double *x) |
int | CubicSolve (double b, double c, double d, double z[]) |
int | QuarticSolve (double b, double c, double d, double e, double *z) |
int Brent | ( | double(*)(double, void *) | Func, |
void * | param, | ||
double | x1, | ||
double | x2, | ||
double | abs_acc, | ||
double | rel_acc, | ||
double * | xroot | ||
) |
Use Brent's method to find the root of known to lie between x1 and x2. Here the function must be in the form
double
Func(x,*p)
, where where x
is the independent variable while *p
is a (void) pointer to any data type containing the function parameters. Absolute accuracies can be specified to check for convergence
[in] | *func | a pointer to a function func(x, *par) |
[in] | *param | a void pointer containing the parameters |
[in] | x1 | the leftmost interval point |
[in] | x2 | the rightmost interval point |
[in] | abs_acc | the desired absolute accuracy.(> 0 if you wish to use it). |
[in] | rel_acc | the desired relative accuracy.(> 0 if you wish to use it). |
[out] | xroot | the zero of the function. |
int CubicSolve | ( | double | b, |
double | c, | ||
double | d, | ||
double | z[] | ||
) |
Solve a cubic equation in the form
For its purpose, it is assumed that ALL roots are real. This makes things faster.
[in] | b | coefficient of the cubic |
[in] | c | coefficient of the cubic |
[in] | d | coefficient of the cubic |
[out] | z | vector containing the roots of the cubic. Roots should be sorted in increasing order. |
Reference:
int QuadraticSolve | ( | double | a, |
double | b, | ||
double | c, | ||
double * | x | ||
) |
Solve a quadratic equation in the form
ax^2 + bx + c = 0
Roots are always assumed to be real and returned in x[] (exit code 0). If complex roots are found the function return exit code 1. Real roots are returned in increasing order. Reference: "Numerical Recipes in C", Press et al., Sect. 5.6
int QuarticSolve | ( | double | b, |
double | c, | ||
double | d, | ||
double | e, | ||
double * | z | ||
) |
Solve a quartic equation in the form
For its purpose, it is assumed that ALL roots are real. This makes things faster.
[in] | b | coefficient of the quartic |
[in] | c | coefficient of the quartic |
[in] | d | coefficient of the quartic |
[in] | e | coefficient of the quartic |
[out] | z | vector containing the (double) roots of the quartic |
Reference:
http://www.1728.com/quartic2.htm (????)
int Ridder | ( | double(*)(double, void *) | Func, |
void * | param, | ||
double | x1, | ||
double | x2, | ||
double | abs_acc, | ||
double | rel_acc, | ||
double * | xroot | ||
) |
Use Ridder's method to find the root of known to lie between x1 and x2. Here the function must be in the form
double
Func(x,*p)
, where where x
is the independent variable while *p
is a (void) pointer to any data type containing the function parameters. Both relative and absolute accuracies can be specified and convergence is achieved by the condition that is realized first. To choose among the two accuracies, set the other one to a negative number.
[in] | *func | a pointer to a function func(x, *par) |
[in] | *param | a void pointer containing the parameters |
[in] | x1 | the leftmost interval point |
[in] | x2 | the rightmost interval point |
[in] | abs_acc | the desired absolute accuracy (> 0 if you wish to use it). |
[in] | rel_acc | the desired relative accuracy (> 0 if you wish to use it). |
[out] | xroot | the zero of the function. |