help-gsl
[Top][All Lists]

## Re: [Help-gsl] Beginner trying to use nonlinear least squares

 From: James Fitzsimons Subject: Re: [Help-gsl] Beginner trying to use nonlinear least squares Date: Sun, 06 Nov 2005 22:37:37 +0000

```Hi Martin,

Thanks for replying to me. I have been away on holiday and am just about
to tackle this again!

On Thu, 2005-10-06 at 20:23 -0400, Martin Jansche wrote:
> On 10/6/05, James Fitzsimons <address@hidden> wrote:
>
> > How would I construct a gsl_multifit_function_fdf for this?
>
> I'm not sure I fully understand the core of your question.  If it's
> about the GSL API, have you looked at the example in the manual
> (http://www.gnu.org/software/gsl/manual/gsl-ref_37.html#SEC492)?

I have looked at this in depth but I am still a bit lost.

> In
> essence, you'll have to separate the parameters of your function into
> those you wish to adjust and those you don't. Gather all the latter
> ones into a struct, and pass a pointer to that struct around as the
> value of the params argument. Next, the adjustable parameters have to
> be treated as components of a gsl_vector. Then, in the simplest case,
> you would write two C functions: one which evaluates the function at a
> given point, and one which computes the partial derivatives at a given
> point.  Initially you can write a naive fdf function which simply
> calls the f() and df() functions.

That definitely helps clarify a few things.

> If you have specific questions about your
> function, you'd probably have to post some more details about that
> function.

This is really where I am struggling (possibly because I am not 100%
rock solid on the math).

I am trying to work out the ego motion (x,y,z,roll,pitch,yaw) of my
camera system. So, the i'th row in my Jacobian matrix will look like:

ci ci ci ci ci ci
[-- -- -- -- -- --]
x  y  z  r  p  a      ( where r = roll, p = pitch and a = yaw)

to compute the partial derivative for ci/x I need to perturb x in the
following formula

delta_Ci = (u + (f * (Xi - delta_x) / Zi)) - (u + (f * Xi / Zi))

where u and f are constants and Xi and Zi are the X and Z values for the
i'th point.

According to the paper I am working from, the rate of change
delta_Ci/delta_x of ci with respect to x approximates ci/x as delta_x
tends to zero.

So I guess the point I am really stumbling on is how to construct my f()
and df() functions using the function above.

> What may be confusing is that it's possible to
> simultaneously fit several functions with common adjustable
> parameters.

Yes, I see this. I can see that once I get this working for computing
ci/x, I will be able to modify my f() and df() methods to simultaneously
calculate the y,z,r,p,a values as well.

Hopefully this makes some sort of sense. I'd really appreciate any
assistance, pointers you can provide.

Regards,
James Fitzsimons
``` signature.asc
Description: This is a digitally signed message part