0

I'm working with the code on the GSL examples page to try to solve a system of four differential equations. I've been wrestling with passing five parameters to the ODE system, and have arrived at one final (I hope!) compile-time error. A snippet follows, giving me the error

114:57: error: invalid conversion from ‘int (*)(double, const double*, 
double*, double**, void*)’ to ‘int (*)(double, const double*, double*, 
double*, void*)’ [-fpermissive]

which corresponds to the line starting with gsl_odeiv2_system:

int main()
{
  double t = 0.0;
  double y[4] = { 0.0, 0.0, 1.0, 1.0 };
  int i, s;

  struct pendula_params * info;
  info->m2 = 1.0;
  info->m1 = 1.0;
  info->l1 = 1.0;
  info->l2 = 1.0;
  info->g  = 1.0;

  gsl_odeiv2_system sys = { pendula, jacobian, 4, &info };

  gsl_odeiv2_driver *d =
    gsl_odeiv2_driver_alloc_y_new (&sys, gsl_odeiv2_step_msadams,
                                   1e-3, 1e-8, 1e-8);

Any thoughts on what might be going on?

Many thanks,

Mark C.

Mark C.
  • 1,773
  • 2
  • 16
  • 26

1 Answers1

1

You can see what the error is by comparing the two function types that appear in the error message.

The gsl_odeiv2_system structure expects the jacobian member to be a pointer to a function that takes a double* as the fourth parameter. But your jacobian function takes a double** as the fourth parameter, which makes it incompatible.

interjay
  • 107,303
  • 21
  • 270
  • 254
  • How'd you know it was `jacobian` and not `pendula`? Seems to work for me! – Mark C. Mar 21 '13 at 16:38
  • @MarkC. Because `jacobian` member of `gsl_odeiv2_system` takes 5 parameters, which matches the function types in the error message. – interjay Mar 21 '13 at 17:02