klib
[Ported from github.com/attractivechaos/klib] added block arena
Brought by drakestapleton
klib / kmath.h
| 1 | #ifndef AC_KMATH_H |
| 2 | #define AC_KMATH_H |
| 3 | |
| 4 | #include <stdint.h> |
| 5 | |
| 6 | #ifdef __cplusplus |
| 7 | extern "C" { |
| 8 | #endif |
| 9 | |
| 10 | /************************** |
| 11 | * Non-linear programming * |
| 12 | **************************/ |
| 13 | |
| 14 | #define KMIN_RADIUS 0.5 |
| 15 | #define KMIN_EPS 1e-7 |
| 16 | #define KMIN_MAXCALL 50000 |
| 17 | |
| 18 | typedef double (*kmin_f)(int, double*, void*); |
| 19 | typedef double (*kmin1_f)(double, void*); |
| 20 | |
| 21 | double kmin_hj(kmin_f func, int n, double *x, void *data, double r, double eps, int max_calls); // Hooke-Jeeves' |
| 22 | double kmin_brent(kmin1_f func, double a, double b, void *data, double tol, double *xmin); // Brent's 1-dimenssion |
| 23 | |
| 24 | /********************* |
| 25 | * Special functions * |
| 26 | *********************/ |
| 27 | |
| 28 | double kf_lgamma(double z); // log gamma function |
| 29 | double kf_erfc(double x); // complementary error function |
| 30 | double kf_gammap(double s, double z); // regularized lower incomplete gamma function |
| 31 | double kf_gammaq(double s, double z); // regularized upper incomplete gamma function |
| 32 | double kf_betai(double a, double b, double x); // regularized incomplete beta function |
| 33 | |
| 34 | #ifdef __cplusplus |
| 35 | } |
| 36 | #endif |
| 37 | |
| 38 | #endif |