From MikePeel.net
Below are some general hints on using GSL, mainly in cases that have caused me headaches trying to figure out.
Nonlinear Least Squares Fitting
GSL does not natively support limits on the parameter values used in nonlinear lsf's. The best way I have found to add limits is to reset the parameter value to the minimum/maximum value whenever it's outside the desired range. For example, if I want to keep a parameter y (which is my first parameter) above zero, I would put the following in the function that returns (f - f_act) / sigma:
if (y < 0)
{
gsl_vector_set(parameters, 0, 0.0);
y = 0;
}
|
where parameters is the first variable (actually, array) passed into the function. See NLLSF example for the full example code.
