On 8/1/07, O. Hartmann <address@hidden> wrote:
Hello,
while using GSL the first time (coming from some Numerical Recipes in C
code pieces) I ran into trouble solving a non-linear least square problem.
The problem ist simple, not to say trivial, some points need to get
fitted in the usual way. The modell-function is a polynomial expression
of degree 15 with 16 coefficients (a_0 - a_15) and in most cases we only
fit the first coefficient, the constant (a_0). Sometimes we need to
select some other coefficients to be fitted for making the polynomial
fitting the dataset.
Well, The Numerical Recipes code offers an elegant method using a 'mask'
for each coefficient, if the corresponding switch in the mask (the mask
represents the amount of coefficients) is set to 'false' or 0, the
coefficient does not get touched and fitted, if set to else, the
coefficient is handled as usual and gets fitted. These operations are
done while preparing the covariant matrix.
The GSL routines, as shown in the example in chapter 37: Nonlinear
Least-Square Fitting seems not to offer a simple 'switch' to do the same
as mentioned above. Does anyone do have a hint?
Well, you can pass whatever data you want to the function through the
'data' parameter. It is declared 'void' so you are responsible to
extract the right data. Define a struct
struct data {
size_t n;
double * y;
int * mask; /* 1 or 0 */
};
and use the 'mask' to multiply the coefficients...