[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] passing multiple parameters to func() & jac() while integ
From: |
Analabha Roy |
Subject: |
Re: [Help-gsl] passing multiple parameters to func() & jac() while integrating ODE's in gsl |
Date: |
Sun, 19 Feb 2006 16:47:10 -0600 |
Thanks, I'll give it a whirl.
---------- Forwarded message ----------
From: Joakim Hove <address@hidden>
Date: Feb 19, 2006 3:46 PM
Subject: Re: [Help-gsl] passing multiple parameters to func() & jac() while
integrating ODE's in gsl
To: Analabha Roy <address@hidden>
"Analabha Roy" <address@hidden> writes:
> I assumed that, in order to do it for multiple parameters, I'd have
> to put the parameters in an array and pass the base address to the
> gsl_odeiv_system datatype, then use pointer arithmetic in the
1. I would strongly recommend defining a struct to contain your set of
parameters; that is considerably less error prone than an array:
typedef struct {
double mass;
double w;
} harmonic_type;
int func(double t, const double y[], double dydt[], void *params) {
harmonic_type *p = (harmonic_type *) params;
double mass = p->mass;
double w = w->w;
...
....
double mass,w;
mass=*(double *)params;
2. I guess this pointer arithimitc comes out wrong, becuse params is
*not* of type double.
params++;
Anyway, you do not have to worry about that when using a struct.
HTH - Joakim
--
Joakim Hove
hove AT ntnu.no /
Tlf: +47 (55 5)8 27 13 / Stabburveien 18
Fax: +47 (55 5)8 94 40 / N-5231 Paradis
http://www.ift.uib.no/~hove/ / 55 91 28 18 / 92 68 57 04