help-gsl
[Top][All Lists]
Advanced

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

[Help-gsl] Re: ODE example, passing parameters (address@hidden)


From: Luke
Subject: [Help-gsl] Re: ODE example, passing parameters (address@hidden)
Date: Thu, 10 Jun 2010 09:45:03 -0700

Willi,

> int
> func (double t, const double y[], double f[], struct par *pz)
> {
>
>  double mu=pz->mu;
>  double om=pz->om;
>  double de=pz->de;
>  //printf ("%.5e %.5e %.5e\n", pz->mu, pz->om, pz->de);
>
>  f[0] = om*y[1];
>  f[1] = -y[0] - mu*y[1]*(y[0]*y[0] - 1);
>  f[2] = de*y[1]*y[2];
>
>  return GSL_SUCCESS;
> }

Change the function call signature to take a void pointer, then use a cast:

int func (double t, const double y[], double f[], void *p) {
  struct par *pz = (struct par*) p;  // cast p as a pointer to struct
par, assign to pz
  ...
}

This should do the trick.  You will need to do the same for the
function jac as well.

Cheers,
~Luke



reply via email to

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