1 /* multifit_nlin/gsl_multifit_nlin.h
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
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.
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.
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.
20 #ifndef __GSL_MULTIFIT_NLIN_H__
21 #define __GSL_MULTIFIT_NLIN_H__
24 #include <gsl/gsl_types.h>
25 #include <gsl/gsl_math.h>
26 #include <gsl/gsl_vector.h>
27 #include <gsl/gsl_matrix.h>
32 # define __BEGIN_DECLS extern "C" {
33 # define __END_DECLS }
35 # define __BEGIN_DECLS /* empty */
36 # define __END_DECLS /* empty */
41 int gsl_multifit_gradient (const gsl_matrix * J, const gsl_vector * f,
44 int gsl_multifit_covar (const gsl_matrix * J, double epsrel, gsl_matrix * covar);
47 /* Definition of vector-valued functions with parameters based on gsl_vector */
49 struct gsl_multifit_function_struct
51 int (* f) (const gsl_vector * x, void * params, gsl_vector * f);
52 size_t n; /* number of functions */
53 size_t p; /* number of independent variables */
57 typedef struct gsl_multifit_function_struct gsl_multifit_function ;
59 #define GSL_MULTIFIT_FN_EVAL(F,x,y) (*((F)->f))(x,(F)->params,(y))
65 int (*alloc) (void *state, size_t n, size_t p);
66 int (*set) (void *state, gsl_multifit_function * function, gsl_vector * x, gsl_vector * f, gsl_vector * dx);
67 int (*iterate) (void *state, gsl_multifit_function * function, gsl_vector * x, gsl_vector * f, gsl_vector * dx);
68 void (*free) (void *state);
70 gsl_multifit_fsolver_type;
74 const gsl_multifit_fsolver_type * type;
75 gsl_multifit_function * function ;
83 gsl_multifit_fsolver *
84 gsl_multifit_fsolver_alloc (const gsl_multifit_fsolver_type * T,
87 void gsl_multifit_fsolver_free (gsl_multifit_fsolver * s);
89 int gsl_multifit_fsolver_set (gsl_multifit_fsolver * s,
90 gsl_multifit_function * f,
91 const gsl_vector * x);
93 int gsl_multifit_fsolver_iterate (gsl_multifit_fsolver * s);
95 const char * gsl_multifit_fsolver_name (const gsl_multifit_fsolver * s);
96 gsl_vector * gsl_multifit_fsolver_position (const gsl_multifit_fsolver * s);
98 /* Definition of vector-valued functions and gradient with parameters
99 based on gsl_vector */
101 struct gsl_multifit_function_fdf_struct
103 int (* f) (const gsl_vector * x, void * params, gsl_vector * f);
104 int (* df) (const gsl_vector * x, void * params, gsl_matrix * df);
105 int (* fdf) (const gsl_vector * x, void * params, gsl_vector * f, gsl_matrix *df);
106 size_t n; /* number of functions */
107 size_t p; /* number of independent variables */
111 typedef struct gsl_multifit_function_fdf_struct gsl_multifit_function_fdf ;
113 #define GSL_MULTIFIT_FN_EVAL_F(F,x,y) ((*((F)->f))(x,(F)->params,(y)))
114 #define GSL_MULTIFIT_FN_EVAL_DF(F,x,dy) ((*((F)->df))(x,(F)->params,(dy)))
115 #define GSL_MULTIFIT_FN_EVAL_F_DF(F,x,y,dy) ((*((F)->fdf))(x,(F)->params,(y),(dy)))
121 int (*alloc) (void *state, size_t n, size_t p);
122 int (*set) (void *state, gsl_multifit_function_fdf * fdf, gsl_vector * x, gsl_vector * f, gsl_matrix * J, gsl_vector * dx);
123 int (*iterate) (void *state, gsl_multifit_function_fdf * fdf, gsl_vector * x, gsl_vector * f, gsl_matrix * J, gsl_vector * dx);
124 void (*free) (void *state);
126 gsl_multifit_fdfsolver_type;
130 const gsl_multifit_fdfsolver_type * type;
131 gsl_multifit_function_fdf * fdf ;
138 gsl_multifit_fdfsolver;
141 gsl_multifit_fdfsolver *
142 gsl_multifit_fdfsolver_alloc (const gsl_multifit_fdfsolver_type * T,
146 gsl_multifit_fdfsolver_set (gsl_multifit_fdfsolver * s,
147 gsl_multifit_function_fdf * fdf,
148 const gsl_vector * x);
151 gsl_multifit_fdfsolver_iterate (gsl_multifit_fdfsolver * s);
154 gsl_multifit_fdfsolver_free (gsl_multifit_fdfsolver * s);
156 const char * gsl_multifit_fdfsolver_name (const gsl_multifit_fdfsolver * s);
157 gsl_vector * gsl_multifit_fdfsolver_position (const gsl_multifit_fdfsolver * s);
159 int gsl_multifit_test_delta (const gsl_vector * dx, const gsl_vector * x,
160 double epsabs, double epsrel);
162 int gsl_multifit_test_gradient (const gsl_vector * g, double epsabs);
164 /* extern const gsl_multifit_fsolver_type * gsl_multifit_fsolver_gradient; */
166 GSL_VAR const gsl_multifit_fdfsolver_type * gsl_multifit_fdfsolver_lmder;
167 GSL_VAR const gsl_multifit_fdfsolver_type * gsl_multifit_fdfsolver_lmsder;
172 #endif /* __GSL_MULTIFIT_NLIN_H__ */