Go to the first, previous, next, last section, table of contents.

Providing the Function to be Minimized

You must provide @math{n} functions of @math{p} variables for the minimization algorithms to operate on. In order to allow for general parameters the functions are defined by the following data types:

Data Type: gsl_multifit_function
This data type defines a general system of functions with parameters.

int (* f) (const gsl_vector * x, void * params, gsl_vector * f)
this function should store the vector result @math{f(x,params)} in f for argument x and parameters params, returning an appropriate error code if the function cannot be computed.
size_t n
the number of functions, i.e. the number of components of the vector f
size_t p
the number of independent variables, i.e. the number of components of the vectors x
void * params
a pointer to the parameters of the function

Data Type: gsl_multifit_function_fdf
This data type defines a general system of functions with parameters and the corresponding Jacobian matrix of derivatives,

int (* f) (const gsl_vector * x, void * params, gsl_vector * f)
this function should store the vector result @math{f(x,params)} in f for argument x and parameters params, returning an appropriate error code if the function cannot be computed.
int (* df) (const gsl_vector * x, void * params, gsl_matrix * J)
this function should store the n-by-p matrix result @math{J_ij = d f_i(x,params) / d x_j} in J for argument x and parameters params, returning an appropriate error code if the function cannot be computed.
int (* fdf) (const gsl_vector * x, void * params, gsl_vector * f, gsl_matrix * J)
This function should set the values of the f and J as above, for arguments x and parameters params. This function provides an optimization of the separate functions for @math{f(x)} and @math{J(x)} -- it is always faster to compute the function and its derivative at the same time.
size_t n
the number of functions, i.e. the number of components of the vector f
size_t p
the number of independent variables, i.e. the number of components of the vectors x
void * params
a pointer to the parameters of the function

Go to the first, previous, next, last section, table of contents.