Bsoft object

struct Bsimplex

Source:

include/simplex.h

Description:

Structure used in the downhill simplex method.

Features:

Nelder and Mead downhill simplex method for generalized parameter fitting
Adapted from Numerical Recipes, 2nd edition, Press et al. 1992
The structure is set up to accommodate any number of variables, parameters,
constants and points.
The structure is very flexible in the sense that only some fields
are absolutely required and with a fixed meaning for the simplex method.
The required fields are:
nparam, param, lolimit, hilimit
The other fields may be recast and used as desired in the user function.
Intended sizes:
param nparam.
lolimit nparam.
hilimit nparam.
constant nconstant.
x npoint*nvar.
fx npoint.
x or fx can be recast as a different pointer, as long as it is handled
by the user before calling kill_simplex.

Code:

#ifndef _Bsimplex_
struct Bsimplex {
int nvar; // Number of variables
int nparam; // Number of parameters
int nconstant; // Number of constants
int npoint; // Number of function values
double* param; // Parameter values
double* lolimit; // Lower limits on parameter values
double* hilimit; // Upper limits on parameter values
double* constant; // Constant values
float* x; // Independent variables: npoint*nvar array
float* fx; // Function values
} ;
#define _Bsimplex_
#endif

// Function prototypes
double simplex(Bsimplex* simp, int maxcycles, double tolerance, double (funk)(Bsimplex *));
Bsimplex* init_simplex(int nvar, int nparam, int nconstant, int npoint);
int kill_simplex(Bsimplex* simp);