File indexing completed on 2025-02-21 10:03:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef __GSL_MULTIROOTS_H__
0021 #define __GSL_MULTIROOTS_H__
0022
0023 #include <stdlib.h>
0024 #include <gsl/gsl_types.h>
0025 #include <gsl/gsl_math.h>
0026 #include <gsl/gsl_vector.h>
0027 #include <gsl/gsl_matrix.h>
0028
0029 #undef __BEGIN_DECLS
0030 #undef __END_DECLS
0031 #ifdef __cplusplus
0032 # define __BEGIN_DECLS extern "C" {
0033 # define __END_DECLS }
0034 #else
0035 # define __BEGIN_DECLS
0036 # define __END_DECLS
0037 #endif
0038
0039 __BEGIN_DECLS
0040
0041
0042
0043 struct gsl_multiroot_function_struct
0044 {
0045 int (* f) (const gsl_vector * x, void * params, gsl_vector * f);
0046 size_t n;
0047 void * params;
0048 };
0049
0050 typedef struct gsl_multiroot_function_struct gsl_multiroot_function ;
0051
0052 #define GSL_MULTIROOT_FN_EVAL(F,x,y) (*((F)->f))(x,(F)->params,(y))
0053
0054 int gsl_multiroot_fdjacobian (gsl_multiroot_function * F,
0055 const gsl_vector * x, const gsl_vector * f,
0056 double epsrel, gsl_matrix * jacobian);
0057
0058
0059 typedef struct
0060 {
0061 const char *name;
0062 size_t size;
0063 int (*alloc) (void *state, size_t n);
0064 int (*set) (void *state, gsl_multiroot_function * function, gsl_vector * x, gsl_vector * f, gsl_vector * dx);
0065 int (*iterate) (void *state, gsl_multiroot_function * function, gsl_vector * x, gsl_vector * f, gsl_vector * dx);
0066 void (*free) (void *state);
0067 }
0068 gsl_multiroot_fsolver_type;
0069
0070 typedef struct
0071 {
0072 const gsl_multiroot_fsolver_type * type;
0073 gsl_multiroot_function * function ;
0074 gsl_vector * x ;
0075 gsl_vector * f ;
0076 gsl_vector * dx ;
0077 void *state;
0078 }
0079 gsl_multiroot_fsolver;
0080
0081 gsl_multiroot_fsolver *
0082 gsl_multiroot_fsolver_alloc (const gsl_multiroot_fsolver_type * T,
0083 size_t n);
0084
0085 void gsl_multiroot_fsolver_free (gsl_multiroot_fsolver * s);
0086
0087 int gsl_multiroot_fsolver_set (gsl_multiroot_fsolver * s,
0088 gsl_multiroot_function * f,
0089 const gsl_vector * x);
0090
0091 int gsl_multiroot_fsolver_iterate (gsl_multiroot_fsolver * s);
0092
0093 const char * gsl_multiroot_fsolver_name (const gsl_multiroot_fsolver * s);
0094 gsl_vector * gsl_multiroot_fsolver_root (const gsl_multiroot_fsolver * s);
0095 gsl_vector * gsl_multiroot_fsolver_dx (const gsl_multiroot_fsolver * s);
0096 gsl_vector * gsl_multiroot_fsolver_f (const gsl_multiroot_fsolver * s);
0097
0098
0099
0100
0101 struct gsl_multiroot_function_fdf_struct
0102 {
0103 int (* f) (const gsl_vector * x, void * params, gsl_vector * f);
0104 int (* df) (const gsl_vector * x, void * params, gsl_matrix * df);
0105 int (* fdf) (const gsl_vector * x, void * params, gsl_vector * f, gsl_matrix *df);
0106 size_t n;
0107 void * params;
0108 };
0109
0110 typedef struct gsl_multiroot_function_fdf_struct gsl_multiroot_function_fdf ;
0111
0112 #define GSL_MULTIROOT_FN_EVAL_F(F,x,y) ((*((F)->f))(x,(F)->params,(y)))
0113 #define GSL_MULTIROOT_FN_EVAL_DF(F,x,dy) ((*((F)->df))(x,(F)->params,(dy)))
0114 #define GSL_MULTIROOT_FN_EVAL_F_DF(F,x,y,dy) ((*((F)->fdf))(x,(F)->params,(y),(dy)))
0115
0116 typedef struct
0117 {
0118 const char *name;
0119 size_t size;
0120 int (*alloc) (void *state, size_t n);
0121 int (*set) (void *state, gsl_multiroot_function_fdf * fdf, gsl_vector * x, gsl_vector * f, gsl_matrix * J, gsl_vector * dx);
0122 int (*iterate) (void *state, gsl_multiroot_function_fdf * fdf, gsl_vector * x, gsl_vector * f, gsl_matrix * J, gsl_vector * dx);
0123 void (*free) (void *state);
0124 }
0125 gsl_multiroot_fdfsolver_type;
0126
0127 typedef struct
0128 {
0129 const gsl_multiroot_fdfsolver_type * type;
0130 gsl_multiroot_function_fdf * fdf ;
0131 gsl_vector * x;
0132 gsl_vector * f;
0133 gsl_matrix * J;
0134 gsl_vector * dx;
0135 void *state;
0136 }
0137 gsl_multiroot_fdfsolver;
0138
0139 gsl_multiroot_fdfsolver *
0140 gsl_multiroot_fdfsolver_alloc (const gsl_multiroot_fdfsolver_type * T,
0141 size_t n);
0142
0143 int
0144 gsl_multiroot_fdfsolver_set (gsl_multiroot_fdfsolver * s,
0145 gsl_multiroot_function_fdf * fdf,
0146 const gsl_vector * x);
0147
0148 int
0149 gsl_multiroot_fdfsolver_iterate (gsl_multiroot_fdfsolver * s);
0150
0151 void
0152 gsl_multiroot_fdfsolver_free (gsl_multiroot_fdfsolver * s);
0153
0154 const char * gsl_multiroot_fdfsolver_name (const gsl_multiroot_fdfsolver * s);
0155 gsl_vector * gsl_multiroot_fdfsolver_root (const gsl_multiroot_fdfsolver * s);
0156 gsl_vector * gsl_multiroot_fdfsolver_dx (const gsl_multiroot_fdfsolver * s);
0157 gsl_vector * gsl_multiroot_fdfsolver_f (const gsl_multiroot_fdfsolver * s);
0158
0159 int gsl_multiroot_test_delta (const gsl_vector * dx, const gsl_vector * x,
0160 double epsabs, double epsrel);
0161
0162 int gsl_multiroot_test_residual (const gsl_vector * f, double epsabs);
0163
0164 GSL_VAR const gsl_multiroot_fsolver_type * gsl_multiroot_fsolver_dnewton;
0165 GSL_VAR const gsl_multiroot_fsolver_type * gsl_multiroot_fsolver_broyden;
0166 GSL_VAR const gsl_multiroot_fsolver_type * gsl_multiroot_fsolver_hybrid;
0167 GSL_VAR const gsl_multiroot_fsolver_type * gsl_multiroot_fsolver_hybrids;
0168
0169 GSL_VAR const gsl_multiroot_fdfsolver_type * gsl_multiroot_fdfsolver_newton;
0170 GSL_VAR const gsl_multiroot_fdfsolver_type * gsl_multiroot_fdfsolver_gnewton;
0171 GSL_VAR const gsl_multiroot_fdfsolver_type * gsl_multiroot_fdfsolver_hybridj;
0172 GSL_VAR const gsl_multiroot_fdfsolver_type * gsl_multiroot_fdfsolver_hybridsj;
0173
0174
0175 __END_DECLS
0176
0177 #endif