[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] A gsl_vector of pointers?

From: John Gehman
Subject: [Help-gsl] A gsl_vector of pointers?
Date: Wed, 23 Mar 2005 12:47:27 +1100

Hello All,

I've got a general question regarding gsl_vector(s) and (in particular) non linear least squares fitting. Several of the associated functions used for nonlinear least squares fitting (the functions whose pointers are arguments to gsl_multifit_function_fdf, as well as gsl_multifit_fdfsolver_set) require as an argument the gsl_vector of values which correspond to those parameters one wishes to float in a nonlinear least squares fit. This is straightforward and reasonable in situations such as the example provided in the documentation.

I, however, have now two unrelated situations for which I do not (yet) have analytic expressions. I want to test the model numerically before I get too carried away with the pencil and paper. Calculating the residuals and gradients are fairly involved (calculating multiple roots in one case, numeric integration in the other case, and using gsl_deriv_central in both cases to fill the Jacobian). The complexity of the problem drives me to organize the problem into data struct(s), and the parameters that I want to float are actually components of these structures.

At the moment it's clumsy, as I can only figure to write two functions which read and write updated values back and forth between the structure components and the gsl_vector of double-precision numbers which is needed to pass into the nonlinear fitting functions. Even if this is an OK workaround, it is prone to human error, as I seem to be fouling unrelated values by implementing the scheme incorrectly (and the application that I'm further along on isn't working either, but that could be for other reasons).

Now, finally, the question: is there actually a way that I can fill a gsl_vector with pointers to doubles (those within my structures) instead of explicit doubles? I might guess there could be some trick with "stride", but I can't find enough explanation to hack with.

Heaps of gratitude for anybody who can help!

John Gehman
Research Fellow
School of Chemistry
University of Melbourne

reply via email to

[Prev in Thread] Current Thread [Next in Thread]