| 1 | /* roots/gsl_roots.h |
| 2 | * |
| 3 | * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Reid Priedhorsky, Brian Gough |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | */ |
| 19 | |
| 20 | #ifndef __GSL_ROOTS_H__ |
| 21 | #define __GSL_ROOTS_H__ |
| 22 | |
| 23 | #include <stdlib.h> |
| 24 | #include "gsl_types.h" |
| 25 | #include "gsl_math.h" |
| 26 | |
| 27 | #undef __BEGIN_DECLS |
| 28 | #undef __END_DECLS |
| 29 | #ifdef __cplusplus |
| 30 | # define __BEGIN_DECLS extern "C" { |
| 31 | # define __END_DECLS } |
| 32 | #else |
| 33 | # define __BEGIN_DECLS /* empty */ |
| 34 | # define __END_DECLS /* empty */ |
| 35 | #endif |
| 36 | |
| 37 | __BEGIN_DECLS |
| 38 | |
| 39 | typedef struct |
| 40 | { |
| 41 | const char *name; |
| 42 | size_t size; |
| 43 | int (*set) (void *state, gsl_function * f, double * root, double x_lower, double x_upper); |
| 44 | int (*iterate) (void *state, gsl_function * f, double * root, double * x_lower, double * x_upper); |
| 45 | } |
| 46 | gsl_root_fsolver_type; |
| 47 | |
| 48 | typedef struct |
| 49 | { |
| 50 | const gsl_root_fsolver_type * type; |
| 51 | gsl_function * function ; |
| 52 | double root ; |
| 53 | double x_lower; |
| 54 | double x_upper; |
| 55 | void *state; |
| 56 | } |
| 57 | gsl_root_fsolver; |
| 58 | |
| 59 | typedef struct |
| 60 | { |
| 61 | const char *name; |
| 62 | size_t size; |
| 63 | int (*set) (void *state, gsl_function_fdf * f, double * root); |
| 64 | int (*iterate) (void *state, gsl_function_fdf * f, double * root); |
| 65 | } |
| 66 | gsl_root_fdfsolver_type; |
| 67 | |
| 68 | typedef struct |
| 69 | { |
| 70 | const gsl_root_fdfsolver_type * type; |
| 71 | gsl_function_fdf * fdf ; |
| 72 | double root ; |
| 73 | void *state; |
| 74 | } |
| 75 | gsl_root_fdfsolver; |
| 76 | |
| 77 | gsl_root_fsolver * |
| 78 | gsl_root_fsolver_alloc (const gsl_root_fsolver_type * T); |
| 79 | void gsl_root_fsolver_free (gsl_root_fsolver * s); |
| 80 | |
| 81 | int gsl_root_fsolver_set (gsl_root_fsolver * s, |
| 82 | gsl_function * f, |
| 83 | double x_lower, double x_upper); |
| 84 | |
| 85 | int gsl_root_fsolver_iterate (gsl_root_fsolver * s); |
| 86 | |
| 87 | const char * gsl_root_fsolver_name (const gsl_root_fsolver * s); |
| 88 | double gsl_root_fsolver_root (const gsl_root_fsolver * s); |
| 89 | double gsl_root_fsolver_x_lower (const gsl_root_fsolver * s); |
| 90 | double gsl_root_fsolver_x_upper (const gsl_root_fsolver * s); |
| 91 | |
| 92 | |
| 93 | gsl_root_fdfsolver * |
| 94 | gsl_root_fdfsolver_alloc (const gsl_root_fdfsolver_type * T); |
| 95 | |
| 96 | int |
| 97 | gsl_root_fdfsolver_set (gsl_root_fdfsolver * s, |
| 98 | gsl_function_fdf * fdf, double root); |
| 99 | |
| 100 | int |
| 101 | gsl_root_fdfsolver_iterate (gsl_root_fdfsolver * s); |
| 102 | |
| 103 | void |
| 104 | gsl_root_fdfsolver_free (gsl_root_fdfsolver * s); |
| 105 | |
| 106 | const char * gsl_root_fdfsolver_name (const gsl_root_fdfsolver * s); |
| 107 | double gsl_root_fdfsolver_root (const gsl_root_fdfsolver * s); |
| 108 | |
| 109 | int |
| 110 | gsl_root_test_interval (double x_lower, double x_upper, double epsabs, double epsrel); |
| 111 | |
| 112 | int |
| 113 | gsl_root_test_residual (double f, double epsabs); |
| 114 | |
| 115 | int |
| 116 | gsl_root_test_delta (double x1, double x0, double epsabs, double epsrel); |
| 117 | |
| 118 | GSL_VAR const gsl_root_fsolver_type * gsl_root_fsolver_bisection; |
| 119 | GSL_VAR const gsl_root_fsolver_type * gsl_root_fsolver_brent; |
| 120 | GSL_VAR const gsl_root_fsolver_type * gsl_root_fsolver_falsepos; |
| 121 | GSL_VAR const gsl_root_fdfsolver_type * gsl_root_fdfsolver_newton; |
| 122 | GSL_VAR const gsl_root_fdfsolver_type * gsl_root_fdfsolver_secant; |
| 123 | GSL_VAR const gsl_root_fdfsolver_type * gsl_root_fdfsolver_steffenson; |
| 124 | |
| 125 | __END_DECLS |
| 126 | |
| 127 | #endif /* __GSL_ROOTS_H__ */ |